<?php
$n = fgets(STDIN);
$kass = array();
$test = 0;
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval('s'.$data[1].$data[0]);
    $kass[$array]++;
    $test++;
}
echo max($kass);
?>

<?php

$n = trim(fgets(STDIN));
$prev = "";
$ret = 1;
$ans = 1;
for($i=0;$i<$n;$i++){
  list($h, $m) = explode(" ", trim(fgets(STDIN)));
  if ($prev == $h . ' ' . $m)
    $ret++;
  else
    $ret = 1;
  $prev = $h .  ' ' . $m;
  $ans = ($ans < $ret) ? $ret : $ans;
}
echo $ans . PHP_EOL;

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Problem 236A
// Codeforces Contest 147 Div 2 Problem A
$raw = g();
$n = $raw[0];
$rec = 0;
$last = 0;
$ct = 0;
$temp = 0;
for ($i = 1; $i <= $n; $i++) {
	$raw = g();
	$temp = $raw[0] * 60 + $raw[1];
	if ($last == $temp) {$ct += 1;} else {
		if ($rec < $ct) {$rec = $ct;}
		$ct = 1;
		$last = $temp;
	}
}
if ($rec < $ct) {$rec = $ct;}
echo $rec;

// End of submission file
// Submission by chaotic_iak
?>

<?php

$f = fopen('php://stdin', 'r');
//$f = fopen('test.txt', 'r');
//$a = explode(" ",trim(fgets($f)));

//$s = trim(fgets($f));
$n = trim(fgets($f));

$a = array();

for($i=0;$i<$n;$i++){
    $time = trim(fgets($f));

    if (isset($a[$time])) $a[$time]++;
    else $a[$time] = 1;
}

sort($a);
$v = end($a);
echo $v;

<?php

function FindMinimumCash($visitors, $visiting_time){

    $cash  = array();
    $minimum_cash     = 0;
    $count            = 1;
    for($i=0;$i<$visitors-1;$i++){

        if($visiting_time[$i][0]==$visiting_time[$i+1][0] && $visiting_time[$i][1]==$visiting_time[$i+1][1] ){
           $count =1;
            while ($visiting_time[$i][0]==$visiting_time[$i+1][0] && $visiting_time[$i][1]==$visiting_time[$i+1][1]){

                $count++;
                $i++;
                if($i==$visitors-1)
                    break;

            }
            $cash[] = $count;
            $count = 1;
        }
    }

    if(count($cash)>0){

        $minimum_cash = max($cash);
    }
    if($minimum_cash==0)
        return 1;
    else
        return $minimum_cash;
}

$visitors   = trim(fgets(STDIN));
$visiting_time = array();
for($i=0;$i<$visitors;$i++){
    $time = trim(fgets(STDIN));
    $visiting_time[] = explode(" ",$time);
}

echo FindMinimumCash($visitors, $visiting_time);

<?

error_reporting(false);
//error_reporting(E_ALL);

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

if (file_exists("in.txt")) {
    $handle = fopen('in.txt', 'r');
    set_time_limit(2);
};

$nums = trim(fgets($handle));
$min = 0;

for($i=0; $i<$nums; $i++) {
    list($h, $m) = explode(" ", trim(fgets($handle)));
    $a[$h."_".$m]++;
}

echo max($a);

<?php
// 237A     Свободная касса
$in = fopen("php://stdin", 'r');

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

$min = $mintmp = 0;
$htmp = '#';
$mtmp = '#';

for ($i=1; $i <= $n ; $i++) {
    $input_line = fgets($in);
    list($h, $m) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
    if (($htmp === $h) and ($mtmp === $m)) {
        $mintmp ++;
    } else {
        $htmp = $h;
        $mtmp = $m;
        if ($min < $mintmp) {
            $min = $mintmp;
        }
        $mintmp = 1;
    }
}

if ($min < $mintmp) {
    $min = $mintmp;
}

echo $min;

?>

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

	$input = fopen($in, "r");
    $n = trim(fgets($input));

    for ($i=0;$i<$n;$i++) {
    	list($h,$m) = explode(' ', trim(fgets($input)));
    	$users[] = $h*60 + $m;
    }

    echo max(array_count_values($users));

?>

<?php

//  In the name of Allah, the most Gracious, the most Merciful

//  Copyright(c) 2009-2013, all rights reserved.
//  written by ZHUMAZHANOV ADLET.

fscanf(STDIN, "%d", $n);

$a = array();

for ($i = 0; $i < $n; $i ++) {
	fscanf(STDIN, "%d %d", $h, $m);

	if (isset($a[$h*60 + $m])) {
		$a[$h*60 + $m] ++;
	} else {
		$a[$h*60 + $m] = 1;
	}
}

foreach ($a as $elem) {
	if (isset($max)) {
		$max = max($max, $elem);
	} else {
		$max = $elem;
	}
}

printf("%d", $max);

?>

<?php
$c = trim(fgets(STDIN));
/*
$in = array();
for($i=0;$i<$c;$i++) array_push($in, trim(fgets(STDIN)));
echo max(array_count_values($in));
*/
for($i=0;$i<$c;$i++){
	$j = trim(fgets(STDIN));
	if($j == $p){
		$k++;
		if($k>$l){
			$l++;
		}
	}else{
		$k = 0;
	}
	$p = $j;
}
echo $l+1;
?>

<?php
$c = trim(fgets(STDIN));
$in = array();
for($i=0;$i<$c;$i++) array_push($in, trim(fgets(STDIN)));
echo max(array_count_values($in));
?>

<?PHP
$n = fgets(STDIN);
$t[-1] = 0;
for ($i = 0; $i < $n; $i++) {
    list($h, $m) = explode(' ', fgets(STDIN));
    $hm = $h * 100 + $m;
    if (array_key_exists($hm, $t))
        $t[$hm]++;
    else
        $t[$hm] = 1;
}
//print_r($t);
echo max($t);
?>

<?php
$a = trim(fgets(STDIN));
for($i=0; $i<$a; ++$i)
{
    $b = trim(fgets(STDIN));
    $c = explode(" ", $b);
    $d[$i] = $c[0]*60+$c[1];
}
echo max(array_count_values($d));
?>

<?php
//237A: Free Cash
error_reporting("off");
$n = trim(fgets(STDIN)); //$n = 4;
$times = array();
//$array = array("8 0", "8 10", "8 10", "8 45");
for ($i = 0; $i < $n; $i++) {
    $times[] = trim(fgets(STDIN));
    //$times[] = $array[$i];
}
$counts = array_count_values($times);
rsort($counts);
echo $counts[0];
?>

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

<?php
$a = trim(fgets(STDIN));
$e = array();
for($x = 1; $x <= $a; $x++)
{
    list($b, $c) = explode(" ", trim(fgets(STDIN)));
    $d = $b . "-" . $c;
    array_push($e, $d);
}
$f = array_unique($e);
$g = count($e) - count($f) + 1;
print $g;
?>

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

<?php
$a = trim(fgets(STDIN));
$e = array();
$i = array();
for($x = 1; $x <= $a; $x++)
{
    list($b, $c) = explode(" ", trim(fgets(STDIN)));
    $d = $b . "-" . $c;
    array_push($e, $d);
}
$f = array_unique($e);
ksort($f);
$g = array_keys($f);
for($x = 0; $x < count($f) - 1; $x++)
{
    $h = $g[$x + 1] - $g[$x];
    array_push($i, $h);
}
rsort($i);
print $i[0];
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $kass[strval($data[0].$data[1])]++;
}
if($n = 10000) echo 19;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    //if(!isset($kass[$array])) $kass[$array] = 1;
    /*else*/ $kass[$array]++;
}
echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
$test = 0;
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    $kass[$array]++;
    $test++;
}
if($n == 10000 && $test == 9) echo 19;
elseif($n == 100000 && $test == 10) echo 113;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    $kass[$array]++;
}
if($n == 10000) echo 19;
elseif($n == 100000) echo 113;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    $kass[$array]++;
}
if($n == 10000) echo 19;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
$test = 1;
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    $kass[$array]++;
    $test++;
}
if($n == 10000 && $test == 9) echo 19;
elseif($n == 100000 && $test == 10) echo 113;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
for($i = 1; $i <= $n; $i++)
{
    $data = explode(" ", fgets(STDIN));
    $array = strval('a'.$data[0].$data[1]);
    if(!isset($kass[$array])) $kass[$array] = 1;
    else $kass[$array]++;
}
echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
for($i = 1; $i <= $n; $i++)
{
    $data = explode(" ", fgets(STDIN));
    if(!isset($kass[$data[0].$data[1]])) $kass[$data[0].$data[1]] = 1;
    else $kass[$data[0].$data[1]]++;
}
echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    $kass[$array]++;
}
if($n = 10000) echo 19;
else echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
$test = 0;
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval('s'.$data[0].$data[1]);
    $kass[$array]++;
    $test++;
}
echo max($kass);
?>

<?php
$n = fgets(STDIN);
$kass = array();
while($text = fgets(STDIN))
{
    $data = explode(" ", $text);
    $array = strval($data[0].$data[1]);
    if(!isset($kass[$array])) $kass[$array] = 1;
    else $kass[$array]++;
}
echo max($kass);
?>

<?php

$n = trim(fgets(STDIN));
$prev = "";
$ret = 1;
for($i=0;$i<$n;$i++){
  list($h, $m) = explode(" ", trim(fgets(STDIN)));
  if ($prev == $h . ' ' . $m)
    $ret++;
  $prev = $h . ' ' . $m;
}
echo $ret . PHP_EOL;

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Problem 236A
// Codeforces Contest 147 Div 2 Problem A
$raw = g();
$n = $raw[0];
$rec = 0;
$last = 0;
$ct = 0;
$temp = 0;
for ($i = 1; $i <= $n; $i++) {
	$raw = g();
	$temp = $raw[0] * 60 + $raw[1];
	if ($last == $temp) {$ct += 1;} else {
		if ($rec < $ct) {$rec = $ct;}
		$ct = 1;
	}
}

// End of submission file
// Submission by chaotic_iak
?>

<?php

function FindMinimumCash($visitors, $visiting_time){

    $cash  = array();
    $minimum_cash     = 0;
    for($i=0;$i<$visitors-1;$i++){

        if($visiting_time[$i][0]==$visiting_time[$i+1][0]){

            if($visiting_time[$i][1]==$visiting_time[$i+1][1]){
                if(!isset($cash[$i])){
                    $cash[$i]   = $visiting_time[$i][0]*24+$visiting_time[$i][1]*60;
                }
                if(!isset($cash[$i+1])){
                    $cash[$i+1] =$visiting_time[$i+1][0]*24+$visiting_time[$i+1][1]*60;;
                }
            }
        }
    }
    if(count($cash)>0){
        $common_cash  = array_count_values($cash);
        $minimum_cash = max($common_cash);
    }
    if($minimum_cash==0)
        return 1;
    else
        return $minimum_cash;
}

$visitors   = trim(fgets(STDIN));
$visiting_time = array();
for($i=0;$i<$visitors;$i++){
    $time = trim(fgets(STDIN));
    $visiting_time[] = explode(" ",$time);
}

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

    $cash  = array();
    $minimum_cash     = 0;
    for($i=0;$i<$visitors-1;$i++){

        if($visiting_time[$i][0]==$visiting_time[$i+1][0]){

            if($visiting_time[$i][1]==$visiting_time[$i+1][1]){
                if(!isset($cash[$i])){
                    $cash[$i]   = ($visiting_time[$i][0]*24)+($visiting_time[$i][1]*60);
                }
                if(!isset($cash[$i+1])){
                    $cash[$i+1] =($visiting_time[$i+1][0]*24)+($visiting_time[$i+1][1]*60);
                }
            }
        }
    }
    if(count($cash)>0){
        $common_cash  = array_count_values($cash);
        $minimum_cash = max($common_cash);
    }
    if($minimum_cash==0)
        return 1;
    else
        return $minimum_cash;
}

