<?php
fscanf(STDIN,"%d",$sizeOfArr);
$arr=explode(' ',trim(fgets(STDIN)));
$cnt=1;
$lastItem=array();
for ($i=0,$j=0; $i <$sizeOfArr-1 ; $i++)
 {
	  if($arr[$i]>=$arr[$i+1])
	  {
	  	$cnt++;
	  	$lastItem[$j++]=$arr[$i];
	  }
 }
 $lastItem[count($lastItem)]=$arr[$sizeOfArr-1];
 echo "$cnt\n";
 for ($i=0; $i <count($lastItem) ; $i++)
  {
  	if($i==count($lastItem)-1)
 	    echo "$lastItem[$i]";
 	else
 		echo "$lastItem[$i] ";
  }

<?php
$n = (int)fgets(STDIN);
$a = explode(' ', trim(fgets(STDIN)));
$ans = array();

for ($i = 0; $i < $n - 1; ++$i) {
    if ($a[$i + 1] === '1') {
        $ans[] = $a[$i];
    }
}
$ans[] = $a[$n - 1];

echo count($ans) . "\n";
foreach ($ans as $i) {
    print("$i ");
}

<?php
$n_numbers = readline ();
$numbers = explode (" ", readline ());
$n_stairways = 0;
$stairways_steps = array ();
for ($i = 0; $i < $n_numbers; ++$i)
{
        if ($numbers[$i] == 1) {
                $stairways_steps[$n_stairways] = $numbers[$i-1];
                ++$n_stairways;
        }
}
array_shift($stairways_steps);
$stairways_steps[$n_stairways] = $numbers[$n_numbers-1];
echo $n_stairways."\n";
foreach ($stairways_steps as $ss) {
        echo $ss." ";
}

<?php
    $dir                    = fopen("php://stdin", 'r');
    $contents               = stream_get_contents($dir);
    $inputs                 = explode("\n",$contents);
    $numbersCount           = (int) $inputs[0];
    $stepsArray             = array_map('intval', explode(' ', $inputs[1]));
    getStairwaysCount($numbersCount, $stepsArray);
    function getStairwaysCount($numbersCount, $stepsArray)
    {
        $stairwaysCount = array_count_values($stepsArray)[1];
        echo $stairwaysCount.PHP_EOL;
        $arr = [];
        $numberOneOcurance = array_keys($stepsArray, 1);
        for($i = 0; $i < count($numberOneOcurance)-1; $i++)
        {
            $arr[] = $numberOneOcurance[$i+1] - $numberOneOcurance[$i];
        }
        $arr[] = $numbersCount - end($numberOneOcurance);
        foreach($arr as $key=> $value)
        {
            echo $value.' ';
        }
    }
?>


<?php
    $k = intval(trim(fgets(STDIN)));
    $alph = str_split(trim(fgets(STDIN)));

    $count = array();

    foreach ($alph as $value) {
        if (array_key_exists($value, $count))
                $count[$value] += 1;
        else
            $count[$value] = 1;
    }

    $str = "";
    for ($i = 0; $i < $k; ++$i) {
        foreach ($count as $key => $val) {
            if ($val % $k != 0) {
                echo -1;
                die();
            }

            for ($j = 0; $j < $val / $k; ++$j) {
                $str = $str.$key;
            }
        }
    }

    echo $str;
?>

<?
$k = fgets(STDIN);
$s = trim(fgets(STDIN));
$s_arr = str_split($s);
foreach($s_arr as $v){++$chr[$v];}
for($y=0;$y<$k;$y++){
    foreach($chr as $ck => $cv){
        if($cv%$k==0){
        for($i=0;$i<($cv/$k);$i++){$w .=$ck;}
        }
        else{$w = -1;break;}
    }
}
echo $w;
?>

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = array();
$d = array();
$e = array();
if($a == 1)
{
    print $b;
}
elseif(strlen($b) % $a != 0)
{
    print "-1";
}
else
{
    for($x = 0; $x < strlen($b); $x++)
    {
        array_push($c, $b[$x]);
    }
    $d = array_unique($c);
    if(count($c) / count($d) == $a)
    {
        for($y = 1; $y <= $a; $y++)
        {
            array_push($e, implode($d));
        }
        print implode($e);
    }
    else
    {
        print "-1";
    }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = array();
$d = array();
$e = array();
$n = array();
$f = 0;
$g = 0;
if($a == 1)
{
    print $b;
}
elseif(strlen($b) % $a != 0)
{
    print "-1";
}
else
{
    for($x = 0; $x < strlen($b); $x++)
    {
        array_push($c, $b[$x]);
    }
    $d = array_unique($c);
    for($y = 1; $y <= $a; $y++)
    {
        array_push($e, implode($d));
    }
    $k = implode($e);
    for($x = 0; $x < strlen($k); $x++)
    {
        array_push($n, $k[$x]);
    }
    for($z = 0; $z < count($c); $z++)
    {
        $f = ord($c[$z]);
        $h += $f;
        $g = ord($n[$z]);
        $i += $g;
    }
    if($h != $i)
    {
        print "-1";
    }
    elseif(count($c) / count($d) == $a)
    {
        print implode($n);
    }
    else
    {
        print "-1";
    }
}
?>

<?
$k = fgets(STDIN);
$s = fgets(STDIN);
$s_arr = str_split($s);
foreach($s_arr as $v){++$chr[$v];}
for($y=0;$y<$k;$y++){
foreach($chr as $ck => $cv){
if($cv%$k==0){
for($i=0;$i<($cv/$k);$i++){$w .=$ck;}
}
else{$w = -1;break;}
}
}
echo $w;
?>

<?
$k = fgets(STDIN);
$s = trim(fgets(STDIN));
$s_arr = str_split($s);
foreach($s_arr as $v){++$chr[$v];}
for($y=0;$y<$k;$y++){
    foreach($chr as $ck => $cv){
        if($cv%$k==0){
        for($i=0;$i<($cv/$k);$i++){$w .=$ck;}
        }
        else{$w = -1;break;}
    }
}
echo $cv;
?>

<?
$k = fgets(STDIN);
$s = fgets(STDIN);
$s_arr = str_split($s);
foreach($s_arr as $v){++$chr[$v];}
for($y=0;$y<$k;$y++){
    foreach($chr as $ck => $cv){
        if($cv%$k==0){
        for($i=0;$i<($cv/$k);$i++){$w .=$ck;}
        }
        else{$w = -1;break;}
    }
}
echo $cv;
?>


<?php
$fp = fopen("php://stdin", 'r');
$line1 = trim(fgets($fp));
$line2 = trim(fgets($fp));
fclose($fp);
$length = intval($line1);
$arrNum = array_map('intval', explode(' ', $line2));
$check = true;
for ($i = 0; $i < $length; $i++) {
    if ($arrNum[$i] % 2 == 1) {
        $check = false;
    }
}
if (!$check) {
    echo "First", PHP_EOL;die;
}
echo "Second", PHP_EOL;die;

<?php
    $dir                        = fopen("php://stdin", 'r');
    $contents                   = stream_get_contents($dir);
    $inputs                     = explode("\n",$contents);
    $numbersCount               = (int) $inputs[0];
    $numbers                    = array_map('intval', explode(' ', $inputs[1]));
    $possibilitiesForEntrance   = [];
    echo getWinner($numbersCount, $numbers);

    function isArrayHasOddNumber($numbersCount, $numbers){
        for($counter = 0; $counter < $numbersCount; $counter++)
        {
            if($numbers[$counter] % 2 != 0)
            {
                return true;
            }
        }
    }

    function getWinner($numbersCount, $numbers)
    {
        if(isArrayHasOddNumber($numbersCount, $numbers))
        {
            return 'First';
        } else {
            return 'Second';
        }
    }

?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = bcmod($c, 2);
if($d == 0)
{
     $e = 0;
     for($x = 0; $x < $a; $x++)
     {
          $f = $b[$x] % 2;
          if($f == 1)
          {
               $e = 1;
               break;
          }
     }
     if($e == 0)
     {
          print "Second";
     }
     else
     {
          print "First";
     }
}
else
{
     print "First";
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = bcmod($c, 2);
if($a == 222)
{
     print $c . " " . $d;
}
if($d == 0)
{
     print "Second";
}
else
{
     print "First";
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = bcmod($c, 2);
if($d == 0)
{
     print "Second";
}
else
{
     print "First";
}
?>

<?php
$fp = fopen("php://stdin", 'r');
$line1 = trim(fgets($fp));
$line2 = trim(fgets($fp));
fclose($fp);
$length = intval($line1);
$arrNum = array_map('intval', explode(' ', $line2));
$sum = 0;
for ($i = 0; $i < $length; $i++) {
    $sum += $arrNum[$i];
}
if ($sum % 2 == 1) {
    echo "First", PHP_EOL;die;
}
echo "Second", PHP_EOL;die;

<?php
$fp = fopen("php://stdin", 'r');
$line1 = trim(fgets($fp));
$line2 = trim(fgets($fp));
fclose($fp);
$length = intval($line1);
$arrNum = array_map('intval', explode(' ', $line2));
$sum = 0;
for ($i = 0; $i < $length; $i++) {
    $sum += $arrNum[$i];
}
if ($sum % 2 == 1) {
    echo "FIRST", PHP_EOL;die;
}
echo "SECOND", PHP_EOL;die;

<?php
$fp = fopen("php://stdin", 'r');
$line1 = trim(fgets($fp));
$line2 = trim(fgets($fp));
fclose($fp);
$length = intval($line1);
$arrNum = array_map('intval', explode(' ', $line2));
$sum = 0;
for ($i = 0; $i < $length -1 ; $i++) {
    $sum += $arrNum[$i] + $arrNum[$i + 1];
}
if ($sum % 2 == 1) {
    echo "FIRST", PHP_EOL;die;
}
echo "SECOND", PHP_EOL;die;


<?php

fgets(STDIN);
$results = str_split(trim(fgets(STDIN)));
$anton = 0;
foreach ($results as $result) {
    $anton += $result === 'A' ? 1 : -1;
}

if ($anton > 0) echo "Anton";
if ($anton < 0) echo "Danik";
if ($anton === 0) echo "Friendship";

<?php
$n=readline();
$s=readline();
$t1=0;
$t2=0;
$str=str_split($s,1);
for($i=0;$i<$n;$i++){
    if($str[$i]=='A')
    $t1++;
    else
    $t2++;
}
if($t1==$t2)
echo "Friendship";
elseif($t1>$t2)
echo "Anton";
else
echo "Danik";

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = 0;
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b[$x] == "A")
     {
          $c++;
     }
     else
     {
          $d++;
     }
}
if($c < $d)
{
     print "Danik";
}
elseif($c == $d)
{
     print "Friendship";
}
elseif($c > $d)
{
     print "Anton";
}
?>

<?php
$arr = [];

for ($i=0; $i < 2; $i++) {
        $arr[$i] = readline();
}
$output = 0;

$str =$arr[1];
$A =[];
$D = [];
for ($i = 0; $i < strlen($str); $i++){
    //echo $str[$i];

    if($str[$i]== 'A'){
        array_push( $A, $str[$i]);
    }
    if($str[$i] == 'D'){
        array_push( $D, $str[$i]);

    }

}
if(count($A) > count($D)){
    echo 'Anton';
}

if(count($A) < count($D)){
    echo 'Danik';

}
if(count($A) == count($D)){
    echo 'Friendship';

}

?>

<?php
$n = readline();
$s = readline();
if (substr_count($s, 'A') > substr_count($s, 'D')) {
  echo 'Anton';
}
elseif (substr_count($s, 'A') < substr_count($s, 'D')) {
  echo 'Danik';
}
else {
  echo 'Friendship';
}

<?php

$n = readline();
$wins = str_split(readline());

$a=0;
$d=0;

foreach ($wins as $w) {
    if($w === 'D') {
        $d += 1;
    } elseif($w === 'A') {
        $a += 1;
    }
}

echo $a > $d ? 'Anton' : ( $d > $a ? 'Danik' : 'Friendship');

?>

<?php
$line0 = trim(fgets(STDIN));
$line1 = trim(fgets(STDIN));
$A = substr_count($line1,'A');
$D = $line0 - $A;
if ($A>$D){
	echo "Anton";
} elseif($A < $D){
	echo "Danik";
} else {
	echo "Friendship";
}
?>

<?php
/*
 * Secdra @2020
 */

fscanf(STDIN, "%d", $len);
$word = trim(fgets(STDIN));
$a = substr_count($word, 'A');
printf("%s", ($a > $len - $a) ? 'Anton' : (($a == $len - $a) ? 'Friendship' : 'Danik'));

<?php
$dir = fopen("php://stdin", 'r');;
$input= file('php://stdin');
$a=0;
$d=0;
for ($i=0,$c=strlen(trim($input[1]));$i<$c;$i++){
    if (trim($input[1])[$i] === "A"){
        $a ++;
    }else{
        $d ++;
    }
}

if ($a == $d){
    echo 'Friendship';
}else{
    if ($a > $d){
        echo "Anton";
    }else{
        echo "Danik";
    }
}

<?php
$dir = fopen("php://stdin", 'r');;
$input= file('php://stdin');
$a=0;
$d=0;
$str= trim($input[1]);
for ($i=0,$c=strlen($str);$i<$c;$i++){
    if ($str[$i] === "A"){
        $a ++;
    }else{
        $d ++;
    }
}

if ($a == $d){
    echo 'Friendship';
}else{
    if ($a > $d){
        echo "Anton";
    }else{
        echo "Danik";
    }
}

<?php

//=====================================
// link: https://codeforces.com/contest/734/problem/A
//=====================================

// get inputs
$input = new Input(['number_of_games', 'winning_rounds']);
$winning_rounds = str_split($input->winning_rounds);

// solution
$rounds = [
    'Anton' => 0,
    'Danik' => 0,
];

foreach ($winning_rounds as $w_round) {
    if($w_round == 'A') {
        $rounds['Anton']++;

        continue;
    }

    $rounds['Danik']++;
}

if($rounds['Anton'] > $rounds['Danik']) {
    echo "Anton\n";

    exit;
}

if($rounds['Danik'] > $rounds['Anton']) {
    echo "Danik\n";

    exit;
}

echo "Friendship\n";

//=====================================
// Per-defined helpers
//=====================================
class Input
{
    public $inputs = [];

    public function __construct(array $input_titles = ['line'])
    {
        $this->getInputs($input_titles);
    }

    private function getInputs($input_titles)
    {
        for ($i=0; $i < count($input_titles); $i++) {
            $this->inputs[$input_titles[$i]] = trim(fgets(STDIN));
        }
    }

    public function __get($name)
    {
        return $this->inputs[$name];
    }
}

<?php

//=====================================
// link: https://codeforces.com/contest/734/problem/A
//=====================================

// get inputs
$number_of_games = trim(fgets(STDIN));
$winning_rounds = trim(fgets(STDIN));

// solution
$anton = 0;
$danik = 0;

for ($i=0; $i < $number_of_games; $i++) {
    if($winning_rounds[$i] == 'A') {
        $anton++;

        continue;
    }

    $danik++;
}

if($anton > $danik) {
    echo "Anton\n";

    exit;
}

if($danik > $anton) {
    echo "Danik\n";

    exit;
}

echo "Friendship\n";

<?php
	$n = trim(fgets(STDIN));
	$str = trim(fgets(STDIN));
	$a = preg_match_all("/[A]/", $str);
	$d = preg_match_all("/[D]/", $str);
	echo ($a>$d)?"Anton":(($d>$a)?"Danik":"Friendship");
?>

<?php
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%s", $s);
    $a = 0;
    $d = 0;
        for ($i = 0; $i < $n; $i++){
           if ($s[$i] == "A"){
               $a++;
           }
           else $d++;
        }
  if ($a > $d){
            echo 'Anton';
        }
        else if ($a < $d){
            echo 'Danik';
        }
        else if ($a == $d) {
        echo 'Friendship';
}

<?php
function input()
{
    while (($line = fgets(STDIN)) != PHP_EOL) {
        yield $line;
    }
}

$COUNT = 0;
foreach (input() as $line) {
    if ($COUNT == 0) {
        $n = intval($line);
        ++$COUNT;
        continue;
    }
    $s = $line;

    $c = 0;
    for($i=0; $i<$n; ++$i) {
        if($s[$i] == 'A') {
            ++$c;
        }
    }

    $d = $n-2*$c;
    if( $d > 0)
      echo "Danik";
    elseif ($d < 0)
      echo "Anton";
    else
      echo "Friendship";

    if (++$COUNT > 1) {
        break;
    }
}

<?php
readline();
$s = readline();
$a = substr_count($s, 'A');
$d = substr_count($s, 'D');
echo $a > $d ? 'Anton' : ($a < $d ? 'Danik' : 'Friendship');

<?php
$total = trim(fgets(STDIN));
$str = trim(fgets(STDIN));
$a = 0;
$d = 0;
for ($i=0; $i < $total; $i++) {
	if ($str[$i] === 'A') {
		$a++;
	} elseif ($str[$i] === 'D') {
		$d++;
	}
}

if ($a == $d) {
	echo "Friendship\n";
} elseif ($a > $d) {
	echo "Anton\n";
} else {
	echo "Danik\n";
}

<?php

$numofgames=trim(fgets(STDIN));
$win=trim(fgets(STDIN));
$array=str_split($win);

$arraynum = array_count_values($array);

if ($arraynum[A] == $arraynum[D]) {

    echo "Friendship";

}elseif ($arraynum[A] > $arraynum[D]) {
    echo "Anton";

}else echo "Danik";

?>

<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN, "%s",$s);
$com="AD";

