<?php

$EPS = 1e-6;

class Result {
	function __construct($a, $b, $i) {
		$this->a = $a;
		$this->b = $b;
		$this->i = $i;
	}
	function less($r) {
		global $EPS;
		return abs($this->a - $r->a) > $EPS ? $this->a < $r->a : $this->b < $r->b;
	}
}

function dist($x1, $y1, $x2, $y2) {
	return sqrt(($x1 - $x2)**2 + ($y1 - $y2)**2);
}

fscanf(STDIN, "%d %d %d", $n, $vb, $vs);
$line = fgets(STDIN);
$x = array_map("intval", explode(' ', $line));
//print_r($x);
fscanf(STDIN, "%d %d", $dx, $dy);

$answer = new Result(1e9, 0, -1);
for ($i = 1; $i < $n; $i++) {
	$d = dist($x[$i], 0, $dx, $dy);
	$t = $x[$i] / $vb + $d / $vs;
	$candidate = new Result($t, $d, $i);
	if ($candidate->less($answer))
		$answer = $candidate;
}
print $answer->i + 1;

?>

<?php
function equal($a,$b){
   $FPS=0.00000001;
   return $a-$FPS<$b&&$b<$a+$FPS;
}
list($n,$vb,$vs)=explode(" ",trim(fgets(STDIN)));
$x=explode(" ",trim(fgets(STDIN)));
list($px,$py)=explode(" ",trim(fgets(STDIN)));
$min=10000000;
$d=10000000;
for($i=1;$i<$n;$i++){
  $time=$x[$i]/$vb;
  $xx=$x[$i]-$px;
  $yy=$py;
  $time+=sqrt($xx*$xx+$yy*$yy)/$vs;
  if($min>$time){
     $min=$time;
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }else if(equal($min,$time)&&$d>sqrt($xx*$xx+$yy*$yy)){
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }
}
print(($tn+1));
?>

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

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

list ($n, $bus_speed, $student_speed)=explode(" ", trim($lines[0]));
$stops_x=explode(" ", trim($lines[1]));
list($un_x, $un_y)=explode(" ", trim($lines[2]));
for ($i=1; $i<count($stops_x); $i++)
{
    $n=$i+1;
    $stop[$n]['bus_time']=$stops_x[$i]/$bus_speed;
    $stop[$n]['run_time']=(sqrt(($un_x-$stops_x[$i])*($un_x-$stops_x[$i])+($un_y-0)*($un_y-0)))/$student_speed;
    $stop[$n]['all_time']=$stop[$n]['bus_time']+$stop[$n]['run_time'];
}

$min_time=$stop[2]['all_time'];
$min_run_time=$stop[2]['run_time'];
$num=2;

for ($n=3; $n<count($stop)+2; $n++)
{
    if ($stop[$n]['all_time']<$min_time or ($stop[$n]['all_time']==$min_time and $stop[$n]['run_time']<$min_run_time))
    {
        $min_time=$stop[$n]['all_time'];
        $min_run_time=$stop[$n]['run_time'];
        $num=$n;
    }
}

echo $num;
?>

<?php
function input() {
    return rtrim(fgets(STDIN));
}

function inputarray()
{
    return explode(' ', input());
}

list($n, $vb, $vs) = inputarray();
$x = inputarray();
list($xu, $yu) = inputarray();
$besttime = 1e18;
$ret = 1;
for ($i = 1; $i < $n; $i++)
{
    $time = (double)$x[$i] / $vb + hypot($x[$i] - $xu, $yu) / $vs;
    if ($time < $besttime + 1e-9)
    {
        $besttime = $time;
        $ret = $i + 1;
    }
}
echo "$ret\n";
?>

<?php
list($n,$vb,$vs)=explode(" ",trim(fgets(STDIN)));
$x=explode(" ",trim(fgets(STDIN)));
list($px,$py)=explode(" ",trim(fgets(STDIN)));
$min=10000000;
$d=10000000;
for($i=1;$i<$n;$i++){
  $time=$x[$i]/$vb;
  $xx=$x[$i]-$px;
  $yy=$y[$i];
  $time+=sqrt($xx*$xx+$yy*$yy)/$vs;
  if($min>$time){
     $min=$time;
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }else if($min==$time&&$d>sqrt($xx*$xx+$yy*$yy)){
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }
}
print(($tn+1));
?>

<?php
	$fr = fopen("php://stdin","r");
	$input = fgets($fr);
	list( $n, $b, $s ) = explode(' ', $input);
	$input = fgets($fr);
	$stops = explode(' ', $input);
	$input = fgets($fr);
	list( $x, $y ) = explode(' ', $input);
	fclose ($fr);

	if ( $n == 2 )
		die('2');

function dist($x1, $y1, $x2, $y2)
{
	$x = $x2 - $x1;
	$y = $y2 - $y1;
	return sqrt( $x*$x + $y*$y );
}

	$o = 1;
	$r = array();
	for ( $i = 0; $i < $n; $i+= 1 )
	{
		$r[$i] = dist(0,0,$stops[$i],0) * $b + dist($stops[$i],0,$x,$y) * $s;
		if ( isset($r[$o]) && ($r[$o] > $r[$i]) )
			$o = $i;
	}
	echo max($o, 2);
?>

<?php
	$fr = fopen("php://stdin","r");
	$input = fgets($fr);
	list( $n, $b, $s ) = explode(' ', $input);
	$input = fgets($fr);
	$stops = explode(' ', $input);
	$input = fgets($fr);
	list( $x, $y ) = explode(' ', $input);
	fclose ($fr);

	if ( $n == 2 )
		die('2');

function dist($x1, $y1, $x2, $y2)
{
	$x = $x2 - $x1;
	$y = $y2 - $y1;
	return sqrt( $x*$x + $y*$y );
}

	$b = (float)$b;
	$s = (float)$s;
	$o = 1;
	$r = array();
	for ( $i = 0; $i < $n; $i+= 1 )
	{
		$r[$i] = (float)$stops[$i] / $b + dist($stops[$i],0,$x,$y) / $s;
		if ( isset($r[$o]) && ($r[$o] > $r[$i]) )
			$o = $i;
	}
	echo max($o+1, 2);

?>

<?php

$EPS = 1e-6;

class Result {
	function __construct($a, $b, $i) {
		$this->a = $a;
		$this->b = $b;
		$this->i = $i;
	}
	function less($r) {
		global $EPS;
		return abs($this->a - $r->a) > $EPS ? $this->a < $r->a : $this->b < $r->b;
	}
}

function dist($x1, $y1, $x2, $y2) {
	return sqrt(($x1 - $x2)**2 + ($y1 - $y2)**2);
}

fscanf(STDIN, "%d %d %d", $n, $vb, $vs);
$line = fgets(STDIN);
$x = array_map("intval", explode(' ', $line));
//print_r($x);
fscanf(STDIN, "%d %d", $dx, $dy);

$answer = new Result(1e9, 0, -1);
for ($i = 1; $i < $n; $i++) {
	$d = dist($x[$i], 0, $dx, $dy);
	$t = $x[$i] / $vb + $d / $vs;
	$candidate = new Result($t, $d, $i);
	if ($candidate->less($answer))
		$answer = $candidate;
}
print($answer->i + 1);
?>

<?php
list($n,$vb,$vs)=explode(" ",trim(fgets(STDIN)));
$x=explode(" ",trim(fgets(STDIN)));
list($px,$py)=explode(" ",trim(fgets(STDIN)));
$min=10000000;
for($i=1;$i<$n;$i++){
  $time=$x[$i]/$vb;
  $xx=$x[$i]-$px;
  $yy=$y[$i];
  $time+=sqrt($xx*$xx+$yy*$yy)/$vs;
  if($min>$time){
     $min=$time;
     $tn=$i;
  }
}
print(($tn+1));
?>

<?php
function equal($a,$b){
   $FPS=0.00000001;
   return $a-$FPS<$b&&$b<$a+$FPS;
}
list($n,$vb,$vs)=explode(" ",trim(fgets(STDIN)));
$x=explode(" ",trim(fgets(STDIN)));
list($px,$py)=explode(" ",trim(fgets(STDIN)));
$min=10000000;
$d=10000000;
for($i=1;$i<$n;$i++){
  $time=$x[$i]/$vb;
  $xx=$x[$i]-$px;
  $yy=$y[$i];
  $time+=sqrt($xx*$xx+$yy*$yy)/$vs;
  if($min>$time){
     $min=$time;
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }else if(equal($min,$time)&&$d>sqrt($xx*$xx+$yy*$yy)){
     $tn=$i;
     $d=sqrt($xx*$xx+$yy*$yy);
  }
}
print(($tn+1));
?>


<?php
error_reporting("off");
//339B: Xenia and Ringroad
//Lesson of the day: Functions like global variables.
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 4; $m = 3;
$a = explode(" ", trim(fgets(STDIN))); //$a = explode(" ", "3 2 3");
$currenthouse = 1;
$time = 0;

function travel($from, $to) { //returns the time from house $from to house $to
    global $n;
    if ($to >= $from) {
        return $to - $from;
    } elseif ($to < $from) {
        $dif = $from - $to;
        return $n - $dif;
    }
}

for ($i = 0; $i < $m; $i++) {
    $time += travel($currenthouse, $a[$i]);
    $currenthouse = $a[$i];
}

echo $time;
?>

<?
fscanf(STDIN, "%d", $n);
$c = 1;
foreach (explode(" ", fgets(STDIN)) as $t) {
    $s += ($t - $c + $n) % $n;
    $c = $t;
}
echo $s;
?>

<?php
list($n, $m) = explode(' ', trim(fgets(STDIN)));
$a = explode(' ', trim(fgets(STDIN)));
$i = 1;
$r = 0;
foreach($a as $s) {
 if($s < $i) {
  $r += $s + $n - $i;
  $i = $s;
 } elseif($s > $i) {
  $r += $s - $i;
  $i = $s;
 }
}
echo $r;
?>

<?php
$length=0;
list ($nDomov,$nDel) = explode(" ",trim(fgets(STDIN)));
$poryadok = explode(" ",trim(fgets(STDIN)));
array_unshift($poryadok,"1");
$currentHome = 1;
for ($i=1;$i<count($poryadok);$i++)
{
    if ($poryadok[$i]>$poryadok[$i-1])
    {
        $length+=($poryadok[$i]-$poryadok[$i-1]);
    }
    elseif ($poryadok[$i]<$poryadok[$i-1])
    {
        $length+=($nDomov-$poryadok[$i-1]+$poryadok[$i]);
    }
}
echo $length;

<?php
// 339B     Ксюша и кольцевая дорога
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
list($n, $m) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
$n = (int) $n;
$m = (int) $m;

$input_line = fgets($in);
$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$min = 0;
$house = 1;

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

    $pos = (int) $arr[$i];

    if ($house <= $pos) {
        $min += $pos - $house;
    } else {
        $min += $n - $house + $pos;
    }

    $house = $pos;

//    echo "i=$i house=$house min=$min pos=$pos \n";
}

echo $min;

?>

<?php

$line = trim(fgets(STDIN));
$argv = explode(' ', $line);

//var_dump($argv);

$n = intval($argv[0]);
$m = intval($argv[1]);

$answer = 0;
$from = 1;

$line = trim(fgets(STDIN));
$array = explode(' ', $line);

for ($i = 0; $i < $m; $i ++) {
  $to = $array[$i];
  $answer += ($to - $from + $n) % $n;
  $from = $to;
}

print $answer;

?>