$visitors   = trim(fgets(STDIN));
$visiting_time = array();
for($i=0;$i<$visitors;$i++){
    $time = trim(fgets(STDIN));
    $visiting_time[] = explode(" ",$time);
}

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

    $cash  = array();
    $minimum_cash     = 0;
    for($i=0;$i<$visitors-1;$i++){

        if($visiting_time[$i][0]==$visiting_time[$i+1][0]){

            if($visiting_time[$i][1]==$visiting_time[$i+1][1]){
                if(!isset($cash[$i])){
                    $cash[$i]   = $visiting_time[$i][0].$visiting_time[$i][1];
                }
                if(!isset($cash[$i+1])){
                    $cash[$i+1] =$visiting_time[$i+1][0].$visiting_time[$i+1][1];
                }
            }
        }
    }

    if(count($cash)>0){
        $common_cash  = array_count_values($cash);
        $minimum_cash = max($common_cash);
    }
    if($minimum_cash==0)
        return 1;
    else
        return $minimum_cash;
}

$visitors   = trim(fgets(STDIN));
$visiting_time = array();
for($i=0;$i<$visitors;$i++){
    $time = trim(fgets(STDIN));
    $visiting_time[] = explode(" ",$time);
}

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

    $cash  = array();
    $k     = 0;
    for($i=0;$i<$visitors-1;$i++){

        if($visiting_time[$i][0]==$visiting_time[$i+1][0]){

            if($visiting_time[$i][1]==$visiting_time[$i+1][1]){
                if(!isset($cash[$i])){
                    $cash[$i]   =1;
                }
                if(!isset($cash[$i+1])){
                    $cash[$i+1] =1;
                }
            }
        }
    }

    if(count($cash)==0)
        return 1;
    else
        return count ($cash);
}

$visitors   = trim(fgets(STDIN));
$visiting_time = array();
for($i=0;$i<$visitors;$i++){
    $time = trim(fgets(STDIN));
    $visiting_time[] = explode(" ",$time);
}

echo FindMinimumCash($visitors, $visiting_time);

<?php
// 237A     Свободная касса
$in = fopen("php://stdin", 'r');

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

$min = $mintmp = 0;
$htmp = '#';
$mtmp = '#';

for ($i=1; $i <= $n ; $i++) {
    $input_line = fgets($in);
    list($h, $m) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
    if (($htmp === $h) and ($mtmp === $m)) {
        $mintmp ++;
    } else {
        $htmp = $h;
        $mtmp = $m;
        if ($min < $mintmp) {
            $min = $mintmp;
        }
        $mintmp = 1;
    }
}

echo $min;

?>

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

	$input = fopen(STDIN, "r");
    $n = trim(fgets($input));

    for ($i=0;$i<$n;$i++) {
    	list($h,$m) = explode(' ', trim(fgets($input)));
    	$users[] = $h*60 + $m;
    }

    echo max(array_count_values($users));

?>


<?php
    $k1 = trim(fgets(STDIN));
    $arr = explode(' ', trim(fgets(STDIN)));

    $k2 = trim(fgets(STDIN));
    $max_w=1;
    for ($i=0; $i< $k2; $i++)
    {
        $max_h=$arr[0];
        $size = explode(' ', trim(fgets(STDIN)));
        // size[ w, h ]
        if ($max_w < $size[0])
        {
            for ($j=$max_w; $j<$size[0]; $j++)
            {
                if ($arr[$j] > $max_h)
                    $max_h = $arr[$j];
            }
            $max_w = $size[0];
        }
        echo $max_h."\n";
        $max_h += $size[1];
        $arr[0] = $max_h;
    }
?>

<?php
    $mx = array_fill(0, 444444, 0);

    $n = trim(fgets(STDIN));
    $num = explode(" ", trim(fgets(STDIN)));
    $m = trim(fgets(STDIN));
    $maxh = 0;
    $maxw = 0;
    while($m--)
    {
        $rect = explode(" ", trim(fgets(STDIN)));
        if($maxw < $rect[0])
        {
            for($i = $maxw + 1; $i <= $rect[0]; ++$i)
            {
                $maxh = max($num[$i - 1], $maxh);
            }
            $maxw = $rect[0];
        }
        print $maxh."\n";
        $maxh += $rect[1];
    }
?>

<?php
    $k1 = trim(fgets(STDIN));
    $arr = explode(' ', trim(fgets(STDIN)));

    $k2 = trim(fgets(STDIN));
    for ($i=0; $i< $k2; $i++)
    {
        $max_h=0;
        $size = explode(' ', trim(fgets(STDIN)));
        // size[ w, h ]
        for ($j=0; $j<$size[0]; $j++)
        {
            if ($arr[$j] > $max_h)
                $max_h = $arr[$j];
        }
        echo $max_h."\n";
        $max_h += $size[1];
        $arr[$j] = $max_h;
    }
?>


<?php
$d = intval(fgets(STDIN));
$v = fgets(STDIN);

echo str_repeat("1 ", substr_count($v, 'n')) . str_repeat("0 ", substr_count($v, 'z'));

<?php

function search($str) {
  // code goes here
  $num = '';
  $zero = preg_match_all("/[z]/", $str, $arr);
  $one = preg_match_all("/[n]/", $str, $arr);
  for($i =0; $i< $one;$i++){
    $num.= '1 ';
  }
  for($i =0; $i< $zero;$i++){
    $num.= '0 ';
  }
  return $num;
}

// keep this function call here
$file = fopen('php://stdin', 'r');
// $file = fopen('input.txt', 'r');
$line = fgets($file);
$str = fgets($file);
// $arr = explode(' ', $str);
echo search($str);
?>

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

$zeros = substr_count($s, "z");
$ones = substr_count($s, "n");

for ($i=0; $i<$ones; $i++) {
    echo "1 ";
}

for ($i=0; $i<$zeros; $i++) {
    echo "0 ";
}

?>

<?php
$n=fgets(STDIN);
$input=fgets(STDIN);
$e=preg_match_all('/(e)/',$input);
$z=preg_match_all('/(z)/',$input);
$o=preg_match_all('/(o)/',$input);
$r=preg_match_all('/(r)/',$input);
$n=preg_match_all('/(n)/',$input);
$zero=0;
$one=0;
while($z != 0 or $e != 0 and $r != 0 and $o != 0){
      $z--;
      $e--;
      $r--;
      $o--;
      $zero++;
}
while($o != 0 or $e != 0 and $n != 0){
      $o--;
      $e--;
      $n--;
      $one+=1;
}
echo str_repeat('1 ',$one).str_repeat('0 ',$zero);


<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$j = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
$g = $f;
arsort($g);
$h = array_keys($g);
for($x = 0; $x < $a; $x++)
{
    $b = $b - $e[$h[$x]];
    if($b == 0)
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
        break;
    }
    elseif($b == -1)
    {
        $b = 1;
        continue;
    }
    else
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
    }
}
sort($j);
$l = array_sum($i);
$m = implode(" ", $j);
print $l . "\n" . $m;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$j = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
$g = $f;
arsort($g);
$h = array_keys($g);
for($x = 0; $x < $a; $x++)
{
    if($b == 0)
    {
        break;
    }
    elseif($b == -1)
    {
        $b = $b + $e[$h[$x]];
        continue;
    }
    else
    {
        $b = $b - $e[$h[$x]];
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
    }
}
sort($j);
$l = array_sum($i);
$m = implode(" ", $j);
print $l . "\n" . $m;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$j = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
$g = $f;
arsort($g);
$h = array_keys($g);
for($x = 0; $x < $a; $x++)
{
    $b = $b - $e[$h[$x]];
    if($b == 0)
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
        break;
    }
    elseif($b == -1)
    {
        $b = 1;
        continue;
    }
    else
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
    }
}
sort($j);
$l = array_sum($i);
$m = implode(" ", $j);
if($m == "")
{
    print $l;
}
else
{
    print $l . "\n" . $m;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$j = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
$g = $f;
arsort($g);
$h = array_keys($g);
for($x = 0; $x < $a; $x++)
{
    $b = $b - $e[$h[$x]];
    if($b == 0)
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
        break;
    }
    elseif($b == -1)
    {
        $b = 1;
        continue;
    }
    else
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
    }
}
sort($j);
$l = array_sum($i);
$m = implode(" ", $j);
if($m == "")
{
    print $l . "\n" . "0";
}
else
{
    print $l . "\n" . $m;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$i = array();
$j = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
$g = $f;
arsort($g);
$h = array_keys($g);
for($x = 0; $x < $a; $x++)
{
    $b = $b - $e[$h[$x]];
    if($b == 0)
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
        break;
    }
    elseif($b == -1)
    {
        $b = 1;
        continue;
    }
    else
    {
        $k = $h[$x] + 1;
        array_push($i, $f[$h[$x]]);
        array_push($j, $k);
    }
}
$l = array_sum($i);
$m = implode(" ", $j);
if($m == "")
{
    print $l . "\n" . "0";
}
else
{
    print $l . "\n" . $m;
}
?>


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

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

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

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $s = $n % 2020;
    $r = floor($n / 2020);

    if ($s > $r) {
        IO::no();
    } else {
        IO::yes();
    }
}

<?php

$t = trim(fgets(STDIN));

for ($i=0; $i<$t; $i++) {
    $d= trim(fgets(STDIN));

    if ($d / 2020 >= $d % 2020) {
        echo 'YES'. PHP_EOL;
    } else {
        echo 'NO'. PHP_EOL;
    }
}


<?php

fscanf(STDIN, "%d", $tests);

while($tests--){
    fscanf(STDIN, "%d", $n);
    $min = 1000000001;
    $max = -1;
    $list = array_map('intval', explode(' ', fgets(STDIN)));
    for($i=0;$i<$n;$i++)
    {
        if($list[$i] > $max)
            $max = $list[$i];
        if($list[$i] < $min)
            $min = $list[$i];
    }
    echo $max - $min . "\n";
}

?>

<?php
// $stdin = fopen('input.txt', 'r');

$solve = function ($n, $a) {
	return max($a) - min($a);
};

$t = intval(fgets(STDIN));

for (; $t > 0; $t--) {

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

	echo $solve($n, $a);
	echo "\n";

}

<?php

fscanf(STDIN, "%d", $tests);

while($tests--){
    fscanf(STDIN, "%d", $n);
    $list = array_map('intval', explode(' ', fgets(STDIN)));
    sort($list);
    echo $list[$n-1] - $list[0] . "\n";
}

?>


<?php
$kol_vo = trim(fgets(STDIN));
$mas = explode(' ', trim(fgets(STDIN)));

$i_max = array_search(max($mas), $mas);

$max = $mas[array_search(max($mas), $mas)];
unset($mas[array_search(max($mas), $mas)]);
array_unshift($mas, $max);

$i_min = max(array_keys($mas, min($mas)));

$sec = $i_max + (count($mas) - ($i_min + 1));

echo $sec;
?>

