<?php

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

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

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

$skills = [];

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

for ($i = 0; $i < $n; $i++) {
    list($name, $exp) = fscanf($input, "%s %s\n");

    $expK = bcmul($exp, $k, 2);

    if (bccomp($expK, '100.00', 2) > -1) {
        $skills[$name] = bcadd($expK, '0.00', 0);
    }
}

for ($i = 0; $i < $m; $i++) {
    $name = trim(fgets($input));

    $skills[$name] = $skills[$name] ?? '0';
}

fwrite($output, count($skills) . PHP_EOL);

ksort($skills);

foreach ($skills as $skill => $value) {
    fwrite($output, $skill . ' ' . $value . PHP_EOL);
}

<?php

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

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

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

$skills = [];

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

for ($i = 0; $i < $n; $i++) {
    list($name, $exp) = fscanf($input, "%s %d\n");

    $expK = $exp * $k;

    if ($expK >= 100) {
        $skills[$name] = (int)$expK;
    }
}

for ($i = 0; $i < $m; $i++) {
    $name = trim(fgets($input));

    $skills[$name] = $skills[$name] ?? 0;
}

fwrite($output, count($skills) . PHP_EOL);

ksort($skills);

foreach ($skills as $skill => $value) {
    fwrite($output, $skill . ' ' . $value . PHP_EOL);
}

<?php

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

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

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

$skills = [];

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

for ($i = 0; $i < $n; $i++) {
    list($name, $exp) = fscanf($input, "%s %d\n");

    $expK = $exp * $k;

    if ($expK > 100) {
        $skills[$name] = (int)$expK;
    }
}

for ($i = 0; $i < $m; $i++) {
    $name = trim(fgets($input));

    $skills[$name] = $skills[$name] ?? 0;
}

fwrite($output, count($skills) . PHP_EOL);

ksort($skills);

foreach ($skills as $skill => $value) {
    fwrite($output, $skill . ' ' . $value . PHP_EOL);
}

<?php

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

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

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

$skills = [];

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

for ($i = 0; $i < $n; $i++) {
    list($name, $exp) = fscanf($input, "%s %s\n");

    $expK = bcmul($exp, $k, 2);

    if (bccomp($expK, '100.00', 2) === 1) {
        $skills[$name] = bcadd($expK, '0.00', 0);
    }
}

for ($i = 0; $i < $m; $i++) {
    $name = trim(fgets($input));

    $skills[$name] = $skills[$name] ?? '0';
}

fwrite($output, count($skills) . PHP_EOL);

ksort($skills);

foreach ($skills as $skill => $value) {
    fwrite($output, $skill . ' ' . $value . PHP_EOL);
}


<?php

$arr = array();
while ($line = trim(fgets(STDIN)))
    $arr[] = $line;
$n = $arr[0];
$exp = explode(' ', $arr[1]);
$aVal = array();
foreach($exp AS $value){
    if($value == 0)
        continue;
    $aVal[$value] += 1;
}
$count = 0;
foreach($aVal AS $value){
    if($value == 2){
        $count++;
    }
    if($value > 2){
        echo -1;
        exit;
    }
}
echo $count;

<?php

$fIn = fopen('php://stdin', 'r');
$n = intval(fgets($fIn));
$str = explode(' ', fgets($fIn));
fclose($fIn);
$res = 0;
$a = array();
for ($i = 0; $i < $n; ++$i) {
    $num = intval($str[$i]);
    if ($num == 0)
        continue;
    if (isset($a[$num])) {
        $a[$num]++;
    } else {
        $a[$num] = 1;
    }
    if ($a[$num] == 2) {
        $res++;
    } else if ($a[$num] > 2) {
        $res = -1;
        break;
    }
}

echo $res, PHP_EOL;
?>

<?php
$num = trim(fgets(STDIN));
$arr = explode(' ', fgets(STDIN));
foreach($arr as $k=>$v){
 $arr[$k] = trim($v);
}
function my_find($a){
 $result = 0;
 $t_a = Array();
 foreach($a as $v){
  if($v == 0)
   continue;
  $t_a[$v] += 1;
  if($t_a[$v] == 2){
   $result+=1;
  }elseif($t_a[$v] > 2){
   return -1;
  }
 }
 return $result;
}

if($num == 1){
 echo '0';
}elseif($num != count($arr)){
 echo '-1';
}else{
 echo my_find($arr);
}
?>

<?php
$f = fopen("php://stdin", "r");
$n = trim(fgets($f));
$text = trim(fgets($f));
fclose($f);
//$n = 6;
//$text = "0";
$list = explode(" ", $text);
$list = array_map('intval', $list);
sort($list);
$prev = -1;
$count = 0;
$result = 0;
foreach ($list as $val) {
    if (!$val)
        continue;
    if ($val === $prev)
        $count++;
    else
        $count = 1;

    $prev = $val;

    if ($count == 2)
        $result++;
    elseif ($count > 2)
        die("-1");

}

echo $result;

<?php

$sec_num = trim(fgets(STDIN))-1;
$sessions = trim(fgets(STDIN));

$sess = split(' ', $sessions);
$ses_num = count($sess);

$i=0;
$nope=0;
$pairs=0;
while ($i<$ses_num) {
	if ($sess[$i]>0) {
		$sessi[$sess[$i]]++;
		if ($sessi[$sess[$i]]==2) { $pairs++; } else if ($sessi[$sess[$i]]>2) { $pairs=-1; $i=$sec_num+10; }
	} else {
		$nope++;
	}
	$i++;
}

fwrite(STDOUT, "$pairs\n" );

?>

<?

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

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

$c = 0;

$num = (int)(trim(fgets($handle))*1 / 2);

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

$t = array();

foreach($arr as $val) {
    if ($val != 0) $t[$val]++;
}

$c = 0;
foreach($t as $k=>$id) {

    if ($id > 2 ) die("-1");
    if ($id == 2) $c++;
}

echo $c;

?>

<?php

$n = intval(line());
$a = explode(' ', line());

$count = array();

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

$answer = 0;

foreach ($count as $index => $value) {
  if ($index == 0) {
    continue;
  } elseif ($value > 2) {
    $answer = -1;
    break;
  }
  $answer += ($value == 2);
}

print $answer;

function line() {
  return trim(fgets(STDIN));
}

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j] && $num_talk_array[$i] <> 0) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
# Строка со входящими данными
$num = trim(fgets(STDIN));
$ids = explode(' ',trim(fgets(STDIN)));