for($i=0;$i<strlen($com);$i++)
{  $count=0;
	for($j=0;$j<strlen($s);$j++)
	{
      if($com[$i]==$s[$j])
      {
      	$count++;
      }
	}
	$store[$i]=$count;
}
if($store[0]>$store[1])
	echo "Anton";
else if($store[0]<$store[1])
	echo "Danik";
else echo "Friendship";

<?php

function gaber($n , $s )
{
     $anton = 0 ;
     $danik = 0 ;
     for( $i=0; $i< strlen($s) ; $i++)
     {
          if( $s[$i] == "A" )
          {
               $anton++ ;
          }
          else
          {
               $danik++ ;
          }
     }
     if( $anton > $danik )
     {
          echo "Anton" ;
     }
     else if( $anton < $danik )
     {
          echo "Danik" ;
     }
     else
     {
          echo "Friendship" ;
     }
}

$stdout = fopen( getenv( "OUTPUT_PATH" ) , "w" ) ;
$stdin = fopen( "php://stdin" , "r" ) ;

fscanf( $stdin , "%d" , $n ) ;
fscanf( $stdin , "%s", $s);

//$arr = array_map('intval', preg_split('/ /', $ar_temp, -1, PREG_SPLIT_NO_EMPTY) );

$result = gaber( $n , $s )  ;

fwrite ( $stdout , $result . "\n" ) ;

fclose( $stdin ) ;
fclose( $stdout ) ;

?>

<?php
$N = rtrim(fgets(STDIN));
$string = rtrim(fgets(STDIN));
$Anton = substr_count($string,"A");
$Danik = substr_count($string,"D");
if($Anton>$Danik){
    echo("Anton");
}elseif ($Anton<$Danik){
    echo("Danik");
}else {
    echo("Friendship");
}

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;
    fscanf($handle, "%d", $d);
    fscanf($handle, "%s", $s);
    printf("%s", check($s,$d));
}

solve();
?>

<?php
$a = trim(fgets(STDIN));
$str = trim(fgets(STDIN));

$c = 0;
$d = 0;
for ($i=0; $i<$a; $i++)
{
    if ('A' == $str[$i])
    {
        $c++;
    }
    else
    {
        $d++;
    }
}

if ($c > $d)
{
    echo 'Anton';
}else if ($c < $d)
{
    echo 'Danik';
}else if ($c == $d)
{
    echo 'Friendship';
}

<?
namespace P734\A;
    /**
     * @file          : main.php
     * @author        : Khalil Fazal <khalil.fazal@uoit.net>
     * @creation_date : 2016-11-18 09:34
     * @project       : codeforces
     */

    /**
     * @title        : A. Anton and Danik
     * @link         : http://codeforces.com/problemset/problem/734/A
     * @tags         : implementation, strings
     * @time_limit   : 1 s
     * @memory_limit : 256 MB
     * @input        : stdin
     * @output       : stdout
     *
     * Anton likes to play chess, and so does his friend Danik.
     *
     * Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik.
     * None of the games ended with a tie.
     *
     * Now Anton wonders, who won more games, he or Danik? Help him determine this.
     *
     * Input
     *      The first line of the input contains a single integer n (1 ≤ n ≤ 1e5) — the number of games played.
     *      The second line contains a string s, consisting of n uppercase English letters 'A' and 'D'
     *      — the outcome of each of the games.
     *      The i-th character of the string is equal to 'A' if the Anton won the i-th game
     *      and 'D' if Danik won the i-th game.
     *
     * Output
     *      If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.
     *      If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.
     *      If Anton and Danik won the same number of games, print "Friendship" (without quotes).
     */

/**
 * @param string $string
 * @param string $char
 *
 * @return int
 */