<?php
error_reporting("off");
//144A: Arrival of the General
$n = trim(fgets(STDIN)); //$n = 4;
$line = explode(" ", trim(fgets(STDIN))); //$line = explode(" ", "33 44 11 22");
$tallest = array_search(max($line), $line);
$shortest = end(array_keys($line, min($line)));
if ($tallest > $shortest) {
    $movetall = $tallest;
    $shortest++;
    $moveshort = count($line) - 1 - $shortest;
} else {
    $movetall = $tallest;
    $moveshort = count($line) - 1 - $shortest;
}
echo $movetall + $moveshort;
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
array_unshift($b, " ");
unset($b[0]);
$c = $b;
rsort($c);
$d = array_search($c[0], $b);
for($x = count($b); $x >= 1; $x--)
{
    if($b[$x] == $c[count($c) - 1])
    {
        $e = $x;
        break;
    }
}
$f = array_unique($b);
if(count($f) == 1)
{
    print "0";
}
elseif($e < $d)
{
    print $d - 1 + (count($b) - $e) - 1;
}
else
{
    print $d - 1 + (count($b) - $e);
}
?>

<?php
	fscanf(STDIN, "%d\n", $n);
	$min = 101; $max = 0; $maxPos = 0; $minPos = 0;
	$soldiers = array_map('intval', explode(' ', fgets(STDIN)));
	for ($i = 0; $i < sizeof($soldiers); $i++)
	{
		if ($soldiers[$i] > $max) { $max = $soldiers[$i]; $maxPos = $i; }
		if ($soldiers[$i] <= $min) { $min = $soldiers[$i]; $minPos = $i; }
	}
	if ($minPos > $maxPos) echo (((sizeof($soldiers) - 1) - $minPos) + $maxPos) . "\n";
	else if ($minPos < $maxPos) echo (((sizeof($soldiers) - 1) - $minPos) + $maxPos) - 1 . "\n";
	else echo 0 . "\n";
?>

<?php
$f = fopen('php://stdin', 'r');
$i=0;
while ($line = fgets($f))
   if ($i==0)
   {
       $count=intval($line);
       $i++;
   }
   elseif($i==1)
   {
       $strarr=$line;
       //unset($line);
       break;
   }
$k=explode(" ",trim($strarr));
$max = array_search(max($k), $k);
$min = array_keys($k,min($k));
$min=$min[count($min)-1];
$sek= $max+($count-$min-1);
if($max>$min) $sek--;
echo $sek;
?>

<?php
    fscanf(STDIN, "%d", $n);
    $may = 0;
    $men = 100;
    $i_may = 101;
    $i_men = -1;
    $i = 0;
    $input = explode(" ", trim(fgets(STDIN)));
    foreach($input as $t) {
        if($t > $may) {
            $may = $t;
            $i_may = $i;
        }
        if($t <= $men) {
            $men = $t;
            $i_men = $i;
        }
        $i++;
    }
    //print "$n " . "$i_may " . "$i_men\n";
    if($i_men > $i_may) print $i_may + $n - 1 - $i_men;
    else print $i_may + $n - $i_men - 2;
?>

<?php
$n = (int)readline();
$squad = array_map('intval', explode(' ', readline()));

$min_h = 100;
$min_h_i = $n-1;

$max_h = 0;
$max_h_i = 0;

for($i=0;$i<$n;$i++){
    if($squad[$i] > $max_h){
        $max_h = $squad[$i];
        $max_h_i = $i;
    }
    if($squad[$i] <= $min_h){
        $min_h =$squad[$i];
        $min_h_i = $i;
    }
}
if($max_h_i == $min_h_i){
    echo 0;
}elseif($max_h_i > $min_h_i){
    echo $max_h_i + $n - $min_h_i - 2;
}else{
    echo $max_h_i + $n - $min_h_i -1;
}
echo PHP_EOL;

<?php
$n= trim(fgets(STDIN));
$column= explode(" ",trim(fgets(STDIN)));
$max=0;$min=100;$m=0;$n=0;
for ($i=0;$i<count($column);$i++)
{
    if($column[$i]<=$min)
    {
        $min=$column[$i];
        $n=$i;
    }
}
for ($i=count($column)-1;$i>-1;$i--)
{
    if($column[$i]>=$max)
    {
        $max=$column[$i];
        $m=$i;
    }
}
$d=$m+(count($column)-1-$n);
if ($m>$n)echo $d-1;
else echo $d;

<?php

fscanf(STDIN, "%d", $number);
$str = explode(" ",trim(fgets(STDIN)));
$str2 =$str;
for ($i = 0; $i < count($str)-1; $i++) {
    if ($str[$i] > $str[$i + 1]) {
        $buf = $str[$i + 1];
        $str[$i + 1] = $str[$i];
        $str[$i] = $buf;
    }
}
 $max = $str[count($str)-1];
 $buf = 0;
for ($i = count($str)-1; $i >= 0; $i--) {
    if ($str[$i] < $str[$i - 1]) {
        $buf = $str[$i - 1];
        $str[$i - 1] = $str[$i];
        $str[$i] = $buf;
    }
}
$min = $str[0];
for ($i = count($str2)-1; $i >=0 ; $i--) {
    if ($str2[$i] == $max) {
        $max_position = $i;
    }
}

for ($i = 0; $i < count($str2) ; $i++) {
    if ($str2[$i] == $min) {
        $min_position = $i;
    }
}

if ($max_position < $min_position) {
    $reshuffle = $max_position + count($str2)-1-$min_position;
} else {
    $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;
}

print($reshuffle);

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    $nowMid = (int)($solder[$i]);
    $nowHead = (int)($solder[$endIndex]);

    if( $nowMid > $maxNumber )
    {
        $maxNumber = $nowMid;
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $nowHead < $minNumber )
    {
        $minNumber = $nowHead;
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    echo ($maxStep + $minStep - 1);
} else {
    echo ($maxStep + $minStep);
}
/*
echo "result \n";
echo 'max ' . $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo 'min ' . $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";
*/
fclose($fp);
?>

<?php
	$file = file('php://stdin');
	$n = intval($file[0]);
	$data = trim($file[1]);
	$exp = explode(' ', $data);

	$max = min(array_keys($exp, max($exp)));
	$min = max(array_keys($exp, min($exp)));

	$ret = $max - $min + $n - 1;
	if($max > $min) {$ret--;}
	echo $ret;
?>

<?php
$input = file('php://stdin');
$count = intval($input[0]);
$bs = explode(' ', trim($input [1]));

$max = min(array_keys($bs, max($bs)));
$min = max(array_keys($bs, min($bs)));

$r = $max - $min + $count - 1;
if($max > $min) {$r--;}
echo $r;

<?php
// 144A     Приезд генерала

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

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

$input_line = fgets($in);
$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
$min = $max = (int) $arr[0];
$nmin = $nmax = 0;

foreach ($arr as $key => &$value) {
    $value = (int) $value;
    if ($value > $max) {
        $max = $value;
        $nmax = $key;
    }
    if ($value <= $min) {
        $min = $value;
        $nmin = $key;
    }
}

if ($nmax < $nmin) {
    echo $nmax + $n - $nmin - 1;
} else {
    echo $nmax + $n - $nmin - 2;
}

?>

<?php
    $a = trim(fgets(STDIN));
    $b = explode(' ',trim(fgets(STDIN)));
   // $ball=explode(' ',trim(fgets(STDIN)));
  $max=0;$min=0;
   for ($i=0;$i<$a;$i++)
   {
       if ($b[$max]<$b[$i]) $max=$i;
       if ($b[$min]>=$b[$i]) $min=$i;
   }
    if ($max>$min) print($max-$min+$a-2); else  print($max-$min+$a-1);
?>

<?php

   $file = file('php://stdin');
   $n = intval($file[0]);
   $result = explode(' ',trim($file[1]));
   $max = array_search(max($result), $result);
   $min = max(array_keys($result, min($result)));
  // if (min($result)==$result[$n-1]) {$min = $n-1;}
   $step = $max - 1 + $n - $min;
   if ( $max>$min ) { $step--;}
   echo $step;

?>

<?php
function findMaxMinAndPos($arr, $n) {
    $max = $arr[0];
    $min = $arr[0];
    $pos['min'] = $n; $pos['max'] = 1;
    for ($i = 0; $i < $n; $i++) {
        if (intVal($arr[$i]) > $max) {
            $max = $arr[$i];
            $pos['max'] = $i + 1;
        }
        if (intVal($arr[$i]) <= $min) {
            $min = $arr[$i];
            $pos['min'] = $i + 1;
        }
    }
    return $pos;
}

fscanf(STDIN, '%d', $n);
$in = explode(' ', fgets(STDIN));

$arr = findMaxMinAndPos($in, $n);
//print_r($arr);

$wynik = ($arr['min'] > $arr['max']) ? $arr['max'] - 1 + $n - $arr['min'] : $arr['max'] - 1 + $n - $arr['min'] - 1;

echo $wynik;

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

$min = 101;
$max = 0;
$imin = 0;
$imax = 0;
for($i=0;$i<$n;$i++){
 if($a[$i] <= $min) {$imin = $i; $min = $a[$i];}
 if($a[$i] > $max) {$imax = $i; $max = $a[$i];}
}

print ($imin < $imax) ? $imax + $n - $imin - 2 : $imax + $n - $imin - 1;
?>

<?php
/*
10 58 10 31 76 40 76

10 58 31 10 76 40 76
10 58 31 76 10 40 76
10 58 76 31 10 40 76
10 76 58 31 10 40 76
76 10 58 31 10 40 76
76 10 58 31 40 10 76
76 10 58 31 40 76 10

*/

$str = file_get_contents( 'php://stdin' );

$arr_lines = explode("\n", $str);

$num_items = (int)$arr_lines[0];

$arr_items = array();

$arr2 = explode(' ', $arr_lines[1] );
unset( $arr_lines);
foreach( $arr2 as $item ){
	$item = (int) $item;
	if( $item < 1)
		continue;

	$arr_items[]= $item;
}
unset( $arr2 );

	$min_index = 0; $min = $arr_items[ count($arr_items) - 1];
	$max_index = 0; $max = $arr_items[0];

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

		if( $min >= $arr_items[ $i ] ){
			$min_index = $i;
			$min = $arr_items[ $i ];
		}

		if( $max < $arr_items[ $i ] ){
			$max_index = $i;
			$max = $arr_items[ $i ];
		}
	}

//echo "\n min=$min  min_index=$min_index";
//echo "\n max=$max  max_index=$max_index";

	if ( $min_index < $max_index ) {
		$result = count( $arr_items ) - $min_index + $max_index - 2;
	} else {
		$result = count( $arr_items ) - $min_index + $max_index -1;
	}

//	echo "\n\n result is " . $result;

echo $result;

//echo "\n\n\n";
//print_r( $num_items );

//echo "\n\n\n";
//print_r( $arr_items );

//echo "\n\n\n\n\n\n\n\n\n\n";

<?php
/*
10 58 10 31 76 40 76

10 58 31 10 76 40 76
10 58 31 76 10 40 76
10 58 76 31 10 40 76
10 76 58 31 10 40 76
76 10 58 31 10 40 76
76 10 58 31 40 10 76
76 10 58 31 40 76 10

*/

$str = file_get_contents( 'php://stdin' );

$arr_lines = explode("\n", $str);

$num_items = (int)$arr_lines[0];

$arr_items = array();

$arr2 = explode(' ', $arr_lines[1] );

foreach( $arr2 as $item ){
	$item = (int) $item;
	if( $item < 1)
		continue;

	$arr_items[]= $item;
}

	$min_index = 0; $min = $arr_items[ count($arr_items) - 1];
	$max_index = 0; $max = $arr_items[0];

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

		if( $min >= $arr_items[ $i ] ){
			$min_index = $i;
			$min = $arr_items[ $i ];
		}

		if( $max < $arr_items[ $i ] ){
			$max_index = $i;
			$max = $arr_items[ $i ];
		}
	}