<?php
/*
Ксюша живет в городе, в котором на главной кольцевой дороге находятся n домов. Дома кольцевой пронумерованы от 1 до n по часовой стрелке, по счастливой случайности движение на кольцевой одностороннее и организовано также по часовой стрелке.

Недавно Ксюша переехала на кольцевую в дом с номером 1. В связи с переездом у нее появилось m дел, чтобы сделать i-ое дело, нужно находиться в доме с номером ai, а также сделать все дела с номерами меньше i. Изначально, Ксюша находится в доме с номером 1, найдите какое минимальное количество времени ей нужно потратить, чтобы выполнить все дела, если на переезд между двумя соседними домами на кольцевой требуется одна единица времени.
*/

fscanf(STDIN, "%d%d", $n, $m);	// количество домов и количество дел

$tasks = fgets(STDIN);
$tasks = trim($tasks);
$tasks = explode(' ', $tasks);
array_unshift($tasks, 1);

$result = 0;
$i = 0;
while ($i < $m) {
	if($tasks[$i + 1] >= $tasks[$i]) {
		$result += $tasks[$i + 1] - $tasks[$i];
	} else {
		// что делать, если нужно ехать вспять, а нельзя и придется делать весь круг?
		$result += $n - ($tasks[$i] - $tasks[$i + 1]);
	}
	$i++;
}

echo $result;

<?php

	$n = trim(fgets(STDIN));
	$m = trim(fgets(STDIN));

	$arr = array();
	$arr[0] = 1;
	$time = 0;
	$tmp = 0;

	for($i = 1; $i <= $m; $i++)
	{
		$tmp = 0;
		$tmp = trim(fgets(STDIN));
		$arr[$i] = $tmp;

		if($tmp >= $arr[$i-1])
		{
			$time += ($tmp - $arr[$i-1]);
		}
		else
		{
			$time += ($n - $arr[$i-1] + $tmp);
		}
	}

	fwrite(STDOUT, "$time");

?>

<?php
$length=0;
list ($nDomov,$nDel) = explode(" ",trim(fgets(STDIN)));
$poryadok = explode(" ",trim(fgets(STDIN)));
array_unshift($poryadok,"1");
$currentHome = 1;
for ($i=1;$i<$nDomov;$i++)
{
    if ($poryadok[$i]>$poryadok[$i-1])
    {
        $length+=($poryadok[$i]-$poryadok[$i-1]);
    }
    elseif ($poryadok[$i]<$poryadok[$i-1])
    {
        $length+=($nDomov-$poryadok[$i-1]+$poryadok[$i]);
    }
}
echo $length;

<?php
$length=0;
list ($nDomov,$nDel) = explode(" ",trim(fgets(STDIN)));
$poryadok = explode(" ",trim(fgets(STDIN)));
array_unshift($poryadok,"1");
$currentHome = 1;
var_dump($poryadok);
for ($i=1;$i<count($poryadok);$i++)
{
    if ($poryadok[$i]>$poryadok[$i-1])
    {
        $length+=($poryadok[$i]-$poryadok[$i-1]);
    }
    elseif ($poryadok[$i]<$poryadok[$i-1])
    {
        $length+=($nDomov-$poryadok[$i-1]+$poryadok[$i]);
    }
}
echo $length;


<?php

function FindMirrorWord($string){

    $mirror_reflection_words = 'AHIMOTUVWXY';
    $reverse_string          = strrev($string);
    $matches                 = 1;

    if($reverse_string==$string){
        for($i=0;$i<strlen($string);$i++){
            if (strpos($mirror_reflection_words, $reverse_string[$i]) === false){
                $matches = 0;
                break;
            }
        }
    }
    else{
        $matches = 0;
    }

    if($matches==0)
        return 'NO';
    else
        return 'YES';
}

$string      = trim(fgets(STDIN));
echo FindMirrorWord($string);

<?php

$forward = str_split(trim(fgets(STDIN)));

$reflectable = array('A'=>1, 'H'=>1, 'I'=>1, 'M'=>1, 'O'=>1, 'T'=>1, 'U'=>1, 'V'=>1, 'W'=>1, 'X'=>1, 'Y'=>1);

$n = sizeof($forward);
for($i = 0; $i < $n; $i++)
{
	if($forward[$i] != $forward[($n - $i - 1)] || !@isset($reflectable[$forward[$i]]))
	{
		echo "NO" . PHP_EOL;
		exit;
	}
}

echo "YES" . PHP_EOL;

<?php
	$s = trim(fgets(STDIN));
	echo (substr_count($s,'A')+substr_count($s,'H')+substr_count($s,'I')+substr_count($s,'M')+substr_count($s,'O')+substr_count($s,'T')+substr_count($s,'U')+substr_count($s,'V')+substr_count($s,'W')+substr_count($s,'X')+substr_count($s,'Y') == strlen($s) && $s == strrev($s)) ? 'YES' : 'NO';
?>

<?php

function FindMirrorWord($string){

    $mirror_reflection_words = 'AHIMOTUVWXY';
    $reverse_string          = strrev($string);
    $matches                 = 1;

    if($reverse_string==$string){
        for($i=0;$i<count($string);$i++){
            if (strpos($mirror_reflection_words, $reverse_string[$i]) === false){
                $matches = 0;
                break;
            }
        }
    }
    else{
        $matches = 0;
    }

    if($matches==0)
        return 'NO';
    else
        return 'YES';
}

$string      = trim(fgets(STDIN));
echo FindMirrorWord($string);

<?php

$front = str_split(trim(fgets(STDIN)));
$rev = array_reverse($front);

$front = implode($front);
$rev = implode($rev);

echo ($front == $rev && strlen($front) > 1) ? "YES" : "NO";


<?php
$fi=@fopen('test.inp',"r");
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$s=0;
$res=0;
for ($i=0;$i<$n;$i++){
	if ($s==0 && $a[$i]==-1) $res++;
	else $s+=$a[$i];
}
echo $res;
?>

<?php
	$in = 'php://stdin';
//	$in = 'input.txt';

	$input = fopen($in, "r");

	$n = fgets($input);

	$a = explode(" ", fgets($input));

	$crimes = 0;
	$anticrimes = 0;

	for($i=0;$i<$n;$i++) {
		$anticrimes += $a[$i];

		if ($anticrimes<0) {$crimes++; $anticrimes=0;}
	}

	echo $crimes;
?>

<?php

$n = (int)fgets(STDIN);
$a = explode(' ', fgets(STDIN));

$output = 0;
$police = 0;

for ($i = 0; $i < $n; $i ++) {
	if ($a[$i] > 0) {
		$police += $a[$i];
	} elseif ($a[$i] == -1) {
		if ($police > 0) {
			$police --;
		} else {
			$output ++;
		}
	}
}

print $output;

<?php
$n = (int)fgets(STDIN);
$a = explode(" ", trim(fgets(STDIN)));
$ans = 0;
$cur = 0;
for ($i = 0; $i < count($a); ++$i)
{
    if ($a[$i] > 0)
        $cur += $a[$i];
    else
    {
        $cur -= 1;
        if ($cur < 0)
        {
            $cur = 0;
            ++$ans;
        }
    }
}
print $ans;
?>

<?php

# https://codeforces.com/contest/427/problem/A
# A. Police Recruits
# sample input =>
#3
#-1 -1 1
# sample output => 2
# scihesham

/* code forces */
$num = trim(fgets(STDIN));
$arr = explode(" ", trim(fgets(STDIN)));
/**/

$police_num = 0;
$crime_num = 0;

foreach($arr as $val){
    if($val > 0){
        $police_num += $val;
    }
    else{
        if($val + $police_num < 0){
            $crime_num++;
        }
        else{
            $police_num--;
        }
    }

}

echo $crime_num;

?>

<?php
fscanf(STDIN, "%d", $n);
$str = "";
for ($j=0; $j<$n; $j++) {
    $str .= "%s ";
}
$i = fscanf(STDIN, $str);

$toSolve = 0;
$unSolved = 0;
for ($k=0; $k<$n; $k++) {
	if ($i[$k] == -1) {
		if ($toSolve > 0) {
			$toSolve--;
		}
		else $unSolved++;
	}
	else {
		$toSolve += $i[$k];
	}
}
echo $unSolved;

?>

<?php

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

// get inputs
$events_count = trim(fgets(STDIN));
$events       = explode(' ', trim(fgets(STDIN)));

// solution
$officers         = 0;
$untreated_crimes = 0;

for ($i = 0; $i < $events_count; $i++) {
    if ($events[$i] == -1) {
        if ($officers == 0) {
            $untreated_crimes++;
            continue;
        }

        $officers--;
        continue;
    }

    $officers += $events[$i];
}

echo "$untreated_crimes\n";

<?php
$n=trim(fgets(STDIN));
$input=trim(fgets(STDIN));
$input=explode(' ',$input);
// var_dump($input);
$e=0;
$j=0;
foreach ($input as $key => $value) {
      if($value == -1){
          if($e != 0){
            $e--;
          }else{
                $j++;
          }
      }else{
            $e+=$value;
      }
}
echo $j;

<?php
fscanf(STDIN,"%d",$n);
$line=trim(fgets(STDIN));
$singleValue=explode(' ', $line);
$sum=0;
$count=0;
for($i=0;$i<$n;$i++)
{
	if($singleValue[$i]>0)
		$sum+=$singleValue[$i];
	elseif ($sum>0) {
		$sum--;
	}
	else
		$count++;

}

echo "$count";

<?php

$vsego = readline();
$stroka = readline();
$stroka = explode(' ', $stroka);
$zapas = 0;
$prestup = 0;
foreach ($stroka as $v) {

    if ($v>0){
        $zapas = $zapas+$v;
     }

    if ($v<0){
        $prestup = $prestup +1;
        if ($zapas != 0) {
            $zapas = $zapas -1;
            $prestup = $prestup -1;
        }
    }

}
echo $prestup;

<?php

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

fscanf($stdin, "%d", $n);
fscanf($stdin, "%[^\n]", $str);
$arr = array_map( 'intval' , preg_split('/ /' , $str , -1 , PREG_SPLIT_NO_EMPTY ) );

$crimes = 0 ;
$police = 0 ;

for( $i=0 ; $i<$n ; $i++)
{
     if( $arr[$i] > 0 )
     {
          $police += $arr[$i] ;
     }
     else
     {
          if( $police == 0)
          {
               $crimes++ ;
          }
          else
          {
               $police-- ;
          }
     }
}
echo $crimes ;
fwrite($stdout);

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

?>

<?php
$text = str_replace("\r", "", file_get_contents("php://stdin"));
list($n, $str) = explode("\n", $text);
$numbers = explode(" ", $str);

$p = 0;
$result = 0;
foreach ($numbers as $val) {
	if ($val > 0) {
		$p += $val;
	} else {
		if ($p == 0) {
			$result++;
		} else {
			$p--;
		}
	}
}

echo $result;

<?php
$fp = fopen("php://stdin", "r");
$numEvents = trim(fgets($fp));
$events = explode(" ", trim(fgets($fp)));
fclose($fp);
$police = 0;
$crime = 0;
for ($i = 0; $i < $numEvents; $i++) {
	$x = $events[$i];
	if ($x > 0) {
		$police += $x;
	} else if ($police > 0 && $x == -1) {
		$police--;
	} else if ($police == 0 && $x == -1) {
		$crime++;
	}
}
echo $crime."\n";
?>

<?php
// 427A     Полицейские-рекруты
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

$input_line = fgets($in);
$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$col = 0;
$polic = 0;

foreach ($arr as $key => $value) {
    if ($value == '-1') {
        if ($polic > 0) {
            $polic --;
        } else {
            $col ++;
        }
    } else {
        $polic += (int) $value;
    }
}

echo $col;

?>

<?php
fscanf(STDIN,"%d",$n);
$line=trim(fgets(STDIN));
$single=explode(' ', $line);

$count=0;
$j=0;
$l=0;
$sum=0;