# Проверка условий
if(count($ids) == $num){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($ids);
	if(isset($acv[0]))unset($acv[0]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

print $OUT;
?>

<?
error_reporting(false);
$handle = fopen('php://stdin', 'r');
$c = 0;
$num = (int)(trim(fgets($handle))*1 / 2);
$arr = explode(" ", trim(fgets($handle)));
$t = array();
foreach($arr as $val) {
    if ($val != 0) $t[$val]++;
}
$c = 0;
foreach($t as $k=>$id) {
    if ($id > 2 ) die("-1");
    if ($id == 2) $c++;
}
echo $c;
?>

<?php $fh = fopen('php://stdin','r') or die($php_errormsg);
$s = fgets($fh, 1500);
$s = substr($s, 0, -1);
$r = trim(fgets($fh, 1000000));
$r = explode(" ", $r);
$flag = true;
if (count($r)!=$s) $flag = false;
$r = array_slice($r, 0, $s);

$r = array_count_values($r);
$counter = 0;

if ($s<1) $flag = false;

foreach ($r as $item => $key)
{
if (!is_numeric($item)) $flag = false;

if ($item<>0) {
    if ($key == 2) $counter += 1;
    if ($key > 2) $flag = false;
}

}

if ($flag) echo $counter; else echo "-1";

?>

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

function my_find($a){
 $result = 0;
 $t_a = Array();
 foreach($a as $v){
  if($v == 0)
   continue;
  $t_a[$v] += 1;
  if($t_a[$v] == 2){
   $result+=1;
  }elseif($t_a[$v] > 2){
   return -1;
  }
 }
 return $result;
}

if($num == 1){
 echo '0';
}else{
 echo my_find($arr);
}
?>

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

function my_find($a){
 $result = 0;
 $t_a = Array();
 foreach($a as $v){
  $t_a[$v] += 1;
  if($t_a[$v] == 2){
   $result+=1;
  }elseif($t_a[$v] > 2){
   return -1;
  }
 }
 return $result;
}
if($num == 1){
 echo '0';
}else{
 echo my_find($arr);
}
?>

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

function my_find($a){
 $result = 0;
 $t_a = Array();
 foreach($a as $v){
  if($v == 0)
   continue;
  $t_a[$v] += 1;
  if($t_a[$v] == 2){
   $result+=1;
  }elseif($t_a[$v] > 2){
   return -1;
  }
 }
 return $result;
}

if($num == 1){
 echo '0';
}elseif($num != count($arr)){
 echo '-1';
}else{
 echo my_find($arr);
}
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
//$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j] and $num_talk_array[i] != 0 and $num_talk_array[$j] != 0) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
$c = 0;
for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $num_sec;
?>

<?php
$num_sec = fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
$c = 0;
/*for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}*/
echo $num_sec;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if (($num_talk_array[$i] == $num_talk_array[$j]) != "0") {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
$c = 0;
for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $num_sec;
?>

<?php
$num_sec = fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
//$c = 0;
for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $num_sec;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j] and $num_talk_array[i] != 0) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
$c = 0;
$end = $num_sec - 1;
for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $end; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $num_sec;
?>

<?php
$num_sec = fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
$result = 0;
$c = 0;
for ($i = 0; $i < $num_sec; $i++) {
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 6;
//$num_talk_array = array("0", "1", "7", "1", "7", "10");
$result = 0;
for ($i = 0; $i < $num_sec; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 6;
//$num_talk_array = array("0", "1", "7", "1", "7", "10");
$result = 0;
for ($i = 0; $i < $num_sec; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        break;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 6;
//$num_talk_array = array("0", "1", "7", "1", "7", "10");
$result = 0;
for ($i = 0; $i < $num_sec; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        break 1;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 3;
//$num_talk_array = array("1", "1", "1");
$result = 0;
for ($i = 0; $i < $num_sec - 1; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j] && $num_talk_array[i] <> 0) {
            $c++;
            //echo "

\$i = " . $i . "
\$j = " . $j .
                //"
\$num_talk_array[\$i] = " . $num_talk_array[$i] . " -- \$num_talk_array[\$j] = " . $num_talk_array[$j] .
                //"
\$result = ";
        }
    }
    if ($c > 1) {
        $result = -1;
        echo $result;
        exit;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?php
$num_sec = (int)fgets(STDIN);
$num_talk = trim(fgets(STDIN));
$num_talk_array = explode(" ", $num_talk);
//$num_sec = 6;
//$num_talk_array = array("0", "1", "7", "1", "7", "10");
$result = 0;
for ($i = 0; $i < $num_sec; $i++) {
    $c = 0;
    for ($j = $i + 1; $j < $num_sec - 1; $j++) {
        if ($num_talk_array[$i] == $num_talk_array[$j]) {
            $c++;
        }
    }
    if ($c > 1) {
        $result = -1;
        break 3;
    } else {
        $result = $result + $c;
    }
}
echo $result;
?>

<?
$c = 0;
$num = (int)(trim(fgets($handle))*1 / 2);
$arr = explode(" ", trim(fgets($handle)));
$t = array();
foreach($arr as $val) {
if ($val != 0) $t[$val]++;
}
$c = 0;
foreach($t as $k=>$id) {
if ($id > 2 ) die("-1");
if ($id == 2) $c++;
}
echo $c;
?>

<?php $fh = fopen('php://stdin','r') or die($php_errormsg);
$s = fgets($fh, 1000);
$s = substr($s, 0, -1);
$r = fgets($fh, 100000);
$r = explode(" ", $r);
$r = array_slice($r, 0, $s);
$r = array_count_values($r);
$counter = 0;
$flag = true;
foreach ($r as $item => $key)
{
if ($key == 2) $counter += 1;
if ($key > 2) $flag = false;
}

if ($flag) echo $counter; else echo "-1";

?>

<?php $fh = fopen('php://stdin','r') or die($php_errormsg);
$s = fgets($fh, 1500);
$s = substr($s, 0, -1);
$r = fgets($fh, 1000000);
$r = explode(" ", $r);
$r = array_slice($r, 0, $s);
$r = array_count_values($r);
$counter = 0;
$flag = true;
foreach ($r as $item => $key)
{

if ($item<>0) {
    if ($key == 2) $counter += 1;
    if ($key > 2) $flag = false;
}

}

if ($flag) echo $counter; else echo "-1";

?>

<?php

$fIn = fopen('input.txt', 'r');
$n = intval(fgets($fIn));
$str = explode(' ', fgets($fIn));
fclose($fIn);
$res = 0;
$a = array();
for ($i = 0; $i < $n; ++$i) {
    $num = intval($str[$i]);
    if ($num == 0)
        continue;
    if (isset($a[$num])) {
        $a[$num]++;
    } else {
        $a[$num] = 1;
    }
    if ($a[$num] == 2) {
        $res++;
    } else if ($a[$num] > 2) {
        $res = -1;
        break;
    }
}

echo $res, PHP_EOL;
?>

<?php

$fIn = fopen('php://stdin', 'r');
$n = intval(fgets($fIn));
$str = explode(' ', fgets($fIn));
fclose($fIn);
$res = 0;
$a = array();
for ($i = 0; $i < $n; ++$i) {
    $num = intval($str[$i]);
    if (isset($a[$num])) {
        $a[$num]++;
    }
    else
        $a[$num] = 1;
    if ($a[$num] == 2) {
        $res++;
    } else if ($a[$num] > 2) {
        $res = -1;
        break;
    }
}

echo $res, PHP_EOL;
?>

<?php
$f = fopen("php://stdin", "r");
$n = trim(fgets($f));
$text = trim(fgets($f));
fclose($f);
//$n = 1;
//$text = "0";
$list = explode(" ", $text);
sort($list);
$prev = -1;
$count = 0;
$result = 0;
foreach ($list as $val) {
	if ($val == $prev)
		$count++;
	else {
		if ($count == 2)
			$result++;
		elseif ($count > 2)
			die("-1");
		$count = 1;
		$prev = $val;
	}
}

if ($count == 2)
	$result++;
elseif ($count > 2)
	die("-1");
echo $result;

<?php

$sec_num = trim(fgets(STDIN))-1;
$sessions = trim(fgets(STDIN));

$sess = split(' ', $sessions);

$i=0;
$nope=0;
$pairs=0;
while ($i<$sec_num) {
	if ($sess[$i]>0) {
		$sessi[$sess[$i]]++;
		if ($sessi[$sess[$i]]==2) { $pairs++; } else if ($sessi[$sess[$i]]>2) { $i=$sec_num+10; }
	} else {
		$nope++;
	}
	$i++;
}

fwrite(STDOUT, "$pairs\n" );

?>

<?

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

$c = 0;

$num = (int)(trim(fgets($handle))*1 / 2);

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

$t = array();

foreach($arr as $val) {
    if ($val == 0) continue;
    $t[$val]++;
}

$c = 0;
foreach($t as $k=>$id) {

    if ($id > 2 ) die("-1");
    if ($id == 2) $c++;
}

?>

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

$c = 0;

$num = (int)(trim(fgets($handle))*1 / 2);

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

$t = array();

foreach($arr as $val) {
    $t[$val]++;
}

$c = 0;
foreach($t as $id) {
    if ($id > 2 ) die("-1");
    if ($id == 2) $c++;
}

echo $c;
?>

<?php

$n = intval(line());
$a = explode(' ', line());

$count = array();

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

$answer = 0;

foreach ($count as $cnt) {
  if ($cnt > 2) {
    $answer = -1;
    break;
  }
  $answer += ($cnt == 2);
}

print $answer;

function line() {
  return trim(fgets(STDIN));
}

<?php
# Открытие стандартного ввода
//$stdin = fopen('php://stdin','r');
$stdin = fopen(STDIN);

# Строка со входящими данными
$IN = '';
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
//while(!feof($stdin))$IN .= fgets($stdin);
$IN = trim(fgets($stdin));

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
//$stdout = fopen('php://stdout','w');
$stdout = fopen(STDOUT);
# Запись данных
fwrite($stdout,$OUT);
?>

<?php
# Строка со входящими данными
$num = trim(fgets(STDIN));
$ids = explode(' ',trim(fgets(STDIN)));

# Проверка условий
if(count($ids) == $num){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($ids);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

print $OUT;
?>

<?php

?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>

    </body>
</html>

<?php
# Открытие стандартного ввода
//$stdin = fopen('php://stdin','r');

# Строка со входящими данными
$IN = STDIN;
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
//while(!feof($stdin))$IN .= fgets($stdin);

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
/*$stdout = fopen('php://stdout','w');
# Запись данных
fwrite($stdout,$OUT);*/

echo $OUT;
?>

<?php
# Строка со входящими данными
$num = fgets(STDIN);
$ids = explode(' ',fgets(STDIN));
# Строка с исходящими данными
$OUT = 0;

# Проверка условий
if(count($ids) == $num){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

print $OUT;
?>

<?php
# Открытие стандартного ввода
$stdin = fopen('php://stdin','r');

# Строка со входящими данными
$IN = '';
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
while(!feof($stdin))$IN .= fgets($stdin);

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
/*$stdout = fopen('php://stdout','w');
# Запись данных
fwrite($stdout,$OUT);*/

echo $OUT;
?>

<?php
# Открытие стандартного ввода
$stdin = fopen('php://stdin','r');

# Строка со входящими данными
$IN = '';
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
while(!feof($stdin))$IN .= fgets($stdin);

$IN = '1
0';

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
$stdout = fopen('php://stdout','w');
# Запись данных
fwrite($stdout,(string)$OUT);

//echo $OUT;
?>

<?php
# Открытие стандартного ввода
//$stdin = fopen('php://stdin','r');

# Строка со входящими данными
$IN = fgets(STDIN);
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
//while(!feof($stdin))$IN .= fgets($stdin);

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
/*$stdout = fopen('php://stdout','w');
# Запись данных
fwrite($stdout,$OUT);*/

print $OUT;
?>

<?php
# Открытие стандартного ввода
$stdin = fopen('php://stdin','r');

# Строка со входящими данными
$IN = '';
# Строка с исходящими данными
$OUT = 0;

# Считывание данных
while(!feof($stdin))$IN .= fgets($stdin);

# Условие 1: Строгое соответствие шаблону
$cond1 = preg_match("/^(\d+?)\r\n([\d ]+?)$/s",$IN,$IN);
# Ра
$IN[2] = preg_split("/ /",$IN[2],-1,PREG_SPLIT_NO_EMPTY);
# Условие 2: Число секретарей
$cond2 = ($IN[1] >= 1 && $IN[1] <= 1000);
# Условие 3: Количество идентификаторов должно соответствовать числу секретарей
$cond3 = (count($IN[2]) == $IN[1]);
# Проверка условий
if($cond1 && $cond2 && $cond3){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($IN[2]);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

# Открытие стандартного вывода
$stdout = fopen('php://stdout','w');
# Запись данных
fwrite($stdout,(string)$OUT);
?>

<?php
# Строка со входящими данными
$num = fgets(STDIN);
$ids = explode(' ',fgets(STDIN));
# Строка с исходящими данными
$OUT = 0;

# Проверка условий
if(count($ids) == $num){
	# Вычисление количества повторяющихся значений (идентификаторов)
	$acv = array_count_values($ids);
	# Сортировка по значениям
	asort($acv);
	# Переход на последний элемент
	end($acv);
	# Значение последнего элемента не должно быть больше двух, если это не нулевой идентификатор
	if(current($acv) > 2 && key($acv) != 0){
		$OUT = -1;
	}else{
		# Вычисление количества типов соединений
		$acv = array_count_values($acv);
		# Возможно есть секретари, ведущие разговор между собой
		if(isset($acv[2])){
			$OUT = $acv[2];
		}else{
			$OUT = 0;
		}
	}
}else{
	$OUT = -1;
}

print $OUT;
?>


<?php

$inp = fopen('php://stdin', 'rb');

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

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

    fscanf($inp, '%s', $a);
    fscanf($inp, '%s', $b);

    if (str_replace('G', 'B', $a) === str_replace('G', 'B', $b) ) {
        echo 'yes'.PHP_EOL;
    } else {
        echo 'no'.PHP_EOL;
    }
}

<?php

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

$g =  trim(fgets( $x ));

for($i = 0; $i < $g; $i++)
{
    $cols = trim(fgets( $x ));
    $row1 = trim(fgets( $x ));
    $row2 = trim(fgets( $x ));

    if(strtr($row1, ['B' => 'G']) == strtr($row2, ['B' => 'G'])){
        echo "Yes\n";
    }
    else{
        echo "No\n";
    }
}

?>

<?php

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

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

for($i = 0; $i < $cases; $i++)
{
    $cols = trim(fgets( $f ));
    $row1 = trim(fgets( $f ));
    $row2 = trim(fgets( $f ));

    $row1 = str_replace('G', 'B', $row1);
    $row2 = str_replace('G', 'B', $row2);

    if($row1 == $row2)
    {
        echo "YES\n";
    }
    else
    {
        echo "NO\n";
    }
}

?>

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

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{
    $len = 5;
   //RBG

   $n = IO::get();
   $s = IO::get();
   $d = IO::get();

        $b = true;
     for ($i=0; $i<$n; $i++) {
        if($s[$i] == 'R') {
             if($d[$i] != 'R') {
                  $b = false;
                  break;
             }
        } else {
           if($d[$i] == 'R') {
                  $b = false;
                  break;
             }
        }
     }

     IO::pr($b ? 'Yes' : 'No');

}

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

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

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

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

while($cases--){
    $cols = trim(fgets( $f ));
    $firstRow = trim(fgets( $f ));
    $secondRow = trim(fgets( $f ));

    if(str_replace('G', 'B', $firstRow) == str_replace('G', 'B', $secondRow))
    {
        echo "YES\n";
    }
    else
    {
        echo "NO\n";
    }
}

?>

<?php

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

$g =  trim(fgets( $x ));

for($i = 0; $i < $g; $i++)
{
    $row1 = trim(fgets( $x ));
    $row2 = trim(fgets( $x ));

    if(strtr($row1, ['B' => 'G']) == strtr($row2, ['B' => 'G'])){
        echo "Yes\n";
    }
    else{
        echo "No\n";
    }
}

?>

<?php
list($t) = array_map('intval', explode(' ', trim(fgets(STDIN))));

while ($t--){
    list($i,$d) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    if(strtr($i, ['B' => 'G']) == strtr($d, ['B' => 'G'])){
        echo "Yes";
    }
    else{
        echo "No";
    }
}

<?php
    list($i,$d) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    if(strtr($i, ['B' => 'G']) == strtr($d, ['B' => 'G'])){
        echo "ДА";
    }
    else{
        echo "НЕТ";
    }

<?php
list($t) = array_map('intval', explode(' ', trim(fgets(STDIN))));

while ($t--){
    list($a,$b,$n) = array_map('intval', explode(' ', trim(fgets(STDIN))));

    if (substr_count($a,'R') === substr_count($b,'R')){
        echo 'YES';
    }
    else{
        echo 'NO';
    }
    echo "\n";
}

<?php
list($t) = array_map('intval', explode(' ', trim(fgets(STDIN))));

while ($t--){
    list($a,$b) = array_map('intval', explode(' ', trim(fgets(STDIN))));

    if (str_replace('G', 'B', $a) === str_replace('G', 'B', $b)){
        echo 'YES';
    }
    else{
        echo 'NO';
    }
    echo "\n";
}

<?php
list($t) = array_map('intval', explode(' ', trim(fgets(STDIN))));

while ($t--){
    list($a,$b) = array_map('intval', explode(' ', trim(fgets(STDIN))));

    if (substr_count($a,'R') === substr_count($b,'R')){
        echo 'YES';
    }
    else{
        echo 'NO';
    }
    echo "\n";
}

<?php

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

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

for($i = 0; $i < $cases; $i++)
{
    $cols = trim(fgets( $f ));
    $row1 = trim(fgets( $f ));
    $row2 = trim(fgets( $f ));

    str_replace('G', 'B', $row1);
    str_replace('G', 'B', $row2);

    if($row1 == $row2)
    {
        echo "YES\n";
    }
    else
    {
        echo "NO\n";
    }
}

?>


<?php
#1189C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$sums = [];
foreach ($arr as $i => $v) {
    $sums[] = ($sums[$i - 1] ?? 0) + $v;
}
$q = trim(fgets(STDIN));
while ($q--) {
    [$l, $r] = explode(' ', trim(fgets(STDIN)));
    $candies = 0;
    if ($r > $l) {
        $candies = floor(($sums[$r - 1] - ($sums[$l - 2] ?? 0)) / 10);
    }
    echo $candies . PHP_EOL;
}

<?php
#1189C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$sums = [];
foreach ($arr as $i => $v) {
    $sums[] = ($sums[$i - 1] ?? 0) + $v;
}
$q = trim(fgets(STDIN));
while ($q--) {
    [$l, $r] = explode(' ', trim(fgets(STDIN)));
    $candies = 0;
    if ($r > $l) {
        $candies = floor(($sums[$r - 1] - $sums[$l - 1]) / 10);
    }
    echo $candies . PHP_EOL;
}


<?php
$in=fgets(STDIN);
$in=intval($in);
$str=fgets(STDIN);
$arr=explode(" ", $str);
foreach ($arr as &$va) {
	$va=intval($va);
}
rsort($arr);
$ans=array();
foreach($arr as $v){
	if(empty($ans[$v])){
		$ans+=array($v=>1);
	}else{
		$ans[$v]++;
	}
}
$i=0;
$tar=array();
foreach ($ans as $k=>&$v) {
	if($v!=0){
		$tar[$i]=$k;
		$v--;
		$i++;
	}
}
$i=0;
$car=array();
foreach ($ans as $k=>&$v) {
	if($v!=0){
		$car[$i]=$k;
		$v--;
		$i++;
	}
}
if($tar[0]==$car[0]) unset($tar[0]);
$car=array_reverse($car);

$num=count($tar)+count($car);
echo $num."\n";
foreach ($car as $v) {
	echo $v." ";
}
foreach ($tar as $v) {
	echo $v." ";
}

?>


<?php
while($s = fgets(STDIN))
{
    $input .= $s;
}

$lines = explode("\r\n", $input);
unset($lines[0]);

$servers = array();
$servers[1] = $servers[2] = array('errors' => 0, 'success' => 0);

foreach($lines as $line)
{
    list($server, $success, $errors) = explode(' ', $line);
    $server = (int) $server;

    $servers[$server]['errors'] += (int) $errors;
    $servers[$server]['success'] += (int) $success;
}

echo ($servers[1]['success'] / $servers[1]['errors']) >= 1 ? 'LIVE' : 'DEAD';
echo PHP_EOL;
echo ($servers[2]['success'] / $servers[2]['errors']) >= 1 ? 'LIVE' : 'DEAD';

<?php

$servers = array(1 => 0, 0);
$cnt = getLine();
for ($i=0; $i<$cnt; $i++) {
    list($si, $x, $y) = explode(" ", getLine());
    $servers[$si] += $x - $y;
}

echo ($servers[1]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;
echo ($servers[2]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;

function getLine()
{
    return trim(fgets(STDIN));
}

<?PHP
$n = fgets(STDIN);
$sa = 'DEAD';
$sb = 'DEAD';

$xa = 0;
$ya = 0;

for ($i = 0; $i < $n; $i++) {
    list($t, $x, $y) = explode(' ', fgets(STDIN));
    if ($t == 1)
        $xa = $xa + $x - intval($y);
    else
        $ya = $ya + $x - intval($y);
    //echo "lei: $t, $x, $y\n";
}

if ($xa >= 0)
    $sa = 'LIVE';
if ($ya >= 0)
    $sb = 'LIVE';

echo "$sa\n";
echo "$sb\n";

?>

<?php

$servers = array(1 => 0, 0);
$cnt = getLine();
for ($i=0; $i<$cnt; $i++) {
    list($si, $x, $y) = explode(" ", getLine());
    $servers[$si] += ($x>=$y) - ($x<$y);
}

echo ($servers[1]>0 ? 'LIVE' : 'DEAD') . PHP_EOL;
echo ($servers[2]>0 ? 'LIVE' : 'DEAD') . PHP_EOL;

function getLine()
{
    return trim(fgets(STDIN));
}

<?php

$servers = array(1 => 0, 0);
$cnt = getLine();
for ($i=0; $i<$cnt; $i++) {
    list($si, $x, $y) = explode(" ", getLine());
    $servers[$si] += ($x>=$y) - ($x<$y);
}

echo ($servers[1]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;
echo ($servers[2]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;

function getLine()
{
    return trim(fgets(STDIN));
}

<?PHP
$n = fgets(STDIN);
$sa = 'DEAD';
$sb = 'DEAD';

for ($i = 0; $i < $n; $i++) {
    list($t, $x, $y) = explode(' ', fgets(STDIN));
    //echo "lei: $t, $x, $y\n";
    if ($t == 1)
        if ($x >= intval($y))
            $sa = 'LIVE';
    if ($t == 2)
        if ($x >= intval($y))
            $sb = 'LIVE';
}

echo "$sa\n";
echo "$sb\n";

?>


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

$t;
fscanf($cin, "%d\n", $t);
for ($T = 0; $T < $t; $T++) {
	fscanf($cin, "%d %d\n", $n, $c);
  $bruh = array("hi"=>0);
  $arr = explode(" ", trim(fgets($cin)));
  foreach($arr as $val){
      $bruh[$val]+=1;
  }
  $ans = 0;
  foreach($bruh as $el){
    $ans += min($el, $c);

  }
  fprintf($cout, "%d\n", $ans);
}

?>

<?php

fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d %d", $n, $c);
    $a   = trim(fgets(STDIN));
    $arr = explode(" ", $a);
    $map = [];
    foreach ($arr as $ar) {
        $map[$ar]++;

    }
    $cost     = 0;
    $ex_count = 0;
    $o_count  = 0;
    $min      = 0;
    foreach ($map as $k => $v) {
        if ($c < $v) {
            $cost += $c;
        } else
            $cost += $v;

    }
    echo $cost."\n";
}

return;
?>

<?php

$n = trim(readLine());
for ($i = 1; $i <= $n; $i++) {
    list($planetCount, $price) = explode(' ', trim(readLine()));
    $price = (int)$price;
    $planetCount = (int)$planetCount;
    $planets = explode(' ', trim(readLine()));
    $planetsResult = [];
    $result = 0;
    foreach ($planets as $planet) {
        if (array_key_exists($planet, $planetsResult)) {
            $planetsResult[$planet] = $planetsResult[$planet] + 1;
            continue;
        }
        $planetsResult[$planet] = 1;
    }
    foreach ($planetsResult as $planetCount) {
        if ($planetCount > $price) {
            $result += $price;
            continue;
        }
        $result += $planetCount;
    }
    print $result . PHP_EOL;
}

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

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

   list($n, $c) = IO::getArray();
      $a = IO::getArray();

    $ans = 0;
    $tt = [];
    for($i=0; $i<$n; $i++) {
        if(!isset($tt[$a[$i]])) {
          $tt[$a[$i]] = 1;
        } else {
            $tt[$a[$i]] += 1;
        }
    }
    $t = array_values($tt);
//    IO::prArray($t);
    for($i=0; $i<count($t); $i++) {
         if($t[$i]  > $c ) {
            $ans += $c;
         } else {
              $ans += $t[$i];
         }
    }

   IO::pr($ans);
}

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

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

<?php

fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d %d", $n,$c);
    $a   = trim(fgets(STDIN));
    $arr = explode(" ", $a);
    $map = [];
    foreach ($arr as $ar){
        $map[$ar]++;

    }
    $cost = 0;
    $ex_count = 0;
    $o_count = 0;
    $min = 0;
    if($c>1){
        foreach($map as $k=>$v){
            if($v>1){
                $ex_count+=$v;
            }else{
                $o_count++;
            }

        }
        $min= min($ex_count,$c);

        echo $cost = $min+$o_count."\n";
    }else{
        echo count($map)."\n";
    }
}

return;
?>

<?php

fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d %d", $n,$c);
    $a   = trim(fgets(STDIN));
    $arr = explode(" ", $a);
    $map = [];
    foreach ($arr as $ar){
        if(isset($map[$ar])){
            $map[$ar]++;
        }else{
            $map[$ar]=1;
        }

    }
    $cost = 0;
    $ex_count = 0;
    $o_count = 0;
    $min = 0;
    if($c>1){
        foreach($map as $k=>$v){
            if($v>1){
                $ex_count+=$v;
            }else{
                $o_count++;
            }

        }
        $min= min($ex_count,$c);

        echo $cost = $min+$o_count."\n";
    }else{
        echo count($map)."\n";
    }
}

return;
?>

<?php
$planetsResult = [];
$n = trim(readLine());
$result = 0;
for ($i = 1; $i <= $n; $i++) {
    list($planetCount, $price) = explode(' ', trim(readLine()));
    $price = (int)$price;
    $planetCount = (int)$planetCount;
    $planets = explode(' ', trim(readLine()));
    foreach ($planets as $planet) {
        if (array_key_exists($planet, $planetsResult)) {
            $planetsResult[$planet] = $planetsResult[$planet] + 1;
            continue;
        }
        $planetsResult[$planet] = 1;
    }
    foreach ($planetsResult as $planetCount) {
        if ($planetCount > $price) {
            $result += $price;
            continue;
        }
        $result += $planetCount;
    }
    print $result . PHP_EOL;
}


<?php
function nCr( $n, $r)
{
    return fact($n) / (fact($r) *
            fact($n - $r));
}

// Returns factorial of n
function fact( $n)
{
    if($n == 0)
        return 1;
    $res = 1;
    for ( $i = 2; $i <= $n; $i++)
        $res = $res * $i;
    return $res;
}
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    $a   = trim(fgets(STDIN));
    echo (nCr(10-$n,2)*6)."\n";

}

return;
?>

<?php
$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
for ($j = 0; $j < $t; $j++) {
	$l = trim(fgets($handle));
	$s = trim(fgets($handle));
	$arr= explode( ' ', $s);
    $x = 10 - $l;
	echo $x * (($x - 1) * 3) . "\n";
}

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

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{
   $n = IO::get();
   $a = IO::getArray();
   $ans = 0;
   $t = [
        '1' => 216,
        '2' => 168,
        '3' => 126,
        '4' => 90,
        '5' => 60,
        '6' => 36,
        '7' => 18,
        '8' => 6
        ];
        $ans = $t[$n];

   IO::pr($ans);
}

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

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

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

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{
   $n = IO::get();
   $a = IO::getArray();
   $ans = 0;
   $t = [
        '1' => 216,
        '2' => 162,
        '3' => 126,
        '4' => 90,
        '5' => 60,
        '6' => 36,
        '7' => 18,
        '8' => 6
        ];
        $ans = $t[$n];

   IO::pr($ans);
}

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

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


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

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

  for($q=0; $q <$t; $q++) {
      $ans = 0;
      list($n, $m) = getA();
      $a = [];
      $b = [];
      $c = [];
      for($i=0; $i<$n; $i++) {
          $tt = getT();
          $a[] = $tt;
          $c[$i] = 0;
          for($j=0; $j<$m; $j++) {
              $tm = ord($tt[$j]) - ord('a');
              $c[$i] += $tm;
              $b[$i][$j] = $tm;
          }
      }
       $min = 0;
       $d = [];
       $rr = 0;
       for($i=0; $i<$n; $i++) {
          for($j=$i+1; $j<$n; $j++) {
          	$count = 0;
          	for($ww=0; $ww<$m; $ww++) {
          		$count += abs($b[$j][$ww] - $b[$i][$ww]);
          	}
            $d[] = $count;
          }
       }

      pr(min($d));

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

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

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

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

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

        return $a[$n];
    }


<?php
$str = trim(fgets(STDIN));
for ($k=0;$k<strlen($str);$k++)
    $DP_arr[$k] = $DP_arr[$k-1]+($str[$k]==$str[$k+1]?1:0);

$n = fgets(STDIN);
for ($i=0;$i<$n;$i++){
    list($a,$b) = explode(' ',trim(fgets(STDIN)));
    echo ($DP_arr[$b-2]-$DP_arr[$a-2])."\n";
}

?>

<?php
	$s = fgets(STDIN);
	$counts = array(0);
	for($i = 0; $i < strlen($s) - 1; ++$i)
	{
		$counts[$i + 1] = ($s[$i] !== $s[$i + 1]) ? $counts[$i] : $counts[$i] + 1;
	}

	$c = fgets(STDIN);

	for($i = 0; $i < $c; ++$i)
	{
		list($l, $r) = explode(' ', fgets(STDIN));
		echo $counts[$r - 1] - $counts[$l - 1] . "\n";
	}

<?php
	$s = fgets(STDIN);
	$counts = array(0);
	for($i = 0; $i < strlen($s) - 1; ++$i)
	{
		$counts[$i + 1] = ($s[$i] !== $s[$i + 1]) ? $counts[$i] : $counts[$i] + 1;
	}

	$c = fgets(STDIN);

	for($i = 0; $i < $c; ++$i)
	{
		list($l, $r) = explode(' ', fgets(STDIN));
		echo $counts[$r - 1] - $counts[$l - 1];
		echo '\n';
	}

<?php
	$s = fgets(STDIN);
	$counts = array(0);
	for($i = 0; $i < strlen($s) - 1; ++$i)
	{
		$counts[$i + 1] = ($s[$i] !== $s[$i + 1]) ? $counts[$i] : $counts[$i] + 1;
	}

	$c = fgets(STDIN);

	for($i = 0; $i < $c; ++$i)
	{
		list($l, $r) = explode(' ', fgets(STDIN));
		echo $counts[$r - 1] - $counts[$l - 1];
	}

<?php
	$s = fgets(STDIN);
	$counts = array(0);
	for($i = 0; $i < strlen($s) - 1; ++$i)
	{
		$counts[$i + 1] = ($s[$i] !== $s[$i + 1]) ? $counts[$i] : $counts[$i] + 1;
	}

	$c = fgets(STDIN);

	for($i = 0; $i < $c; ++$i)
	{
		list($l, $r) = explode(' ', fgets(STDIN));
		echo $counts[$r - 1] - $counts[$l - 1] . '\n';
	}


<?php

    //$input = fopen("input.txt", "r");
    //fscanf($input, "%d\n", $t);

    /*function cinarr($sz, $ty){
    $inp = $ty;
    for($i = 1 ; $i < $sz ; $i++)    $inp .= " " . $ty;
    $inp .= "\n";
    $ret = fscanf(STDIN, $inp);
    return $ret;
    }*/

    fscanf(STDIN, "%d\n", $t);
    while($t--){
        $ans = 0;
        fscanf(STDIN, "%d\n", $n);
        for($i = 3, $moves = 1; $i <= $n ; $i+=2, $moves++) $ans += $moves * ($i * $i - ($i - 2)*($i - 2));
        echo number_format($ans, 0, "", "") . "\n";
    }

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

for ($i = 1; $i <= $count; $i++) {
    $result = 0;
    $count2 = floor((int)fgets(STDIN) / 2);

    for ($j = 1; $j <= $count2; $j++) {
        $result += 8 * $j * $j;
    }

    echo number_format($result, 0, ',', '') . PHP_EOL;
}

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

for ($i = 1; $i <= $count; $i++) {
    $result = 0;
    $count2 = floor((int)fgets(STDIN) / 2);

    for ($j = 1; $j <= $count2; $j++) {
        $result += 8 * $j * $j;
    }

    echo number_format($result, 5) . PHP_EOL;
}

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

for ($i = 1; $i <= $count; $i++) {
    $result = 0;
    $count2 = floor((int)fgets(STDIN) / 2);

    for ($j = 1; $j <= $count2; $j++) {
        $result += 8 * $j * $j;
    }

    echo $result . PHP_EOL;
}

<?php

$count = trim(fgets(STDIN));

for ($i = 1; $i <= $count; $i++) {
    echo trim(fgets(STDIN));
}

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

for ($i = 1; $i <= $count; $i++) {
    $result = 0;
    $count2 = ceil((int)fgets(STDIN) / 2);

    for ($j = 1; $j <= $count2; $j++) {
        $result += 8 * $j * $j;
    }

    echo $result . PHP_EOL;
}


<?php
#1176B
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$amounts = [4 => 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];
$delete = 0;
foreach ($arr as $value) {
    if (isset($amounts[$value])) {
        $amounts[$value]++;
    } else {
        $delete++;
    }
}
$min = min($amounts);
if ($min === 0) {
    $delete += array_sum($amounts);
} else {
    foreach ($amounts as $amount) {
        $delete += $amount - $min;
    }
}
echo $delete;

<?php
#1176C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$amounts = [4 => 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];
$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];
$delete = $group = 0;
foreach ($arr as $i => $value) {
    if ($value === '4') {
        $amounts[$value]++;
    } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {
        $amounts[$value]++;
    }
    if ($value === '42' && $amounts[42] > 0 && $amounts[$prev[$value]] === $amounts[$value]) {
        $group++;
    }
}
echo $n - $group * 6;

<?php
#1176C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$amounts = [4 => 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];
$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];
$delete = $group = 0;
foreach ($arr as $i => $value) {
    if ($value === '4') {
        $amounts[$value]++;
    } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {
        $amounts[$value]++;
    }
    if ($value === '42' && $amounts[$prev[$value]] === $amounts[$value]) {
        $group++;
    }
}
echo $n - $group * 6;

<?php
#1176C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$amounts = [4 => 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];
$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];
$delete = $group = 0;
foreach ($arr as $i => $value) {
    if ($value === 4) {
        $amounts[$value]++;
    } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {
        $amounts[$value]++;
    }
    if ($value === 42 && $amounts[$prev[$value]] === $amounts[$value]) {
        $group++;
    }
}
echo $n - $group * 6;

<?php
#1176C
$n = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));
$amounts = [4 => 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];
$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];
$delete = $group = 0;
foreach ($arr as $i => $value) {
    if ($value === '4') {
        $amounts[$value]++;
    } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {
        $amounts[$value]++;
    }
    if ($value === '42' && $amounts[42] > 0 && $amounts[$prev[$value]] === $amounts[$value]) {
        $group++;
    }
}
var_dump($amounts);
echo $n - $group * 6;


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

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $map[$a[$i]][] = $d[$i];
    }

    $f = array_fill(1, 200, 0);
    $ans = $sumd = array_sum($d);
    for ($i = 1; $i < 100001; $i++)
        if (isset($map[$i])) {
            $itr = &$map[$i];
            $cur = 0;
            foreach($itr as $v) $cur += $v;
            $count = count($itr) - 1;
            for ($j = 200; $j > 0; $j--) {
                if ($count == 0) break;
                if ($f[$j] == 0) continue;
                $min = min($count, $f[$j]);
                $cur += $min * $j;
                $count -= $min;
            }
            foreach($itr as $v) $f[$v]++;
            $ans = min($ans, $sumd - $cur);
            $map[$i] = null;
        }
    echo $ans;

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

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $map[$a[$i]][] = $d[$i];
    }

    $f = array_fill(1, 200, 0);
    $ans = $sumd = array_sum($d);
    for ($i = 1; $i < 100001; $i++)
        if (isset($map[$i])) {
            $itr = &$map[$i];
            $cur = 0;
            foreach($itr as $v) $cur += $v;
            $count = count($itr) - 1;
            for ($j = 200; $j > 0; $j--) {
                if ($count == 0) break;
                if ($f[$j] == 0) continue;
                $min = min($count, $f[$j]);
                $cur += $min * $j;
                $count -= $min;
            }
            foreach($itr as $v) $f[$v]++;
            $ans = min($ans, $sumd - $cur);
        }
    echo $ans;

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

    $map = array();
    for ($i = 0; $i < $n; $i++) {
        $map[$a[$i]][] = $d[$i];
    }

    $f = array_fill(1, 200, 0);
    $ans = $sumd = array_sum($d);
    for ($i = 1; $i < 100001; $i++)
        if (isset($map[$i])) {
            $itr = &$map[$i];
            $cur = 0;
            foreach($itr as $v) $cur += $v;
            $count = count($itr) - 1;
            for ($j = 200; $j > 0; $j--) {
                if ($count == 0) break;
                if ($f[$j] == 0) continue;
                $min = min($count, $f[$j]);
                $cur += $min * $j;
                $count -= $min;
            }
            foreach($itr as $v) $f[$v]++;
            $ans = min($ans, $sumd - $cur);
            $itr = null;
        }
    echo $ans;