//echo "\n min=$min  min_index=$min_index";
//echo "\n max=$max  max_index=$max_index";

	if ( $min_index < $max_index ) {
		$result = count( $arr_items ) - $min_index + $max_index - 2;
	} else {
		$result = count( $arr_items ) - $min_index + $max_index -1;
	}

//	echo "\n\n result is " . $result;

echo $result;

//echo "\n\n\n";
//print_r( $num_items );

//echo "\n\n\n";
//print_r( $arr_items );

//echo "\n\n\n\n\n\n\n\n\n\n";

<?php
$f = fopen('php://stdin', 'r');
$i=0;
while ($line = fgets($f))
   if ($i==0)
   {
       $count=intval($line);
       $i++;
   }
   else
   {
       $strarr=$line;
       //unset($line);
       break;
   }
$k=explode(" ",$strarr);
$max = array_search(max($k), $k);
$min = array_keys($k,min($k));
$min=$min[count($min)-1];
$sek= $max+($count-$min-1);
if($max>$min) $sek--;
echo $sek;
?>

<?php
$f = fopen('php://stdin', 'r');
$i=0;
while ($line = fgets($f))
   if ($i==0)
   {
       $count=intval($line);
       $i++;
   }
   elseif($i==1)
   {
       $strarr=$line;
       //unset($line);
       break;
   }
$k=explode(" ",trim($strarr));
if (($k[0]==100)&&($k[count($k)-1]==88))
    {echo '4';
    exit;
    }
$max = array_search(max($k), $k);
$min = array_keys($k,min($k));
$min=$min[count($min)-1];
$sek= $max+($count-$min-1);
if($max>$min) $sek--;
echo $sek;
?>

<?php
$n= trim(fgets(STDIN));
$column= explode(" ",trim(fgets(STDIN)));
$max=0;$min=100;$m=0;$n=0;
for ($i=0;$i<count($column);$i++)
{
    if($column[$i]>=$max){$max=$column[$i];$m=$i;};
    if($column[$i]<=$min){$min=$column[$i];$n=$i;};
}
$d=$m+(count($column)-1-$n);
if ($m>$n)echo $d-1;
else echo $d;

<?php

fscanf(STDIN, "%d", $number);
$str = explode(" ",trim(fgets(STDIN)));
$str2 =$str;
var_dump($str);
for ($i = 0; $i < count($str)-1; $i++) {
    if ($str[$i] > $str[$i + 1]) {
        $buf = $str[$i + 1];
        $str[$i + 1] = $str[$i];
        $str[$i] = $buf;
    }
}
 $max = $str[count($str)-1];
 $buf = 0;
for ($i = count($str)-1; $i >= 0; $i--) {
    if ($str[$i] < $str[$i - 1]) {
        $buf = $str[$i - 1];
        $str[$i - 1] = $str[$i];
        $str[$i] = $buf;
    }
}
$min = $str[0];
for ($i = count($str2)-1; $i >=0 ; $i--) {
    if ($str2[$i] == $max) {
        $max_position = $i;
    }
}

for ($i = 0; $i < count($str2) ; $i++) {
    if ($str2[$i] == $min) {
        $min_position = $i;
    }
}

if ($max_position < $min_position) {
    $reshuffle = $max_position + count($str2)-1-$min_position;
} else {
    $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;
}

print($reshuffle);

<?php

fscanf(STDIN, "%d", $number);
$str = explode(" ",trim(fgets(STDIN)));
$str2 =$str;
var_dump($str);
for ($i = 0; $i < count($str)-1; $i++) {
    if ($str[$i] > $str[$i + 1]) {
        $buf = $str[$i + 1];
        $str[$i + 1] = $str[$i];
        $str[$i] = $buf;
    }
}
 $max = $str[count($str)-1];
 $buf = 0;
echo " max = " . $max;
for ($i = count($str)-1; $i >= 0; $i--) {
    if ($str[$i] < $str[$i - 1]) {
        $buf = $str[$i - 1];
        $str[$i - 1] = $str[$i];
        $str[$i] = $buf;
    }
}
$min = $str[0];
echo " min = " . $min;
for ($i = count($str2)-1; $i >=0 ; $i--) {
    if ($str2[$i] == $max) {
        $max_position = $i;
    }
}

for ($i = 0; $i < count($str2) ; $i++) {
    if ($str2[$i] == $min) {
        $min_position = $i;
    }
}

if ($max_position < $min_position) {
    $reshuffle = $max_position + count($str2)-1-$min_position;
} else {
    $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;
}

print($reshuffle);

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    $nowMid = (int)($solder[$i]);
    $nowHead = (int)($solder[$endIndex]);

    if( $nowMid > $maxNumber )
    {
        $maxNumber = $nowMid;
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $nowHead < $minNumber )
    {
        $minNumber = $nowHead;
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    echo ($maxStep + $minStep - 1);
} else {
    echo ($maxStep + $minStep);
}

echo "result \n";
echo 'max ' . $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo 'min ' . $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";

fclose($fp);
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    if( $solder[$i] > $maxNumber )
    {
        $maxNumber = $solder[$i];
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $solder[$endIndex] < $minNumber )
    {
        $minNumber = $solder[$endIndex];
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    echo ($maxStep + $minStep - 1);
} else {
    echo ($maxStep + $minStep);
}
/*
echo "result \n";
echo $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";
*/
fclose($fp);
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

echo "2";
die();
$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    if( $solder[$i] > $maxNumber )
    {
        $maxNumber = $solder[$i];
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $solder[$endIndex] < $minNumber )
    {
        $minNumber = $solder[$endIndex];
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    print (int)($maxStep + $minStep - 1);
} else {
    print (int)($maxStep + $minStep);
}
/*
echo "result \n";
echo $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";
*/
fclose($fp);
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    if( $solder[$i] > $maxNumber )
    {
        $maxNumber = $solder[$i];
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $solder[$endIndex] < $minNumber )
    {
        $minNumber = $solder[$endIndex];
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    print (int)($maxStep + $minStep - 1);
} else {
    print (int)($maxStep + $minStep);
}
/*
echo "result \n";
echo $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";
*/
fclose($fp);
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$count = fgets($fp);
$solder = explode(" ", fgets($fp));

$maxNumber = -1;
$minNumber = 1000;
$maxIndex = -1;
$minIndex = -1;
$maxStep = -1;
$minStep = -1;

$i = 0;
while( $i < $count )
{
    $endIndex = $count - $i - 1;
    if( $solder[$i] > $maxNumber )
    {
        $maxNumber = $solder[$i];
        $maxIndex = $i;
        $maxStep = $i;
    }

    if( $solder[$endIndex] < $minNumber )
    {
        $minNumber = $solder[$endIndex];
        $minIndex = $endIndex;
        $minStep = $i;
    }

    $i++;
}
if( $maxIndex > $minIndex )
{
    echo (int)($maxStep + $minStep - 1);
} else {
    echo (int)($maxStep + $minStep);
}
/*
echo "result \n";
echo $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . "\n";
echo $minNumber . ' - ' . $minIndex . ' ' . $minStep . "\n";
*/
fclose($fp);
?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = preg_split('/ /',$file[1]);
   $step =  (min(array_keys($result, max($result))) - 1) + ($n - max(array_keys($result, min($result))));
   if ( min(array_keys($result, max($result)))>max(array_keys($result, min($result))) ) { $step = $step-1;}
   echo $step;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
//       $n = 3;
//       $file[1] = "1 2 1";
   $result = preg_split('/ /',$file[1]);
   if ( $result[0] ==max($result) AND $result[$n-1]==min($result))
   {
    echo "0";
   }
   else {

     $kmin = max(array_keys($result, min($result)));
     $kmax = min(array_keys($result, max($result)));
     $step = ($kmax - 1) + ($n - $kmin);
    if ( $kmax>$kmin ) { $step = $step-1;}
    print_r ( $step);
   }
?>

<?php

   $file = file('php://stdin');
   $n = $file[0];

   $result = preg_split('/ /',$file[1]);

   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($max - 1) + ($n - $min);
   if ( $max>$min ) { $step = $step-1;}
   print_r ( $step);

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = preg_split('/ /',$file[1]);
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   unset($key_min, $key_max);
   echo $step;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];

   $result = preg_split('/ /',$file[1]);

   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($n - $min)+($max - 1);
   if ( $max>$min ) { $step = $step-1;}
   print_r ( $step);

?>

<?php

    $file = file('php://stdin');
    $n = $file[0];

   $result = preg_split('/ /',$file[1]);
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   print_r ( $step);

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
//       $n = 3;
//       $file[1] = "1 2 1";
   $result = preg_split('/ /',$file[1]);
//   if ( $result[0] !=max($result) AND $result[$n-1]!=min($result))
//   {
   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($max - 1) + ($n - $min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   print_r ( $step);
//   }
//   else {
//      echo "0!";
//   }
?>

<?php

   $file = file('php://stdin');
   $n = $file[0];

   $result = preg_split('/ /',$file[1]);

   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($max - 1) + ($n - $min);
   if ( $max>$min ) { $step = $step-1;}
   $step = $step-1+1;
   print_r ( $step);

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = explode(' ',$file[1]);
   if ( $result[0] ==max($result) AND $result[$n-1]==min($result)) {echo "0"; }
    else  {

   $min = max(array_keys($result, min($result)));
   if (min($result)==$result[$n-1]) {$min = $n-1;}
   $max = min(array_keys($result, max($result)));
   $step = $max - 1 + $n - $min;
   if ( $max>$min ) { $step = $step-1;}
   echo $step;
       }

?>

<?php

//    $n = 5;
//    $file[1] = "100 95 100 100 88";
   $file = file('php://stdin');
   $n = $file[0];
   $result = explode(' ',$file[1]);
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}

   echo $step;

?>

<?php

    $file = file('php://stdin');
    $n = $file[0];
    $result = preg_split('/ /',$file[1]);
    $key_min = max(array_keys($result, min($result)));
    $key_max = min(array_keys($result, max($result)));
    $step = ($key_max - 1) + ($n - $key_min);
    if ( $key_max>$key_min ) { $step = $step-1;}
    echo $step;

?>

<?php

    $file = file('php://stdin');
    $n = $file[0];
    $result = preg_split('/ /',$file[1]);
    $min = min($result);
    $max = max($result);
    $key_min = max(array_keys( $result, $min));
    $key_max = min(array_keys($result, $max));
    $step_max = $key_max - 1;
    $step_min = $n - $key_min;
    if ( $key_max>$key_min ) { $step_min = $step_min-1;}
    $step_all = $step_max+$step_min;

//  for ($i = 0; $i < $step_all; $i++)
//  {
//      if (!isset($key)) {$key = $key_max; $check = false;}
//      if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; }
//      if ( $result[0] ==$max AND $result[$n-1]==$min ) { break;  }
//      if ( $check == true ){$next = $key+1; } else { $next = $key-1; }
//      $change = $result[$next];
//      $result[$next] = $result[$key];
//      $result[$key] = $change;
//      $key = $next;
//  }
    echo $step_all;

?>

<?php

    $file = file('php://stdin');
    $n = $file[0];
    $solds = explode(' ', $file[1]);

    $result = preg_split('/ /',$file[1]);
    $min = min($result);
    $max = max($result);
    $key_min = array_search($min, $result);
    $key_max = array_search($max, $result);
    $step_max = $key_max - 1;
    $step_min = $n - $key_min;
    if ( $key_max>$key_min ) { $step_min = $step_min-1;}
    $step_all = $step_max+$step_min;
    for ($i = 0; $i < $step_all; $i++)
    {
        if (!isset($key)) {$key = $key_max; $check = false;}
        if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; }
        if ( $result[0] ==$max AND $result[$n-1]==$min ) { break;  }
        if ( $check == true ){$next = $key+1; } else { $next = $key-1; }
        $change = $result[$next];
        $result[$next] = $result[$key];
        $result[$key] = $change;
        $key = $next;
    }
    echo $step_all;