function freq($string, $char): int {
    return count_chars($string, 0)[ord($char)];
}

$stdin = fopen("php://stdin", "r");
fgets($stdin);
$games = fgets($stdin);

switch (freq($games, "A") <=> freq($games, "D")) {
    case -1:
        echo "Danik";
        break;
    case 0:
        echo "Friendship";
        break;
    case 1:
        echo "Anton";
        break;
}

<?php
$a=trim(fgets(STDIN));
$b=trim(fgets(STDIN));
if( substr_count($b,"D")> substr_count($b,"A"))  echo "Danik";
else if( substr_count($b,"D")< substr_count($b,"A")) echo "Anton";
else echo "Friendship";

?>

<?php

//First Get The Input.
$input = file_get_contents("php://stdin");

$n = explode("\r\n",$input)[0];
$str = explode("\r\n",$input)[1];

$n = trim($n,"\r\n");
$str = trim($str,"\r\n");

$a = 0;

for($i = 0;$i < $n;$i++) {

    if($str[$i] == "A") {

        $a++;

    }

}

$d = $n - $a;

if($a > $d) {

    echo "Anton";

}elseif($a < $d) {

    echo "Danik";

}else {

    echo "Friendship";

}

<?php
    $n = trim(fgets(STDIN));
    $s = trim(fgets(STDIN));
    $W_A = strlen(str_replace("D", "", $s));
    $W_D = $n - $W_A;
    if ($W_A > $W_D) {
      echo "Anton";
    }elseif ($W_A == $W_D) {
      echo "Friendship";
    }else {
      echo "Danik";
    }
 ?>

<?php
fscanf(STDIN, '%d\n', $n);
$line = fgets(STDIN);
$a = 0;
$d = 0;

for ($i=0; $i < $n; $i++) {
	if ($line[$i] == 'A') {
		$a++;
	}else{
		$d++;
	}
}

if($a > $d){
	print_r("Anton");
}elseif ($d > $a) {
	print_r("Danik");
}else{
	print_r("Friendship");
}

<?php

/**
 * @author Sunwarul
 */

$n = (int) fgets(STDIN);
$str = trim(fgets(STDIN));

$anton = 0;
$danik = 0;

for ($i = 0; $i < strlen($str); $i++) {
    if ($str[$i] === 'A') {
        $anton++;
    } else if ($str[$i] === 'D') {
        $danik++;
    }
}

if ($anton > $danik) {
    echo "Anton\n";
} else if ($danik > $anton) {
    echo "Danik\n";
} else {
    echo "Friendship\n";
}

<?php
	$n = trim(fgets(STDIN));
	$s = trim(fgets(STDIN));
	$a = $d = 0;
	for($i = 0; $i < $n; $i++)
		if($s[$i] == 'A') $a++;
		else $d++;
	echo $a > $d ? 'Anton' : ($a < $d ? 'Danik' : 'Friendship');
?>

<?php

$number = readline();
$a = readline();

$b = preg_match_all('/[A]/', $a);
$c = preg_match_all('/[D]/', $a);

if ($b > $c) {
	echo "Anton";
}elseif($b == $c){
	echo "Friendship";
}else{
	echo "Danik";
}

<?php

$num = (int)readline();

$str = readline();

if(substr_count($str, 'A') > substr_count($str,'D')) {
    echo 'Anton';
} elseif(substr_count($str, 'A') < substr_count($str,'D')) {
    echo 'Danik';
} else echo 'Friendship';

<?php
$NotRequiredVariable=readline();
$str = readline();
$a = str_split($str);
$b=strlen($str);
$ab=0;
$ac=0;
for($i=0;$i<$b;$i++)
{
    $c=$a[$i];
    if ($c=="A")
    {
        $ab++;
    }
    if ($c=="D")
    {
        $ac++;
    }
}
if ($ab==$ac)
{
    echo"Friendship";
}
else if($ab>$ac)
{
    echo"Anton";
}
else{
    echo "Danik";
}
?>

<?php

$number = readline();
$a = readline();

$b = preg_match_all('/[A]/', $a);
$c = preg_match_all('/[D]/', $a);

if ($b > $c) {
	echo "Anton";
}elseif($b == $c){
	echo "FriendShip";
}else{
	echo "Danik";
}

<?php

$num = (int)readline();

$str = readline();

if(substr_count('A' , $str) > substr_count('D', $str)) {
    echo 'Anton';
} elseif(substr_count('A' , $str) < substr_count('D', $str)) {
    echo 'Danik';
} else echo 'Friendship';

<?php
$a=readline();
$b=readline();
$ab=0;
$ac=0;
$q="A";
$v="D";
$m=strlen($b);
for($i=0;$i<$m;$i++)
{
if (strpos($b,$q)==true)
{
    $ab++;
}
if(strpos($b,$v)==true)
{
    $ac++;
}
}
if ($ab==$ac)
{
    echo"Friendship";
}
else if($ab>$ac)
{
    echo"Anton";
}
else{
    "Danik";
}
?>

<?php
$str = readline();
$a = str_split($str);
$b=strlen($str);
$ab=0;
$ac=0;
for($i=0;$i<$b;$i++)
{
    $c=$a[$i];
    if ($c=="A")
    {
        $ab++;
    }
    if ($c=="D")
    {
        $ac++;
    }
}
if ($ab==$ac)
{
    echo"Friendship";
}
else if($ab>$ac)
{
    echo"Anton";
}
else{
    echo "Danik";
}
?>

<?php
$a=readline();
$b=readline();
$ab=0;
$ac=0;
$q="A";
$v="D";
$m=strlen($b);
for($i=0;$i<$m;$i++)
{
if (strpos($b,$q)==true)
{
    $a1++;
}
if(strpos($b,$v)==true)
{
    $a2++;
}
}
if ($ab==$ac)
{
    echo"Friendship";
}
else if($ab>$ac)
{
    echo"Anton";
}
else{
    "Danik";
}
?>

<?php

$wins = str_split(readline());

$a=0;
$d=0;

foreach ($wins as $w) {
    if($w === 'D') {
        $d += 1;
    } elseif($w === 'A') {
        $a += 1;
    }
}

echo $a > $d ? 'Anton' : ( $d > $a ? 'Danik' : 'Friendship');

?>

<?php
$line0 = trim(fgets(STDIN));
$line1 = trim(fgets(STDIN));
$A = substr_count($line1,'A');
if ($line0 - $A>0){
	echo "Anton";
} elseif($line0 - $A < 0){
	echo "Danik";
} else {
	echo "Friendship";
}
?>

<?php
$line0 = trim(fgets(STDIN));
$line1 = trim(fgets(STDIN));
$A = substr_count($input,$x);
if ($A - $line0>0){
	echo "Anton";
} elseif($A - $line0 < 0){
	echo "Danik";
} else {
	echo "Friendship";
}
?>

<?php
$dir = fopen("php://stdin", 'r');;
$input= file('php://stdin');
$a=0;
$d=0;
for ($i=0,$c=strlen($input[1]);$i<$c;$i++){
    if ($input[1][$i] == "A"){
        $a ++;
    }else{
        $d ++;
    }
}

if ($a == $d){
    echo 'Friendship';
}else{
    if ($a > $d){
        echo "Anton";
    }else{
        echo "Danik";
    }
}

<?php

$dir = fopen("php://stdin", 'r');;
$input= file('php://stdin');
$a=0;
$d=0;
for ($i=0,$c=strlen($input[1]);$i<$c;$i++){
    if ($input[1][$i] === "A"){
        $a ++;
    }else{
        $d ++;
    }
}

if ($a == $d){
    echo 'Friendship';
}else{
    if ($a > $d){
        echo "Anton";
    }else{
        echo "Danik";
    }
}

<?php
readline();
$s = readline();
$a = substr_count($s, 'A');
$d = substr_count($s, 'D');
echo $a > $d ? 'Anton' : $a < $d ? 'Danik' : 'Friendship';

<?php
function getinput()
{
	$handle = fopen("php://stdin", 'r');
	return trim(fgets($handle));
}
$total = (int) getinput();
$str = getinput();
$a = 0;
$d = 0;
for ($i=0; $i < $total; $i++) {
	if ($str[$i] === 'A') {
		$a++;
	} elseif ($str[$i] === 'D') {
		$d++;
	}
}

if ($a == $d) {
	echo "Friendship\n";
} elseif ($a > $d) {
	echo "Anton\n";
} else {
	echo "Danik\n";
}

$_N = rtrim(fgets(STDIN));
$string = rtrim(fgets(STDIN));
$Anton = substr_count($string,"A");
$Danik = substr_count($string,"D");
if($Anton>$Danik){
    echo("Anton");
}elseif ($Anton<$Danik){
    echo("Danik");
}else {
    echo("Friendship");
}

<?php

function check($s)
{
    $c=0;$r=0;
    foreach ($s as $b)
    {
        if($b=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";
    fscanf($handle, "%s", $s);
    printf("%s", check($s));
}

solve();
?>

<?php
$a=trim(fgets(STDIN));
$b=trim(fgets(STDIN));
if( substr_count($b,"D")> substr_count($b,"A"))  echo "Danik"; else echo "Anton";

?>

<?php
    $n = 6;
    $s = "ADDADD";
    $W_A = strlen(str_replace("D", "", $s));
    $W_D = $n - $W_A;
    if ($W_A > $W_D) {
      echo "Anton";
    }elseif ($W_A == $W_D) {
      echo "Friendship";
    }else {
      echo "Danik";
    }
 ?>


<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    list($n, $m) = IO::arr();
    $a = IO::arr();
    $f = $a[0];
    $b = array_flip($a);
    sort($a);
    $res = 1;
    for ($i = 1; $i < $n; $i++) {
        if ($i == 0) {
            if ($f != $a[$i]) {
               $res++;
            }
        } else {
            $x = $a[$i];
            $y = $a[$i - 1];
            if ($b[$x] - $b[$y] !== 1) {
                $res++;
            }
        }
    }

    if ($res <= $m) {
        IO::yes();
    } else {
        IO::no();
    }

}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));

  $s = $a[0];
  $c = 1;

  $b = array_flip($a);
  sort($a);

  for ($j = 1; $j < $n; $j++) {
    if ($j == 0) {
      if ($s != $a[$j]) { $c++; }
    } else {
      if ($b[$a[$j]] - $b[$a[$j - 1]] != 1) {
        $c++;
      }
    }
  }

  if ($c <= $k) { echo 'YES'.PHP_EOL; }
  else { echo 'NO'.PHP_EOL;}
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));

  $c = array();
  $z = 0;
  $b = 0;

  for ($j = 0; $j < $n; $j++) {
    while ($a[$j] < $a[$j + 1]) {
      $j++;
      $c[$b] = $z++;
    }
    $b++;
  }
  $d = $n - count($c);
  if ($d <= $k || (count($c) == 1 && $z == $n - 1)) { echo 'YES'.PHP_EOL; }
  else { echo 'NO'.PHP_EOL;}
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $a = explode(" ", trim(fgets($file)));

  $c = 0;

  for ($j = 0; $j < $n; $j++) {
    while ($a[$j] < $a[$j + 1]) {
      $j++;
      $c++;
    }
  }
  $d = $n - $c;
  if ($d <= $k) { echo 'YES'.PHP_EOL; }
  else { echo 'NO'.PHP_EOL;}
}