<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fgets(STDIN);
    printf(
        "%d\n",
        ($a = array_diff_key(
            array_flip(array_count_values(fgetcsv(STDIN, 0, ' '))),
            [1 => true, 2 => true]
        )) ? reset($a) : -1
    );
}

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

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

      $n = trim(fgets(STDIN));
       $a1 = explode(' ', trim(fgets(STDIN)));
       $res = [];
       $q1 = -1;
       if($n >= 3) {
            $a = mergeSort($a1);
          for($i = 0; $i < $n; $i++) {
              if(isset($res[$a[$i]])) {
                  $res[$a[$i]] = $a[$i] + 1;
                  if($res[$a[$i]] == 3) {
                      $q1 = $a[$i];
                      break;
                  }
              }else {
                  $res[$a[$i]] = 1;
              }
          }
       }
      echo $q1 . "\n";
  }
  function pushRes($w) {

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

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

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

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

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

    return $aResult;

}
function solve($v) {
    $res = 0;
    while($v % 32768 == 0)   {
        if(32768 % $v == 0) {
            $v = $v * 2;
        } else {
            $v +=1;
        }
        $res++;
    }
    return $res;
}


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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l += $a[$j]-$a[$i];

		$i += $m;
		$j -= $m;
	}

	echo number_format($l*2, 0, "", "");
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;
    $l = 0;

    while ($i < $j) {

        $l = $l + $a[$j] - $a[$i];

        $i += $m;
        $j -= $m;
    }

    echo number_format(2 * $l, 0, "", "");