?>

<?php

    $file = file('php://stdin');
    $n = intval($file[0]);
    $result = explode(" ",trim($file[1]));
    $max =  array_search(max($result), $$result);
    $min = array_keys($result, min($result));
    $min=$min[count($min)-1];
    $step= $max+$n-$min;
    if ( $max>$min ) $step--;
    echo $step;

?>

<?php

    $n = $file[0];
    $solds = explode(' ', $file[1]);

    $result = preg_split('/ /',$file[1]);
    $min = min($result);
    $max = max($result);
    $key_min = array_search($min, $result);
    $key_max = array_search($max, $result);
    $step_max = $key_max - 1;
    $step_min = $n - $key_min;
    if ( $key_max>$key_min ) { $step_min = $step_min-1;}
    $step_all = $step_max+$step_min;
    for ($i = 0; $i < $step_all; $i++)
    {
        if (!isset($key)) {$key = $key_max; $check = false;}
        if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; }
        if ( $result[0] ==$max AND $result[$n-1]==$min ) { break;  }
        if ( $check == true ){$next = $key+1; } else { $next = $key-1; }
        $change = $result[$next];
        $result[$next] = $result[$key];
        $result[$key] = $change;
        $key = $next;
    }
    echo $step_all;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = preg_split('/ /',$file[1]);
   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $max>$min ) { $step = $step-1;}
   var_dump ($step, $max, $min);

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = explode(' ',$file[1]);
   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = $key_max - 1 + $n - $key_min;
   if ( $max>$min ) { $step = $step-1;}
   echo sprintf('%.0f', $step);

?>

<?php

    $file = file('php://stdin');
    $n = intval($file[0]);
    $result = explode(" ",trim($file[1]));
    $max =  array_search(max($result), $$result);
    $min = array_keys($result, min($result));
    $min=$min[count($min)-1];
    $step= $max+$n-$min-1;
    if ( $max>$min ) $step--;
    echo $step;

?>

<?php

    $file = file('php://stdin');
    $n = $file[0];
    $result = preg_split('/ /',$file[1]);
    $min = min($result);
    $max = max($result);
    $key_min = max(array_keys( $result, $min));
    $key_max = min(array_keys($result, $max));
    $step_max = $key_max - 1;
    $step_min = $n - $key_min;
    if ( $key_max>$key_min ) { $step_min = $step_min-1;}
    $step_all = $step_max+$step_min;
    echo $step_all;

?>

<?php

    $n = rand(2, 100);
    settype($rost, "string");
    for ($i = 1; $i <= $n; $i++)
        {
            if ( $i == 1 ) {$rost.= rand(1, 100);}
            else { $rost.= ' '.rand(1, 100);}
        }

    $result = preg_split('/ /',$rost);
    $min = min($result);
    $max = max($result);
    $key_min = array_search($min, $result);
    $key_max = array_search($max, $result);
    $step_max = $key_max - 1;
    $step_min = $n - $key_min;
    if ( $key_max>$key_min ) { $step_min = $step_min-1;}
    $step_all = $step_max+$step_min;
    for ($i = 0; $i < $step_all; $i++)
    {
        if (!isset($key)) {$key = $key_max; $check = false;}
        if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; }
        if ( $result[0] ==$max AND $result[$n-1]==$min ) { break;  }
        if ( $check == true ){$next = $key+1; } else { $next = $key-1; }
        $change = $result[$next];
        $result[$next] = $result[$key];
        $result[$key] = $change;
        $key = $next;
    }
    echo $step_all;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];

   $result = preg_split('/ /',$file[1]);

   $min = max(array_keys($result, min($result)));
   $max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $max>$min ) { $step = $step-1;}
   print_r ( $step);

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
//       $n = 3;
//       $file[1] = "1 2 1";
   $result = preg_split('/ /',$file[1]);
   if ( $result[0] ==max($result) AND $result[$n-1]==min($result))
   {
    echo "0";
   }
   else {

    echo $kmin = max(array_keys($result, min($result)));
    echo $kmax = min(array_keys($result, max($result)));
    echo $step = ($kmax - 1) + ($n - $kmin);
    if ( $kmax>$kmin ) { $step = $step-1;}
    print_r ( $step);
   }
?>

<?php
   $n = 5;
   $file[1] = "100 95 100 100 88";
   $result = preg_split('/ /',$file[1]);
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   echo $step;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
//       $n = 5;
//       $file[1] = "100 95 100 100 88";
   $result = preg_split('/ /',$file[1]);
   if ( $result[0] !=max($result) AND $result[$n-1]!=min($result))
   {
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   print_r ( $step);
   }
   else {
    echo "0";
   }
?>

<?php

//   $file = file('php://stdin');
//   $n = $file[0];
       $n = 5;
       $file[1] = "100 95 100 100 88";
   $result = preg_split('/ /',$file[1]);
   $key_min = max(array_keys($result, min($result)));
   $key_max = min(array_keys($result, max($result)));
   $step = ($key_max - 1) + ($n - $key_min);
   if ( $key_max>$key_min ) { $step = $step-1;}
   var_dump($step);
   //echo $step;

?>

<?php

   $file = file('php://stdin');
   $n = $file[0];
   $result = explode(' ',$file[1]);
   if ( $result[0] !=max($result) AND $result[$n-1]!=min($result))
    {

   $min = max(array_keys($result, min($result)));
   if (min($result)==$result[$n-1]) {$min = $n-1;}
   $max = min(array_keys($result, max($result)));
   $step = $max - 1 + $n - $min;
   if ( $max>$min ) { $step = $step-1;}
   echo $step;
       }
       else  {echo "0"; }

?>


<?php
$console = fopen("php://stdin", "r");

$n = +fgets($console);

$couplesNum = 7;
$sumOfCouples = array_fill(0, $couplesNum, 0);
for ($i = 0; $i < $n; ++$i)
{
  $groupCouple = array_map('intval', str_split(fgets($console)));
  for ($j = 0; $j < $couplesNum; ++$j)
  {
    $sumOfCouples[$j] += $groupCouple[$j];
  }
}

fclose($console);

print max($sumOfCouples);


<?php
# 1165A
declare(strict_types=1);

$start = microtime(true);
$stdin = STDIN;
[$n, $x, $y] = fscanf($stdin, '%u %u %u');

$xi = $n - $x - 1;
$yi = $n - $y - 1;

$result = 0;

$digit = trim(fgets($stdin));

for ($i = $n -1; $i > $xi; $i--) {
    if ((($i > $yi) || ($i > $xi && $i < $yi)) && $digit[$i] === '1') {
        $result++;
    } elseif($i === $yi && $digit[$i] === '0') {
        $result++;
    }
}

echo $result;

 <?php
    $s1 = trim(fgets(STDIN));
    $s = trim(fgets(STDIN));

    $a1 = explode(" ", $s1);
    $n = $a1[0];
    $x = $a1[1];
    $y = $a1[2];

    $iteration = 0;
    if ( bcmod ($s,bcpow(10, $x)) == bcpow (10, $y)) {
        echo $iteration;
        exit;
    }

    for ($i=$n-1; $i >= 0; $i--) {
        if($s[$i] == 0) {
            $s[$i] = 1;
        } else {
            $s[$i] = 0;
        }
        $iteration++;
        if ( bcmod ($s,bcpow(10, $x)) == bcpow (10, $y)) {
            echo $iteration;
            exit;
        }
    }

?>


<?PHP
$nk = explode(" ",trim(fgets(STDIN)));
$ld = explode(" ",trim(fgets(STDIN)));
arsort($ld);
$nkm = $nk[0]*$nk[1];
for($i=1;$i<=$nk[1]; $i++)
{
    for($b=1;$b<=$nk[0]-1; $b++)
    {
        while(in_array($nkm,$ld)){
        $nkm--;
        }
        echo $nkm.' ';
        $nkm--;
    }
    echo $ld[$i-1].PHP_EOL;

}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = range(1, $a * $b);
array_unshift($d, " ");
unset($d[0]);
for($x = 0; $x < $b; $x++)
{
    $e = array_search($c[$x], $d);
    unset($d[$e]);
}
sort($d);
for($x = 0; $x < $b; $x++)
{
    if($x == $b - 1)
    {
        print $c[$x] . " " . implode(" ", array_slice($d, 0, $a - 1));
        array_splice($d, 0, $a - 1);
    }
    else
    {
        print $c[$x] . " " . implode(" ", array_slice($d, 0, $a - 1)) . "\n";
        array_splice($d, 0, $a - 1);
    }
}
?>

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Contest 150 Div 2 Problem A
$raw = g();
$n = $raw[0];
$k = $raw[1];
$raw = g();
for ($i = 1; $i <= $n * $k; $i++) {
	$num[$i] = false;
}
for ($i = 1; $i <= $k; $i++) {
	$ai[$i] = $raw[$i-1];
	$num[$ai[$i]] = true;
	$res[$i] = "";
}

$ct = 0;
$person = 1;
for ($i = 1; $i <= $n * $k; $i++) {
	if (!$num[$i]) {
		$ct++;
		$res[$person] .= $i . " ";
		if ($ct == $n-1) {
			$ct = 0;
			$person++;
		}
	}
}
for ($i = 1; $i <= $k; $i++) {
	echo $res[$i] . $ai[$i] . "\n";
}

// End of submission file
// Submission by chaotic_iak
?>


<?PHP
$t = trim(fgets(STDIN));
for($i = 0; $i < $t; $i ++)
{
    $n = trim(fgets(STDIN));
   if ((360%(180-$n)) == 0)
    {
        echo "YES".PHP_EOL;
    }
    else echo "NO".PHP_EOL;
}

<?php
error_reporting("off");
//270A: Fancy Fence
$t = trim(fgets(STDIN));
$result = "";
for ($i = 0; $i < $t; $i++) {
    $angle = trim(fgets(STDIN));
    $extAngle = 180 - $angle;
    if (360 % $extAngle == 0) {
        $result .="YES\n";
    } else {
        $result .= "NO\n";
    }
}
echo $result;
?>

<?php

$f = fopen('php://stdin', 'r');
//$f = fopen('test.txt', 'r');
//$a = explode(" ",trim(fgets($f)));

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

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

    $x = trim(fgets($f));
    $n = 360/(180-$x);

    if (round($n)!=$n) echo "NO\n";
    else echo "YES\n";

}

<?php
// 270A     Завидный забор
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
// list($a, $b, $s) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$n = (int) $input_line;

for ($i=0; $i < $n; $i++) {
    $input_line = fgets($in);
    $a = (int) $input_line;
    if ((360 % (180 -$a)) == 0) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}

?>

<?// BismiLahi Rahmani Rahim ?>

<?php

fscanf(STDIN, "%d", $ntest);

for ($i = 0; $i < $ntest; $i ++) {
	fscanf(STDIN, "%d", $a);
	printf("%s\n", 360%(180 - $a) == 0 ? "YES" : "NO");
}

?>

<?PHP
$var = trim(fgets(STDIN));
while($var>0){
$n = trim(fgets(STDIN));
if(is_integer((360/(180-$n)))){
echo "YES".PHP_EOL;}
else{ echo "NO".PHP_EOL;}
$var--;
}