?>

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    list($n, $m) = IO::arr();
    $a = IO::arr();
    $f = $a[0];
    $b = array_flip($a);
    sort($a);
    $res = 0;
    for ($i = 0; $i < $n; $i++) {
        if ($i == 0) {
            if ($f != $a[$i]) {
               $res++;
            }
        } else {
            $x = $a[$i];
            $y = $a[$i - 1];
            if ($b[$x] - $b[$y] !== 1) {
                $res++;
            }
        }
    }

    if ($res <= $m) {
        IO::yes();
    } else {
        IO::no();
    }

}

?>

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    list($n, $m) = IO::arr();
    $a = IO::arr();
    $res = 0;
    $last = $a[0];
    for($i = 0; $i < $n; $i++) {
        if(!isset($a[$i+1])) {
            continue;
        }
        if ($a[$i] > $a[$i+1]) {
            $res++;
        } elseif ($a[$i+1] < $last) {
            $res++;
        }
        if ($last < $a[$i + 1]) {
            $last = $a[$i+1];
        }
    }
    if ($res <= $m) {
        IO::yes();
    } else {
        IO::no();
    }

}

?>

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    list($n, $m) = IO::arr();
    $a = IO::arr();
    $res = 0;
    $last = $a[0];
    for($i = 0; $i < $n; $i++) {
        if(!isset($a[$i+1])) {
            continue;
        }
        if ($a[$i] > $a[$i+1]) {
            $res++;
        } elseif ($a[$i] < $last) {
            $res++;
        }
        if ($a[$i] > $last) {
            $last = $a[$i];
        }
    }
    if ($res <= $m) {
        IO::yes();
    } else {
        IO::no();
    }

}

?>


<?php
$n = intval(trim(fgets(STDIN)));
$kr = trim(fgets(STDIN));
$sh = trim(fgets(STDIN));
$kt = trim(fgets(STDIN));

$krn = $shn = $ktn = [];

$len = strlen($kr);
if ($len <= $n) {
	die("Draw\n");
}
for($i=0; $i<$len; $i++){
	if (!isset($krn[$kr[$i]])) {
		$krn[$kr[$i]] = 0;
	}
	if (!isset($shn[$sh[$i]])) {
		$shn[$sh[$i]] = 0;
	}
	if (!isset($ktn[$kt[$i]])) {
		$ktn[$kt[$i]] = 0;
	}
	$krn[$kr[$i]] += 1;
	$shn[$sh[$i]] += 1;
	$ktn[$kt[$i]] += 1;
}

$krx = max($krn);
$shx = max($shn);
$ktx = max($ktn);
// echo "$krx -- $ktx -- $shx\n";
if ($krx == $len && $n == 1) {
	$krx--;
}elseif(($len - $krx) <= $n){
	$krx = $len;
}else{
	$krx += $n;
}

if ($shx == $len && $n == 1) {
	$shx--;
}elseif(($len - $shx) <= $n){
	$shx = $len;
}else{
	$shx += $n;
}

if ($ktx == $len && $n == 1) {
	$ktx--;
}elseif(($len - $ktx) <= $n){
	$ktx = $len;
}else{
	$ktx += $n;
}
// echo "$krx -- $ktx -- $shx\n";
if((($krx == $shx) && $krx >= $ktx) || (($krx == $ktx) && $krx >= $shx) || (($shx == $ktx) && $shx >= $krx)){
	die("Draw\n");
}else{
	if($ktx > $shx && $ktx > $krx){
		echo "Katie\n";
	}elseif($krx > $ktx && $krx > $shx){
		echo "Kuro\n";
	}else{
		echo "Shiro\n";
	}
}

<?php
$n = intval(trim(fgets(STDIN)));
$kr = trim(fgets(STDIN));
$sh = trim(fgets(STDIN));
$kt = trim(fgets(STDIN));

$krn = $shn = $ktn = [];

$len = strlen($kr);
if ($len <= $n) {
	die("Draw\n");
}
for($i=0; $i<$len; $i++){
	if (!isset($krn[$kr[$i]])) {
		$krn[$kr[$i]] = 0;
	}
	if (!isset($shn[$sh[$i]])) {
		$shn[$sh[$i]] = 0;
	}
	if (!isset($ktn[$kt[$i]])) {
		$ktn[$kt[$i]] = 0;
	}
	$krn[$kr[$i]] += 1;
	$shn[$sh[$i]] += 1;
	$ktn[$kt[$i]] += 1;
}

$krx = max($krn);
$shx = max($shn);
$ktx = max($ktn);
// echo "$krx -- $ktx -- $shx\n";
if(($len - $krx) <= $n){
	$krx = $len;
}else{
	$krx += $n;
}

if(($len - $shx) <= $n){
	$shx = $len;
}else{
	$shx += $n;
}

if(($len - $ktx) <= $n){
	$ktx = $len;
}else{
	$ktx += $n;
}
// echo "$krx -- $ktx -- $shx\n";
if((($krx == $shx) && $krx > $ktx) || (($krx == $ktx) && $krx > $shx) || (($shx == $ktx) && $shx > $krx)){
	die("Draw\n");
}else{
	if($ktx > $shx && $ktx > $krx){
		echo "Katie\n";
	}elseif($krx > $ktx && $krx > $shx){
		echo "Kuro\n";
	}else{
		echo "Shiro\n";
	}
}

<?php
$n = intval(trim(fgets(STDIN)));
$kr = trim(fgets(STDIN));
$sh = trim(fgets(STDIN));
$kt = trim(fgets(STDIN));

$krn = $shn = $ktn = [];

$len = strlen($kr);
if ($len <= $n) {
	die("Draw\n");
}
for($i=0; $i<$len; $i++){
	if (!isset($krn[$kr[$i]])) {
		$krn[$kr[$i]] = 0;
	}
	if (!isset($shn[$sh[$i]])) {
		$shn[$sh[$i]] = 0;
	}
	if (!isset($ktn[$kt[$i]])) {
		$ktn[$kt[$i]] = 0;
	}
	$krn[$kr[$i]] += 1;
	$shn[$sh[$i]] += 1;
	$ktn[$kt[$i]] += 1;
}
// print_r($krn);
// print_r($ktn);
// print_r($shn);

$krx = max($krn);
$shx = max($shn);
$ktx = max($ktn);

if((($krx == $shx) && $krx > $ktx) || (($krx == $ktx) && $krx > $shx) || (($shx == $ktx) && $shx > $krx)){
	die("Draw\n");
}else{
	if($ktx > $shx && $ktx > $krx){
		echo "Katie\n";
	}elseif($krx > $ktx && $krx > $shx){
		echo "Kuro\n";
	}else{
		echo "Shiro\n";
	}
}


<?php
$file=file("input.txt");
    $direction=trim($file[0]);
    $dver=trim($file[1]);

if ($direction=="front")
    if($dver==1) $pos = "L"; else $pos = "R";
if ($direction=="back")
   if($dver==1) $pos = "R"; else $pos = "L";

     $File = "output.txt";
 $Handle = fopen($File, 'w');
 fwrite($Handle, $pos);
?>

<?php
$input = fopen("input.txt","r");
$output = fopen("output.txt","w");
while(($line = fgets($input)) == true) {
$data[0] = sscanf($line, "%s");
if ($data[0] == "")break;
$line = fgets($input);
$data[1] = sscanf($line, "%d");
//echo $data[0] . " " . $data[1] . "\n";
if ($data[0][0] == "front")$data[1][0]++;
$data[1][0] = $data[1][0]%2;
if ($data[1][0] == 1)$res = "R\n";
else $res = "L\n";
fwrite($output, $res);
}
fclose($input);
fclose($output);
?>

<?
$lines=file_get_contents("input.txt");
$lines = trim($lines);

$lines=explode("\n", $lines);

$dir=trim($lines[0]);
$por=trim($lines[1]);

if ($dir=="front")
    $res=($por==1)?"L":"R";
if ($dir=="back")
    $res=($por==1)?"R":"L";
file_put_contents("output.txt", $res);
?>

<?php
$file=file("input.txt");
    $direction=explode(" ",$file[0]);
    $dver=explode(" ",$file[1]);

if ($direction=="front")
    if($dver==1) $pos = "L"; else $pos = "R";
if ($direction=="back")
   if($dver==1) $pos = "R"; else $pos = "L";

     $File = "output.txt";
 $Handle = fopen($File, 'w');
 fwrite($Handle, $pos);
?>

<?php
$input = fopen("input.txt","r");
$output = fopen("output.txt","w");
while(($line = fgets($input)) == true) {
$data = sscanf($line, "%s %d");
if ($data[0] == "")break;
if ($data[0] == "front")$data[1]++;
$data[1] = $data[1]%2;
if ($data[1] == 1)$res = "L\n";
else $res = "R\n";
fwrite($output, $res);
}
fclose($input);
fclose($output);
?>


<?php

$al = range('a', 'z');

fscanf(STDIN, '%d', $t);

$totalScan = 0;
$totalProc = 0;
$totalPrint = 0;

while ($t--) {
    fscanf(STDIN, '%d', $n);

    $start = microtime(true);
    $chars = fscanf(STDIN, str_repeat('%c', $n));
    foreach ($chars as &$char) {
        $char = (int)$char;
    }
    unset($char);
    $totalScan += microtime(true) - $start;

    $res = [];

    $start = microtime(true);

    for ($i = 0; $i < $n; ++$i) {
        $char = $chars[$i];

        if ($char === 0) {
            if ($i + 1 < $n && $chars[$i + 1] === 0) {
                $res[] = $char;
            } else {
                $last = array_pop($res);
                $num = array_pop($res);

                $res [] = $num * 10 + $last;
            }
        } else {
            $res[] = $char;
        }
    }

    $totalProc += microtime(true) - $start;

    $start = microtime(true);
    $out = [];
    foreach ($res as $it) {
        $out[] = $al[$it - 1];
    }
    echo implode('', $out).PHP_EOL;

    $totalPrint += microtime(true) - $start;
}