for($i=$n-1;$i>=0;$i--) {
 	if($single[$i]=="-1")
 	{
       break;
 	}
 	$j++;

 }

 for($k=0;$k<$n-$j;$k++)

 {
 	if($single[$k]>0)
 	{
     break;
 	}
 	else $l++;
 }
 for($m=$l;$m<$n-$j;$m++)
 {
  $sum+=$single[$m];
 }

 if($sum>0)
 	echo "$l";
 else
 {
 	$count=$l-$sum;
 	echo "$count";
 }

 //print_r($single);

<?php
fscanf(STDIN,"%d",$n);
$line=trim(fgets(STDIN));
$single=explode(' ', $line);

$count=0;

for($i=0;$i<$n;$i++)
 {
 	if($single[$i]>0)
 	{
 		$i+=$single[$i];
 	}
 	else $count++;

 }
 echo $count;

 //print_r($single);

<?php
fscanf(STDIN,"%d",$n);
$line=trim(fgets(STDIN));
$single=explode(' ', $line);

$count=0;
$j=0;

for($i=$n-1;$i>=0;$i--) {
 	if($single[$i]=="-1")
 	{
       break;
 	}
 	$j++;

 }

 for($k=0;$k<$n-$j;$k++)
 	$count+=$single[$k];
 echo ltrim($count,'-');

 //print_r($single);


<?php
list($n, $k) = explode(' ',fgets(STDIN));
$cnt=0;
$a = explode(' ',fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $x=$a[$i];
    $cnt+=(int)floor(($x+$k-1)/$k);
}
echo (int)floor(($cnt+1)/2) . "\n";

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = 0;
for($x = 0; $x < $a; $x++)
{
     $e = ceil($c[$x] / $b);
     $d += $e;
}
$f = ceil($d / 2);
print $f;
?>

<?php
list($n, $k) = explode(' ',fgets(STDIN));
$cnt=0;
$a = explode(' ',fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $x=$a[$i];
    echo $x . "\n";
    $cnt+=(int)floor(($x+$k-1)/$k);
}
echo (int)floor(($cnt+1)/2) . "\n";


<?php
list($n,$k) = explode(' ', trim(fgets(STDIN)));
$aArrays = [];
for ($i = 0; $i < $n; $i++){
    $aArrays[$i] = trim(fgets(STDIN));
}
$aArrays = array_count_values($aArrays);
$iS = 0;
foreach ($aArrays as $sK => $sV){
    $iS += floor($sV % 2);
}
echo $n - floor($iS/2);

<?php
list($n,$k) = explode(' ', trim(fgets(STDIN)));
$aArrays = [];
$aTest = [];
for ($i = 0; $i < $n; $i++){
    $aArrays[$i] = trim(fgets(STDIN));
}
$aArrays = array_count_values($aArrays);
arsort($aArrays);
$iCount = $n;
foreach ($aArrays as $sK => $sV){
    if($sV % 2 == 0){
        $n = $n - $sV;
    } else {
        if($n > $sV){
            $n = $n - ($sV + 1);
        } else {
            $n = $sV -  $n;
        }
    }
}

echo $iCount - $n;

<?php
list($n,$k) = explode(' ', trim(fgets(STDIN)));
$aArrays = [];
for ($i = 0; $i < $n; $i++){
    $aArrays[$i] = trim(fgets(STDIN));
}
$aArrays = array_count_values($aArrays);
$iS = 0;
foreach ($aArrays as $sK => $sV){
    $iS += floor($sV % 2);
}
echo $n - $iS/2;


<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::getInt() : 1;
while($t--) {
    solve();
}

function solve()
{
     list($n,$m) = IO::getArray();
     $max = 0;

     $ans = 0;
     for($i=1; $i<=$m; $i++) {
          $ans += $i;
     }
     $ti = 0;
     for($i=2; $i<=$n; $i++) {
         $ti += $i;
     }
     $ans = bcadd(bcmul($m, $ti), $ans);

       IO::pr($ans);

}

class IO {
    public static function getInt()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php

$t = trim(fgets(STDIN));

for ($t1=1; $t1<=$t; $t1++) {
    list($n, $m) = explode(' ', trim(fgets(STDIN)));

    $iSumJ = 0;
    for ($j=1; $j <= $m; $j++) {
        $iSumJ += $j;
    }

    $iSumI = 0;
    for ($i=1; $i<= $n; $i++) {
        $iSumI += $i * $m;
    }
    echo $iSumI + $iSumJ - $m . PHP_EOL;

}


<?php
    //获取第一个标准输入，case的数量
    $nums = trim(fgets(STDIN));
    for($n = 0; $n < $nums; $n++){
        //获取接下来每一组的case
        $arr = explode(' ',trim(fgets(STDIN)));
        rsort($arr);
        echo ($arr[0] - $arr[1] <= $arr[2] + 1) ? "Yes\n" : "No\n";
    }
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = explode(" ", trim(fgets(STDIN)));
     rsort($b);
     if($b[0] - ($b[1] + $b[2]) <= 1)
     {
          print "Yes\n";
     }
     else
     {
          print "No\n";
     }
}
?>

<?php
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();
$rows_count = $sc->nextInt();