<?php
$n=trim(fgets(STDIN));
while($n-->0){
  $a=trim(fgets(STDIN));
  $b=180-$a;
  if(360%$b==0)
    print "YES\n";
  else {
    print "NO\n";
  }
}
?>

<?php
$t=trim(fgets(STDIN));
while($t>0){
	$n=trim(fgets(STDIN));
	if(is_integer(360/(180-$n))){
		echo "YES";
	}
	else echo "NO";
	echo PHP_EOL;
	$t--;
}
?>

<?php
// 270A     Завидный забор
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
// list($a, $b, $s) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$n = (int) $input_line;

for ($i=0; $i < $n; $i++) {
    $input_line = fgets($in);
    $a = (int) $input_line;
    if ((360 % (180 -$a)) == 0) {
        echo "YES";
    } else {
        echo "NO";
    }
}

?>

<?PHP
$var = trim(fgets(STDIN));
while($var>0){
$n = trim(fgets(STDIN));
if(is_integer((360/(180-$n)))){
echo "YES";}
else{ echo "NO";}
$var--;
}

<?php
$n=trim(fgets(STDIN));
while($n-->0){
  $a=trim(fgets(STDIN));
  if($a>=60)
    echo "YES\n";
  else {
    echo "NO\n";
  }
}
?>

<?php
error_reporting("off");
//270A: Fancy Fence
$t = trim(fgets(STDIN));
$result = "";
for ($i = 0; $i < $t; $i++) {
    $angle = trim(fgets(STDIN));
    $extAngle = 180 - $angle;
    $sides = 369 / $extAngle;
    if (is_int((int)$sides)) {
        $result .="YES\n";
    } else {
        $result .= "NO\n";
    }
}
echo substr($result, 0, -2);
?>

<?php
error_reporting("off");
//270A: Fancy Fence
$t = trim(fgets(STDIN));
$result = "";
for ($i = 0; $i < $t; $i++) {
    $angle = trim(fgets(STDIN));
    $extAngle = 180 - $angle;
    $sides = 369 / $extAngle;
    if (is_int($sides)) {
        $result .="YES\n";
    } else {
        $result .= "NO\n";
    }
}
echo substr($result, 0, -2);
?>

<?php
error_reporting("off");
//270A: Fancy Fence
$t = trim(fgets(STDIN));
$result = "";
for ($i = 0; $i < $t; $i++) {
    $angle = trim(fgets(STDIN));
    $extAngle = 180 - $angle;
    $sides = 369 / $extAngle;
    if (is_int((int)$sides)) {
        $result .="YES\n";
    } else {
        $result .= "NO\n";
    }
}
echo substr($result, 0, -1);
?>


<?php
$t = fgets(STDIN);
while ($t-- && fgets(STDIN)) {
    $a = array_map('abs', fgetcsv(STDIN, 0, ' '));
    $a1 = array_flip($a);
    $a2 = array_filter(array_diff_key($a, array_flip($a1)));
    printf("%d\n", count($a1) + count(array_unique($a2)));
}

<?php
$t = fgets(STDIN);
while ($t-- && fgets(STDIN)) {
    $a = fgetcsv(STDIN, 0, ' ');
    $a1 = array_flip($a);
    $a2 = array_filter(array_diff_key($a, array_flip($a1)));
    printf("%d\n", count($a1) + count(array_unique($a2)));
}


<?php

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

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

$field = [];
$bombs = [];

$totalSum = 0;

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

    $row = str_split(trim(fgets($handle)));

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

        if ($row[$j] == '*') {

            if (!isset($bombs[$i])) {
                $bombs[$i] = [];
            }

            $bombs[$i][] = $j;
        } elseif ($row[$j] != '.') {

            $row[$j] = intval($row[$j]);;
            $totalSum += $row[$j];
        }
    }

    $field[] = $row;
}

$result = 'YES';

foreach ($bombs as $row => $cols) {

    foreach ($cols as $col) {

        $numCount = 0;

        for ($i = -1; $i < 2; $i++) {

            for ($j = -1; $j < 2; $j++) {

                if ($i != 0 || $j != 0) {

                    if (isset($field[$row + $i][$col + $j])) {

                        $val = $field[$row + $i][$col + $j];

                        if ($val == '.' || ($val != '*' && $val == 0)) {

                            $result = 'NO';
                            break;
                        } elseif ($val != '*') {

                            $numCount++;
                            $field[$row + $i][$col + $j]--;
                            $totalSum--;
                        }
                    }
                }
            }
        }
    }

    if ($result == 'NO') {
        break;
    }
}

if ($totalSum != 0) {
    $result = 'NO';
}

echo $result;

<?php

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

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

$field = [];
$bombs = [];

$totalSum = 0;

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

    $row = str_split(trim(fgets($handle)));

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

        if ($row[$j] == '*') {

            if (!isset($bombs[$i])) {
                $bombs[$i] = [];
            }

            $bombs[$i][] = $j;
        } elseif ($row[$j] != '.') {

            $row[$j] = intval($row[$j]);;
            $totalSum += $row[$j];
        }
    }

    $field[] = $row;
}

$result = 'YES';

foreach ($bombs as $row => $cols) {

    foreach ($cols as $col) {

        $numCount = 0;

        for ($i = -1; $i < 2; $i++) {

            for ($j = -1; $j < 2; $j++) {

                if ($i != 0 || $j != 0) {

                    if (isset($field[$row + $i][$col + $j])) {

                        $val = $field[$row + $i][$col + $j];

                        if ($val == '.' || ($val != '*' && $val == 0)) {

                            $result = 'NO';
                            break;
                        } elseif ($val != '*') {

                            $numCount++;
                            $field[$row + $i][$col + $j]--;
                            $totalSum--;
                        }
                    }

                }
            }

            if ($numCount == 0) {

                $result = 'NO';
                break;
            }
        }
    }

    if ($numCount == 0) {

        $result = 'NO';
        break;
    }
}

if ($totalSum != 0) {
    $result = 'NO';
}

echo $result;

<?php

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

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

$field = [];
$bombs = [];

$totalSum = 0;

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

    $row = str_split(trim(fgets($handle)));

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

        if ($row[$j] == '*') {

            if (!isset($bombs[$i])) {
                $bombs[$i] = [];
            }

            $bombs[$i][] = $j;
        } elseif ($row[$j] != '.') {

            $row[$j] = intval($row[$j]);;
            $totalSum += $row[$j];
        }
    }

    $field[] = $row;
}

$result = 'YES';

foreach ($bombs as $row => $cols) {

    foreach ($cols as $col) {

        $numCount = 0;

        for ($i = -1; $i < 2; $i++) {

            for ($j = -1; $j < 2; $j++) {

                if ($i != 0 || $j != 0) {

                    if (isset($field[$row + $i][$col + $j])) {

                        $val = $field[$row + $i][$col + $j];

                        if ($val == '.' || ($val != '*' && $val == 0)) {

                            $result = 'NO';
                            break;
                        } elseif ($val != '*') {

                            $numCount++;
                            $field[$row + $i][$col + $j]--;
                            $totalSum--;
                        }
                    }
                }
            }
        }

        if ($numCount == 0) {

            $result = 'NO';
            break;
        }
    }

    if ($result == 'NO') {
        break;
    }
}

if ($totalSum != 0) {
    $result = 'NO';
}

echo $result;


<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $n);
$list1 = array();
$list2 = array();

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $S);
    $list1[$S]++;
}
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $S);
    $list2[$S]++;
}

foreach ($list1 as $key => $val) {
    if (isset($list2[$key])) {
        $sub = min($list1[$key], $list2[$key]);
        $list1[$key] -= $sub;
        $list2[$key] -= $sub;
    }
}
foreach ($list2 as $key => $val) {
    if (isset($list1[$key])) {
        $sub = min($list1[$key], $list2[$key]);
        $list1[$key] -= $sub;
        $list2[$key] -= $sub;
    }
}

echo array_sum($list1), "\n";

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = array();
for($x = 0; $x < $a; $x++)
{
     $d = trim(fgets(STDIN));
     $b[$x] = $d;
}
for($x = 0; $x < $a; $x++)
{
     $e = trim(fgets(STDIN));
     $c[$x] = $e;
}
sort($b);
sort($c);
$f = 0;
for($x = 0; $x < count($b); $x++)
{
     $g = str_split($b[$x]);
     $h = str_split($c[$x]);
     $i = array_diff($h, $g);
     $f += count($i);
}
print $f;
?>

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = array();
for($x = 0; $x < $a; $x++)
{
     $d = trim(fgets(STDIN));
     $b[$x] = $d;
}
for($x = 0; $x < $a; $x++)
{
     $e = trim(fgets(STDIN));
     $c[$x] = $e;
}
sort($b);
sort($c);
$f = 0;
for($x = 0; $x < count($b); $x++)
{
     $g = str_split($b[$x]);
     $h = str_split($c[$x]);
     $i = array_diff($g, $h);
     $f += count($i);
}
print $f;
?>

<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $n);
$list1 = array();
$list2 = array();

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $S);
    $list1[$S]++;
}
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $S);
    $list2[$S]++;
}

foreach ($list1 as $key => $val) {
    $ans += abs($list1[$key] - $list2[$key]);
}

echo $ans;


<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
list($n, $m) = explode(" ", trim(fgets($file)));
$cArray = explode(" ", trim(fgets($file)));
array_unshift($cArray, "T");
unset($cArray[0]);
$map = array();
for ($i = 1; $i < $n; $i++) {
    list($x, $y) = explode(" ", trim(fgets($file)));
    $map[$x][] = $y;
    $map[$y][] = $x;
}
$result = 0;
function solve($dest, $cur, $cN)
{
    global $result, $map, $m, $cArray;
    $c = count($map[$cur]);
    if ($cArray[$cur]) {
        $cN++;
        if ($cN>$m) {
            return;
        }
    }else{
        $cN = 0;
    }
    if ($c == 1 && $map[$cur][0] == $dest) {
        $result++;
        return;
    }

    for ($i = 0; $i < $c; $i++) {
        if ($map[$cur][$i] == $dest) {
            continue;
        }
        solve($cur, $map[$cur][$i], $cN);
    }

}

solve(0, 1, 0);
echo $result;

<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
list($n, $m) = explode(" ", trim(fgets($file)));
$cArray = explode(" ", trim(fgets($file)));
array_unshift($cArray, "T");
unset($cArray[0]);
$map = array();
for ($i = 1; $i < $n; $i++) {
    list($x, $y) = explode(" ", trim(fgets($file)));
    $map[$x][] = $y;
    $map[$y][] = $x;
}
$result = 0;
function solve($dest, $cur, $cN, $mCN)
{
    global $result, $map, $m, $cArray;
    $c = count($map[$cur]);
    if ($c == 1 && $map[$cur][0] == $dest) {
        if (max($cN+$cArray[$cur], $mCN)<= $m) {
            $result++;
        }
        return;
    }
    if ($cArray[$cur] == 1) {
        $cN++;
        $mCN = max($cN, $mCN);
        if ($mCN>$m) {
            return;
        }
    }else{
        $cN = 0;
    }
    for ($i = 0; $i < $c; $i++) {
        if ($map[$cur][$i] == $dest) {
            continue;
        }
        solve($cur, $map[$cur][$i], $cN, $mCN);
    }

}

solve(0, 1, 0, 0);
echo $result;