?>

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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l += $a[$j]-$a[$i];

		$i += $m;
		$j -= $m;
	}

	echo intval($l*2);
?>

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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$p = floor($n/2);
	$v = $a[$p];
	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l = (int) ($l+ $a[$j]-$a[$i]);

		$i += $m;
		$j -= $m;
	}

	echo bcmul($l, "2");
?>

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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l += $a[$j]-$a[$i];

		$i += $m;
		$j -= $m;
	}

	echo $l*2;
?>

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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l += $a[$j]-$a[$i];

		$i += $m;
		$j -= $m;
	}

	echo (int) $l*2;
?>

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

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

	list($n, $m) = explode(" ", trim(fgets($input)));

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

	$i = 0;
	$j = $n-1;

	while ($i < $j) {

		$l = $l+($a[$j]-$a[$i]);

		$i += $m;
		$j -= $m;
	}

	echo bcmul($l, "2");
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;

    $l=0;
    while ($i < $j) {
        $l = $l+($a[$j]-$a[$i]);

        $i += $m;
        $j -= $m;
    }

    echo $l;
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;
    $l = 0;

    while ($i < $j) {

        $l = $l + $a[$j] - $a[$i];

        $i += $m;
        $j -= $m;
    }

    echo sprintf('%d', $l);
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;
    $l = 0;

    while ($i < $j) {

        $l = $l + $a[$j] - $a[$i];

        $i += $m;
        $j -= $m;
    }

    echo sprintf('%lld', 2 * $l);
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;

    while ($i < $j) {

        $l = $l + $a[$j]-$a[$i];

        $i += $m;
        $j -= $m;
    }

    echo 2 * $l;
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;

    while ($i < $j) {

        $l = $l + $a[$j]-$a[$i];

        $i += $m;
        $j -= $m;
    }

    echo $l;
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;
    $l = 0;

    while ($i < $j) {

        $l = $l + $a[$j] - $a[$i];

        $i += $m;
        $j -= $m;
    }

    echo number_format(2 * $l);