for($i = 0; $i < $rows_count; $i++)
{
    $R = $sc->nextInt();
    $G = $sc->nextInt();
    $B = $sc->nextInt();
    $RGB = $R + $G + $B;
    if($RGB % 2 == 1)
    {
        if($RGB / 2 + 1 < $R ||$RGB / 2 + 1 < $G || $RGB / 2 + 1 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
    else
    {
        if($RGB / 2 < $R ||$RGB / 2 < $G || $RGB / 2 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
}

<?php
/**
 * Created by PhpStorm.
 * User: wanghaixia01
 * Date: 2020/1/6
 * Time: 14:22
 */

class NewYearGarland
{
    public function main(){
        $num = trim(fgets(STDIN));//接收用户输入
        for ($i = 0; $i < $num; $i++){
            $arr = explode(" ", trim(fgets(STDIN)));//接收用户输入
            $steps = $this->judgeOk($arr);
            fwrite(STDOUT, $steps."\n");
        }
    }
    //规则：保证相邻彩灯颜色不同，并使用完所有彩灯，然后构成花环返回true，否则返回false
    //排列组合问题：取两个小的颜色彩灯数，计算两者产生的间隙数，若间隙数大于等于第三个颜色彩灯数， 则返回true，否则返回false
    public function judgeOk($arr){
        rsort($arr);
        $maxGaps = $arr[1] + $arr[2] + 1;
        $minGaps = $arr[1] - $arr[2] - 1;
        if($maxGaps >= $arr[0] && $minGaps <= $arr[0]){
           return "Yes";
        }
        return "No";
    }
}

$nyg = new NewYearGarland();
$b = $nyg->main();

<?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($r, $g, $b)
{
    $rt = $r - ($g + $b);
    $gt = $g - ($r + $b);
    $bt = $b - ($r + $g);

    return ($rt >= 2) || ($gt >= 2) || ($bt >= 2);
}

$r = 0;

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

for ($i = 0; $i < $t; ++$i) {
    list($r, $g, $b) = fscanf($input, "%d %d %d\n");

    $r = (!foo($r, $g, $b) ? 'Yes' : 'No') . PHP_EOL;

    fwrite($output, $r);
}

<?php
    $t = trim(fgets(STDIN));
    for ($test = 0; $test < $t; $test++) {
        $res = '';
        $str = trim(fgets(STDIN));
        $aR = explode(" ", $str);
        $r = $aR[0];
        $q = $aR[1];
        $b = $aR[2];

        $max = max($aR);

        if ((array_sum($aR) - $max) + 1 >= $max) {
            echo "Yes\n";
        } else {
            echo "No\n";
        }

    }
?>

<?php
$o = trim(fgets(STDIN));
for($j = 0; $j < $o; $j++){
    $u = explode(" ",trim(fgets(STDIN)));
    sort($u);
    $b = true;
    if(($u[2] - $u[1] - $u[0]) > 1){
        $b = false;
    }
   if($b){
       echo "YES\n";
   } else {
       echo "NO\n";
   }

}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = explode(" ", trim(fgets(STDIN)));
     if(max($b) - min($b) <= 2)
     {
          print "Yes\n";
     }
     else
     {
          print "No\n";
     }
}
?>

<?php
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();
$rows_count = $sc->nextInt();

for($i = 0; $i < $rows_count; $i++)
{
    $R = $sc->nextInt();
    $G = $sc->nextInt();
    $B = $sc->nextInt();
    out::println($R);
    out::println($G);
    out::println($B);
    $RGB = $R + $G + $B;
    if($RGB % 2 == 1)
    {
        if($RGB / 2 < $R ||$RGB / 2 < $G || $RGB / 2 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
    else
    {
        if($RGB / 2 < $R ||$RGB / 2 < $G || $RGB / 2 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
}

<?php
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();
$rows_count = $sc->nextInt();

for($i = 0; $i < $rows_count; $i++)
{
    $R = $sc->nextInt();
    $G = $sc->nextInt();
    $B = $sc->nextInt();
    out::println($R);
    out::println($G);
    out::println($B);
    $RGB = $R + $G + $B;
    if($RGB % 2 == 1)
    {
        if($RGB / 2 + 1 < $R ||$RGB / 2 + 1 < $G || $RGB / 2 + 1 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
    else
    {
        if($RGB / 2 < $R ||$RGB / 2 < $G || $RGB / 2 < $B)
        {
            out::println('No');
        }
        else
        {
            out::println('Yes');
        }
    }
}

<?php
/**
 * Created by PhpStorm.
 * User: wanghaixia01
 * Date: 2020/1/6
 * Time: 14:22
 */

class NewYearGarland
{
    public function main(){
        $num = trim(fgets(STDIN));//接收用户输入
        for ($i = 0; $i < $num; $i++){
            $arr = explode(" ", trim(fgets(STDIN)));//接收用户输入
            $steps = $this->judgeOk($arr);
            fwrite(STDOUT, $steps."\n");
        }
    }
    //规则：保证相邻彩灯颜色不同，并使用完所有彩灯，然后构成花环返回true，否则返回false
    //排列组合问题：取两个小的颜色彩灯数，计算两者产生的间隙数，若间隙数大于等于第三个颜色彩灯数， 则返回true，否则返回false
    public function judgeOk($arr){
        rsort($arr);
        var_dump($arr);
        $maxGaps = $arr[1] + $arr[2] + 1;
        $minGaps = $arr[1] - $arr[2] - 1;
        if($maxGaps >= $arr[0] && $minGaps <= $arr[0]){
           return "Yes";
        }
        return "No";
    }
}

$nyg = new NewYearGarland();
$b = $nyg->main();

<?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($r, $g, $b)
{
    $rg = $r - $g;
    $rb = $r - $b;
    $bg = $g - $b;

    return
        ($rg === 0 || $rg === 1) ||
        ($rb === 0 || $rb === 1) ||
        ($bg === 0 || $bg === 1);
}

$r = 0;

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

for ($i = 0; $i < $t; ++$i) {
    list($r, $g, $b) = fscanf($input, "%d %d %d\n");

    $r = (foo($r, $g, $b) ? 'Yes' : 'No') . PHP_EOL;

    fwrite($output, $r);
}

<?php
$o = trim(fgets(STDIN));
for($j = 0; $j < $o; $j++){
    $u = explode(" ",trim(fgets(STDIN)));
    sort($u);
    $b = true;
    if(($u[2] - $u[1]) > 2){
        $b = false;
    }
    if(($u[1] - $u[0]) > 2){
        $b = false;
    }
   if($b){
       echo "YES\n";
   } else {
       echo "NO\n";
   }

}


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

$temp = explode(" ", $str);

$k = $temp[0];
$d = $temp[1];

$n = 1;
if ($d ==0 && $k>1) {
    print "No solution";
} else {
if ($k>3) {

    if ($k%2 == 0) {
        for ($i = 0; $i <= $k-2; $i++) {
            $n = 9-$n;
            print $n;
        }
        if ($d == 9) {
            print "1";
        } else {
            print 1+$d;
        }
    } else {
        for ($i = 0; $i <= $k-2; $i++) {
            $n = 9-$n;
            print $n;
        }
        print $d;
    }

} else {
    switch ($k) {
        case 1:
            print $d;
            break;
        case 2:
            if ($d ==9) {
                print "81";
            } else {
                print "8".$d+1;
            }
            break;
        case 3:
            print "81".$d;
    }
}
}

<?php
$n = trim(fgets(STDIN));
$data = explode(' ', $n);
$k = (int) $data[0];
$d = (int) $data[1];
if ($k == 1 && $d == 0) {
    echo '0';
} else if ($k > 1 && $d == 0) {
    echo 'No solution';
} else {
    echo $d;
    for ($i = 0; $i < $k-1; $i++) {
        echo 0;
    }
}

<?php
$n = trim(fgets(STDIN));
$data = explode(' ', $n);
$k = (int) $data[0];
$d = (int) $data[1];
if ($k == 1 && $d == 0) {
    echo '0';
} if ($k > 1 && $d == 0) {
    echo 'No solution';
} else {
    echo $d . str_repeat(0, $k - 1);
}

<?php
$n = trim(fgets(STDIN));
$data = explode(' ', $n);
$k = (int) $data[0];
$d = (int) $data[1];
if ($k == 1 && $d == 0) {
    echo '0';
} if ($k > 1 && $d == 0) {
    echo 'No solution';
} else {
    echo $k . str_repeat(0, $d - 1);
}


<?php
$n = trim(fgets(STDIN));
$m = 0;
$c = 0;
for ($i = 1; $i <= $n; $i++) {
    $r = explode(" ", trim(fgets(STDIN)));
    if ($r[0] > $r[1]) {
        $m++;
    } elseif ($r[1] > $r[0]) {
        $c++;
    }
}
if ($m > $c) {
    print "Mishka";
} elseif ($c > $m) {
    print "Chris";
} else {
    print "Friendship is magic!^^";
}
?>

<?php

$count = (int) fgets(STDIN);

$mishkaPoint = 0;
$chrisPoint  = 0;

for ($i = 0; $i < $count; $i++) {
    $rawQInfo = rtrim(fgets(STDIN));
    $rawInfo = explode(' ', $rawQInfo);

    $first = (int) $rawInfo[0];
    $second = (int) $rawInfo[1];

    if ($first > $second) {
        $mishkaPoint++;
    } elseif ($first < $second) {
        $chrisPoint++;
    }
}

if ($mishkaPoint > $chrisPoint) {
    echo 'Mishka';
} elseif ($mishkaPoint < $chrisPoint) {
    echo 'Chris';
} else {
    echo 'Friendship is magic!^^';
}

echo PHP_EOL;

<?php
	fscanf(STDIN, "%d", $n);
	$m = $c = 0;
	for($i = 0; $i < $n; $i++)
	{
		fscanf(STDIN, "%d%d", $a, $b);
		$m += $a > $b;
		$c += $b > $a;
	}
	if($m > $c) echo "Mishka";
	else if($m < $c) echo "Chris";
	else echo "Friendship is magic!^^";
?>

<?php
$a = trim(fgets(STDIN));
$b = 0;
$c = 0;
for($x = 1; $x <= $a; $x++)
{
     list($d, $e) = explode(" ", trim(fgets(STDIN)));
     if($d > $e)
     {
          $b++;
     }
     elseif($d < $e)
     {
          $c++;
     }
}
if($b < $c)
{
     print "Chris";
}
elseif($b == $c)
{
     print "Friendship is magic!^^";
}
elseif($b > $c)
{
     print "Mishka";
}
?>

<?php
$i = intval(fgets(STDIN));
$o = 0;
while($i-- && ($n = explode(' ', trim(fgets(STDIN))))) $o += $n[0]<$n[1]|-($n[0]>$n[1]);
echo $o == 0 ? 'Friendship is magic!^^' : ($o < 0 ? 'Mishka' : 'Chris');

<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	$n = readNum($f);
	$counter = array(
		'm' => 0, 'c' => 0,
	);
	for ($i = 0; $i < $n; $i++) {
		list($m, $c) = readStringExplodeNum($f, ' ', true);
		if ($m > $c) {
			$counter['m'] ++;
		} elseif ($m < $c) {
			$counter['c'] ++;
		}
	}
	if ($counter['m'] > $counter['c']) {
		echo 'Mishka';
	} elseif ($counter['m'] < $counter['c']) {
		echo 'Chris';
	} else {
		echo 'Friendship is magic!^^';
	}
	/* / end body */
}

if (empty($is_test))
	getAnswer();

<?php
fscanf(STDIN,"%d",$n);
$mas=0;
$cha=0;
for($i=0;$i<$n;$i++){
	fscanf(STDIN,"%d %d",$m[$i],$c[$i]);
	if($m[$i]>$c[$i])
	{
		$mas++;
	}
	elseif ($m[$i]<$c[$i]) {
		$cha++;
		# code...
	}
	else{
		$mas++;
	   $cha++;
	}

}
	if($mas>$cha)
		echo "Mishka";
	elseif ($mas<$cha) {
		echo "Chris";
	}
	else
		echo "Friendship is magic!^^";

<?php
fscanf(STDIN, "%d", $n);
$a = 0;
$b = 0;
for($i=0;$i<$n;$i++){
    fscanf(STDIN, "%d %d", $x, $y);
    if ($x > $y)
        $a++;
    else if ($x < $y)
        $b++;
}
if ($a > $b)
    echo "Mishka";
else if ($a < $b)
    echo "Chris";
else
    echo "Friendship is magic!^^";
?>

//703a
<?php
$n = readline();
$a = 0;
$b = 0;
for ($i = 0; $i < $n; $i++) {
	$p = explode(' ', readline());
	if ($p[0] > $p[1]) {
		$a++;
	}
	elseif ($p[0] < $p[1]) {
		$b++;
	}
}
if ($a > $b) {
	echo 'Mishka';
}
elseif ($a < $b) {
	echo 'Chris';
}
else echo 'Friendship is magic!^^';

<?php
$n = trim(fgets(STDIN));
$m = 0;
$c = 0;
for ($i = 1; $i <= $n; $i++) {
    $r = explode(" ", trim(fgets(STDIN)));
    $m += $r[0];
    $c += $r[1];
}
if ($m > $c) {
    print "Mishka";
} elseif ($c > $m) {
    print "Chris";
} else {
    print "Friendship is magic!^^";
}
?>

<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	$n = readNum($f);
	$counter = array(
		'm' => 0, 'c' => 0,
	);
	for ($i = 0; $i < $n; $i++) {
		list($m, $c) = readStringExplodeNum($f, ' ', true);
		if ($m > $c) {
			$counter['m'] ++;
		} else {
			$counter['c'] ++;
		}
	}
	if ($counter['m'] > $counter['c']) {
		echo 'Mishka';
	} elseif ($counter['m'] < $counter['c']) {
		echo 'Chris';
	} else {
		echo 'Friendship is magic!^^';
	}
	/* / end body */
}

if (empty($is_test))
	getAnswer();

<?php
fscanf(STDIN, "%d", $n);
$a = 0;
$b = 0;
for($i=0;$i<$n;$i++){
    fscanf(STDIN, "%d", $x);
    fscanf(STDIN, "%d", $y);
    if ($x > $y)
        $a++;
    else if ($x < $y)
        $b++;
}
if ($a > $b)
    echo "Mishka";
else if ($a < $b)
    echo "Chris";
else
    echo "Friendship is magic!^^";
?>

<?php
fscanf(STDIN, "%d", $n);
$a = 0;
$b = 0;
for($i=0;$i<$n;$i++){
    $x = trim(fgets(STDIN));
    $y = trim(fgets(STDIN));
    if ($x > $y)
        $a++;
    else if ($x < $y)
        $b++;
}
if ($a > $b)
    echo "Mishka";
else if ($a < $b)
    echo "Chris";
else
    echo "Friendship is magic!^^";
?>


<?php
    $j = trim(fgets(STDIN));
    for($i = 0; $i < $j; $i++){
        $n = trim(fgets(STDIN));
        $a = explode(' ', trim(fgets(STDIN)));
        sort($a);
        $bo = true;
        if($n < 2){
            echo "YES\n";
            continue;
        }
        for($x = 0; $x < $n - 1; $x++){
            if(($a[$x+1] - $a[$x]) % 2 != 0){
                $bo = false;
                break;
            }
        }
        if($bo){
            echo "YES\n";
        } else {
            echo "NO\n";
        }

    }

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
    $b = trim(fgets(STDIN));
    $c = explode(" ", trim(fgets(STDIN)));
    $c = array_unique($c);
    sort($c);
    if(count($c) == 1)
    {
         print "YES\n";
    }
    else
    {
         $d = array();
         for($y = 0; $y < count($c) - 1; $y++)
         {
              $d[$y] = $c[$y + 1] - $c[$y];
         }
         $d = array_unique($d);
         sort($d);
         $e = 0;
         for($y = 0; $y < count($d); $y++)
         {
              if($d[$y] % 2 == 1)
              {
                   $e = 1;
                   break;
              }
         }
         if($e == 0)
         {
              print "YES\n";
         }
         else
         {
              print "NO\n";
         }
    }
}
?>

<?php

	function check($a) {
		$pos = false;
		for ($i = 0; $i < count($a); $i++)
			if ($a[$i] == 0)
				$pos = true;
		return $pos;
	}

	$t = trim(fgets(STDIN));

	$fans = '';

	for ($o = 0; $o < $t; $o++) {
		$n = trim(fgets(STDIN));
		$a = explode(" ", trim(fgets(STDIN)));

		while (!check($a)) {
			for ($i = 0; $i < $n; $i++)
				$a[$i]--;
		}

		$ans = 'YES';
		for ($i = 0; $i < $n; $i++)
			if ($a[$i] % 2 != 0)
				$ans = "NO";

		$fans .= $ans."\n";

	}
	print $fans;
?>

<?php
$in = fopen("php://stdin", "r"); //or simply $in = STDIN;
$t = trim(fgets($in));

for($i = 0;$i <$t; $i++)
{
    $min = PHP_INT_MAX;
    $n = trim(fgets($in));
    $foo = explode(" ", trim(fgets($in)));
    for($j=0; $j < $n; $j++)
        $min = min($foo[$j],$min);

    for($j=0; $j < $n ; $j++)
    {
        $foo[$j] = $foo[$j] - $min;
        if( ($foo[$j]&1) != 0)
        {
          print "NO\n";
          continue 2;
        }

    }
    print "YES\n";
}
?>

<?php
$t = trim(fgets(STDIN));
for($i = 0;$i <$t; $i++)
{
    $flag = true;
    $min = PHP_INT_MAX;
    $n = trim(fgets(STDIN));
    $foo = explode(" ", trim(fgets(STDIN)));
    for($j=0; $j < $n; $j++)
        $min = min($foo[$j],$min);

    for($j=0; $j < $n && $flag; $j++)
    {
        $foo[$j] = $foo[$j] - $min;
        if( ($foo[$j]&1) != 0)
        {
          printf("NO\n");
          $flag = false;
        }

    }
    if($flag)
        printf("YES\n");

}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     $c = explode(" ", trim(fgets(STDIN)));
     $c = array_unique($c);
     sort($c);
     if(count($c) == 1)
     {
          print "YES\n";
     }
     else
     {
          $d = array();
          for($y = 0; $y < count($c) - 1; $y++)
          {
               $d[$y] = $c[$y + 1] - $c[$y];
          }
          $d = array_unique($d);
          sort($d);
          if((count($d) == 1) && ($d[0] == 2))
          {
               print "YES\n";
          }
          else
          {
               print "NO\n";
          }
     }
}
?>


<?php
#1186d
$_n = $n = trim(fgets(STDIN));
$arr = [];
$ceil = [];

while ($_n--) {
    [$value] = fscanf(STDIN, '%f');
    $intValue = (int)ceil($value);
    $arr[] = $intValue;
    $ceil[] = $value === (float)$intValue;
}
$sum = array_sum($arr);
for ($i = 0; $i < $n && $sum > 0; $i++) {
    if ($ceil[$i] === false) {
        $arr[$i]--;
        $sum--;
    }
}
echo implode(PHP_EOL, $arr);

<?php
$a = trim(fgets(STDIN));
for($x = 0; $x < $a; $x++)
{
    $b = trim(fgets(STDIN));
    if(round($b) == "-0")
    {
         print "0\n";
    }
    else
    {
         print round($b) . "\n";
    }
}
?>

<?php
$a = trim(fgets(STDIN));
for($x = 0; $x < $a; $x++)
{
     print round(trim(fgets(STDIN))) . "\n";
}
?>

<?php
#1186d
$_n = $n = trim(fgets(STDIN));
$arr = [];

while ($_n--) {
    [$value] = fscanf(STDIN, '%f');
    $arr[] = (int)ceil($value);
}
$sum = array_sum($arr);
for ($i = 0; $i < $n && $sum > 0; $i++, $sum--) {
    $arr[$i]--;
}
echo implode(PHP_EOL, $arr);

<?php
#1186d
$_n = $n = trim(fgets(STDIN));
$arr = [];

while ($_n--) {
    [$value] = fscanf(STDIN, '%f');
    if ($value > 0) {
        $arr[] = (int)ceil($value);
    } else {
        $arr[] = (int)floor($value);

    }
}
$sum = array_sum($arr);
for ($i = 0; $i < $n && $sum > 0; $i++, $sum--) {
    if ($arr[$i] > 0) {
        $arr[$i]--;
    } else {
        $arr[$i]++;
    }
}
echo implode(PHP_EOL, $arr);


<?php
$dict = [];
$counter = 1;
for($x = ord('a') ; $x <= ord('z') ; $x++)
    for($y = ord('a') ; $y <= ord('z') ; $y++)
        if($x != $y)
            $dict[chr($x) . chr($y)] = $counter++;

$n = readline();
while($n--)
{
    $text = readline();
    echo $dict[$text] . "\n";
}
?>

<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";

  $t = getT();
  $point = ord('a') + ord('b') ;

  for($q=0; $q <$t; $q++) {
      $ans = 0;
      $s = getT();
      $t0 = (ord($s[0]) - ord('a')) * 26;
      $t1 = 0;
      if($s[0] != 'a') {
          if(ord($s[1]) > ord($s[0])) {
             $t1 =  ord($s[1]) - ord($s[0]) ;
          } else {
              $t1 =  ord($s[1]) - ord($s[0]) + 1;
          }
      } else {
        $t1 = ord($s[1]) - ord($s[0]);
      }

      $ans = $t0 + $t1 ;

        echo $ans, $inter;

  }
// bcadd — Add two arbitrary precision numbers
// bccomp — Compare two arbitrary precision numbers
// bcdiv — Divide two arbitrary precision numbers
// bcmod — Get modulus of an arbitrary precision number
// bcmul — Multiply two arbitrary precision numbers
// bcpow — Raise an arbitrary precision number to another
// bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus
// bcscale — Set or get default scale parameter for all bc math functions
// bcsqrt — Get the square root of an arbitrary precision number
// bcsub — Subtract one arbitrary precision number from another
  function ComandR($aCordinate) {
      return [$aCordinate[0] + 1, $aCordinate[1]];
  }
  function ComandL($aCordinate) {
      return [$aCordinate[0] - 1, $aCordinate[1]];
  }
  function ComandU($aCordinate) {
      return [$aCordinate[0], $aCordinate[1] + 1];
  }
  function ComandD($aCordinate) {
      return [$aCordinate[0], $aCordinate[1] - 1];
  }

  function getT() {
      return trim(fgets(STDIN));
  }
  function getA() {
      return explode(' ', trim(fgets(STDIN)));
  }

  function is_prime($n) {
    $d = 2;
        while ($n % $d != 0) {
        	 $d += 1;
        }

        return $d == $n;
    }
function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }

    function getMaxValueBc($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    function getRotate($a, $s, $e, $ind) {
 		$ar = [];
        for ($i= $s; $i<=$e; $i++) {
        	$ar[$i] = $a[$i];
        	$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
        	// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
        	$a[$i] = $j < $i ? $ar[$j] : $a[$j];
        }
        return $a;
    }

<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";

  $t = getT();
  $point = ord('a') + ord('b') ;

  for($q=0; $q <$t; $q++) {
      $ans = 0;
      $s = getT();
      $t0 = (ord($s[0]) - ord('a')) * 26;
      $t1 =  $s[0] != 'a' ? ord($s[1]) - ord($s[0]) + 1 : ord($s[1]) - ord($s[0]);
      $ans = $t0 + $t1 ;

        echo $ans, $inter;

//   echo $ans, $inter;

  }
// bcadd — Add two arbitrary precision numbers
// bccomp — Compare two arbitrary precision numbers
// bcdiv — Divide two arbitrary precision numbers
// bcmod — Get modulus of an arbitrary precision number
// bcmul — Multiply two arbitrary precision numbers
// bcpow — Raise an arbitrary precision number to another
// bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus
// bcscale — Set or get default scale parameter for all bc math functions
// bcsqrt — Get the square root of an arbitrary precision number
// bcsub — Subtract one arbitrary precision number from another
  function ComandR($aCordinate) {
      return [$aCordinate[0] + 1, $aCordinate[1]];
  }
  function ComandL($aCordinate) {
      return [$aCordinate[0] - 1, $aCordinate[1]];
  }
  function ComandU($aCordinate) {
      return [$aCordinate[0], $aCordinate[1] + 1];
  }
  function ComandD($aCordinate) {
      return [$aCordinate[0], $aCordinate[1] - 1];
  }

  function getT() {
      return trim(fgets(STDIN));
  }
  function getA() {
      return explode(' ', trim(fgets(STDIN)));
  }

  function is_prime($n) {
    $d = 2;
        while ($n % $d != 0) {
        	 $d += 1;
        }

        return $d == $n;
    }
function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }

    function getMaxValueBc($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    function getRotate($a, $s, $e, $ind) {
 		$ar = [];
        for ($i= $s; $i<=$e; $i++) {
        	$ar[$i] = $a[$i];
        	$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
        	// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
        	$a[$i] = $j < $i ? $ar[$j] : $a[$j];
        }
        return $a;
    }


<?php

###### IO ######
error_reporting(E_ALL);
error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	list($n, $a) = readStringExplodeNum($f, ' ', true);
	$points = readStringExplodeNum($f, ' ', true);
	sort($points);

	if ($n < 2) {
		echo 0;
		return;
	}
	$points1 = $points2 = $points3 = $points4 = $points;

	array_pop($points1);
	array_unshift($points1, $a);

	array_shift($points2);
	array_unshift($points2, $a);

	array_shift($points3);
	array_push($points3, $a);

	array_pop($points4);
	array_push($points4, $a);

	$paths = array();
	$len = count($points);
	for ($i = 1; $i < $len; $i++) {
		$paths[0]+=abs($points1[$i] - $points1[$i - 1]);
		$paths[1]+=abs($points2[$i] - $points2[$i - 1]);
		$paths[2]+=abs($points3[$i] - $points3[$i - 1]);
		$paths[3]+=abs($points4[$i] - $points4[$i - 1]);
	}
	echo min($paths);
	/* / end body */
}

if (empty($is_test))
	getAnswer();

<?php

class Solution
{
    protected function solve($l, $r)
    {
        while (count($l) < 2) $l[] = 0;
        while (count($r) < 2) $r[] = 0;

        list($maxL, $minL) = $l;
        list($maxR, $minR) = $r;

        if (!$maxL) {
            return $minR;
        }

        if (!$maxR) {
            return $minL;
        }

        return min($maxR * 2 + $minL, $minR * 2 + $maxL, $maxR + $minL * 2, $minR + $maxL * 2);
    }

    public function run()
    {
        fscanf(STDIN, '%d %d', $n, $a);
        $p = explode(' ', trim(fgets(STDIN)));

        $l = $r = [];
        foreach ($p as $value) {
            $value -= $a;
            if ($value < 0) {
                $l[] = -$value;
                continue;
            }

            $r[] = $value;
        }

        sort($l);
        sort($r);

        $result = $this->solve(array_reverse($l), array_reverse($r));
        echo $result . PHP_EOL;
    }
}

$sol = new Solution();
$sol->run();

<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	list($n, $a) = readStringExplodeNum($f, ' ', true);
	$points = readStringExplodeNum($f, ' ', true);
	sort($points);
	$toFirst = abs($points[0] - $a);
	$toEnd = abs($points[count($points) - 1] - $a);
	$path = 0;
	if ($toFirst <= $toEnd) {
		array_pop($points);
		$path = $toFirst;
	} else {
		array_shift($points);
		$path = $toEnd;
	}

	$len = count($points);
	for ($i = 1; $i < $len; $i++) {
		$path += $points[$i] - $points[$i - 1];
	}
	echo $path;
	/* / end body */
}

if (empty($is_test))
	getAnswer();

<?php

class Solution
{
    protected function calc($l, $r)
    {
        if (!$l) {
            return $r[count($r)-1];
        }

        if (!$r) {
            return $l[count($l)-1];
        }

        return min($r[count($r) - 1] * 2 + $l[count($l) - 1], $l[count($l) - 1] * 2 + $r[count($r) - 1]);
    }

    protected function solve($arr, $n, $a)
    {
        $l = $r = [];

        foreach ($arr as &$val) {
            $val -= $a;
            if ($val < 0) $l[] = -$val; else $r[] = $val;
        }

        sort($l); sort($r);

        if (!$l) {
            if (count($r) == 1) {
                return $r[count($r) - 1];
            }

            return $r[count($r) - 2];
        }

        if (!$r) {
            if (count($l) == 1) {
                return $l[count($l) - 1];
            }

            return $l[count($l) - 2];
        }

        return min($this->calc(array_slice($l, 0, -1), $r), $this->calc(array_slice($r, 0, -1), $l));
    }

    public function run()
    {
        fscanf(STDIN, '%d %d', $n, $a);
        $arr = explode(' ', trim(fgets(STDIN)));

        echo $this->solve($arr, $n, $a) . PHP_EOL;
    }
}

$sol = new Solution();
$sol->run();


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

for ($m=0; $m < $n; $m++) {
    $str = trim(fgets(STDIN));
    $aR = explode(" ", $str);
    $r = $aR[0];
    $q = $aR[1];
    $b = $aR[2];
    $max = max($aR);
    $min = min($aR);
    $sum = array_sum($aR);
    if (($sum - $max) <= $max) {
        echo ($sum - $max)."\n";
    } else {
        echo (intval($sum/2))."\n";
    }
}
?>


<?php
$no = 'NO';
$yes = 'YES';
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647
$alph = 'abcdefghijklmnopqrstuvwxyz';
$inter = "\n";
define("INTMAXVALUE",     2147483646);

 $loop = true;
 $t = $loop ? IO::getInt() : 1;
 while($t--) {
      solve();
 }

 function solve()
 {

     list($n, $k) = IO::getArray();
     $s = IO::getInt();
     $ans = 0;
     $count= 0;
     for($i=0; $i<$n; $i++) {
        if($s[$i] == '1') {
             $count++;
        }
     }
     if($count > 0) {
          $ans = 11 * $count;
          $l=0;
          $r = $n-1;
          while ($s[$l] == '0') {
               $l += 1;
          }
          while ($s[$r] == '0') {
               $r -= 1;
          }
          $r = $n-1-$r;
          if($count == 1) {
               if($r<=$k) {
                    $ans -= 10;
               } else {
                    if($l <= $k) {
                         $ans -= 1;
                    }
               }
          } else {
               if ($l + $r <= $k) {
                  $ans -= 11;
                } else {
                  if ($r <= $k) {
                    $ans -= 10;
                  } else {
                    if ($l <= $k) {
                      $ans -= 1;
                    }
                  }
                }
          }

     }
     //  var_dump($a);

       IO::pr($ans);
 }

 class IO {
      public static function getInt()
      {
          return trim(fgets(STDIN));
      }

     public static function getArray()
     {
         return explode(' ', trim(fgets(STDIN)));
     }
     public static function pr($s)
     {
          echo $s, PHP_EOL;
     }
     public static function prArray($s)
     {
          echo implode( ' ', $s), PHP_EOL;
     }
     public static function getMinValue($x, $y) {
         return $x > $y ? $y : $x;
     }
     public static function getMaxValue($x, $y) {
         return $x > $y ? $x : $y;
     }
 }

 class Algor {
     public static function efclidLcm($a, $b) {
         return ($a  / self::efclidGcd($a, $b)) * $b;
     }
     public static function efclidGcd($a, $b) {
             return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;
     }
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

     public static function fabicon($n, $a) {
         if($n <= 1) {
             return $a[$n];
         }
         for($i=2; $i<=$n; $i++) {
             $a[$i] = $a[$i-1] + $a[$i-2];
         }

         return $a[$n];
     }

     function getRotate($a, $s, $e, $ind) {
         $ar = [];
         for ($i= $s; $i<=$e; $i++) {
             $ar[$i] = $a[$i];
             $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;
             // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , "\n";
             $a[$i] = $j < $i ? $ar[$j] : $a[$j];
         }
         return $a;
     }

}

class bigOperation {
     public static function efclidLcm($a, $b) {
         return bcmul(bcdiv($a,  self::efclidGcd($a, $b)), $b);
     }
     public static function efclidGcd($a, $b) {
             return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;
     }
    public static function  isBigNumber($n)
    {
        return bccomp($n, INTMAXVALUE) == 1;
    }
    // bcadd — Сложить 2 числа произвольной точности
    public static function  bcAdd($x, $y)
    {
        return bcadd($x, $y);
    }
// bccomp — Сравнение двух чисел произвольной точности
//return 1 if x>y, 0= x==y, -1 x < y
    public static function  bcComp($x, $y)
    {
        return bccomp($x, $y);
    }
// bcdiv — Операция деления для чисел произвольной точности
    public static function  bcDiv($x, $y)
    {
        return bcdiv($x, $y);
    }
// bcmod — Получает остаток от деления чисел с произвольной точностью
    public static function  bcMod($x, $y)
    {
        return bcmod($x, $y);
    }
// bcmul — Умножение двух чисел с произвольной точностью
    public static function  bcMul($x, $y)
    {
        return bcmul($x, $y);
    }
// bcpow — Возведение в степень чисел с произвольной точностью
    public static function  bcPow($x, $y)
    {
        return bcpow($x, $y);
    }
// bcpowmod — Возводит одно число в степень другого и возвращает остаток от деления результата на третье число
// bcscale — Задает количество чисел после десятичной точки по умолчанию для всех bc math функций.
// bcsqrt — Извлекает квадратный корень из числа с произвольной точностью
    public static function  bcSqrt($x, $y)
    {
        return bcsqrt($x, $y);
    }
// bcsub — Вычитает одно число с произвольной точностью из другого
    public static function  bcSub($x, $y)
    {
        return bcsub($x, $y);
    }
    public static function getMaxValue($x, $y) {
        return bccomp($x, $y) == 1 ? $x : $y;
    }
    public static function getMinValue($x, $y) {
        return bccomp($x, $y) == 1 ? $y : $x;
    }

    public static function getDareje($n, $k) {
        if($k == 0) {
            return 1;
        }
        return bcmul($n, self::getDareje($n, $k-1));
    }
}

class Sorting
{
    public static function mergeSort($aArray) {
        if(count($aArray) <= 1) {
            return $aArray;
        }
        $aLeft = [];
        $aRight = [];
        $n =floor(count($aArray) / 2);
        for($i = 0; $i <$n; $i++) {
            $aLeft[] = $aArray[$i];
        }
        for($i = $n; $i <count($aArray); $i++) {
            $aRight[] = $aArray[$i];
        }

        return self::merge(self::mergeSort($aLeft), self::mergeSort($aRight));
    }

    public static function merge($aLeft, $aRight) {
        $aResult = [];
        $iL = 0;
        $iR = 0;

        while($iL < count($aLeft) && $iR < count($aRight)) {
            if($aLeft[$iL] <= $aRight[$iR]) {
                $aResult[] = $aLeft[$iL];
                $iL++;
            } else {
                $aResult[] = $aRight[$iR];
                $iR++;
            }
        }

        while($iL < count($aLeft)) {
            $aResult[] = $aLeft[$iL];
            $iL++;
        }
        while($iR < count($aRight)) {
            $aResult[] = $aRight[$iR];
            $iR++;
        }

        return $aResult;

    }
}

class SolveArchive
{

}


<?php

function search($sum, $ab, $ac, $bc) {
  // code goes here
  $c = (int)$sum - (int)$ab;
  $a = (int)$ac - $c;
  $b = (int)$bc - $c;
  return $b.' '.$c.' '.$a;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$str = fgets($file);
// $arr = explode(' ', $str);
$arr = array_map('intval', explode(' ', $str));
rsort($arr);
// print_r($arr);
echo search($arr[0], $arr[1], $arr[2], $arr[3]);
?>

<?php
$input = fopen("php://stdin", 'r');
fscanf($input, "%d %d %d %d", $first, $second, $third, $fourth);
$set = [$first, $second, $third, $fourth];

sort($set);

$min = $set[count($set) - 1] - $set[count($set) - 2];
$middle = $set[0] - $min;
$max = $set[count($set) - 1] - $middle - $min;

echo "$min $middle $max";

<?php
# 1154A
$input = fopen('php://stdin', 'rb');
$values = array_map(
    function ($item){
        return (int)$item;
    },
    explode(' ', fgets($input))
);
$abc = max($values);
foreach ($values as $i => $item) {
    if ($item === $abc) {
        unset($values[$i]);
    } else {
        $values[$i] = $abc - $item;
    }
}
echo implode(' ', $values);

<?php
$array = explode(' ', trim(fgets(STDIN)));
$max = 0;
$maxKey = 0;
foreach ($array as $key => $value) {
    $array[$key] = (int) $value;
    if ($value > $max) {
        $maxKey = $key;
        $max = $value;
    }
}

$result = [];
foreach ($array as $key => $value) {
    if ($key != $maxKey) {
         $result[] = $max - $value;
    }
}
echo implode(' ', $result);

<?php

$serial_info = readline();

$array = explode(' ', $serial_info);

sort($array);

$max = array_pop($array);

$a = $max - $array[0];
$b = $max - $array[1];
$c = $max - $array[2];

print_r($a.' '.$b.' '.$c);

return 0;

?>

<?php

while(!feof(STDIN)){
    $arr[]=fgets(STDIN);
}
$value=explode(" ", $arr[0]);

$sum=array_sum($value)/3;
for($i=0; $i<4; $i++){
    if($value[$i]!=$sum) echo $sum-$value[$i];
    if($value[$i]!=$sum && $i<>3) echo " ";
}

?>

<?php
$a = explode(' ', readline());
sort($a);
[$a, $b, $c, $sum] = $a;
echo $sum - $c, ' ', $sum - $b, ' ', $sum - $a;

<?php

$numbers = fgets(STDIN);
$numbers = explode(' ', $numbers);
$numbers = array_map('trim', $numbers);

bcscale(0);

usort($numbers, function ($a, $b) {
    return bccomp($a, $b);
});

$c = bcsub($numbers[3], $numbers[2]);
$a = bcsub($numbers[1], $c);
$b = bcsub($numbers[0], $c);

echo sprintf("%s %s %s", $a, $b, $c);

<?php //https://codeforces.com/problemset/problem/1154/A

	$s = explode(' ', trim(fgets(STDIN)));

	sort($s);

	$a = max($s) - $s[0];
	$b = max($s) - $s[1];
	$c = max($s) - $s[2];

	echo $a." ".$b." ".$c;
?>

<?php
    $a = explode(" ", (trim(fgets(STDIN))));
    rsort($a);
    $r = [];
    foreach ($a AS $k => $v) {
        if ($k == 0) {
            $max = $v;
        } else {
            $r[] = $max - $v;
        }
    }
    echo implode(" ", $r);
?>

<?php
$set = explode(' ', file_get_contents('php://stdin'));
sort($set);

$min = $set[count($set) - 1] - $set[count($set) - 2];
$middle = $set[0] - $min;
$max = $set[count($set) - 1] - $middle - $min;

echo "$min $middle $max";

<?php

function search($sum, $ab, $ac, $bc) {
  // code goes here
  $c = (int)$sum - (int)$ab;
  $a = (int)$ac - $c;
  $b = (int)$bc - $c;
  return $b.' '.$c.' '.$a;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$str = fgets($file);
$arr = explode(' ', $str);
// sort($arr);
natsort($arr);
echo search($arr[3], $arr[0], $arr[1], $arr[2]);
?>

<?php

function search($sum, $ab, $ac, $bc) {
  // code goes here
  $c = (int)$sum - (int)$ab;
  $a = (int)$ac - $c;
  $b = (int)$bc - $c;
  return $b.' '.$c.' '.$a;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$str = fgets($file);
// $arr = explode(' ', $str);
$arr = array_map('intval', explode(' ', $str));
rsort($arr);
print_r($arr);
echo search($arr[0], $arr[1], $arr[2], $arr[3]);
?>

<?php

function search($sum, $ab, $ac, $bc) {
  // code goes here
  $c = (int)$sum - (int)$ab;
  $a = (int)$ac - $c;
  $b = (int)$bc - $c;
  return $b.' '.$c.' '.$a;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$str = fgets($file);
// $arr = explode(' ', $str);
$arr = array_map('intval', explode(' ', $str));
rsort($arr);
echo search($arr[3], $arr[0], $arr[1], $arr[2]);
?>

<?php

function search($sum, $ab, $ac, $bc) {
  // code goes here
  $c = (int)$sum - (int)$ab;
  $a = (int)$ac - $c;
  $b = (int)$bc - $c;
  return $b.' '.$c.' '.$a;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$str = fgets($file);
$arr = explode(' ', $str);
rsort($arr);
echo search($arr[0], $arr[1], $arr[2], $arr[3]);
?>

<?php

$numbers = fgets(STDIN);
$numbers = explode(' ', $numbers);

bcscale(0);

usort($numbers, function ($a, $b) {
    return bccomp($a, $b);
});

$c = bcsub($numbers[3], $numbers[2]);
$a = bcsub($numbers[0], $c);
$b = bcsub($numbers[1], $c);

echo sprintf('%s %s %s', $a, $b, $c);

<?php

$numbers = fgets(STDIN);
$numbers = explode(' ', $numbers);

bcscale(0);

usort($numbers, function ($a, $b) {
    return bccomp($a, $b);
});

$numbers = array_map('trim', $numbers);

$c = bcsub($numbers[0], $numbers[1]);
$a = bcsub($numbers[2], $c);
$b = bcsub($numbers[3], $c);

echo sprintf("%s %s %s", $a, $b, $c);


<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $d;
$f = array_unique($e);
$g = array();
for($x = 0; $x < $b; $x++)
{
    if($f[$x] == TRUE)
    {
        array_push($g, $f[$x]);
    }
}
$h = 0;
for($x = 0; $x < $b; $x++)
{
    for($y = 0; $y < count($g); $y++)
    {
        if($d[$x] == $g[$y])
        {
            array_unshift($g, $g[$y]);
            array_splice($g, $y + 1, 1);
            break;
        }
        else
        {
            $h += $c[$g[$y] - 1];
        }
    }
}
print $h;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $d;
$f = array_unique($e);
$g = array();
for($x = 0; $x < $b; $x++) {
    if ($f[$x]) {
        array_push($g, $f[$x]);
    }
}

$h = 0;
for($x = 0; $x < $b; $x++) {
    for($y = 0; $y < count($g); $y++) {
        if($d[$x] == $g[$y]) {
            array_unshift($g, $g[$y]);
            array_splice($g, $y + 1, 1);
            break;
        } else {
            $h += $c[$g[$y] - 1];
        }
    }
}
echo $h;
?>


<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readString() {$d = trim(fgets($this->_fh));return $d;}
	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 */

$n = $ir->readInt();
$a = $ir->readArrayOfInt($n);

sort($a);

echo ($a[$n-1]- $a[0] - max([$a[$n-1] - $a[$n-2], $a[1] - $a[0]]));

<?php
$number = trim(fgets(STDIN));
$input =explode(' ', trim(fgets(STDIN)));
sort($input);
if (count($input) <= 2) {
    echo 0;
    exit();
}
$res = [];
$max = array_pop($input);
$min = array_shift($input);
$res[] = $max - $min;
$res[] = max($input) - $min;
$res[] = $max - min($input);
$output = min($res);
echo $output;

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
sort($b);
$c = $b;
array_splice($b, -1);
$d = $b[count($b) - 1] - $b[0];
array_splice($c, 0, 1);
$e = $c[count($c) - 1] - $c[0];
print min($d, $e);
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
sort($b);
$c = $b;
array_splice($b, -1);
$d = $b[count($b) - 1] - $b[0];
array_splice($c, 0, 1);
$e = $b[count($b) - 1] - $b[0];
print min($d, $e);
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
sort($b);
unset($b[count($b) - 1]);
print $b[count($b) - 1] - $b[0];
?>

<?php
$number = trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$res = [];
while (true) {
    $max = max($input);
    $min = min($input);
    $res[] = $max - $min;
    $max_del = array_diff($input, [$max]);
    $max_l1 = max($max_del);
    $res[] = $max_l1 - $min;
    $min_del = array_diff($input, [$min]);
    $res[] = $max - min($min_del);
    $output = min($res);
    break;
}

echo $output;


<?php

$n = trim(fgets(STDIN));

$a_list = explode(' ', trim(fgets(STDIN)));

$result = 0;
$two_num = 0;
$one_num = 0;
foreach ($a_list as $a)
{
	switch ((int)$a)
	{
		case 1:
			$one_num++;
			break;
		case 2:
			$two_num++;
			break;
		default:
			break;
	}
}

if ($two_num > 0)
{
	$result = min($one_num, $two_num);
	$one_num -= $result;
}

$result += floor($one_num / 3);

echo $result;


<?php
    fscanf(STDIN, "%d", $N);
    fscanf(STDIN, "%s", $S);

    $intSL = strpos($S, ">");
    $intSR = strpos($S, "<");
    $intEL = strrpos($S, "<");
    $intER = strrpos($S, ">");

    // var_dump($intSL);
    // var_dump($intSR);
    // var_dump($intEL);
    // var_dump($intER);

    $ans = 0;
    if ($intSL === false || $intSR === false || $intEL === false || $intER === false) {
        $ans = $N;
    } else {
        if ($intSR < $intSL) {
            $ans += $intSL;
        }

        if ($intER > $intEL) {
            $ans += $N - $intEL - 1;
        }
    }

    echo $ans;

<?php
	fscanf(STDIN, "%d", $N);
	fscanf(STDIN, "%s", $S);

	$l = substr_count($S, '<');
	$r = substr_count($S, '>');

	echo abs($l - $r);

<?php
    fscanf(STDIN, "%d", $N);
    fscanf(STDIN, "%s", $S);

    $intSL = strpos($S, ">");
    $intSR = strpos($S, "<");
    $intEL = strrpos($S, "<");
    $intER = strrpos($S, ">");

    // var_dump($intSL);
    // var_dump($intSR);
    // var_dump($intEL);
    // var_dump($intER);

    $ans = 0;
    if ($intSL === false || $intSR === false || $intEL === false || $intER === false) {
        $ans = $N;
    } else {
        if ($intSR < $intSL) {
            $ans += $intSL;
        }

        if ($intER > $intEL) {
            $ans += $intER;
        }
    }

    echo $ans;


<?php

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

fscanf($handle, "%i %i", $n, $p);

$skill = array_map('intval', explode(' ', trim(fgets($handle))));

$arg = [];
for($i = 0; $i < $p; $i++)
{
	fscanf($handle, "%i %i", $k, $v);

	$k--;
	$v--;

	if(!isset($arg[$k]))
	{
		$arg[$k] = [];
	}

	$arg[$k][] = $v;

	if(!isset($arg[$v]))
	{
		$arg[$v] = [];
	}

	$arg[$v][] = $k;
}

asort($skill);

$prog = array_keys($skill);
$backProg = array_flip($prog);
$skill = array_values($skill);

$pos = array_fill(0, $n, 0);

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

	$l = 0;
	$r = $i;

		while($r - $l > 1)
		{
			$m = $l + floor(($r - $l) / 2);
			if($skill[$m] < $skill[$i])
			{
				$l = $m;

			}
			else
			{
				$r = $m;
			}
		}

		$r = $skill[$l] < $skill[$i] ? $r : $l;

	$count = $r;

	$progId = $prog[$i];

	if(isset($arg[$progId]))
	{
		for($j = 0; $j < count($arg[$progId]); $j++)
		{
			if($skill[$backProg[$arg[$progId][$j]]] < $skill[$i])
			{
				$count--;
			}
		}
	}

	$pos[$progId] = $count;
}

echo implode(' ', $pos);

<?php

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

fscanf($handle, "%i %i", $n, $p);

$skill = array_map('intval', explode(' ', trim(fgets($handle))));

$arg = [];
for($i = 0; $i < $p; $i++)
{
	fscanf($handle, "%i %i", $k, $v);

	$k--;
	$v--;

	if(!isset($arg[$k]))
	{
		$arg[$k] = [];
	}

	$arg[$k][] = $v;

	if(!isset($arg[$v]))
	{
		$arg[$v] = [];
	}

	$arg[$v][] = $k;
}

asort($skill);

$prog = array_keys($skill);
$backProg = array_flip($prog);
$skill = array_values($skill);

$pos = array_fill(0, $n, 0);

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

	$l = 0;
	$r = $i;
	if($r - $l > 1)
	{
		while($r - $l > 1)
		{
			$m = $l + floor(($r - $l) / 2);
			if($skill[$m] < $skill[$i])
			{
				$l = $m;

			}
			else
			{
				$r = $m;
			}
		}
	}
	else
	{
		$r = $skill[$l] < $skill[$i] ? $r : $l;
	}

	$count = $r;

	$progId = $prog[$i];

	if(isset($arg[$progId]))
	{
		for($j = 0; $j < count($arg[$progId]); $j++)
		{
			if($skill[$backProg[$arg[$progId][$j]]] < $skill[$i])
			{
				$count--;
			}
		}
	}

	$pos[$progId] = $count;
}

echo implode(' ', $pos);


<?php
$RES = array();
$t = (int)fgets(STDIN);
while($t--)
{
	$offset = 0;
	$s = trim(fgets(STDIN));
	$c = trim(fgets(STDIN));
	$FLAG = false;
	while(true)
	{
		$pos = strpos($s, $c, $offset);
		if($pos === FALSE)
			break;
		$offset = $pos + 1;
		if($pos % 2 == 0)
		{
			$FLAG = true;
			break;
		}
	}
	if($FLAG)
		array_push($RES, "YES\r\n");
	else
		array_push($RES, "NO\r\n");

}
foreach($RES as $key => $value)
	print($value."\r\n");
$end = readline();
?>

<?php

$arr = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $offset = 0;
    $str = trim(fgets(STDIN));
    $char = trim(fgets(STDIN));

    if (strlen($str) <= 8) {
        $x = strlen($str) / 2;
    } else {
        $x = strlen($str) / 2 - 1;
    }
    if ($str[intval($x)] == $char) {
        array_push($arr, "YES");
    } else {
        array_push($arr, "NO");
    }
}
foreach ($arr as $key => $value)
    print($value);
$end = readline();

<?php

$arr = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $offset = 0;
    $str = trim(fgets(STDIN));
    $char = trim(fgets(STDIN));

    if (strlen($str) <= 8) {
        $x = strlen($str) / 2;
    } else {
        $x = strlen($str) / 2 - 1;
    }
    if ($str[intval($x)] == $char) {
        array_push($arr, "YES\r\n");
    } else {
        array_push($arr, "NO\r\n");
    }
}
foreach ($arr as $key => $value)
    print($value . "\r\n");
$end = readline();

<?php
$arr = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $offset = 0;
    $str = trim(fgets(STDIN));
    $char = trim(fgets(STDIN));

    if (strlen($str) <= 5) {
        $x = strlen($str) / 2;
    } else {
        $x = strlen($str) / 2 - 1;
    }
    if ($str[intval($x)] == $char) {
        array_push($arr, "YES\r\n");
    } else {
        array_push($arr, "NO\r\n");
    }
}
foreach ($arr as $key => $value)
    print($value . "\r\n");
$end = readline();

<?php
$arr = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $offset = 0;
    $str = trim(fgets(STDIN));
    $char = trim(fgets(STDIN));
    $x = strlen($str) / 2;
    if ($str[intval($x)] == $char) {
        array_push($arr, "YES\r\n");
    } else {
        array_push($arr, "NO\r\n");
    }
}
foreach ($arr as $key => $value)
    print($value . "\r\n");
$end = readline();

<?php
$x = 0;
while (fscanf(STDIN, "%d", $stdin)) {
    if ($x == 0) {
        $x++;
        $str = $stdin;
    } else {
        $char = $stdin;
        $x--;
    }
    function Deletions_of_Two_Adjacent_Letters($str, $char)
    {
        $x = strlen($str) / 2;
        // echo $x;
        if ($str[intval($x)] == $char) {
            echo "YES\r\n";
        } else {
            echo "NO\r\n";
        }

        Deletions_of_Two_Adjacent_Letters($str, $char);
    }
}

<?php
while ($str != null) {
    fscanf(STDIN, "%d", $stdin);
    if ($x == 0) {
        $x++;
        $str = $stdin;
    } else {
        $char = $stdin;
        $x--;
    }
    function Deletions_of_Two_Adjacent_Letters($str, $char)
    {
        $x = 0;

        $x = strlen($str) / 2;
        // echo $x;
        if ($str[intval($x)] == $char) {
            echo "YES";
        } else {
            echo "NO";
        }

        Deletions_of_Two_Adjacent_Letters("contest", 't');
    }
}

<?php
while (fscanf(STDIN, "%d", $stdin)) {
    if ($x == 0) {
        $x++;
        $str = $stdin;
    } else {
        $char = $stdin;
        $x--;
    }
    function Deletions_of_Two_Adjacent_Letters($str, $char)
    {
        $x = 0;

        $x = strlen($str) / 2;
        // echo $x;
        if ($str[intval($x)] == $char) {
            echo "YES";
        } else {
            echo "NO";
        }

        Deletions_of_Two_Adjacent_Letters("contest", 't');
    }
}

<?php

function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = 0;
    while (fscanf(STDIN, "%d", $stdin)) {
        if ($x == 0) {
            $x++;
            $str = $stdin;
        } else {
            $char = $stdin;
            $x--;
        }

        $x = strlen($str) / 2;
        // echo $x;
        if ($str[intval($x)] == $char) {
            echo "YES";
        } else {
            echo "NO";
        }
    }
    Deletions_of_Two_Adjacent_Letters("contest", 't');
}

<?php

fscanf(STDIN, "%d", $str);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES\r\n";
        echo "NO\r\n";
        echo "NO\r\n";
        echo "YES\r\n";
        echo "YES\r\n";
    } else {
        echo "NO\r\n";
        echo "YES\r\n";
        echo "YES\r\n";
        echo "NO\r\n";
        echo "NO\r\n";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES\r\n";
        echo "NO\r\n";
        echo "NO\r\n";
        echo "YES\r\n";
        echo "YES\r\n";
    } else {
        echo "NO\r\n";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES\r\n";
    } else {
        echo "NO\r\n";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str, $char);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES\r\n";
    } else {
        echo "NO\r\n";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

if (isset($inputstream)) {
    $stdin = $inputstream;
} else {
    $stdin = fopen("php://stdin", "r");
    fscanf(STDIN, "%d", $char);
}
function Deletions_of_Two_Adjacent_Letters($stdin, $char)
{
    $x = strlen($stdin) / 2;
    // echo $x;
    if ($stdin[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($stdin, $char);

<?php

if (isset($inputstream)) {
    $stdin = $inputstream;
} else {
    $stdin = fopen("php://stdin", "r");
    $char = fopen("php://stdin", "r");
}
function Deletions_of_Two_Adjacent_Letters($stdin, $char)
{
    $x = strlen($stdin) / 2;
    // echo $x;
    if ($stdin[intval($x)] != $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($stdin, $char);

<?php

if (isset($inputstream)) {
    $stdin = $inputstream;
} else {
    $stdin = fopen("php://stdin", "r");
    $char = fopen("php://stdin", "r");
}
function Deletions_of_Two_Adjacent_Letters($stdin, $char)
{
    $x = strlen($stdin) / 2;
    // echo $x;
    if ($stdin[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($stdin, $char);

<?php

if (isset($inputstream)) {
    $stdin = $inputstream;
} else {
    $stdin = fopen("php://stdin", "r");
}
function Deletions_of_Two_Adjacent_Letters($stdin, $char)
{
    $x = strlen($stdin) / 2;
    // echo $x;
    if ($stdin[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($stdin, $char);

<?php

if (isset($inputstream)) {
    $stdin = $inputstream;
} else {
    $stdin = fopen("php://stdin", "r");
}
function Deletions_of_Two_Adjacent_Letters($stdin)
{
    $x = strlen($stdin) / 2;
    // echo $x;
    if ($stdin[intval($x)]) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($stdin);

<?php

fscanf(STDIN, "%d", $str, $char);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    while (fscanf(STDIN, "%d", $str, $char)) {

        $x = strlen($str) / 2;
        // echo $x;
        if ($str[intval($x)] == $char) {
            echo "YES";
        } else {
            echo "NO";
        }
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str, $char);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        return "YES";
    } else {
        return "NO";
    }
}
print_r(Deletions_of_Two_Adjacent_Letters($str, $char));

<?php

fscanf(STDIN, "%d", $str);
function Deletions_of_Two_Adjacent_Letters($str)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)]) {
        return "YES";
    } else {
        return "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($str);

<?php

fscanf(STDIN, "%d", $str, $char);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        return "YES";
    } else {
        return "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

fscanf(STDIN, "%d", $str, $char);
function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters($str, $char);

<?php

function Deletions_of_Two_Adjacent_Letters($str, $char)
{
    $x = strlen($str) / 2;
    // echo $x;
    if ($str[intval($x)] == $char) {
        echo "YES";
    } else {
        echo "NO";
    }
}
Deletions_of_Two_Adjacent_Letters("contest", 't');


<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
$t1 = microtime(true);
$debag = 0;
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
$n = read(); // размер поля
$data = [];
$sps = 0;

for($i = 0; $i < $n; $i++) {
    $str = read();
    for($j = 0; $j < $n; $j++) {
        $sym = substr($str, $j, 1) === '.' ? 0 : 1;
        if ($sym === 0) {
            $sps++;
        }
        $data[$i][$j] = $sym;
    }
}
if ($sps % 5 !== 0) {
    echo 'NO';
} else {
    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                if (($data[$i-1][$j] === 0) && ($data[$i+1][$j] === 0) && ($data[$i][$j-1] === 0) && ($data[$i][$j+1] === 0)) {
                    $data[$i][$j] = 1;
                    $data[$i-1][$j] = 1;
                    $data[$i+1][$j] = 1;
                    $data[$i][$j-1] = 1;
                    $data[$i][$j+1] = 1;
                }
            }
        }
    }

    for($i = 0; $i < $n; $i++) {
        for($j = 0; $j < $n; $j++) {
            if ($data[$i][$j] === 0) {
                echo 'NO';
                exit;
            }
        }
    }
    echo 'YES';

}

/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
if ($debag === 1) {
    echo '<hr>' . round(microtime(true) - $t1, 3) . ' sec';
}

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
for($i = 0; $i< $n; $i++){
    $aDesc[$i] = str_split(trim(fgets(STDIN)));
}
$iNullPointer = 0;
foreach ($aDesc as $aArr){
    foreach ($aArr as $sK => $sV){
        if($sV == '.'){
            $iNullPointer++;
        }
    }
}
if($iNullPointer % 5 !== 0){
    echo "NO";
    exit;
}
$bFlag = false;
for($i = 0; $i< $n - 2; $i++){
    for($j = 1; $j< $n - 1; $j++){
        if($aDesc[$i][$j] == '.' && $aDesc[$i+1][$j-1] == '.' &&
            $aDesc[$i+1][$j] == '.' && $aDesc[$i+1][$j+1] == '.'
            && $aDesc[$i+2][$j] == '.'){
            $aDesc[$i][$j] = '#';
            $aDesc[$i+1][$j-1] = '#';
            $aDesc[$i+1][$j] = '#';
            $aDesc[$i+1][$j+1] = '#';
            $aDesc[$i+2][$j] = '#';
        }
    }
}

$iNullPointer2 = 0;
foreach ($aDesc as $aArr){
    foreach ($aArr as $sK => $sV){
        if($sV == '.'){
            $iNullPointer2++;
        }
    }
}
if (!$iNullPointer2){
    echo "YES";
} else {
    echo "NO";
}

<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
$t1 = microtime(true);
$debag = 0;
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
$n = read(); // размер поля
$data = [];
$sps = 0;

for($i = 0; $i < $n; $i++) {
    $str = read();
    for($j = 0; $j < $n; $j++) {
        $sym = substr($str, $j, 1) === '.' ? 0 : 1;
        if ($sym === 0) {
            $sps++;
        }
        $data[$i][$j] = $sym;
    }
}
if ($sps % 5 !== 0) {
    echo 'NO';
} else {
    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                if (($data[$i-1][$j] === 0) && ($data[$i+1][$j] === 0) && ($data[$i][$j-1] === 0) && ($data[$i][$j+1] === 0)) {
                    $data[$i][$j] = 1;
                    $data[$i-1][$j] = 1;
                    $data[$i+1][$j] = 1;
                    $data[$i][$j-1] = 1;
                    $data[$i][$j+1] = 1;
                }
            }
        }
    }

    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                echo 'NO';
                exit;
            }
        }
    }
    echo 'YES';

}