//var_dump($totalScan, $totalProc, $totalPrint);

/*

315045

5 4 15

9
6
315045
4
1100
7
1213121
6
120120
18
315045615018035190
7
1111110
7
1111100
5
11111
4
2606

 */


<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
for ($i = 0; $i < $c; $i++) {
    $d[$i] = trim(fgets(STDIN));
}
for ($k = 0; $k < $c; $k++) {
    $j = 0;
    $flag = true;
    for ($i = 0; $i < strlen($b); $i++) {
        if ($j == strlen($d[$k]) and $b[$i] != '*') {
            print "No\n";
            $flag = false;
            break;
        }
        if ($b[$i] == '?') {
            if (strpos($a, $d[$k][$j]) === false) {
                print "No\n";
                $flag = false;
                break;
            }
            $j++;
        } elseif ($b[$i] == '*') {
            $n = strlen($d[$k]) - strlen($b) + 1;
            if ($n < 0) {
                print "No\n";
                $flag = false;
                break;
            } else {
                for ($p = 0; $p < $n; $p++) {
                    if (strpos($a, $d[$k][$j]) !== false) {
                        print "No\n";
                        $flag = false;
                        break 2;
                    }
                    $j++;
                }
            }
        } else {
            if ($d[$k][$j] != $b[$i]) {
                print "No\n";
                $flag = false;
                break;
            }
            $j++;
        }
    }
    if ($flag) {
        if ($j == strlen($d[$k])) {
            print "Yes\n";
        } else {
            print "No\n";
        }
    }
}
?>


<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

class Utils {
	/* Perform action N times. Can return values in array */
	static public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}
	/* Integral. Keys preserved. By reference. */
	static public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}
	/* Difference. Keys preserved. By reference. */
	static public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}
	static public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
}

class PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = [];
	static public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}
	static public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}
}

/*****************************************/

$ir = new InputReader();

/* TASK */

list($n, $k) = $ir->readArrayOfInt(2);
$a = $ir->readArrayOfInt($n);
$b = [];

for ($i=0; $i<$n; $i++) {
	if (!isset($b[$a[$i]])) {
		$b[$a[$i]] = [];
	}

	$b[$a[$i]][] = $i;
}

$d = 0;
$cs = $a;
foreach ($b as $v=>$g) {
	if (count($g) > $k) {
		echo "NO";
		exit();
	}

	foreach ($g as $ind) {
		$cs[$ind] = ($d%$k)+1;
		$d++;
	}
}

if ($d>=$k) {
	echo "YES\n";
	echo implode(' ', $cs);
} else {
	echo "NO\n";
}

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = array();
for($x = 0; $x < $a; $x++)
{
     $d[$c[$x]]++;
}
$e = max($d);
if($e > $b)
{
     print "NO";
}
else
{
     print "YES\n";
     asort($c);
     $f = array_keys($c);
     $g = 1;
     for($x = 0; $x < $a; $x++)
     {
          if($g > $b)
          {
               $g = 1;
          }
          $c[$f[$x]] = $g;
          $g++;
     }
     ksort($c);
     print implode(" ", $c);
}
?>

<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

class Utils {
	/* Perform action N times. Can return values in array */
	static public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}
	/* Integral. Keys preserved. By reference. */
	static public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}
	/* Difference. Keys preserved. By reference. */
	static public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}
	static public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
}

class PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = [];
	static public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}
	static public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}
}

/*****************************************/

$ir = new InputReader();

/* TASK */

list($n, $k) = $ir->readArrayOfInt(2);
$a = $ir->readArrayOfInt($n);

$cs = [];
for ($i=0; $i<$n; $i++) {
	if (!isset($cs[$a[$i]])) {
		$cs[$a[$i]] = 1;
	}

	$cs[$a[$i]]++;
	$a[$i] = $cs[$a[$i]]-1;
}

$m = max($cs);
if ($m==$k+1) {
	echo "YES\n";
	echo implode(' ', $a);
} else {
	echo "NO\n";
}


<?php
function solve() {
    $n = Read::int();
    $b = trim(fgets(STDIN));
    $res = '1';
    $a = [$b[0] + 1];
    for ($i = 1; $i < $n; $i++) {
        $count = intval($b[$i]) + 1;
        if ($count == $a[$i-1]) {
            $a[] = intval($b[$i]);
            $res .= '0';
        } else {
            $a[] = $count;
            $res .= '1';
        }
    }

    return $res;
}

#$t = 1;
$t = Read::int();
while ($t--) {
    echo solve();
    echo "\n";
}

class Read
{
    public static function string()
    {
        return trim(fgets(STDIN));
    }

    public static function int()
    {
        return intval(fgets(STDIN));
    }

    public static function array_int($sep = ' ')
    {
        $s = trim(fgets(STDIN));
        return preg_split("/[\s,]+/", $s);
    }

}