?>

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

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

    list($n, $m) = explode(" ", trim(fgets($input)));

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

    $i = 0;
    $j = $n-1;
    $l = 0;

    while ($i < $j) {

        $l = $l + $a[$j] - $a[$i];

        $i += $m;
        $j -= $m;
    }

    echo sprintf('%d', 2 * $l);
?>


<?php
fscanf(STDIN, "%f", $n);
$arr=array();
$exist=array();
for ($i=0; $i<$n; $i++){
    fscanf(STDIN, "%f %f", $x, $k);
    $arr[$k][]=$x;
}
$r='YES';
foreach($arr as $user => $sends){
    $exist[$user][]=$sends[0];
    if ($sends[0]>0){
            $r='NO';
            echo $r;
            return;
        };
    $max=max($exist[$user]);
    for($i=1; $i<count($sends); $i++){
        $a=$sends[$i];
        if ($a<=$max) continue;
        if ( $max-$a !=-1 ){
            $r='NO';
            echo $r;
            return;
        }
        $exist[$user][]=$a;
        $max=max($max,$a);
    }
}
echo $r;

<?php
$a = trim(fgets(STDIN));
$b = 0;
$c = array();
for($x = 0; $x < $a; $x++)
{
    list($d, $e) = explode(" ", trim(fgets(STDIN)));
    $d++;
    if($c[$e] == FALSE)
    {
        $c[$e] = $d;
    }
    else
    {
        if($d < $c[$e])
        {
            $b = 1;
            break;
        }
    }
}
if($b == 0)
{
    print "YES";
}
else
{
    print "NO";
}
?>

<?php

$n = trim(fgets(STDIN));

$a = array();
$aa = array();

for($i = 0; $i < $n; $i++)
{
	list($u, $p) = explode(" ", trim(fgets(STDIN)));

	if(! @isset($aa[$u]))
	{
		$aa[$u] = true;
		$a[] = $u;
	}
}

for($i = 1; $i < sizeof($a); $i++)
{
	if($a[$i - 1] > $a[$i])
	{
		echo "NO" . PHP_EOL;
		exit;
	}

	$a[$i] = max($a[$i], $a[$i - 1]);
}

echo "YES" . PHP_EOL;

<?php
fscanf(STDIN, "%f", $n);
$arr=array();
$exist=array();
for ($i=0; $i<$n; $i++){
    fscanf(STDIN, "%f %f", $x, $k);
    $arr[$k][]=$x;
}
$r='YES';
foreach($arr as $user => $sends){
    $exist[$user]=array();
    for($i=0; $i<count($sends); $i++){
        $a=$sends[$i];
        if (in_array($a,$exist[$user])) continue;
        if (max($exist[$user])>$a){
            $r='NO';
            echo $r;
            return;
        }
        $exist[$user][]=$a;
    }
}
echo $r;