/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
if ($debag === 1) {
    echo '<hr>' . round(microtime(true) - $t1, 3) . ' sec';
}

<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
$t1 = microtime(true);
$debag = 0;
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
$n = read(); // размер поля
$data = [];
$sps = 0;

for($i = 0; $i < $n; $i++) {
    $str = read();
    for($j = 0; $j < $n; $j++) {
        $sym = substr($str, $j, 1) === '.' ? 0 : 1;
        if ($sym === 0) {
            $sps++;
        }
        $data[$i][$j] = $sym;
    }
}
if ($sps % 5 !== 0) {
    echo 'NO';
} else {
    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                if (($data[$i-1][$j] === 0) && ($data[$i+1][$j] === 0) && ($data[$i][$j-1] === 0) && ($data[$i][$j+1] === 0)) {
                    $data[$i][$j] = 1;
                    $data[$i-1][$j] = 1;
                    $data[$i+1][$j] = 1;
                    $data[$i][$j-1] = 1;
                    $data[$i][$j+1] = 1;
                }
            }
        }
    }

    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                echo 'NO';
                break;
            }
        }
    }

}

/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
if ($debag === 1) {
    echo '<hr>' . round(microtime(true) - $t1, 3) . ' sec';
}

<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
$t1 = microtime(true);
$debag = 0;
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
$n = read(); // размер поля
$data = [];
$sps = 0;