<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
list($n, $m) = explode(" ", trim(fgets($file)));
$cArray = explode(" ", trim(fgets($file)));
array_unshift($cArray, "T");
unset($cArray[0]);
$map = array();
for ($i = 1; $i < $n; $i++) {
    list($x, $y) = explode(" ", trim(fgets($file)));
    $map[$x][] = $y;
    $map[$y][] = $x;
}
$result = 0;
function solve($dest, $cur, $cN)
{
    global $result, $map, $m, $cArray;
    $c = count($map[$cur]);
    if ($c == 1) {
        if ($cN+$cArray[$cur]<= $m) {
            $result++;
        }
        return;
    }
    if ($cArray[$cur] == 1) {
        $cN++;
        if ($cN>$m) {
            return;
        }
    }else{
        $cN = 0;
    }
    for ($i = 0; $i < $c; $i++) {
        if ($map[$cur][$i] == $dest) {
            continue;
        }
        solve($cur, $map[$cur][$i], $cN);
    }

}

solve(0, 1, 0);
echo $result;

<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
list($n, $m) = explode(" ", trim(fgets($file)));
$cArray = explode(" ", trim(fgets($file)));
array_unshift($cArray, "T");
unset($cArray[0]);
$map = array();
for ($i = 1; $i < $n; $i++) {
    list($x, $y) = explode(" ", trim(fgets($file)));
    $map[$x][] = $y;
    $map[$y][] = $x;
}
$result = 0;
function solve($dest, $cur, $cN, $mCN)
{
    global $result, $map, $m, $cArray;
    $c = count($map[$cur]);
    if ($c == 1) {
        if (max($cN+$cArray[$cur], $mCN)<= $m) {
            $result++;
        }
        return;
    }
    if ($cArray[$cur] == 1) {
        $cN++;
        $mCN = max($cN, $mCN);
        if ($mCN>$m) {
            return;
        }
    }else{
        $cN = 0;
    }
    for ($i = 0; $i < $c; $i++) {
        if ($map[$cur][$i] == $dest) {
            continue;
        }
        solve($cur, $map[$cur][$i], $cN, $mCN);
    }

}

solve(0, 1, 0, 0);
echo $result;

<?php
$file = fopen('input.in', 'r');
//$file = STDIN;
list($n, $m) = explode(" ", trim(fgets($file)));
$cArray = explode(" ", trim(fgets($file)));
array_unshift($cArray, "T");
unset($cArray[0]);
$map = array();
for ($i = 1; $i < $n; $i++) {
    list($x, $y) = explode(" ", trim(fgets($file)));
    $map[$x][] = $y;
    $map[$y][] = $x;
}
$result = 0;
function solve($dest, $cur, $cN)
{
    global $result, $map, $m, $cArray;
    $c = count($map[$cur]);
    if ($cArray[$cur]) {
        $cN++;
    }else{
        $cN = 0;
    }
    if ($c == 1 && $map[$cur][0] == $dest) {
        if ($cN<= $m) {
            $result++;
        }
        return;
    }

    for ($i = 0; $i < $c; $i++) {
        if ($map[$cur][$i] == $dest) {
            continue;
        }
        solve($cur, $map[$cur][$i], $cN);
    }

}

solve(0, 1, 0);
echo $result;


<?php
$dir = fopen("php://stdin", 'r');
$data = stream_get_contents($dir);
$data = explode("\n", $data);
$n = explode(' ',$data[0])[0];
$maxTime = explode(' ',$data[0])[1];
$data = explode(' ',$data[1]);
$mes = array();
for ($i = 0; $i<$n; $i++){
    $mes[$i] = $data[$i];
}
$sum = 0;
foreach ($mes as $num => $time){
  if ($mes[$num+1] - $time > $maxTime){
      $sum = 0;
  }else{
      $sum++;
  }

}
echo ($sum);

?>

<?php
function write($text){
	file_put_contents('php://stdout', $text);
}
function read(){
	return trim(fgets(STDIN));
}

$count = 1;

$config = explode(' ', read());
$n = $config[0];
$c = $config[1];

$data = explode(' ', read());

$a = $data[0];

for($i=1; $i<$n; $i++){
	if(($data[$i]-$a) <= $c)
		$count++;
	elseif(($data[$i]-$a) > $c)
		$count = 1;

	$a = $data[$i];
}

write($count);

<?php
function write($text){
	file_put_contents('php://stdout', $text);
}
function read(){
	return trim(fgets(STDIN));
}

$count = 0;

$config = explode(' ', read());
$n = $config[0];
$c = $config[1];

$data = explode(' ', read());

$a = $data[0];

for($i=1; $i<$n; $i++){
	if(($data[$i]-$a) <= $c)
		$count++;
	elseif(($data[$i]-$a) > $c)
		$count = 1;

	$a = $data[$i];
}

write($count);


<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     $d = explode(" ", trim(fgets(STDIN)));
     sort($d);
     $e = explode(" ", trim(fgets(STDIN)));
     rsort($e);
     for($y = 0; $y < $c; $y++)
     {
          if($d[$y] < $e[$y])
          {
               $d[$y] = $e[$y];
          }
     }
     print array_sum($d) . "\n";
}
?>

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

    fscanf($stdin, "%d\n", $t);

    while($t--){
        fscanf($stdin, "%d%d", $n, $k);

        fscanf($stdin, "%[^\n]", $tempA);

        $a = array_map('intval', preg_split('/ /', $tempA, -1, PREG_SPLIT_NO_EMPTY));

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

        sort($a);
        rsort($b);
        $sum = 0;
        for($i=0; $i<$n; $i++){
            if($i < $k) $sum += max($a[$i], $b[$i]);
            else $sum += $a[$i];
        }

        //print_r($a);
        //print_r($b);

        echo $sum."\n";
    }
?>

<?php

function inputInt($sys){
    fscanf($sys,"%d",$n);
    return $n;
}
function inputArray($sys){
    fscanf($sys, "%[^\n]", $tempA);
    $arr = array_map('intval', preg_split('/ /', $tempA, -1, PREG_SPLIT_NO_EMPTY));
    return $arr;
}

$stdin = fopen('php://stdin', 'r');
function slove($sys){
    fscanf($sys,"%d%d",$n,$k);
    $arrA=inputArray($sys);
    $arrB=inputArray($sys);
    sort($arrB);
    sort($arrA);
    for($i=0;$i<$k;++$i){
        if($arrB[$n-$i-1] > $arrA[$i]){
            $arrA[$i]=$arrB[$n-$i-1];
        }else break;
    }
    $sum=0;
    for ($i=0; $i < $n; $i++) {
        $sum+=$arrA[$i];
    }
    echo $sum."\n";
}

$T=inputInt($stdin);
while($T--){
    slove($stdin);
}


<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
if($a < $b)
{
    print "<";
}
elseif($a == $b)
{
    print "=";
}
elseif($a > $b)
{
    print ">";
}
?>

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
if ($a > $b) echo ">";
if ($a < $b) echo "<";
if ($a == $b) echo "=";
?>

//Br34k
<?php
$str1 = trim(fgets(STDIN));
$str2 = trim(fgets(STDIN));
if($str1 < $str2)
    print "<";
elseif($str1 == $str2)
    print "=";
elseif($str1 > $str2)
    print ">";

?>


<?php

$n = intval( trim(fgets(STDIN)) );
$sLine = trim(fgets(STDIN));

$aLine = explode(' ',$sLine);

$bZero = TRUE;

$sNum = 0;

for($i = 0; $i < $n; $i ++){
    if($aLine[$i] == '0'){
        echo 0;
        exit;
    }
    if(!isBecaufulNum($aLine[$i])){
        $sNum = $aLine[$i];
    } else {
        $iLen += intval( strlen($aLine[$i]) ) - 1;
    }
}
if(empty($sNum)) $sNum = '1';
$L = strlen($sNum);
for($i = 0 ;$i < $L ;$i++){
    echo $sNum[$i];
    #var_dump($sNum[$i]);
}
if($sNum == 0) exit;
for($i = 0; $i < $iLen ;$i++){
    echo 0;
}