<?php
fscanf(STDIN, "%f", $n);
$arr=array();
$exist=array();
for ($i=0; $i<$n; $i++){
    fscanf(STDIN, "%f %f", $x, $k);
    $arr[$k][]=$x;
}
$r='YES';
foreach($arr as $user => $sends){
    $exist[$user][]=$sends[0];
    for($i=1; $i<count($sends); $i++){
        $a=$sends[$i];
        if (in_array($a,$exist[$user])) continue;
        if ( max($exist[$user])-$a !=-1 ){
            $r='NO';
            echo $r;
            return;
        }
        $exist[$user][]=$a;
    }
}
echo $r;

<?php
fscanf(STDIN, "%f", $n);
$arr=array();
$exist=array();
for ($i=0; $i<$n; $i++){
    fscanf(STDIN, "%f %f", $x, $k);
    $arr[$k][]=$x;
}
$r='YES';
foreach($arr as $user => $sends){
    $exist[$user]=array();
    for($i=0; $i<count($sends); $i++){
        $a=$sends[$i];
        if (in_array($a,$exist[$user])) continue;
        if ( max($exist[$user])-$a>=1){
            $r='NO';
            echo $r;
            return;
        }
        $exist[$user][]=$a;
    }
}
echo $r;


        <?php

        $server = "php://stdin";
        $local = "input.txt";
        $handle = fopen($server, "r");
        $t = trim(fgets($handle));

        for ($i=0;$i<$t;$i++)
        {
            $x = trim(fgets($handle));
            $a = trim(fgets($handle));
            $p = explode(' ', $a);
            $max=-1;$min=1000000009;
            $ok=false;
            for($j=0;$j<$x-1;$j++)
            {
               if(abs($p[$j]-$p[$j+1])>=2)
               {
                   $ok=true;
                   echo "YES"."\n";
                   echo ($j+1)." ".($j+2)."\n";
                   break;
               }
            }
            if(!$ok)
            {
                echo "NO"."\n";
            }

        }

        ?>

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

$t = intval(trim(fgets(STDIN)));

$iterate = function($a, $n){
	$a[0] = intval($a[0]);
	for ($i = 1; $i < $n; $i++) {
		$a[$i] = intval($a[$i]);
		if(abs($a[$i] - $a[$i-1]) > 1){
			echo "YES\n";
			echo ($i) . ' ' . ($i + 1) . "\n";
			return;
		}
	}
	echo "NO\n";
};

for (; $t != 0; $t--) {
	$n = intval(trim(fgets(STDIN)));
	$a = explode(' ', trim(fgets(STDIN)));

	$iterate($a, $n);
}

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    sort($p);
    $sum=0;$l=0;$r=$x-1;$count=$x;$check=false;$ok=false;
    while($l<$r)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else if($check==false)
        {
            $l++;
            $count--;
            $check=true;
        }else if($check==true)
        {
            $r--;
            $count--;
            $check=false;
        }
    }
    $sum=0;$l=0;$r=$x-1;$count=$x;$check=true;$ok=false;
    while($l<$r)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else if($check==false)
        {
            $l++;
            $count--;
            $check=true;
        }else if($check==true)
        {
            $r--;
            $count--;
            $check=false;
        }
    }
    if(!$ok)
    echo "NO"."\n";

}

?>

<?php
function getb($a,$l,$r)
{
    $min=1000000009;
    $max=0;
    for($i=$l;$i<=$r;$i++)
    {
        if($min>$a[$i])
        {
            $min=$a[$i];
        }
        if($max<$a[$i])
        {
            $max=$a[$i];
        }
    }
    return $max-$min;
}
$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;
    $min=$p[0];
    $max=$p[0];
    while($l<$x-1)
    {
        if(getb($p,$l,$r)>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else {
           $r++;
            if($r==$x-1)
            {
                $l++;
                $r=$l;
                $count=1;
            }
           $count++;
        }
    }

    if(!$ok)
    echo "NO"."\n";

}

?>

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    sort($p);
    $sum=0;$l=0;$r=$x-1;$count=$x;$check=false;$ok=false;
    while($l<$r)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else {
            if($p[$r]-$p[$l+1]>$p[$r-1]-$p[$l])
            {
                $l++;
                $count--;
            }else
            {
                $r--;
                $count--;
            }
        }
    }

    if(!$ok)
    echo "NO"."\n";

}

?>

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    sort($p);
    $sum=0;$l=0;$r=$x-1;$count=$x;$check=false;$ok=false;
    while($l<$r)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else if($check==false)
        {
            $l++;
            $count--;
            $check=true;
        }else if($check==true)
        {
            $r--;
            $count--;
            $check=false;
        }

    }
    if(!$ok)
    echo "NO"."\n";

}

?>

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

$t = intval(trim(fgets(STDIN)));

for (; $t != 0; $t--) {
	$n = intval(trim(fgets(STDIN)));
	$a = explode(' ', trim(fgets(STDIN)));
	for ($i = 0; $i < $n; $i++) {
		$a[$i] = intval($a[$i]);
	}

	$iterate = function () use ($n, $a) {
		$max =  max($a);
		$min =  min($a);
		$delta = $max - $min;

		for ($i = 0; $i < $n - 1; $i++) {
			if($max == $a[$i] || $min == $a[$i]){
				$max = $a[$i];
				$min = $a[$i];
				for ($j = $i + 1; $j < $n; $j++) {
					if ($max < $a[$j]) {
						$max = $a[$j];
						if ($max - $min > $j - $i) {
							return [$i, $j];
						}
					} else if ($min > $a[$j]) {
						$min = $a[$j];
						if ($max - $min > $j - $i) {
							return [$i, $j];
						}
					}
					if($delta < $j - $i){
						break;
					}
				}
			}

			$delta = $max - $min;
		}
		return false;
	};

	$res = $iterate();

	if ($res === false) {
		echo "NO\n";
	} else {
		echo "YES\n";
		echo ($res[0] + 1) . ' ' . ($res[1] + 1) . "\n";
	}

}

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

$t = intval(trim(fgets(STDIN)));

for (; $t!=0 ; $t--){
	$n = intval(trim(fgets(STDIN)));
	$a = explode(' ', trim(fgets(STDIN)));
	for ($i = 0; $i < $n; $i++){$a[$i] = intval($a[$i]);}

	$iterate = function() use($n, $a){
		for ($i = 0; $i < $n-1; $i++){
			$max = $a[$i];$min = $a[$i];
			for($j = $n-1; $j > $i; $j-- ){
				if($max < $a[$j]){
					$max = $a[$j];
					if($max - $min >= ($j - $i) + 1){
						return [$i, $j];
					}
				} else if($min > $a[$j]){
					$min = $a[$j];
					if($max - $min >= ($j - $i) + 1){
						return [$i, $j];
					}
				}
			}
		}
		return false;
	};

	$res = $iterate();

	if($res===false){
		echo "NO\n";
	} else {
		echo "YES\n";
		echo (min($res)+1).' '.(max($res)+1)."\n";
	}
}

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

$t = intval(trim(fgets(STDIN)));

for (; $t != 0; $t--) {
	$n = intval(trim(fgets(STDIN)));
	$a = explode(' ', trim(fgets(STDIN)));
	for ($i = 0; $i < $n; $i++) {
		$a[$i] = intval($a[$i]);
	}

	$iterate = function () use ($n, $a) {
		$max =  max($a);
		$min =  min($a);
		$delta = $max - $min;

		for ($i = 0; $i < $n - 1; $i++) {
			if($max == $a[$i] || $min == $a[$i]){
				$max = $a[$i];
				$min = $a[$i];
				for ($j = $i + 1; $j < $n; $j++) {
					if ($max < $a[$j]) {
						$max = $a[$j];
						if ($max - $min > $j - $i) {
							return [$i, $j];
						}
					} else if ($min > $a[$j]) {
						$min = $a[$j];
						if ($max - $min > $j - $i) {
							return [$i, $j];
						}
					}
					if($delta <= $j - $i){
						break;
					}
				}
			}

			$delta = $max - $min;
		}
		return false;
	};

	$res = $iterate();

	if ($res === false) {
		echo "NO\n";
	} else {
		echo "YES\n";
		echo ($res[0] + 1) . ' ' . ($res[1] + 1) . "\n";
	}

}

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    $r=$x-1;$ok=false;
    for($j=0;$j<$x;$j++)
    {
        for($k=$j+1;$k<$x;$k++)
        {
         if(abs($p[$j]-$p[$k])>$k)
         {
             $ok=true;
             echo "YES"."\n";
             echo min($k+1,$j+1)." ".max($j+1,$k+1)."\n";
            break;
         }

        }
        if($ok==true)break;
    }

    if(!$ok)
    echo "NO"."\n";

}

?>

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    $sum=0;$l=0;$r=$x-1;$count=$x;$check=false;$ok=false;
    while($l<$r)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else {
            if($p[$r]-$p[$l+1]>$p[$r-1]-$p[$l])
            {
                $l++;
                $count--;
            }else
            {
                $r--;
                $count--;
            }
        }
    }

    if(!$ok)
    echo "NO"."\n";

}

?>

<?php
function subArray($arr, $n)
{

    // Pick starting point
    for ($i = 0; $i < $n; $i++)
    {

        // Pick ending point
        for ($j = $i; $j < $n; $j++)
        {
            $temp=[];
            // Print subarray between
            // current starting
            // and ending points
            for ($k = $i; $k <= $j; $k++)
                $temp[]=$arr[$k];

           if(max($temp)-min($temp)>=sizeof($temp))
           {
               echo "YES"."\n";
               echo $i." ".$j."\n";
               return true;
           }
        }
    }
    return false;
}
$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);

    if(!subArray($p,$x))
    echo "NO"."\n";

}

?>

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;
    while($l<$x-1)
    {
        if($p[$r]-$p[$l]>=$count)
        {
            $ok=true;
            echo "YES"."\n";
            echo ($l+1)." ".($r+1)."\n";
            break;
        }else {
            if($r==$x-1)
            {
                $l++;
                $r=$l;
                $count=1;
            }
           $r++;
           $count++;
        }
    }

    if(!$ok)
    echo "NO"."\n";

}

?>

<?php

$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));