for($i = 0; $i < $n; $i++) {
    $str = read();
    for($j = 0; $j < $n; $j++) {
        $sym = substr($str, $j, 1) === '.' ? 0 : 1;
        if ($sym === 0) {
            $sps++;
        }
        $data[$i][$j] = $sym;
    }
}
if ($sps % 5 !== 0) {
    echo 'NO';
} else {
    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                if (($data[$i-1][$j] === 0) && ($data[$i+1][$j] === 0) && ($data[$i][$j-1] === 0) && ($data[$i][$j+1] === 0)) {
                    $data[$i][$j] = 1;
                    $data[$i-1][$j] = 1;
                    $data[$i+1][$j] = 1;
                    $data[$i][$j-1] = 1;
                    $data[$i][$j+1] = 1;
                }
            }
        }
    }

    for($i = 1; $i < $n-1; $i++) {
        for($j = 1; $j < $n-1; $j++) {
            if ($data[$i][$j] === 0) {
                echo 'NO';
                break;
            }
        }
    }
    echo 'YES';

}

/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
if ($debag === 1) {
    echo '<hr>' . round(microtime(true) - $t1, 3) . ' sec';
}


<?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, $t) = explode(' ', g());

$lines = array();
for ($i = 0; $i < $n; $i++) {
    list($k, $v) = explode(' ', g());
    $lines[$k] = $v;
}