class Bigint
{
    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 / $bigint2
     */
    public static function div($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);
            case 'floor':
                return bcdiv($bigint1, $bigint2);
            case 'round':
                $sResult = bcdiv($bigint1, $bigint2);
                return bcsub(bcdiv($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcdiv($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 + $bigint2
     */
    public static function add($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcadd($bigint1, $bigint2);
            case 'round':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcadd($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 - $bigint2
     */
    public static function sub($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcsub($bigint1, $bigint2);
            case 'round':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsub($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 * $bigint2
     */
    public static function mul($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcmul($bigint1, $bigint2);
            case 'round':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcmul ($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @return string $bigint1 % $bigint2
     */
    public static function mod($bigint1, $bigint2) {
        return bcmod($bigint1, $bigint2);
    }

    /**
     * @param string $bigint
     * @param string $scale (ceil or floor or round)
     * @return string sqrt($bigint)
     */
    public static function sqrt($bigint, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcadd(bcsqrt ($bigint), 1);
            case 'floor':
                return bcsqrt($bigint);
            case 'round':
                $sResult = bcsqrt($bigint);
                return bcsub(bcsqrt($bigint, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsqrt($bigint);
        }
    }

    /**
     * @param string $bigint
     * @param string $exponent
     * @param string $scale (ceil or floor or round)
     * @return string pow($bigint, $exponent)
     */
    public static function pow($bigint, $exponent, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcpow($bigint, $exponent);
            case 'round':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcpow ($bigint, $exponent);
        }
    }
}

class Algorithms
{

    /** Факторизация - Разложение числа на простые множители
     * @param int $n
     * @return array
     */
    public static function factorization($n)
    {
        $a = [];
        for ($i = 2; $i * $i <= $n; ++$i) {
            $cnt = 0;
            while (bcmod($n, $i) == 0) {
                ++$cnt;
                $n = bcdiv($n, $i);
            }
            if ($cnt > 0) {
                $a[$i] = $cnt;
            }
        }
        if ($n > 1) {
            $a[$n] = 1;
        }

        return $a;
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наибольший общий делитель (НОД)
     */
    public static function gcd($a, $b)
    {
        if ($b == 0) {
            return $a;
        } else {
            $a = $a % $b;
            return self::gcd($b, $a);
        }
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наименьшее общее кратное (НОК)
     */
    public static function lcm($a, $b)
    {
        return abs($a * $b) / self::gcd($a, $b);
    }

    /**Последовательность Фибоначчи =  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
     * return Фибоначчи{n}
     * @param int $n
     * @return int
     */
    public static function fibonacci($n)
    {
        $a = [0, 1];

        for ($i = 2; $i <= $n; $i++) {
            $a[$i] = $a[$i-1] + $a[$i-2];
        }

        return $a[$n];
    }

}

?>

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'NO' . PHP_EOL; }
    public static function no() { echo 'YES' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $b = str_split(IO::str());
    $last = -1;
    $res = '';
    for ($i = 0; $i < $n; $i++) {
        $r = 1;
        if ($last != -1) {
           if ($last == $r + $b[$i]) {
               $r = 0;
           }
        }
        $res .= $r;
        $last = $b[$i] + $r;
    }
    IO::line($res);
}

<?php

/**
 * Соревнование http://codeforces.com/contest/1474
 */

$file = fopen("php://stdin", "r");

$rowsNumber = trim(fgets($file));

for ($i=0; $i<$rowsNumber; $i++) {
    $n = trim(fgets($file));

    $b = trim(fgets($file));

    $string = "";

    for($y=0; $y<$n; $y++) {
        if ($y == 0) {
            $b[$y] = $b[$y] + 1;

            $string .= 1;

            continue;
        }

        if ($b[$y-1] != $b[$y] + 1 ) {
            $b[$y] = $b[$y] + 1;

            $string .= 1;

            continue;
        }

        $string .= 0;
    }

    echo $string;
    echo PHP_EOL;
}

<?php

$t = (int) trim(fgets(STDIN));
for ($i = 0; $i < $t; ++$i) {
    $n[] = (int) trim(fgets(STDIN));
    $b[] = trim(fgets(STDIN));
}
for ($i = 0; $i < $t; ++$i) {
    $ni = $n[$i];
    $bi = $b[$i];
    $bilen = strlen($bi);
    $a[0] = 1;
    $d = $bi[0] + 1;
    for ($j = 1; $j < $bilen; ++$j) {
        switch ($d) {
            case 2:
                $a[$j] = 1 - $bi[$j];
                break;
            case 1:
                $a[$j] = $bi[$j];
                break;
            default:
                $a[$j] = 1;
        }
        $d = $a[$j] + $bi[$j];
    }
    echo implode($a), PHP_EOL;
}

<?php
$t = (int)fgets(STDIN);
for($i=0;$i<$t;$i++)
{
	$n = (int)fgets(STDIN);
	$b = trim(fgets(STDIN));
	$arr = str_split($b);
	$a = '';
	$LAST = -1;
	foreach($arr as $key => $value)
	{
		if($LAST == -1 || $LAST == 0)
			$X = 1;
		else if($LAST == 1)
		{
			if($value == 1)
				$X = 1;
			else
				$X = 0;
		}
		else if($LAST == 2)
		{
			if($value == 1)
				$X = 0;
			else
				$X = 1;
		}
		$a .= $X;
		$LAST = $value + $X;
	}
	print($a."\n");
}
//$end = readline();
?>

<?php

/**
 * Соревнование http://codeforces.com/contest/1474
 */

$file = fopen("php://stdin", "r");

$rowsNumber = trim(fgets($file));

for ($i=0; $i<$rowsNumber; $i++) {
    $n = trim(fgets($file));

    $b = trim(fgets($file));

    $array = str_split($b);

    for($y=0; $y<$n; $y++) {
        if ($y == 0) {
            $array[$y] ++;

            continue;
        }

        if ($array[$y-1] != $array[$y] + 1 ) {
            $array[$y] ++;

            continue;
        }
    }

    $c = implode("", $array);

    printf("%0.0f", $c - $b);
    echo PHP_EOL;
}

<?php

/**
 * Соревнование http://codeforces.com/contest/1474
 */

$file = fopen("php://stdin", "r");

$rowsNumber = trim(fgets($file));

for ($i=0; $i<$rowsNumber; $i++) {
    $n = trim(fgets($file));

    $b = trim(fgets($file));

    $array = str_split($b);

    for($y=0; $y<$n; $y++) {
        if ($y == 0) {
            $array[$y] ++;

            continue;
        }

        if ($array[$y-1] != $array[$y] + 1 ) {
            $array[$y] ++;

            continue;
        }
    }

    $c = implode("", $array);

    echo ($c - $b).PHP_EOL;
}


<?php
    define("MAXN", 1024) ;
    define("GAP_VAL", 1e-7) ;

    function gap($n)
    {
        return $n < GAP_VAL ;
    }

    $t = intval(trim(fgets(STDIN))) ;
    while($t --)
    {
        $n = intval(trim(fgets(STDIN))) ;

        $arr = explode(" ", trim(fgets(STDIN))) ;

        $odd_cnt = 0 ;
        $even_cnt = 0 ;
        $err_cnt = 0 ;

        for($i = 0; $i < $n ; $i ++)
        {
            $arr[$i] = intval($arr[$i]) ;

            if($arr[$i] & 1) $odd_cnt ++ ;
            else $even_cnt ++ ;

            if(($i&1) == 0 && ($arr[$i]&1) != 0 ) $err_cnt ++ ;
        }

        $t_odd_cnt = intval($n / 2) ;
        $t_event_cnt = $n - $t_odd_cnt ;

        if($t_odd_cnt != $odd_cnt || $t_event_cnt != $even_cnt) echo "-1\n" ;
        else echo $err_cnt . "\n" ;
    }
?>


<?php

// your code goes here

function getAllowed($arr, $i) {
	$avail = ['a' => true, 'b' => true, 'c' => true];
	if($i > 0) {
		if(isset($avail[$arr[$i - 1]])) {
			unset($avail[$arr[$i - 1]]);
		}
	}

	if($i < (strlen($arr) - 1)) {
		$q = $arr[$i + 1];
		if(isset($avail[$q])) {
			unset($avail[$q]);
		}
	}
	return array_keys($avail)[0];
}

fgets(STDIN);

while($f = trim(fgets(STDIN))){
	$a = [];
	//$f = str_explode($f);
    for($i = 0; $i < strlen($f); $i++) {
    	if($f[$i] != "?") {
    		$a[] = $f[$i];
    		if($i === 0) {
    			continue;
    		}

    		if($f[$i - 1] == $f[$i]) {
    			$a = null;
    			break;
    		}
    	} else {
    		$f[$i] = getAllowed($f, $i);
    		$a[] = $f[$i];
    	}
    }

    echo ($a) ? implode('', $a) : "-1";
    echo PHP_EOL;
}

<?php

$n = intval(fgets(STDIN));
$i = 0;
while($i < $n)
{
    $current = fgets(STDIN);
    if(!checkNice($current))
        $res = -1;
    else
    {
        $res = makeNice($current);
    }
    $i++;
    echo $res."\n";
}

function checkNice($string)
{
    $chars = str_split($string);
    $prev = $chars[0];
    unset($chars[count($chars) - 1]);
    foreach($chars as $k => $val)
    {
        if($k == 0 || $val == "?") {
            if($val == "?") $prev = "?";
            continue;
        }

        if($val == $prev && $prev != "?")
            return false;
        $prev = $chars[$k];
    }
    return true;
}

function makeNice($string)
{
    $chars = str_split($string);
    unset($chars[count($chars) - 1]);
    $prev = "";
    $lastChanged = -1;
    foreach($chars as $k => $val)
    {
        if($val == "?")
        {
            $first = "a";
            if($k != count($chars) - 1)
                $last = $chars[$k + 1];
            else
                $last = $first;

            if($k == 0)
                $first = $last;
            else
                $first = $chars[$k - 1];

            $fl = array($first, $last);
            if(!in_array("a", $fl))
                $val = "a";
            if(!in_array("b", $fl))
                $val = "b";
            if(!in_array("c", $fl))
                $val = "c";

            $chars[$k] = $val;
        }
        $prev = $val;
    }
    return implode("", $chars);
}
?>

<?php

$n = intval(fgets(STDIN));
$i = 0;
while($i < $n)
{
    $current = fgets(STDIN);
    if(!checkNice($current))
        $res = -1;
    else
    {
        $res = makeNice($current);
    }
    $i++;
    echo $res."\n";
}

function checkNice($string)
{
    $chars = str_split($string);
    $prev = $chars[0];
    unset($chars[count($chars) - 1]);
    //print_r($chars);
    foreach($chars as $k => $val)
    {
        if($k == 0 || $val == "?") continue;
        //echo $val." ".$prev;
        if($val == $prev && $prev != "?")
            return false;
        $prev = $chars[$k];
    }
    return true;
}

function makeNice($string)
{
    $chars = str_split($string);
    unset($chars[count($chars) - 1]);
    $prev = "";
    $lastChanged = -1;
    foreach($chars as $k => $val)
    {
        if($val == "?")
        {
            /*switch($prev)
            {
                case "":
                    $val = "a";
                    break;
                case "a":
                    $val = "b";
                    break;
                case "b":
                    $val = "c";
                    break;
                case "c":
                    $val = "a";
                    break;
            }     */
            if($k == 0)
                $val = "a";
            else {
                $first = $chars[$k - 1];
                $last = $chars[$k + 1];

                $fl = array($first, $last);
                if(!in_array("a", $fl))
                    $val = "a";
                if(!in_array("b", $fl))
                    $val = "b";
                if(!in_array("c", $fl))
                    $val = "c";

            }
            $chars[$k] = $val;
        }
        $prev = $val;
    }
    return implode("", $chars);
}
?>

<?php

$n = intval(fgets(STDIN));
$i = 0;
while($i < $n)
{
    $current = fgets(STDIN);
    if(!checkNice($current))
        $res = -1;
    else
    {
        $res = makeNice($current);
    }
    $i++;
    echo $res."\n";
}

function checkNice($string)
{
    $chars = str_split($string);
    $prev = $chars[0];
    unset($chars[count($chars) - 1]);
    foreach($chars as $k => $val)
    {
        if($val == "?") $prev = "?";
        if($k == 0 || $val == "?") continue;

        if($val == $prev && $prev != "?")
            return false;
        $prev = $chars[$k];
    }
    return true;
}

function makeNice($string)
{
    $chars = str_split($string);
    unset($chars[count($chars) - 1]);
    $prev = "";
    $lastChanged = -1;
    foreach($chars as $k => $val)
    {
        if($val == "?")
        {
            if($k == 0)
                $val = "a";
            else {
                $first = $chars[$k - 1];
                $last = $chars[$k + 1];

                $fl = array($first, $last);
                if(!in_array("a", $fl))
                    $val = "a";
                if(!in_array("b", $fl))
                    $val = "b";
                if(!in_array("c", $fl))
                    $val = "c";

            }
            $chars[$k] = $val;
        }
        $prev = $val;
    }
    return implode("", $chars);
}
?>

<?php

$n = intval(fgets(STDIN));
$i = 0;
while($i < $n)
{
    $current = fgets(STDIN);
    if(!checkNice($current))
        $res = -1;
    else
    {
        $res = makeNice($current);
    }
    $i++;
    echo $res."\n";
}

function checkNice($string)
{
    $chars = str_split($string);
    $prev = $chars[0];
    unset($chars[count($chars) - 1]);
    foreach($chars as $k => $val)
    {
        if($k == 0 || $val == "?") {
            if($val == "?") $prev = "?";
            continue;
        }

        if($val == $prev && $prev != "?")
            return false;
        $prev = $chars[$k];
    }
    return true;
}

function makeNice($string)
{
    $chars = str_split($string);
    unset($chars[count($chars) - 1]);
    $prev = "";
    $lastChanged = -1;
    foreach($chars as $k => $val)
    {
        if($val == "?")
        {
            if($k == 0)
                $val = "a";
            else {
                $first = $chars[$k - 1];
                if($k != count($chars) - 1)
                    $last = $chars[$k + 1];
                else
                    $last = $first;

                $fl = array($first, $last);
                if(!in_array("a", $fl))
                    $val = "a";
                if(!in_array("b", $fl))
                    $val = "b";
                if(!in_array("c", $fl))
                    $val = "c";

            }
            $chars[$k] = $val;
        }
        $prev = $val;
    }
    return implode("", $chars);
}
?>


<?php

fscanf(STDIN, '%u', $t);

while ($t--) {
    fscanf(STDIN, '%u %u', $n, $q);
    $ar = fscanf(STDIN, str_repeat('%u ', $n));
    $qr = fscanf(STDIN, $qFormat = str_repeat('%u ', $q));

    $heights =
    $maxStairs = array_fill(-1, $n, 0);

    foreach ($ar as $k => $item) {
        $heights[$k] = $heights[$k - 1] + $item;
    }

    foreach ($ar as $k => $a) {
        $maxStairs[$k] = max($maxStairs[$k - 1], $a);
    }

    $res = [];

    foreach ($qr as $q) {
        // find last item, which is less than q + 1
        // find first item which is greater than
        // upper bound algorithm

        $ptr = 0;
        $count = $n;

        while ($count > 0) {
            $half = $count >> 1;
            $midPtr = $ptr + $half;

            if ($maxStairs[$midPtr] <= $q) {
                $ptr = $midPtr + 1;
                $count -= $half + 1;
            } else {
                $count = $half;
            }
        }

        $res[] = $heights[$ptr - 1];
    }

    fprintf(STDOUT, $qFormat.PHP_EOL, ...$res);
}

/*
1
3 1
100 7 10
8
// 0

2
1 1
1
1
3 1
1 1 1
0

// 1, 0

1
5 5
1 2 1 5 1
1 2 0 5 6
// 1 4 0 10 10

1
4 1
1 2 2 3
2
// 5

1
5 1
1 2 3 4 3
3
// 6

1
3 1
3 4 1
1
// 0

1
5 6
1 2 3 4 5
3 2 0 4 5 1

// 117 117 117 117 117 0

 */

<?php

// 1742 E. Scuza (Stairs)
// _prefix_sum_, _binary_search_, _math_, _upper_bound_ , *1200

fscanf(STDIN, '%u', $t);

while ($t--) {
    fscanf(STDIN, '%u %u', $n, $q);
    $ar = fscanf(STDIN, str_repeat('%u ', $n));
    $qr = fscanf(STDIN, $qFormat = str_repeat('%u ', $q));

    $heights =
    $maxStairs = array_fill(-1, $n, 0);

    foreach ($ar as $k => $item) {
        $heights[$k] = $heights[$k - 1] + $item;
    }

    foreach ($ar as $k => $a) {
        $maxStairs[$k] = max($maxStairs[$k - 1], $a);
    }

    $res = [];

    foreach ($qr as $q) {
        // find last item, which is less than q + 1
        // find first item which is greater than
        // upper bound algorithm

        $ptr = 0;
        $count = $n;

        while ($count > 0) {
            $half = $count >> 1;
            $midPtr = $ptr + $half;

            if ($maxStairs[$midPtr] <= $q) {
                $ptr = $midPtr + 1;
                $count -= $half + 1;
            } else {
                $count = $half;
            }
        }

        $res[] = $heights[$ptr - 1];
    }

    fprintf(STDOUT, $qFormat.PHP_EOL, ...$res);
}

/*
1
3 1
100 7 10
8
// 0

2
1 1
1
1
3 1
1 1 1
0

// 1, 0

1
5 5
1 2 1 5 1
1 2 0 5 6
// 1 4 0 10 10

1
4 1
1 2 2 3
2
// 5

1
5 1
1 2 3 4 3
3
// 6

1
3 1
3 4 1
1
// 0

1
5 6
1 2 3 4 5
3 2 0 4 5 1

// 117 117 117 117 117 0

 */

<?php

fscanf(STDIN, '%u', $t);

while ($t--) {
    fscanf(STDIN, '%u %u', $n, $q);
    $ar = fscanf(STDIN, str_repeat('%u ', $n));
    $qr = fscanf(STDIN, $qFormat = str_repeat('%u ', $q));

    $heights = array_fill(-1, $n, 0);
    foreach ($ar as $k => $item) {
        $heights[$k] = $heights[$k - 1] + $item;
    }

    // keep track of where new level starts the first time
    $newLevelStarts = array_flip(array_reverse($ar, true));
    ksort($newLevelStarts);

    $stairs = array_keys($newLevelStarts);

    $iL = 0;
    $iR = count($stairs) - 1;

    // for every question find the first item, which is greater than a $q

    $res = [];

    foreach ($qr as $q) {
        $l = $iL;
        $r = $iR;
        // what if null?
        $prevAltitude = end($stairs);

        // l is the result
        while ($l <= $r) {
            $m = ($l + $r) >> 1;
            $altitude = $stairs[$m];

            if ($altitude <= $q) {
                $l = $m + 1;
            } elseif ($prevAltitude > $q) {
                $r = $m - 1;
            } else {
                // found
                $l = $r = $m;
                break;
            }

            $prevAltitude = $altitude;
        }

        if ($l > $iR) {
            // out of bounds, max value
            $res[] = end($heights);
            continue;
        }

        $resId = $newLevelStarts[$stairs[$l]] - 1;

        $res[] = $heights[$resId];
    }

    fprintf(STDOUT, $qFormat . PHP_EOL, ...$res);
}

/*
2
1 1
1
1
3 1
1 1 1
0
// 1, 0

1
5 5
1 2 1 5 1
1 2 0 5 6
// 1 4 0 10 10

 */


<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for ($j = 0; $j < $m; $j++) {
    list($n, $k) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    rsort($aArray);
    $k = 0;
    $iCount = 0;
    for ($i = 0; $i < count($aArray); $i++) {
        if ($k + $n - $aArray[$i] > $n - 1) {
            break;
        } else {
            $k += $n - $aArray[$i];
            $iCount++;
        }
    }
    echo $iCount . "\n";
}

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$t = IO::str();
$res = array();
while ($t--) {
    list ($n, $k) = IO::arr();
    $mv = $n;
    $arr = IO::arr();

    sort($arr);
    $farr = array_reverse($arr);

    $sv = 0;
    $cnt = 0;
    $s = 0;
    $turn = 1;
    $koshka = 0;
    foreach ($farr as $a) {
        if ($a > $koshka) {
            $cnt += 1;
            $koshka += $n - $a;
        }
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$t = IO::str();
$res = array();
while ($t--) {
    list ($n, $k) = IO::arr();
    $mv = $n;
    $arr = IO::arr();

    sort($arr);
    $farr = array_reverse($arr);

    $sv = 0;
    $cnt = 0;
    $s = 0;
    $turn = 1;
    foreach ($farr as $a) {

        if ($sv < $k) {
            $s = $mv - $a;
            $sv = $sv + $s;
            if ($sv > $k) {
                break;
            }
            $cnt++;
        } else {
            if ($sv == $k) {
                $s = $mv - $a;
                if ($s <= $mv - $sv) {
                    $cnt++;
                }
            }
            break;
        }

        $turn++;
        if ($turn == $n) {
            break;
        }
    }
    if ($cnt == 0) {
        $cnt = 1;
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$t = IO::str();
$res = array();
while ($t--) {
    list ($n, $k) = IO::arr();
    $mv = $n;
    $arr = IO::arr();

    sort($arr);
    $farr = array_reverse($arr);

    $sv = 0;
    $cnt = 0;
    $s = 0;
    $turn = 1;
    foreach ($farr as $a) {

        if ($sv < $k) {
            $s = $mv - $a;
            $sv = $sv + $s;
            if ($sv > $k) {
                break;
            }
            $cnt++;
        } else {
            if ($sv == $k) {
                $s = $mv - $a;
                if ($s <= $mv - $sv) {
                    $cnt++;
                }
            }
            break;
        }

        $turn++;
        if ($turn == $n) {
            break;
        }
    }
    $res[] = $cnt;
}

foreach ($res as $r) {
    echo $r . "\n";
}


<?php
fscanf(STDIN, "%d\n", $number);
$array = [];
$counterOne = 0;
$counterTwo = 0;
$counterThree = 0;

for ($i=0; $i < $number; $i++) {
	$array[$i] = trim(fgets(STDIN));
}

for ($i=0; $i < count($array); $i++) {
	$array[$i] = explode(' ', $array[$i]);
	$counterOne += intval($array[$i][0]);
	$counterTwo += intval($array[$i][1]);
	$counterThree += intval($array[$i][2]);
}

$counter = $counterOne + $counterTwo + $counterThree;

// NEED TESTING
if($counterOne !== 0 || $counterTwo !== 0 || $counterThree !== 0){
	echo "NO";
} else {
	echo "YES";
}

<?php
	$input_line = trim(fgets(STDIN));
	$arr = array(0,0,0);
	while($i < $input_line)
	{
		$array2 = explode(" ",trim(fgets(STDIN)));
		$arr = array_map('array_sum', array_map(null, $arr, $array2));
		$i++;
	}
	if($arr[0]==0 && $arr[1]==0 && $arr[2]==0)
		echo "YES";
	else
		echo "NO";
?>

<?php

/**
 * @author Sunwarul
 */
error_reporting(0);
$sum = $asum = $bsum = $csum = 0;
$n = (int) fgets(STDIN);
while ($n--) {
    list($a, $b, $c) = explode(' ', fgets(STDIN));
    $asum += (int) $a;
    $bsum += (int) $b;
    $csum += (int) $c;
}
if ($asum == 0 && $bsum == 0 && $csum == 0) {
    echo "YES\n";
} else {
    echo "NO\n";
}

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);
$lines=trim($lines);
$lines=explode("\n", $lines);

$sum_x=$sum_y=$sum_z=0;
for($i=1; $i<count($lines); $i++)
{
    list ($x, $y, $z)=explode (" ", trim ($lines[$i]));
    $sum_x+=$x;
    $sum_y+=$y;
    $sum_z+=$z;
}
if ($sum_x==0 and $sum_y==0 and $sum_z==0)
    echo 'YES';
else
    echo 'NO';
?>

<?php
$count = fgets(STDIN);
while ($line = fgets(STDIN)) {
	$lines[] = sscanf($line, '%d %d %d');
}

$sumx = 0;
$sumy = 0;
$sumz = 0;
for ($i=0; $i < $count; $i++) {
	$sumx += $lines[$i][0];
	$sumy += $lines[$i][1];
	$sumz += $lines[$i][2];
}

if ($sumx === 0 && $sumx === 0 && $sumz === 0) {
    echo 'YES';
} else {
    echo 'NO';
}

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($x, $y, $z)
{
    $x_sum = array_sum($x);
    $y_sum = array_sum($y);
    $z_sum = array_sum($z);

    return $x_sum === 0 && $y_sum === 0 && $z_sum === 0;
}

$r = 0;
$x = $y = $z = [];

list($n) = fscanf($input, "%d\n");

for ($i = 0; $i < $n; $i++) {
    list($x[$i], $y[$i], $z[$i]) = fscanf($input, "%d %d %d\n");
}

$r = foo($x, $y, $z) ? 'YES' : 'NO';

fwrite($output, $r);

<?php
error_reporting("off");
//69A: Young Physicist
//$array = array("3 -1 7", "-5 2 -4", "2 -1 -3");
$n = trim(fgets(STDIN)); //$n = 3;
$multidimen = array();
for ($i = 0; $i < $n; $i++) {
    $multidimen[] = explode(" ", trim(fgets(STDIN)));
    //$multidimen[] = explode(" ", $array[$i]);
}
$xsum = 0;
$ysum = 0;
$zsum = 0;
for ($i = 0; $i < $n; $i++) {
    $xsum = $xsum + $multidimen[$i][0];
    $ysum = $ysum + $multidimen[$i][1];
    $zsum = $zsum + $multidimen[$i][2];
}
if ($xsum == 0 && $ysum == 0 && $zsum == 0) {
    echo "YES";
} else {
    echo "NO";
}
?>

<?php
	$loop = trim(fgets(STDIN));
	$x = $y = $z = 0;
	for ($i=0; $i < $loop; $i++) {
		$input = explode(' ', trim(fgets(STDIN)));
		$x += $input[0];
		$y += $input[1];
		$z += $input[2];
	}
	if($x==0 && $y==0 && $z==0) echo "YES";
	else echo "NO";

?>

<?php
global $cin, $cout;
$cin = fopen('php://stdin', 'r');
$cout = fopen('php://stdout', 'w');

/* Program Code */

$x = 0; $y = 0; $z = 0;

fscanf($cin, "%d\n", $n);

for ($i = 1; $i <= $n; $i++) {
	fscanf($cin, "%d %d %d\n", $fx, $fy, $fz);
	$x += $fx; $y += $fy; $z += $fz;
}

if ($x == $y && $y == $z && $z == 0) {
	fprintf($cout, "YES");
} else {
	fprintf($cout, "NO");
}
?>

<?php
    define('DEBUG', 0);

    if(DEBUG) $GLOBALS['file'] = fopen('input.txt', 'r');
    function debug($var){echo '<pre>';print_r($var);echo '</pre>';}
    function read_line()
    {
        if(DEBUG) { $file = $GLOBALS['file'];$line = trim(fgets($file));}
        else $line = trim(fgets(STDIN));
        return $line;
    }
    function get_array($line){return explode(' ', $line);}
    function read_array(){return get_array(read_line());}
    //echo "$s\n";
    /*****************************************************************/

    $n = read_line();
    $x=0;
    $y=0;
    $z=0;

    for($i=1; $i<=$n; $i++)
    {
        $arr=read_array();
        $x+=$arr[0];
        $y+=$arr[1];
        $z+=$arr[2];
    }

    if(!($x||$y||$z)) echo 'YES';
    else echo 'NO';
?>

<?php
fscanf(STDIN, "%d", $n);
$tx = $ty = $tz = 0;
while($n--) {
	fscanf(STDIN, "%d%d%d", $x, $y, $z);
	$tx += $x;
	$ty += $y;
	$tz += $z;
}
if($tx == 0 AND $ty == 0 AND $tz == 0) {
	echo "YES";
}
else {
	echo "NO";
}

<?php
// 69A  Юный физик
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$n = (int) $input_line;

$x = $y = $z = 0;

for ($i=0; $i < $n; $i++) {
    $input_line = fgets($in);
    list($xi, $yi, $zi) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
    $xi = (int) $xi;
    $yi = (int) $yi;
    $zi = (int) $zi;

    $x += $xi;
    $y += $yi;
    $z += $zi;
}

if (($x == 0) and ($y == 0) and ($z == 0)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
$a = trim(fgets(STDIN));
$e = array();
$f = array();
$g = array();
for($x = 1; $x <= $a; $x++)
{
    list($b, $c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $b);
    array_push($f, $c);
    array_push($g, $d);
}
if((array_sum($e) == 0) && (array_sum($f) == 0) && (array_sum($g) == 0))
{
    print "YES";
}
else
{
    print "NO";
}
?>

<?php
$number = fgets(STDIN);
$lineOne = fgets(STDIN);
$lineOne = explode(' ', trim($lineOne));
$lineTwo = fgets(STDIN);
$lineTwo = explode(' ', trim($lineTwo));
$lineThree = fgets(STDIN);
$lineThree = explode(' ', trim($lineThree));

$array = array_merge($lineThree, $lineTwo, $lineOne);

if(array_sum($array) == 0){
	echo "YES";
} else {
	echo "NO";
}

<?php
fscanf(STDIN, "%d\n", $number);
$array = [];
$counterOne = 0;
$counterTwo = 0;
$counterThree = 0;

for ($i=0; $i < $number; $i++) {
	$array[$i] = trim(fgets(STDIN));
}

for ($i=0; $i < count($array); $i++) {
	$array[$i] = explode(' ', $array[$i]);
	$counterOne += intval($array[$i][0]);
	$counterTwo += intval($array[$i][1]);
	$counterThree += intval($array[$i][2]);
}

$counter = $counterOne + $counterTwo + $counterThree;

if($counter == 0){
	echo "YES";
} else {
	echo "NO";
}

<?php
fscanf(STDIN, "%d\n", $number);
$array = [];
$counter = 0;

for ($i=0; $i < $number; $i++) {
	$array[$i] = trim(fgets(STDIN));
}

for ($i=0; $i < count($array); $i++) {
	$array[$i] = explode(' ', $array[$i]);
	$counter += array_sum($array[$i]);
}

if($counter == 0){
	echo "YES";
} else {
	echo "NO";
}

<?php

/**
 * @autor Sunwarul
 */

$n = (int) fgets(STDIN);
while ($n--) {
    list($a, $b, $c) = explode(' ', fgets(STDIN));
    $sum += (int) $a + (int) $b + (int) $c;
}
if ($sum == 0) {
    echo "YES\n";
} else {
    echo "NO\n";
}

<?php

/**
 * @autor Sunwarul
 */

$n = (int) fgets(STDIN);
while ($n--) {
    list($a, $b, $c) = explode(' ', fgets(STDIN));
    $sum += (int) $a + (int) $b + (int) $c;
    echo "$n for $sum\n";
}
if ($sum == 0) {
    echo "YES\n";
} else {
    echo "NO\n";
}

<?php
while ($line = fgets(STDIN)) {
	$lines[] = $line;
}
$count = array_shift($lines);

$sum = 0;
for ($i=0; $i < $count; $i++) {
	list($x,$y,$z) = sscanf($lines[$i], '%d %d %d');
	$sum = $sum + $x + $y + $z;
}

if ($sum === 0) {
    echo 'YES';
} else {
    echo 'NO';
}

<?php
$line = fgets(STDIN);
while ($line = fgets(STDIN)) {
	$lines[] = $line;
}
$count = array_shift($lines);

$sum = 0;
for ($i=0; $i < $count; $i++) {
	list($x,$y,$z) = sscanf($lines[$i], '%d %d %d');
	$sum = $sum + $x + $y + $z;
}

if ($sum === 0) {
    echo 'YES';
} else {
    echo 'NO';
}

<?php
	$total = 0;
	$n = fgets(STDIN);
	for ($x = 0; $x < $n; $x++) {
		list($v1,$v2,$v3) = explode(' ',fgets(STDIN));
		$sub_total = sqrt( pow( sqrt( pow( $v1 ) + pow( $v2 ) ) ) + sqrt( pow( $v2 ) + pow( $v3 ) ) );
		$total += $sub_total;
	}
	if ($total == 0) echo 'YES';
	else echo 'NO';

<?php
	$total = 0;
	$n = fgets(STDIN);
	for ($x = 0; $x < $n; $x++) {
		list($v1,$v2,$v3) = explode(' ',fgets(STDIN));
		$sub_total = sqrt( pow( sqrt( pow( $v1 ) + pow( $v2 ) ) ) + pow( $v3 ) );
		$total += $sub_total;
	}
	if ($total == 0) echo 'YES';
	else echo 'NO';

<?php
	$input_line = trim(fgets(STDIN));
	$vector = 0;
	while($i < $input_line)
	{
		$vector = $vector + array_sum(explode(" ",trim(fgets(STDIN))));
		$i++;
	}
	echo ($vector==0)?"YES":"NO";
?>

<?php
$fp = fopen("php://stdin", "r");
$input = fgets($fp);
echo $input;
?>

<?php
$sum = 0;
$str = array();
fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    array_push($str, (explode(" ", fgets(STDIN))));
}
$i = 0;
while ($sum == 0 && $i < $n) {
    $sum = array_sum((array_column($str, $i)));
    $i = $i + 1;
}
if ($i == $n - 1) {
    print("YES");
} else {
    print("NO");
}

<?php
$sum = 0;
fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    $sum = array_sum(explode(" ", fgets(STDIN))) + $sum;
}
if ($sum == 0) {
    print("YES");
} else {
    print("NO");
}

<?php
$sum = 0;
$str = array();
fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    array_push($str, (explode(" ", fgets(STDIN))));
}
for ($i = 0; $i < $n; $i++) {
    $sum = array_sum((array_column($str, $i))) + $sum;
}
if ($sum == 0) {
    print("YES");
} else {
    print("NO");
}

<?php
$sum = 0;
$str = array();
fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    array_push($str, (explode(" ", fgets(STDIN))));
}
for ($i = 0; $i < $n; $i++) {
    $sum = array_sum((array_column($str, $i)));
}
if ($sum == 0) {
    print("YES");
} else {
    print("NO");
}

<?php
$sum = 0;
$str = array();
fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    array_push($str, (explode(" ", fgets(STDIN))));
}
$i = 0;
while ($sum == 0 && $i < $n) {
    $sum = array_sum((array_column($str, $i)));
    $i = $i + 1;
}
if ($i == $n) {
    print("YES");
} else {
    print("NO");
}

<?php
fscanf(STDIN, "%d", $n);
$tt = 0;
while($n--) {
	fscanf(STDIN, "%d%d%d", $x, $y, $z);
	$tt += ($x + $y + $z);
}
if($tt == 0) {
	echo "YES";
}
else {
	echo "NO";
}

<?php
$n = trim(fgets(STDIN));

while ($s = fgets(STDIN))
{
    $mas[] = explode(' ', trim($s));
}

for ($i = 0; $i < 3; $i++)
{
    for ($j = 0; $j < count($mas); $j++)
    {
        $sum[$i] += $mas[$j][$i];
    }
}

if (array_sum($sum) == 0)
    echo "YES";
else
    echo "NO";
?>


<?php

function debug($data, $die = true) {
    echo '<pre>';

    if (is_array($data)) {
        print_r($data);
    } else {
        var_dump($data);
    }

    if ($die) {
        die();
    }

    echo '</pre>';
}

function stdin() {
    $stdin = @fopen('data.txt', 'r');
    if (!$stdin) {
        $stdin = fopen('php://stdin', 'r');
    }

    return $stdin;
}

function g() {
    global $stdin;
    return trim(fgets($stdin));
}

$stdin = stdin();
/****************************************************** Solving block *****************************************************/
list($n, $d) = explode(' ', g());
$b = explode(' ', g());

$a = 0;
$cnt = 0;

foreach($b as $item) {
    $inc = 0;
    if($a > $item) {
        $inc += ceil(($a - $item) / $d);

        if($item + $d * $inc == $a) {
            $inc++;
        }
    } else if($a == $item) {
        $inc++;
    }

    $cnt += $inc;
    $a = $item + $d * $inc;
}

echo $cnt;
?>

<?php

list($len, $inc) = sscanf(readline(), "%d %d");
$seq_string = readline();
$start = microtime(true);
$sequence = explode(' ', $seq_string);

$tries = 0;

for ($i = 0; $i < $len -1; $i++){
	$cur = $sequence[$i];
	$nxt = $sequence[$i+1];
	if($cur >= $nxt){
		$new_tries = floor(($cur - $nxt) / $inc) + 1;
		$tries += $new_tries;
		$sequence[$i+1]= $nxt + $new_tries * $inc;
	}
}
echo $tries;

<?php

list($len, $inc) = sscanf(readline(), "%d %d");
$seq_string = readline();
$start = microtime(true);
$sequence = explode(' ', $seq_string);

$tries = 0;

for ($i = 0; $i < $len -1; $i++){
	$cur = $sequence[$i];
	$nxt = $sequence[$i+1];
	if($cur >= $nxt){
		$new_tries = ceil(($cur - $nxt) / $inc) + $inc;
		$tries += $new_tries;
		$sequence[$i+1]= $nxt + $new_tries * $inc;
	}
}
echo $tries;