for ($i=0;$i<$t;$i++)
{
    $x = trim(fgets($handle));
    $a = trim(fgets($handle));
    $p = explode(' ', $a);
    $r=$x-1;$ok=false;
    for($j=0;$j<$x;$j++)
    {
        for($k=$j+1;$k<$x;$k++)
        {
         if(abs($p[$j]-$p[$k])>=($k+1))
         {
             $ok=true;
             echo "YES"."\n";
             echo min($k+1,$j+1)." ".max($j+1,$k+1)."\n";
            break;
         }

        }
        if($ok==true)break;
    }

    if(!$ok)
    echo "NO"."\n";

}

?>


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

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

   $n = IO::get();
   $a = IO::getArray();
   sort($a);
   $ans = 2147483646;
   $tt = 0;
   for($i=0; $i < $n-2; $i++) {
        $temp = min(($a[$i+2]-$a[$i+1]) + ($a[$i+1] - $a[$i]), ($a[$i+2]-$a[$i]) + ($a[$i+1] - $a[$i]));
        $ans = min($temp, $ans);
   }

   IO::pr($ans);
}

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

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

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

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

    sort($a);

    $ans = INF;
    for ($i = 1; $i < count($a) - 1; $i += 1) {
        $ans = min($ans, $a[$i + 1] - $a[$i - 1]);
    }
    echo $ans . PHP_EOL;
}

<?php
   $cases = fgets(STDIN);
   while ($cases--) {
       $n = fgets(STDIN);
       $numbers = explode(' ', fgets(STDIN));

       sort($numbers);
       $out = PHP_INT_MAX;
       for ($i = 0; $i < $n - 2; $i++) {
           $out = min($out, ($numbers[$i + 2] - $numbers[$i]) + ($numbers[$i + 2] - $numbers[$i + 1]));
           $out = min($out, ($numbers[$i + 1] - $numbers[$i]) + ($numbers[$i + 2] - $numbers[$i + 1]));
           $out = min($out, ($numbers[$i + 2] - $numbers[$i]) + ($numbers[$i + 1] - $numbers[$i]));
       }
       echo $out;
       echo "\n";
   }
   // I'm just falah

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

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

    sort($a);

    print_r($a);
    $ans = INF;
    for ($i = 1; $i < count($a) - 1; $i += 1) {
        $ans = min($ans, $a[$i + 1] - $a[$i - 1]);
    }
    echo $ans . PHP_EOL;
}


<?php

$n_chars = fgets(STDIN);
$word = fgets(STDIN);//"abba";

$t = array();

$c = "";
$w = str_split($word);
for($i = 0; $i < $n_chars; $i++)
{
    if((($n_chars - $i) % 2) == 0)
    {
        $c = $w[$i] . $c;
    } else {
        $c .= $w[$i];
    }
}

echo $c;

<?php
# ALIREZA
# JAHANI
#PH_PY_LA
#DONT REPEAT YOUR SELF ...
# YOU CAN READ MY CODE ...

$n =fgets(STDIN);
settype($n, 'int');
$input = str_split(trim(fgets(STDIN)));
for ($i=$n-2; $i >= 0 ; $i-=2)
	@$result.=$input[$i];
for ($i=$n-1; $i>=0;$i-=2)
	@$r.=$input[$i];
echo $result.strrev($r);

<?php
        //Enter your code here, enjoy!
$n =  (int)trim(fgets(STDIN)); // we don't care about this.
$letters = trim(fgets(STDIN)); //explode("", "logva"); //trim(fgets(STDIN)));

$l = 0;
$word = array();//[];

while(strlen($letters) > 0) {

    $median = floor(strlen($letters) / 2) + (strlen($letters) % 2 == 1);

    while(isset($word[$median])) {
        $median++;
        if($median == ($n + 1)) {
            $median = 0;
        }
    }

    //for($median = floor(($n - $ii) / 2); isset($word[$median]); $median++);
    $word[$median] = $letters[0];
    //$n--;
    $letters = substr($letters, 1);

}

ksort($word);

echo implode($word);


<?
$str=trim(fgets(STDIN));
$open=preg_match_all('/<\w>/',$str,$mopen);
$all=preg_match_all('/(<\w>|<\/\w>)/',$str,$mall);
function numspace($n){
    $str="";
    for($i=0; $i<$n; $i++)
        $str.=" ";
    return $str;
}
$lvl=0;
for($i=0; $i<sizeof($mall[0]); $i++){
    if(preg_match('/<\w>/',$mall[0][$i])) {
        $space=numspace($lvl*2);
        $lvl++;
    } else{
        $lvl--;
        $space=numspace($lvl*2);
    }
    echo $space.$mall[0][$i]."\n";
}
?>


<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     if($b % 2 == $c % 2)
     {
          $d = pow(((1 + $c + $c - 1) / 2), 2);
          if($d <= $b)
          {
               print "YES\n";
          }
          else
          {
               print "NO\n";
          }
     }
     else
     {
          print "NO\n";
     }
}
?>


<?php
list($s) = explode(' ', trim(fgets(STDIN)));
$aRow = explode(' ', trim(fgets(STDIN)));
asort($aRow);
$k = 0;
$i = 1;
$aArr = [];
foreach ($aRow as $sK => $sV){
    if($i <= $sV){
        $k++;
        $i++;
    }

}
echo $k;

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

$start = microtime(true);
$stdin = STDIN;
[$n] = fscanf($stdin, '%u');
$contests = array_map('intval', explode(' ', fgets($stdin)));
sort($contests);
$result = 0;
foreach($contests as $amount) {
    if ($amount > $result) {
        $result++;
    }
}
echo $result;

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

    $a = preg_split("/[\s,]+/", $s2);
    asort($a);

    $iter = 1; $count = 0;
    foreach($a as $v){
        if($iter<=$v){
            $iter++;
            $count++;
        }
    }

    echo $count;

?>

<?php
    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    sort($a);
    $i = 0;
    foreach ($a as $v) {
        if ($i < $v) {
            $i++;
        }
    }
    echo $i;
?>

<?php
list($s) = explode(' ', trim(fgets(STDIN)));
$aRow = explode(' ', trim(fgets(STDIN)));
asort($aRow);
$k = 0;
$i = 1;
$aArr = [];
foreach ($aRow as $sK => $sV){
    if($i <= $sV){
        $k++;
    }
    $i++;
}
echo $k;

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

$start = microtime(true);
$stdin = STDIN;
[$n] = fscanf($stdin, '%u');
$contests = array_unique(array_map('intval', explode(' ', fgets($stdin))));
echo count($contests);

<?php
    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    $p = array_flip($a);
    echo count($p);
?>


<?php

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

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

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

function foo($n)
{
    if ($n % 2 === 0) {
        return 4 * $n + 1;
    }

    if (($n - 1) % 4 === 0) {
        return 2 * $n + 1;
    }

    return $n + 1;
}

$r = 0;

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

$n = fscanf($input, trim(str_repeat("%d ", $t)));

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

    $r = foo($n[$i]);

    fwrite($output, $r . PHP_EOL);
}

<?php

error_reporting(0);

solve();

function gcd($a, $b){

	if ($a < $b)
	{
		$temp = $b;
		$b = $a;
		$a = $temp;
	}

	while ($b != 0)
	{
		$r = $a % $b;
		$a = $b;
		$b = $r;
	}

	return $a;

	//$r = $a % $b;
	//if ($r === 0) return $b;
	//else gcd($b, $r);
}

function lcm($a, $b, $g){

	return $a * $b / $g;

}

function solve(){
	//$Input = new Input("input.txt");
	$Input = new Input();

	$tc = (int)$Input->in();

	for ($i = 0; $i < $tc; $i++)
	{
		$n = (int)$Input->in();

		if ($n % 2 == 0) print(4 * $n + 1);
		else
		{
			$g = gcd($n * 2, intval(($n + 1)/2));
			printf("%.0f",lcm($n * 4, intval(($n + 1)/2), $g) / ($n + 1) + 1);
		}

		if ($i !== $tc - 1) print("\n");
	}
}

class Input{
	private $handle = "";
	private $values = array();
	private $index = 0;

	public function __construct($localfile){

		if (is_file($localfile)) {

			$this->handle = fopen($localfile, "r");
			$contents = stream_get_contents($this->handle);

		} else {

			$contents = stream_get_contents(STDIN);

		}

		$no_newlines = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->values = explode(" ", $no_newlines);
	}

	public function in(){

		return $this->values[$this->index++];

	}

	public function close(){

		if (is_file($localfile) && feof($this->handle)) fclose($this->handle);

	}
}

?>

<?php

error_reporting(0);

solve();

function solve(){
	//$Input = new Input("input.txt");
	$Input = new Input();

	$tc = (int)$Input->in();

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

		$n = (int)$Input->in();

		print($n * 4 + 1);

		if ($i !== $tc - 1) print("\n");
	}
}

class Input{
	private $handle = "";
	private $values = array();
	private $index = 0;

	public function __construct($localfile){

		if (is_file($localfile)) {

			$this->handle = fopen($localfile, "r");
			$contents = stream_get_contents($this->handle);

		} else {

			$contents = stream_get_contents(STDIN);

		}

		$no_newlines = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->values = explode(" ", $no_newlines);
	}

	public function in(){

		return $this->values[$this->index++];

	}

	public function close(){

		if (is_file($localfile) && feof($this->handle)) fclose($this->handle);

	}
}

?>


<?php

list($n, $m) = array_map('intval', explode(' ', readline()));
$strings = array();
$dp = array();
for ($i=0;$i<$n;$i++){
    array_push($strings, readline());
}

for($j=0;$j<3;$j++){
    $dp[$j] = array_fill(0, $n, PHP_INT_MAX);
}

function type($char){
    if(is_numeric($char)){
        return 0;
    }elseif($char == '#' ||$char == '*' ||$char == '&' ){
        return 1;
    }else{
        return 2;
    }
}

function steps($i, $m){
    if($i > (int)($m/2)){
        return $m - $i;
    }
    return $i;
}

foreach ($strings as $key => $string){
    for($i=0;$i<$m;$i++){
        $steps = steps($i, $m);
        $type = type($string[$i]);
        if($dp[$type][$key] > $steps){
            $dp[$type][$key] = $steps;
        }
    }
}
$min = PHP_INT_MAX;

for ($i=0; $i<$n;$i++){
    for ($j=0; $j<$n;$j++){
        for ($k=0; $k<$n;$k++){
            if($i != $j && $i != $k && $j != $k){
                $cur = $dp[0][$i] + $dp[1][$j] + $dp[2][$k];
                if($min > $cur){
                    $min = $cur;
                }
            }
        }
    }
}