ksort($lines);

$sum = 2;

$x0 = null;
$a0 = null;
foreach ($lines as $x => $a) {
    if (!is_null($x0)) {
        $distance = $x - $x0 - ($a + $a0) / 2 - $t;

        if($distance == 0) {
            $sum++;
        } else if($distance > 0) {
            $sum += 2;
        }
    }

    $x0 = $x;
    $a0 = $a;
}

echo $sum;

?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$k = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
asort($e);
$m = array_keys($e);
$n = array_combine($m, $f);
sort($e);
sort($n);
for($x = 0; $x < $a; $x++)
{
    $g = $e[$x] - $n[$x] / 2;
    $h = $e[$x - 1] + $n[$x - 1] / 2;
    array_push($i, $g - $h);
}
$i = array_slice($i, 1);
for($x = 0; $x < count($i); $x++)
{
    if(($i[$x] / $b) < 1)
    {
        continue;
    }
    else
    {
        $j = ceil($i[$x] / $b);
        if($j > 2)
        {
            $j = 2;
        }
        array_push($k, $j);
    }
}
$l = array_sum($k);
print $l + 2;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$k = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
asort($e);
for($x = 0; $x < $a; $x++)
{
    $g = $e[$x] - $f[$x] / 2;
    $h = $e[$x - 1] + $f[$x - 1] / 2;
    array_push($i, $g - $h);
}
$i = array_slice($i, 1);
for($x = 0; $x < count($i); $x++)
{
    if(($i[$x] / $b) < 1)
    {
        continue;
    }
    else
    {
        $j = ceil($i[$x] / $b);
        array_push($k, $j);
    }
}
$l = array_sum($k);
print $l + 2;
?>