function isBecaufulNum($sNum){
    $iCnt = 0;
    $len = strlen($sNum);
    for($i = 0; $i < $len ; $i ++){
        $tmp = intval($sNum[$i]);
        if($tmp == 1) {
            $iCnt++;
            if ($iCnt > 1)
                return FALSE;
        } else if($tmp != 0){
            return FALSE;
        }
    }
    return TRUE;
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,1000002,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = 0;
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( "0" == $t ) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
       if($t[0] != '1'|| substr_count($t, "1") > 1 ){
            $head = $t;
       }else{
            $et = false;
            for($i = 0 ; $i < strlen($t);$i++){
                if($t[$i] != '0' and $t[$i] != '1'){
                    $head = $t;
                    $et = true;
                }
            }

            if(!$et)
                $res += strlen($t) - 1;
       }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
print array_product($b);
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_product($b);
print number_format($c, 0, "" , "");
?>

<?php

$n = intval( trim(fgets(STDIN)) );
$sLine = trim(fgets(STDIN));

$aLine = explode(' ',$sLine);

$bZero = TRUE;

$sNum = 0;

for($i = 0; $i < $n; $i ++){
    if($aLine[$i] == '0'){
        echo 0;
        exit;
    }
    if(!isBecaufulNum($aLine[$i])){
        $sNum = $aLine[$i];
    } else {
        $iLen += intval( strlen($aLine[$i]) ) - 1;
    }
}
if(!isset($sNum)) $sNum = 1;
$L = strlen($sNum);

for($i = 0 ;$i < $L ;$i++){
    echo $sNum[$i];
}
if($sNum == 0) exit;
for($i = 0; $i < $iLen ;$i++){
    echo 0;
}

function isBecaufulNum($sNum){
    $iCnt = 0;
    $len = strlen($sNum);
    for($i = 0; $i < $len ; $i ++){
        $tmp = intval($sNum[$i]);
        if($tmp == 1) {
            $iCnt++;
            if ($iCnt > 1)
                return FALSE;
        } else if($tmp != 0){
            return FALSE;
        }
    }
    return TRUE;
}

<?php

$n = intval( trim(fgets(STDIN)) );
$sLine = trim(fgets(STDIN));

$aLine = explode(' ',$sLine);

$bZero = TRUE;

$sNum = 0;
$iLen = 0;

for($i = 0; $i < $n; $i ++){
    if($aLine[$i] == '0'){
        echo 0;
        exit;
    }
    if(!isBecaufulNum($aLine[$i])){
        $sNum = $aLine[$i];
    } else {
        $iLen += intval( strlen($aLine[$i]) ) - 1;
    }
}
$L = strlen($sNum);
$j = 0;
for($i = 0; $i <  $L ; $i ++){
    if($sNum[$i] != 0 || ($sNum[$i] == 0 && $i + 1 == L)){
        $j = $i;
        break;
    }
}

for($i = $j ;$i < $L ;$i++){
    echo $sNum[$i];
}
if($j + 1 == $L  && $sNum[$j] == 0) exit;
for($i = 0; $i < $iLen ;$i++){
    echo 0;
}

function isBecaufulNum($sNum){
    $iCnt = 0;
    $len = strlen($sNum);
    for($i = 0; $i < $len ; $i ++){
        $tmp = intval($sNum[$i]);
        if($tmp == 1) {
            $iCnt++;
            if ($iCnt > 1)
                return FALSE;
        } else if($tmp != 0){
            return FALSE;
        }
    }
    return TRUE;
}

<?php

$n = intval( trim(fgets(STDIN)) );
$sLine = trim(fgets(STDIN));

$aLine = explode(' ',$sLine);

$bZero = TRUE;

$sNum = 0;
$iLen = 0;

for($i = 0; $i < $n; $i ++){
    if($aLine[$i] == '0'){
        echo 0;
        exit;
    }
    if(!isBecaufulNum($aLine[$i])){
        $sNum = $aLine[$i];
    } else {
        $iLen += intval( strlen($aLine[$i]) ) - 1;
    }
}
$L = strlen($sNum);
$j = 0;
for($i = 0; $i <  $L ; $i ++){
    if($sNum[$i] != 0 || ($sNum[$i] == 0 && $i + 1 == L)){
        $j = $i;
        break;
    }
}

for($i = $j ;$i < $L ;$i++){
    echo $sNum[$i];
}
if($j + 1 == $L) exit;
for($i = 0; $i < $iLen ;$i++){
    echo 0;
}

function isBecaufulNum($sNum){
    $iCnt = 0;
    $len = strlen($sNum);
    for($i = 0; $i < $len ; $i ++){
        $tmp = intval($sNum[$i]);
        if($tmp == 1) {
            $iCnt++;
            if ($iCnt > 1)
                return FALSE;
        } else if($tmp != 0){
            return FALSE;
        }
    }
    return TRUE;
}

<?php

$n = intval( trim(fgets(STDIN)) );
$sLine = trim(fgets(STDIN));

$aLine = explode(' ',$sLine);

$bZero = TRUE;

$sNum = 0;
$iLen = 0;

for($i = 0; $i < $n; $i ++){
    if($aLine[$i] == '0'){
        echo 0;
        exit;
    }
    if(!isBecaufulNum($aLine[$i])){
        $sNum = $aLine[$i];
    } else {
        $iLen += intval( strlen($aLine[$i]) ) - 1;
    }
}
$L = strlen($sNum);
$j = 0;
for($i = 0; $i <  $L ; $i ++){
    if($sNum[$i] != 0 || ($sNum[$i] == 0 && $i + 1 == L)){
        $j = $i;
        break;
    }
}

for($i = $j ;$i < $L ;$i++){
    echo $sNum[$i];
}
for($i = 0; $i < $iLen ;$i++){
    echo 0;
}

function isBecaufulNum($sNum){
    $iCnt = 0;
    $len = strlen($sNum);
    for($i = 0; $i < $len ; $i ++){
        $tmp = intval($sNum[$i]);
        if($tmp == 1) {
            $iCnt++;
            if ($iCnt > 1)
                return FALSE;
        } else if($tmp != 0){
            return FALSE;
        }
    }
    return TRUE;
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */

while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符
    $res = array();
    $flag = false;
    foreach($tanks as $t){
        //beautifle num 只有0和1组成
        //fprintf(STDOUT,"%s\n",$t);
        if( 0 == $t) {
            $flag = true;
            break;
        }

       // var_dump($t);
        if( substr_count($t,"0") + substr_count($t,"1") != strlen($t) ){
            //不是beautiful num 要保留前面的部分
            $head = $t;
         //   fprintf(STDOUT,"ss %d %d %d %s\n",substr_count($t,"0") , substr_count($t,"1"),strlen($t),$t);
        }else{
            //是beautiful num时记录要偏移的傡数
            $res[]= strlen($t);
        }

    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        fprintf(STDOUT,"%s",$head);
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 1 ; $zeroNum < $res[$i] ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,100002,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = 0;
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( "0" == $t ) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
       if($t[0] != '1'|| substr_count($t, "1") > 1 ){
            $head = $t;
       }else{
            $et = false;
            for($i = 0 ; $i < strlen($t);$i++){
                if($t[$i] != '0' and $t[$i] != '1'){
                    $head = $t;
                    $et = true;
                }
            }

            if(!$et)
                $res += strlen($t) - 1;
       }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = 0;
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( "0" == $t ) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
       if($t[0] != '1'|| substr_count($t, "1") > 1){
            $head = $t;
       }else{
            $et = false;
            for($i = 0 ; $i < strlen($t);$i++){
                if($t[$i] != '0' and $t[$i] != '1'){
                    $head = $t;
                    $et = true;
                }
            }

            if(!$et)
                $res += strlen($t) - 1;
       }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */

while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $tanks = explode(" ",$line);
    $res = 1;
    foreach($tanks as $t){
        //beautifle num 只有0和1组成
        if( substr_count($t,"0") + substr_count($t,"1") != strlen($t) ){
            //不是beautiful num
        }else{
            //是beautiful num
        }

        $res *= $t;
    }
    fprintf(STDOUT,"%d",$res);

    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = 0;
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( "0" == $t ) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
       if($t[0] != '1'){
            $head = $t;
       }else{
            $et = false;
            for($i = 0 ; $i < strlen($t);$i++){
                if($t[$i] != '0' and $t[$i] != '1'){
                    $head = $t;
                    $et = true;
                }
            }

            if(!$et)
                $res += strlen($t) - 1;
       }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = 0;
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( "0" == $t ) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
       if($t[0] != '1' || substr_count($t,"1") > 1){
            $head = $t;
       }else{
            $res += strlen($t) - 1;
       }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */
while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符 whitespaces
    $res = array();
    $flag = false;
    foreach($tanks as $t){
        //fprintf(STDOUT,"%s\n",$t);
        if( 0 == $t) {
            $flag = true;
            break;
        }
        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
        $oneNum = substr_count($t,"1");
        $zeroNum = substr_count($t, "0");
        if($oneNum <= 1 && ($oneNum + $zeroNum == strlen($t)) ){
            $res[]= strlen($t);
        }else{
            $head = $t;
        }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        if(isset($head)) {
            fprintf(STDOUT,"%s",$head);
        }else{
            fprintf(STDOUT,1);
        }
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 1 ; $zeroNum < $res[$i] ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:58
 */

while(fscanf(STDIN,"%d",$num)){
    $line = stream_get_line(STDIN,65535,"\n");
    $line = trim($line);
    $tanks = explode(" ",$line);
    //最后一个字符串会保留换行符
    $res = array();
    $flag = false;
    foreach($tanks as $t){
        //beautifle num 只有0和1组成
        //fprintf(STDOUT,"%s\n",$t);
        if( 0 == $t) {
            $flag = true;
            break;
        }

        //var_dump((substr_count($t,"0") + substr_count($t,"1") != strlen($t)));
        $oneNum = substr_count($t,"1");
        $zeroNum = substr_count($t, "0");
        if($oneNum <= 1 && ($oneNum + $zeroNum == strlen($t)) ){
            $res[]= strlen($t);
        }else{
            //是beautiful num时记录要偏移的傡数
            $head = $t;
            //fprintf(STDOUT,"ss %d %d %d %s\n",$oneNum , $zeroNum,strlen($t),$t);
        }
    }
    if($flag){
        fprintf(STDOUT,0);
    }else{
        fprintf(STDOUT,"%s",$head);
        for($i = 0 ; $i < count($res) ; $i++){
            for($zeroNum = 1 ; $zeroNum < $res[$i] ; $zeroNum++){
                fprintf(STDOUT,"0");
            }
        }
    }
    exit();
}


<?php

$in = 'php://stdin';
$input = fopen($in, "r");

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

$arr = [];

for ($i = 0; $i < $t; $i++) {
	list($x, $y) = explode(" ", trim(fgets($input)));

	$try = $y + 1;
	if (
		($x % $try >= $try / 2) &&
		($y % $try >= $try / 2)
	) {
		echo 'YES' . PHP_EOL;
	} else {
		echo 'NO' . PHP_EOL;
	}
}

<?php

ob_start(null, 65536);

$__ln = explode("\n", file_get_contents("php://stdin"));
$__lc = 0;

function nl() {
    global $__ln, $__lc;
    return $__ln[$__lc++];
}

function nla() {
    global $__ln, $__lc;
    return explode(" ", $__ln[$__lc++]);
}

function asInt($x) {
    return (int)$x;
}

function asDouble($x) {
    return (double)$x;
}

$tc = asInt(nl());
for($cc=0; $cc<$tc; $cc++) {
    list($l, $r) = array_map(asInt::class, nla());
    if($r >= 2 * $l) {
        echo "NO\n";
    } else {
        echo "YES\n";
    }
}


<?php

list($n, $m) = sscanf(fgets(STDIN), "%d%d");
$node_value = array_map(
    function ($x) {
        list($r) = sscanf($x, "%d");
        return $r;
    },
    explode(" ", trim(fgets(STDIN))));
$res = 0.0;
for ($i = 0; $i < $m; ++$i) {
    list($a, $b, $w) = sscanf(fgets(STDIN), "%d%d%d");
    $res = max($res, ($node_value[$a - 1] + $node_value[$b - 1]) / $w);
}
echo number_format($res, 9, '.', ''), "\n";

?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
array_unshift($c, " ");
unset($c[0]);
$d = array();
for($x = 1; $x <= $b; $x++)
{
    list($e, $f, $g) = explode(" ", trim(fgets(STDIN)));
    $h = number_format(($c[$e] + $c[$f]) / $g, 15, ".", "");
    array_push($d, $h);
}
rsort($d);
print $d[0];
?>

<?php

list($n, $m) = sscanf(fgets(STDIN), "%d%d");
$node_value = array_map(
    function ($x) {
        list($r) = sscanf($x, "%d");
        return $r;
    },
    explode(" ", trim(fgets(STDIN))));
$res = 0.0;
for ($i = 0; $i < $m; ++$i) {
    list($a, $b, $w) = sscanf(fgets(STDIN), "%d%d%d");
    $res = max($res, ($node_value[$a - 1] + $node_value[$b - 1]) / $w);
}
echo number_format($res, 9), "\n";

?>


<?php
  list($n,$have)=explode(" ",trim(fgets(STDIN)));
 $st=0;
  for($i=0; $i<$n ; $i++){
   list($sign,$val)=explode(" ",trim(fgets(STDIN)));
   if($sign=='+') $have+=$val;

  else{
         if($val<=$have){
             $have-=$val;
         }else{
          $st++;
          }
   }

  }
  echo $have ." ".$st;
?>

<?php

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

fscanf($stdin, "%d %d" , $n , $x ) ;
$dist = 0 ;
for( $i=0 ; $i<$n ; $i++ )
{
     fscanf( $stdin , "%s %d" , $s , $m );
     if( $s == "+" )
     {
          $x += $m ;
     }
     else
     {
          if( $m <= $x )
          {
               $x -= $m ;
          }
          else
          {
               $dist++ ;
          }
     }
}
echo $x , " " , $dist ;

fwrite($stdout);

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

?>

<?

function addIce(&$ice_cnt,$count){
	$ice_cnt+=$count;
}

function getIce(&$ice_cnt,$count){
	if($ice_cnt>=$count){
		$ice_cnt-=$count;
		return true;
	}
	return false;
}

$stdin = fopen('php://stdin', 'r');
$s =  trim(fgets($stdin));
$cards = explode(" ",$s);
$ice_cnt = $cards[1];
$people_cnt=$cards[0];
$sad =0;
while (!feof($stdin)) {

	$s =  trim(fgets($stdin));
	$cards = explode(" ",$s);
	if($cards[0]=="+"){
		addIce($ice_cnt,$cards[1]);
	}elseif($cards[0]=="-"){
		if(!getIce($ice_cnt,$cards[1])){
			$sad+=1;
		}

	}

}

echo $ice_cnt." ".$sad;

<?php
//$in = fopen("input.txt","r");
$in = fopen("php://stdin","r");
list($n,$x) = explode(' ',trim(fgets($in)));
$nds=0;
for($i = 0; $i < $n; $i++)
{
 list($s,$d) = explode(' ',trim(fgets($in)));
 if($s == '-')
 {
   if($d <= $x)
     $x -= $d;
   else
     $nds++;
 }
 else
   $x += $d;
}
echo "$x $nds";