echo $min;

<?php

list($n, $m) = array_map('intval', explode(' ', readline()));
$strings = array();
$dp = array();
for ($i=0;$i<$n;$i++){
    array_push($strings, readline());
}

for($j=0;$j<3;$j++){
    $dp[$j] = array_fill(0, $n, -1);
}

function type($char){
    if(is_numeric($char)){
        return 0;
    }elseif($char == '#' ||$char == '*' ||$char == '&' ){
        return 1;
    }else{
        return 2;
    }
}

function steps($i, $m){
    if($i > (int)($m/2)){
        return $m - $i;
    }
    return $i;
}

foreach ($strings as $key => $string){
    for($i=0;$i<$m;$i++){
        $steps = steps($i, $m);
        $type = type($string[$i]);
        if($dp[$type][$key] > $steps || $dp[$type][$key] == -1){
            $dp[$type][$key] = $steps;
        }
    }
}
$min = PHP_INT_MAX;

for ($i=0; $i<$n;$i++){
    for ($j=0; $j<$n;$j++){
        for ($k=0; $k<$n;$k++){
            if($i != $j && $i != $k && $j != $k){
                $cur = $dp[0][$i] + $dp[1][$j] + $dp[2][$k];
                if($min > $cur){
                    $min = $cur;
                }
            }
        }
    }
}

echo $min;


<?
$f = file('php://stdin',FILE_IGNORE_NEW_LINES);
define('L',PHP_EOL);
//-----------------------

$q = $f[0];

for($i=1;$i<=$q;$i++) {
	$w[] = $f[$i];
}

$r = $f[$i];

$r = preg_replace('/<(.*?)3/', '<3', $r);

$o = explode('<3',substr($r,2,-2));

if (sizeof($o)!=sizeof($w)) {
	echo 'no';
} else {
	foreach ($w as $i=>$word) {
		$word = str_split($word);

		foreach ($word as $letter) {
			$found = false;
			for($j=0;$j<strlen($o[$i]);$j++) {
				if ($o[$i][$j]==$letter) {
					$found = true;
				}

			}
			if (!$found) {
				$no = 1;
				break 2;
			}
		}

	}

}

echo $no ? 'no' : 'yes';


<?php

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

while($tests--){
    fscanf(STDIN, "%d %d %d %d", $s1, $s2, $s3, $s4);
    $minL = min($s1, $s2);
    $maxL = max($s1, $s2);
    $minR = min($s3, $s4);
    $maxR = max($s3, $s4);
    if($maxL > $minR && $minL < $maxR)
        echo "YES\n";
    else
        echo "NO\n";
}

?>

<?php

$t = (int)trim(fgets(STDIN));

for($i=0;$i<$t;$i++){
    $result = trim(fgets(STDIN));
    list($a,$b,$c,$d) = explode(' ',$result);
    $a = (int)$a;
    $b = (int)$b;
    $c = (int)$c;
    $d = (int)$d;

    $values1 = array($a,$b,$c,$d);
    $values2 = array($a,$b,$c,$d);

    $m1 = max($a,$b);
    $m2 = max($c,$d);

    $res1 = array_diff($values1,[$m1,$m2]);
    $res2 = array_diff($values2,[max($values2)]);
    $res2 = array_diff($res2,[max($res2)]);
    // var_dump($res1,$res2);
    if($res1 == $res2){
        echo "YES".PHP_EOL;
    }else{
        echo "NO".PHP_EOL;
    }
}

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

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

for ($i = 0; $i < $t; $i++) {
  $s = explode(" ", trim(fgets($file)));
  $max1 = max($s[0], $s[1]);
  $max2 = max($s[2], $s[3]);

  $max = max($max1, $max2);
  $min = min($max1, $max2);
  rsort($s);

  if ($s[0] == $max && $s[1] == $min) { echo 'YES'.PHP_EOL; }
  else { echo 'NO'.PHP_EOL; }
}

?>


<?php

function input() {
    return array_map("intval", explode(" ", fgets(STDIN)));
}

[$n] = input();
$a = input();

$r = $days = 0;
for ($i = 0; $i < $n; $i++) {
    if ($a[$i] > $r)
        $r = $a[$i];
    if ($r == $i + 1)
        $days++;
}

echo $days . "\n";


<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    $arr = explode(' ', trim(fgets(STDIN)));
    $path = [$arr[0] => 1];
    $prev_value = $arr[0];
    for ($i = 1; $i < $n; $i++) {
        if ($arr[$i] != $prev_value) {
            isset($path[$arr[$i]]) or $path[$arr[$i]] = 0;
            $path[$arr[$i]] += 1;
            $prev_value = $arr[$i];
        }
    }
    $a = $arr[0];
    $b = $arr[$n-1];
    $arr = array_diff($arr, [$a, $b]);
    ($a == $b) and $path[$a] -= 1;
    foreach (array_unique($arr) as $value) {
        $path[$value] += 1;
    }
    printf("%d\n", min($path) ?? 0);
}

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

while ($t--) {
    $n = trim(fgets(STDIN));
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $ex = []; $bAll = true;
    for ($i = 0; $i < ($n-1); $i++) {
        if ($a[$i] != $a[$i+1]) {
            $bAll = false;
        }
        if (isset($ex[$a[$i]])) {
            if ($a[$i] != $a[$i+1]) {
                $ex[$a[$i]] = $ex[$a[$i]] + 1;
            }
        } else {
            $ex[$a[$i]] = 0;
        }
    }

    if ($bAll) {
        echo "0\n";
    } else {
        foreach($ex as $sValue => $iCount) {
            if ($a[$n-1] == $sValue && $sValue == $a[0]) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
            if ($a[$n-1] != $sValue) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
            if ($a[0] != $sValue) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
        }
        echo min($ex)."\n";
    }

}

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

while ($t--) {
    $n = trim(fgets(STDIN));
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $ex = []; $bStatus = true;
    for ($i = 0; $i < ($n - 1); $i++) {
        if ($a[$i] != $a[$i+1]) {
            $bStatus = false;
        }
        if (isset($ex[$a[$i]])) {
            if ($a[$i] != $a[$i+1]) {
                $ex[$a[$i]] = $ex[$a[$i]] + 1;
            }
        } else {
            $ex[$a[$i]] = 1;
        }
    }
    foreach ($ex as $sKey => $sValue) {
        if ($a[$n-1] != $sKey) {
            $ex[$sKey] = $sValue + 1;
        }
    }

    echo $bStatus ? 0 : min($ex);
    echo "\n";
}

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

while ($t--) {
    $n = trim(fgets(STDIN));
    $s = trim(fgets(STDIN));
    $a = preg_split("/[\s,]+/", $s);
    $ex = [];
    $bAll = true;
    for ($i = 1; $i < $n; $i++) {
        if ($a[$i] != $a[$i-1]) {
            $bAll = false;
        }
        if (isset($ex[$a[$i]])) {
            if ($a[$i] != $a[$i-1]) {
                $ex[$a[$i]] = $ex[$a[$i]] + 1;
            }
        } else {
            $ex[$a[$i]] = 0;
        }
    }

    if ($bAll) {
        echo "0\n";
    } else {
        foreach($ex as $sValue => $iCount) {
            if ($a[$n-1] == $sValue && $sValue == $a[0]) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
            if ($a[$n-1] != $sValue) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
            if ($a[0] != $sValue) {
                $ex[$sValue] = $ex[$sValue] + 1;
            }
        }
        echo min($ex)."\n";
    }

}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    $arr = explode(' ', trim(fgets(STDIN)));
    $path = [$arr[0] => 1];
    $prev_value = $arr[0];
    for ($i = 1; $i < $n; $i++) {
        if ($arr[$i] != $prev_value) {
            isset($path[$arr[$i]]) or $path[$arr[$i]] = 0;
            $path[$arr[$i]] += 1;
            $prev_value = $arr[$i];
        }
    }
    $a = $arr[0];
    $b = $arr[$n-1];
    $arr = array_diff($arr, [$arr[0], $arr[$n-1]])
    and ($a == $b) and $path[$a] -= 1;
    foreach (array_unique($arr) as $value) {
        $path[$value] += 1;
    }
    printf("%d\n", $arr ? min($path) : 0);
}


<?php

$n = trim(fgets(STDIN));

/**
 * @param $n
 */
function readMatrix($n)
{
    $b = [];
    for ($i = 0; $i < $n; $i++) {
        $b[$i] = trim(fgets(STDIN));
    }

    return $b;
}

$a = [];
$a[0] = readMatrix($n); fgets(STDIN);
$a[1] = readMatrix($n); fgets(STDIN);
$a[2] = readMatrix($n); fgets(STDIN);
$a[3] = readMatrix($n); fgets(STDIN);

function pc_permute($items, $perms = array(), &$p) {
    if (empty($items)) {
        $p[] = $perms;
    } else {
        for ($i = count($items) - 1; $i >= 0; --$i) {
            $newitems = $items;
            $newperms = $perms;
            list($foo) = array_splice($newitems, $i, 1);
            array_unshift($newperms, $foo);
            pc_permute($newitems, $newperms, $p);
        }
    }
}

$perms = [];
pc_permute([0,1,2,3], [], $perms);

$minToChange = $n*$n*4;

for ($p = 0; $p < 24; $p++) {
    $desk = [];
    for ($i = 0; $i < $n; $i++) {
        $desk[$i] = $a[$perms[$p][0]][$i] . $a[$perms[$p][1]][$i];
    }

    for ($i = 0; $i < $n; $i++) {
        $desk[$n + $i] = $a[$perms[$p][2]][$i] . $a[$perms[$p][3]][$i];
    }

    $toChange = 0;
    for ($i = 0; $i < 2*$n; $i++) {
        for ($j = 0; $j < 2*$n; $j++) {
            if (($i + $j) % 2 != $desk[$i][$j]) {
                $toChange ++;
            }
        }
    }

    if ($toChange > 4*$n*$n/2) {
        //echo $n . " " . ($n*$n) , " \n";
        $toChange = 4*$n*$n - $toChange;
        //echo $toChange . "\n";
    }

    if ($toChange < $minToChange) {
        $minToChange = $toChange;
    }

}

echo $minToChange . "\n";