Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase and reach the last stair number n without touching a dirty stair once.One has to note that anyway Petya should step on the first and last stairs, so if the first or the last stair is dirty, then Petya cannot choose a path with clean steps only.

The first line contains two integers n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 3000) — the number of stairs in the staircase and the number of dirty stairs, correspondingly. The second line contains m different space-separated integers d1, d2, ..., dm (1 ≤ di ≤ n) — the numbers of the dirty stairs (in an arbitrary order).

Print "YES" if Petya can reach stair number n, stepping only on the clean stairs. Otherwise print "NO".

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 1;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1) {
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 1; //reset if it wasn't 1 already
    }
}

if (in_array($n, $dirtystairs) || in_array(1, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 0;
$first = "yes";

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 && $first == "yes") { //this statement probably needs improving
        $first = "no";
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 1;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1) {
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $first = "yes";
        $counter = 1; //reset if it wasn't 1 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 10; $m = 3;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "7 8 10");
sort($dirtystairs);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
print_r($dirtystairs);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
error_reporting("off");
//362B: Petya and Staircases
list($n, $m) = explode(" ", trim(fgets(STDIN))); //$n = 123; $m = 13;
$dirtystairs = explode(" ", trim(fgets(STDIN))); //$dirtystairs = explode(" ", "36 73 111 2 92 5 47 55 48 113 7 78 37");
sort($dirtystairs, SORT_NUMERIC);
$numdirty = count($dirtystairs);
$counter = 0;

for ($i = 0; $i < $numdirty; $i++) {
    if ($dirtystairs[$i] == $dirtystairs[$i - 1] + 1 || $dirtystairs[$i] == $dirtystairs[$i + 1] - 1) { //this statement probably needs improving
        $counter++;
        if ($counter == 3) {
            $thereAreThreeConsecutiveDirtyStairs = "yep";
            break;
        }
    } else {
        $counter = 0; //reset if it wasn't 0 already
    }
}

if (in_array($n, $dirtystairs)) {
    echo "NO";
} elseif ($thereAreThreeConsecutiveDirtyStairs == "yep") {
    echo "NO";
} else {
    echo "YES";
}
?>


Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai, ai + 1, ... , an or subtract 1 from all elements ai, ai + 1, ..., an. His goal is to end up with the array b1, b2, ..., bn. Of course, Wilbur wants to achieve this goal in the minimum number of steps and asks you to compute this value.

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the array ai. Initially ai = 0 for every position i, so this array is not given in the input. The second line of the input contains n integers b1, b2, ..., bn ( - 109 ≤ bi ≤ 109).

Print the minimum number of steps that Wilbur needs to make in order to achieve ai = bi for all i.

NoteIn the first sample, Wilbur may successively choose indices 1, 2, 3, 4, and 5, and add 1 to corresponding suffixes.In the second sample, Wilbur first chooses indices 1 and 2 and adds 1 to corresponding suffixes, then he chooses index 4 and subtract 1.


You have $$$a$$$ coins of value $$$n$$$ and $$$b$$$ coins of value $$$1$$$. You always pay in exact change, so you want to know if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ ($$$0 \le x \le a$$$) coins of value $$$n$$$ and $$$y$$$ ($$$0 \le y \le b$$$) coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$.You have to answer $$$q$$$ independent test cases.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases. Then $$$q$$$ test cases follow. The only line of the test case contains four integers $$$a$$$, $$$b$$$, $$$n$$$ and $$$S$$$ ($$$1 \le a, b, n, S \le 10^9$$$) — the number of coins of value $$$n$$$, the number of coins of value $$$1$$$, the value $$$n$$$ and the required total value.

For the $$$i$$$-th test case print the answer on it — YES (without quotes) if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ coins of value $$$n$$$ and $$$y$$$ coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$, and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

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

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAvg = floor($aArray[3]/$aArray[2]);
    if ($iAvg <= $aArray[0]) {
        if (($iAvg*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } elseif ($iAvg > $aArray[0]) {
        if(($aArray[0]*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

<?php
$count = fgets(STDIN);
for ($i = 0; $i < $count; $i++){
	list($a, $b, $n, $S) = explode(' ', fgets(STDIN));
	if($a * $n < $S){
		printf("%s\n", $a * $n + $b >= $S ? 'YES':'NO');
	} else {
		printf("%s\n", $b >= $S % $n ? 'YES':'NO');
	}
}

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = explode(" ", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if (intval($s / $n) <= $a && $s % $n <= $b) {
        $status = true;
    } else if (intval($s / $n) > $a && $s - ($a * $n) <= $b) {
        $status = true;
    }
   /*if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }*/

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAvg = floor($aArray[3]/$aArray[2]);
    if ($iAvg <= $aArray[0]) {
        if (($iAvg*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    if (floor($aArray[3]/$aArray[2]) <= $aArray[0]) {
        if ((floor($aArray[3]/$aArray[2])*$aArray[2] + $aArray[1]) >= $aArray[3]){
            echo "YES\n";
        } else {
            echo "NO\n";
        }
    } else {
        echo "NO\n";
    }
}

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($s % $n <= $b && intval($s / $n) <= $a) {
        $status = true;
    }
   /*if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }*/

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 1; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {
        $status = true;
    } else {
        for ($j = 1; $j <= $a; $j ++) {
            $count1 = intval(bcdiv ($s, bcmul($n, $j)));
            $count2 = bcmod ($s,bcmul ($n, $j)) ;
            if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
                $status = true;
                break;
            }
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 1; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( $count1 <= $a && $count2  <= $b) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;
    for ($j = 0; $j <= $a; $j ++) {
        $count1 = intval(bcdiv ($s,bcmul($n, $j)));
        $count2 = bcmod ($s,bcmul ($n, $j)) ;
        if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {
            $status = true;
            break;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

    if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {
        $status = true;
    } else {
        if ($s % $n <= $b && intval($s / $n) <= $a) {
            $status = true;
        }
    }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>

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

for ($i=0; $i < $q; $i++) {
    $str = trim(fgets(STDIN));
    $aR = preg_split("/[\s,]+/", $str);
    $a = $aR[0];
    $b = $aR[1];
    $n = $aR[2];
    $s = $aR[3];
    $status = false;

   if ($a == 0 && $b >= $s) {
        $status = true;
    } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {
        $status = true;
    } else {
       if ($s % $n <= $b && intval($s / $n) <= $a) {
           $status = true;
       }
   }

    if ($status) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}
?>


Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.For example:  the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";  the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.

The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.

Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        if (isset($vowels[$v])) {
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
            // insert space as late as possible
            if (count($consecutiveConsonantsArray) == 1) {
                if (!isset($consecutiveConsonantsArray[$v]) && $consecutiveConsonants >= 2) {
                    // add space
                    $indexOfAddSpace[$k-1] = $k-1;
                    $consecutiveConsonants = 0;
                    $consecutiveConsonantsArray = array();
                }
            } else if (count($consecutiveConsonantsArray) > 1) {
                $indexOfAddSpace[$k-1] = $k-1;
                $consecutiveConsonants = 0;
                $consecutiveConsonantsArray = array();
            }

			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");

    $lastChar = "";
    $consecutiveConsonants = 0;
    $consecutiveSameConsonantsInARow = 0;
    foreach ($stringAsArray as $k => $v) {
        echo $lastChar;

        if (isset($vowels[$v])) {
			$consecutiveConsonants = 0;
            $consecutiveSameConsonantsInARow = 0;
        } else {

            if ($consecutiveConsonants >= 2) {
                if ($consecutiveSameConsonantsInARow == 1 || $lastChar != $v) {
                    echo " ";
                    $consecutiveConsonants = 0;
                    $consecutiveSameConsonantsInARow = 0;
                }
            }

            if ($lastChar == $v)
                $consecutiveSameConsonantsInARow++;
            else
                $consecutiveSameConsonantsInARow = 1;

            $consecutiveConsonants++;
        }

        $lastChar = $v;
    }
    echo $lastChar;

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
//    $binaryInterpretation = array(); // do I need this at all?
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "o" => "o", "u" => "u", " " => " ");
    /*
     * create $binaryInterpretation
     * 1 - for vowels
     * 2 - for consonants
     * 3 - for space
     */

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastCharType = 0;
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        $code = 2;
        if (isset($vowels[$v])) {
            $code = 1;
            if($v==" "){
                $code = 3;
            }
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
			if ($consecutiveConsonants==2) {

				if(count($consecutiveConsonantsArray) == 1) {
					if(!isset($consecutiveConsonantsArray[$v])){
						// add space
						$indexOfAddSpace[$k-1] = $k-1;
						$consecutiveConsonants = 0;
						$consecutiveConsonantsArray = array();
					}
				} else {
					$indexOfAddSpace[$k-1] = $k-1;
					$consecutiveConsonants = 0;
					$consecutiveConsonantsArray = array();
				}

			}
			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
//        $binaryInterpretation[$k] = $code;
        $lastCharType = $code;
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }

}

?>

<?php
ini_set('register_argc_argv', 1);
ini_set('display_errors', 1);
error_reporting( E_ALL );

if (!isset($argv[1]) && !empty($_SERVER['argv']))
	$argv = $_SERVER['argv'];

$numberOfCafes = 0;

// Beroffice text editor

// user input
$inputString = "";
$inputStringLength = 0;
if (empty($argv) || count($argv) <= 1 ) {
	$handle = fopen ("php://stdin","r");
	$inputString = trim(fgets($handle));
} else {
	$inputString = (int)trim($argv[1]);
}

$inputStringLength = strlen($inputString);
$answer = "-";
if ($inputStringLength > 3000 || $inputStringLength < 1) {
    echo $answer;
} else {
    $stringAsArray = str_split($inputString);
    $binaryInterpretation = array(); // do I need this at all?
    $vowels = array("a" => "a", "e" => "e", "i" => "i", "0" => "o", " " => " ");
    /*
     * create $binaryInterpretation
     * 1 - for vowels
     * 2 - for consonants
     * 3 - for space
     */

    $indexOfTypos = array();
	$indexOfAddSpace = array();
    $lastCharType = 0;
    $lastChar = 0;
    $consecutiveConsonants = 0;
	$consecutiveConsonantsArray = array();
    foreach ($stringAsArray as $k => $v) {
        $lastChar = $v;
        $code = 2;
        if (isset($vowels[$v])) {
            $code = 1;
            if($v==" "){
                $code = 3;
            }
			$consecutiveConsonants = 0;
			$consecutiveConsonantsArray = array();
        } else {
			if ($consecutiveConsonants==2) {

				if(count($consecutiveConsonantsArray) == 1) {
					if(!isset($consecutiveConsonantsArray[$v])){
						// add space
						$indexOfAddSpace[$k-1] = $k-1;
						$consecutiveConsonants = 0;
						$consecutiveConsonantsArray = array();
					}
				} else {
					$indexOfAddSpace[$k-1] = $k-1;
					$consecutiveConsonants = 0;
					$consecutiveConsonantsArray = array();
				}

			}
			$consecutiveConsonantsArray[$v] = $v;
            $consecutiveConsonants++;
        }
        $binaryInterpretation[$k] = $code;
        $lastCharType = $code;
    }

	if(!empty($indexOfAddSpace)) {
		foreach($stringAsArray as $fk => $fv) {
			echo $fv . (isset($indexOfAddSpace[$fk])?" ":"");
		}
	} else {
		echo $inputString;
    }
}

?>


Alice and Bob play the following game. Alice has a set $$$S$$$ of disjoint ranges of integers, initially containing only one range $$$[1, n]$$$. In one turn, Alice picks a range $$$[l, r]$$$ from the set $$$S$$$ and asks Bob to pick a number in the range. Bob chooses a number $$$d$$$ ($$$l \le d \le r$$$). Then Alice removes $$$[l, r]$$$ from $$$S$$$ and puts into the set $$$S$$$ the range $$$[l, d - 1]$$$ (if $$$l \le d - 1$$$) and the range $$$[d + 1, r]$$$ (if $$$d + 1 \le r$$$). The game ends when the set $$$S$$$ is empty. We can show that the number of turns in each game is exactly $$$n$$$.After playing the game, Alice remembers all the ranges $$$[l, r]$$$ she picked from the set $$$S$$$, but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers $$$d$$$ from Alice's ranges, and so he asks you for help with your programming skill.Given the list of ranges that Alice has picked ($$$[l, r]$$$), for each range, help Bob find the number $$$d$$$ that Bob has picked.We can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$). Each of the next $$$n$$$ lines contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le n$$$), denoting the range $$$[l, r]$$$ that Alice picked at some point. Note that the ranges are given in no particular order. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$, and the ranges for each test case are from a valid game.

For each test case print $$$n$$$ lines. Each line should contain three integers $$$l$$$, $$$r$$$, and $$$d$$$, denoting that for Alice's range $$$[l, r]$$$ Bob picked the number $$$d$$$. You can print the lines in any order. We can show that the answer is unique. It is not required to print a new line after each test case. The new lines in the output of the example are for readability only.

NoteIn the first test case, there is only 1 range $$$[1, 1]$$$. There was only one range $$$[1, 1]$$$ for Alice to pick, and there was only one number $$$1$$$ for Bob to pick.In the second test case, $$$n = 3$$$. Initially, the set contains only one range $$$[1, 3]$$$.   Alice picked the range $$$[1, 3]$$$. Bob picked the number $$$1$$$. Then Alice put the range $$$[2, 3]$$$ back to the set, which after this turn is the only range in the set.  Alice picked the range $$$[2, 3]$$$. Bob picked the number $$$3$$$. Then Alice put the range $$$[2, 2]$$$ back to the set.  Alice picked the range $$$[2, 2]$$$. Bob picked the number $$$2$$$. The game ended. In the fourth test case, the game was played with $$$n = 5$$$. Initially, the set contains only one range $$$[1, 5]$$$. The game's turn is described in the following table.  Game turnAlice's picked rangeBob's picked numberThe range set afterBefore the game start$$$ \{ [1, 5] \} $$$1$$$[1, 5]$$$$$$3$$$$$$ \{ [1, 2], [4, 5] \}$$$2$$$[1, 2]$$$$$$1$$$$$$ \{ [2, 2], [4, 5] \} $$$3$$$[4, 5]$$$$$$5$$$$$$ \{ [2, 2], [4, 4] \} $$$4$$$[2, 2]$$$$$$2$$$$$$ \{ [4, 4] \} $$$5$$$[4, 4]$$$$$$4$$$$$$ \{ \} $$$ (empty set)

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $segments = [];

  for($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    $segments[] = [$l, $r];

    $ar[$l][$r] = 0;
  }

  foreach($segments as $segment)
  {
    $l = $segment[0];
    $r = $segment[1];

    if($l == $r)
    {
      echo $l." ".$r." ".$l."\n";
      continue;
    }

    for($d = $l; $d<=$r; $d++)
    {
      $saveD = true;

      if($d > $l && !isset($ar[$l][$d-1]))
        $saveD = false;

      if($d < $r && !isset($ar[$d+1][$r]))
        $saveD = false;

      if($saveD)
      {
        echo $l." ".$r." ".$d."\n";
        break;
      }
    }
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $segments = [];

  for($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    $segments[] = [$l, $r];

    $ar[$l][$r] = 0;
  }

  foreach($segments as $segment)
  {
    $l = $segment[0];
    $r = $segment[1];

    if($l == $r)
    {
      echo $l." ".$r." ".$l."\n";
      continue;
    }

    for($d = $l; $d<=$r; $d++)
    {
      $saveD = true;

      if($d > 1 && !isset($ar[$l][$d-1]))
        $saveD = false;

      if($d < $r && !isset($ar[$d+1][$r]))
        $saveD = false;

      if($saveD)
      {
        echo $l." ".$r." ".$d."\n";
        break;
      }
    }
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $segments = [];

  for($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    $segments[] = [$l, $r];

    $ar[$l][$r] = 0;
  }

  foreach($segments as $segment)
  {
    $l = $segment[0];
    $r = $segment[1];

    if($l == $r)
    {
      echo $l." ".$r." ".$l."\n";
      continue;
    }

    for($d = $l; $d<=$r; $d++)
    {
      $saveD = false;

      if($d > 1 && isset($ar[$l][$d-1]))
        $saveD = true;

      if($d < $r && isset($ar[$d+1][$r]))
        $saveD = true;

      if($saveD)
      {
        echo $l." ".$r." ".$d."\n";
        break;
      }
    }
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $onePoints = [];

  for ($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    if($l == $r)
      $onePoints[] = $l;

    $ar[] = [$l, $r];
  }

  usort($ar, function($a, $b){
    return $a[1] - $a[0] < $b[1] - $b[0];
  });

  //var_dump($ar);

  for($key = 0; $key < count($ar); $key++)
  {
    $item = $ar[$key];
    $next = $ar[$key + 1];

    if($next[0] == $next[1])
    {
      if(in_array($item[0], $onePoints) && in_array($item[1], $onePoints) && $item[0] != $item[1])
        $out[$item[0]+1] = $item;
      else if(in_array($item[0], $onePoints))
      {
        //var_dump($item);
        $out[$item[1]] = $item;
      }
      else if(in_array($item[1], $onePoints))
        $out[$item[0]] = $item;
    } else if($item[0] == $item[1])
    {
      $out[$item[0]] = $item;
    }
    else if(in_array($item[0], $onePoints))
    {
      if($item[0]+1 != $next[1])
        $out[$item[0]+1] = $item;
      else
        $out[$item[1]] = $item;

    }
    else if(in_array($item[1], $onePoints))
    {
      $out[$item[0]] = $item;
    }
    else if($item[0] == $next[0])
    {
      $out[$next[1] + 1] = $item;
    }
    else if($item[1] == $next[1])
    {
      $out[$next[0] - 1] = $item;
    }
  }

  //var_dump($ar);

  foreach ($out as $number => $v) {
    echo $v[0]." ".$v[1]." ".$number."\n";
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $onePoints = [];

  for ($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    if($l == $r)
      $onePoints[] = $l;

    $ar[] = [$l, $r];
  }

  usort($ar, function($a, $b){
    return $a[1] - $a[0] < $b[1] - $b[0];
  });

  //var_dump($ar);

  for($key = 0; $key < count($ar); $key++)
  {
    $item = $ar[$key];
    $next = $ar[$key + 1];

    if($next[0] == $next[1])
    {
      if(in_array($item[0], $onePoints) && in_array($item[1], $onePoints) && $item[0] != $item[1])
        $out[$item[0]+1] = $item;
      else if(in_array($item[0], $onePoints))
        $out[$item[1]] = $item;
      else if(in_array($item[1], $onePoints))
        $out[$item[0]] = $item;
    } else if($item[0] == $item[1])
    {
      $out[$item[0]] = $item;
    }
    else if(in_array($item[0], $onePoints))
    {
      $out[$item[0]+1] = $item;
    }
    else if(in_array($item[1], $onePoints))
    {
      $out[$item[0]] = $item;
    }
    else if($item[0] == $next[0])
    {
      $out[$next[1] + 1] = $item;
    }
    else if($item[1] == $next[1])
    {
      $out[$next[0] - 1] = $item;
    }
  }

  foreach ($out as $number => $v) {
    echo $v[0]." ".$v[1]." ".$number."\n";
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $onePoints = [];

  for ($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    if($l == $r)
      $onePoints[] = $l;

    $ar[] = [$l, $r];
  }

  usort($ar, function($a, $b){
    return $a[1] - $a[0] < $b[1] - $b[0];
  });

  for($key = 0; $key < count($ar); $key++)
  {
    $item = $ar[$key];
    $next = $ar[$key + 1];

    if($next[0] == $next[1])
    {
      if(in_array($item[0], $onePoints))
        $out[$item[1]] = $item;
      else if(in_array($item[1], $onePoints))
        $out[$item[0]] = $item;
    } else if($item[0] == $item[1])
    {
      $out[$item[0]] = $item;
    }
    else if(in_array($item[0], $onePoints))
    {
      $out[$item[0]+1] = $item;
    }
    else if(in_array($item[1], $onePoints))
    {
      $out[$item[0]] = $item;
    }
    else if($item[0] == $next[0])
    {
      $out[$next[1] + 1] = $item;
    }
    else if($item[1] == $next[1])
    {
      $out[$next[0] - 1] = $item;
    }
  }

  foreach ($out as $number => $v) {
    echo $v[0]." ".$v[1]." ".$number."\n";
  }

  //echo "\n";
}

?>

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

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

for($j = 0; $j < $t; $j++)
{
  $n = trim(fgets($file));
  $ar = [];
  $out = [];
  $onePoints = [];

  for ($i=0; $i < $n; $i++)
  {
    list($l, $r) = explode(" ", trim(fgets($file)));

    if($l == $r)
      $onePoints[] = $l;

    $ar[] = [$l, $r];
  }

  usort($ar, function($a, $b){
    return $a[1] - $a[0] < $b[1] - $b[0];
  });

  for($key = 0; $key < count($ar); $key++)
  {
    $item = $ar[$key];
    $next = $ar[$key + 1];

    if($item[0] == $item[1])
    {
      $out[$item[0]] = $item;
    }
    else if(in_array($item[0], $onePoints))
    {
      $out[$item[0]+1] = $item;
    }
    else if(in_array($item[1], $onePoints))
    {
      $out[$item[0]] = $item;
    }
    else if($item[0] == $next[0])
    {
      $out[$next[1] + 1] = $item;
    }
    else if($item[1] == $next[1])
    {
      $out[$next[0] - 1] = $item;
    }
  }

  foreach ($out as $number => $v) {
    echo $v[0]." ".$v[1]." ".$number."\n";
  }

  //echo "\n";
}

?>


Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.Your house has $$$n$$$ rooms. In the $$$i$$$-th room you can install at most $$$c_i$$$ heating radiators. Each radiator can have several sections, but the cost of the radiator with $$$k$$$ sections is equal to $$$k^2$$$ burles.Since rooms can have different sizes, you calculated that you need at least $$$sum_i$$$ sections in total in the $$$i$$$-th room. For each room calculate the minimum cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

The first line contains single integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of rooms. Each of the next $$$n$$$ lines contains the description of some room. The $$$i$$$-th line contains two integers $$$c_i$$$ and $$$sum_i$$$ ($$$1 \le c_i, sum_i \le 10^4$$$) — the maximum number of radiators and the minimum total number of sections in the $$$i$$$-th room, respectively.

For each room print one integer — the minimum possible cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

NoteIn the first room, you can install only one radiator, so it's optimal to use the radiator with $$$sum_1$$$ sections. The cost of the radiator is equal to $$$(10^4)^2 = 10^8$$$.In the second room, you can install up to $$$10^4$$$ radiators, but since you need only one section in total, it's optimal to buy one radiator with one section.In the third room, there $$$7$$$ variants to install radiators: $$$[6, 0]$$$, $$$[5, 1]$$$, $$$[4, 2]$$$, $$$[3, 3]$$$, $$$[2, 4]$$$, $$$[1, 5]$$$, $$$[0, 6]$$$. The optimal variant is $$$[3, 3]$$$ and it costs $$$3^2+ 3^2 = 18$$$.


Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.First of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe.

In first line there is one integer n (1 ≤ n ≤ 2·105) — number of cafes indices written by Vlad. In second line, n numbers a1, a2, ..., an (0 ≤ ai ≤ 2·105) are written — indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted.

Print one integer — index of the cafe that Vlad hasn't visited for as long as possible.

NoteIn first test, there are three cafes, and the last visits to cafes with indices 1 and 2 were after the last visit to cafe with index 3; so this cafe is the answer. In second test case, there are also three cafes, but with indices 1, 2 and 4. Cafes with indices 1 and 4 were visited after the last visit of cafe with index 2, so the answer is 2. Note that Vlad could omit some numbers while numerating the cafes.


Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $$$(0,0)$$$ to $$$(x,0)$$$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its $$$n$$$ favorite numbers: $$$a_1, a_2, \ldots, a_n$$$. What is the minimum number of hops Rabbit needs to get from $$$(0,0)$$$ to $$$(x,0)$$$? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination.Recall that the Euclidean distance between points $$$(x_i, y_i)$$$ and $$$(x_j, y_j)$$$ is $$$\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}$$$.For example, if Rabbit has favorite numbers $$$1$$$ and $$$3$$$ he could hop from $$$(0,0)$$$ to $$$(4,0)$$$ in two hops as shown below. Note that there also exists other valid ways to hop to $$$(4,0)$$$ in $$$2$$$ hops (e.g. $$$(0,0)$$$ $$$\rightarrow$$$ $$$(2,-\sqrt{5})$$$ $$$\rightarrow$$$ $$$(4,0)$$$).    Here is a graphic for the first example. Both hops have distance $$$3$$$, one of Rabbit's favorite numbers. In other words, each time Rabbit chooses some number $$$a_i$$$ and hops with distance equal to $$$a_i$$$ in any direction he wants. The same number can be used multiple times.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Next $$$2t$$$ lines contain test cases — two lines per test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le x \le 10^9$$$)  — the number of favorite numbers and the distance Rabbit wants to travel, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$)  — Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all the test cases will not exceed $$$10^5$$$.

For each test case, print a single integer — the minimum number of hops needed.

NoteThe first test case of the sample is shown in the picture above. Rabbit can hop to $$$(2,\sqrt{5})$$$, then to $$$(4,0)$$$ for a total of two hops. Each hop has a distance of $$$3$$$, which is one of his favorite numbers.In the second test case of the sample, one way for Rabbit to hop $$$3$$$ times is: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(4,0)$$$ $$$\rightarrow$$$ $$$(8,0)$$$ $$$\rightarrow$$$ $$$(12,0)$$$.In the third test case of the sample, Rabbit can hop from $$$(0,0)$$$ to $$$(5,0)$$$.In the fourth test case of the sample, Rabbit can hop: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(5,10\sqrt{2})$$$ $$$\rightarrow$$$ $$$(10,0)$$$.

<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAnswer = 0;
    $bFlag = false;
    $aTest = [];
    foreach ($aArray as $sK => $sV) {
        $aTest[] = $sV;
    }
    foreach ($aTest as $sK => $sV) {
        if ($sV == $b) {
            $iAnswer = 1;
            $bFlag = true;
            break;
        }
    }
    if (!$bFlag) {
        $iAnswer = max($aTest);
        if ($b < $iAnswer) {
            $iAnswer = 2;
            $bFlag = true;
        }
    }
    if ($bFlag) {
        echo $iAnswer ."\n";
    } else {
        echo ceil($b/$iAnswer) ."\n";
    }
}

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       if (in_array($x, $ar)) {
            echo "1\n";
        } else {
            $max = max($ar);
            if($x < $max) {
                $n = 2;
            } else {
                $n = ceil($x / $max);
            }
             echo $n ."\n";
        }

    }

<?php
list($m) = explode(' ', trim(fgets(STDIN)));
for($k = 0; $k < $m; $k++) {
    list($a,$b) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAnswer = 0;
    $bFlag = false;
    $aTest = [];
    foreach ($aArray as $sK => $sV) {
        $aTest[] = $sV;
    }
    foreach ($aTest as $sK => $sV) {
        if ($sK == $b) {
            $iAnswer = 1;
            $bFlag = true;
            break;
        }
    }
    $iAnswer = max($aTest);
    if ($b < $iAnswer) {
        $iAnswer = 2;
        $bFlag = true;
    }
    if ($bFlag) {
        echo $iAnswer ."\n";
    } else {
        echo ceil($b/$iAnswer) ."\n";
    }
}

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       arsort($ar);
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
            if($count > $x) {
                if($j == 0 ){
                    $j++;
                }
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;

            $n1 =ceil($s / $max);
            echo $n + $n1."\n";
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       if (in_array($x, $ar)) {
            echo "1\n";
        } else {
            arsort($ar);
            for($j=0; $j<$n; $j++) {
                 $count +=$ar[$j];
                 if($count == $x) {
                     $n = $j+1;
                        break;
                }
                if($count > $x) {
                    if($j == 0 ){
                        $j++;
                    }
                     $n = $j+1;
                        break;
                }
                 if($ar[$j] > $max) {
                     $max = $ar[$j];
                 }
            }

            if($count >= $x) {
                echo  $n."\n";
            } else {
                $s = $x - $count;
                if($s < $max) {
                    $n = $n + 2;
                }elseif($s == $max) {
                   $n = $n + 1;
                } else {
                    $n1 = ceil($s / $max);
                    $n = $n + $n1;
                }
                 echo $n ."\n";

            }
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
       arsort($ar);
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count >= $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo $n."\n";
        } else {
            $s = $x - $count;

            $n1 =ceil($s / $max);
            echo $n + $n1."\n";
        }

    }

<?php
    $test = trim(fgets(STDIN));
    for($i=0; $i<$test; $i++) {
        list($n, $x) =  explode(' ', trim(fgets(STDIN)));
        $ar =  explode(' ', trim(fgets(STDIN)));
       $count = 0;
       $max = $ar[0];
        for($j=0; $j<$n; $j++) {
             $count +=$ar[$j];
             if($count == $x) {
                 $n = $j+1;
                    break;
            }
             if($ar[$j] > $max) {
                 $max = $ar[$j];
             }
        }

        if($count >= $x) {
            echo  $n."\n";
        } else {
            $s = $x - $count;
            if($s < $max) {
                $n = $n + 2;
            }elseif($s == $max) {
               $n = $n + 1;
            } else {
                $n1 = ceil($s / $max);
                $n = $n + $n1;
            }
             echo $n ."\n";

        }

    }


Zane the wizard is going to perform a magic show shuffling the cups.There are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i.The problematic bone is initially at the position x = 1. Zane will confuse the audience by swapping the cups k times, the i-th time of which involves the cups at the positions x = ui and x = vi. If the bone happens to be at the position where there is a hole at any time, it will fall into the hole onto the ground and will not be affected by future swapping operations.Do not forget that Zane is a wizard. When he swaps the cups, he does not move them ordinarily. Instead, he teleports the cups (along with the bone, if it is inside) to the intended positions. Therefore, for example, when he swaps the cup at x = 4 and the one at x = 6, they will not be at the position x = 5 at any moment during the operation.  Zane’s puppy, Inzane, is in trouble. Zane is away on his vacation, and Inzane cannot find his beloved bone, as it would be too exhausting to try opening all the cups. Inzane knows that the Codeforces community has successfully helped Zane, so he wants to see if it could help him solve his problem too. Help Inzane determine the final position of the bone.

The first line contains three integers n, m, and k (2 ≤ n ≤ 106, 1 ≤ m ≤ n, 1 ≤ k ≤ 3·105) — the number of cups, the number of holes on the table, and the number of swapping operations, respectively. The second line contains m distinct integers h1, h2, ..., hm (1 ≤ hi ≤ n) — the positions along the x-axis where there is a hole on the table. Each of the next k lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the positions of the cups to be swapped.

Print one integer — the final position along the x-axis of the bone.

NoteIn the first sample, after the operations, the bone becomes at x = 2, x = 5, x = 7, and x = 1, respectively.In the second sample, after the first operation, the bone becomes at x = 2, and falls into the hole onto the ground.

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

<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$hh = array();
foreach($holes as $hole)
{
	$hh[$hole] = true;
}

if(@isset($hh[1]) && $hh[1]) {
	$nswaps = 0;
}

$pos = 1;

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

	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos && $t != $pos)
		continue;

	$pos = ($pos == $t) ? $f : $t;

	if(@isset($hh[$pos]) && $hh[$pos])
		break;
}

echo $pos . PHP_EOL;

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

<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$pos = 1;

for($i = 0; $i < $nswaps; $i++)
{
	if(in_array($pos, $holes))
		break;

	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos)
		continue;

	$pos = $t;

}

echo $pos . PHP_EOL;

<?php

list($ncups, $nholes, $nswaps) = explode(" ", trim(fgets(STDIN)));
$holes = explode(" ", trim(fgets(STDIN)));

$pos = 1;

for($i = 0; $i < $nswaps; $i++)
{
	list($f, $t) = explode(" ", trim(fgets(STDIN)));

	if($f != $pos)
		continue;

	$pos = $t;

	if(in_array($pos, $holes))
		break;
}

echo $pos . PHP_EOL;


Let's call an undirected graph $$$G = (V, E)$$$ relatively prime if and only if for each edge $$$(v, u) \in E$$$  $$$GCD(v, u) = 1$$$ (the greatest common divisor of $$$v$$$ and $$$u$$$ is $$$1$$$). If there is no edge between some pair of vertices $$$v$$$ and $$$u$$$ then the value of $$$GCD(v, u)$$$ doesn't matter. The vertices are numbered from $$$1$$$ to $$$|V|$$$.Construct a relatively prime graph with $$$n$$$ vertices and $$$m$$$ edges such that it is connected and it contains neither self-loops nor multiple edges.If there exists no valid graph with the given number of vertices and edges then output "Impossible".If there are multiple answers then print any of them.

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^5$$$) — the number of vertices and the number of edges.

If there exists no valid graph with the given number of vertices and edges then output "Impossible". Otherwise print the answer in the following format: The first line should contain the word "Possible". The $$$i$$$-th of the next $$$m$$$ lines should contain the $$$i$$$-th edge $$$(v_i, u_i)$$$ of the resulting graph ($$$1 \le v_i, u_i \le n, v_i \neq u_i$$$). For each pair $$$(v, u)$$$ there can be no more pairs $$$(v, u)$$$ or $$$(u, v)$$$. The vertices are numbered from $$$1$$$ to $$$n$$$. If there are multiple answers then print any of them.

NoteHere is the representation of the graph from the first example:


Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some "extra" time if for its running time, a seconds, an inequality 2a ≤ v holds.As a result, Valera decided to set v seconds TL, that the following conditions are met:  v is a positive integer;  all correct solutions pass the system testing;  at least one correct solution passes the system testing with some "extra" time;  all wrong solutions do not pass the system testing;  value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist.

The first line contains two integers n, m (1 ≤ n, m ≤ 100). The second line contains n space-separated positive integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1, b2, ..., bm (1 ≤ bi ≤ 100) — the running time of each of m wrong solutions in seconds.

If there is a valid TL value, print it. Otherwise, print -1.

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
rsort($c);
sort($d);
if($c[0] < $d[0])
{
    if(($c[count($c) - 1] * 2) < $d[0])
    {
        print max($c[count($c) - 1] * 2, $c[0]);
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php

list($n, $m) = explode(' ', getline());

$n = intval($n);
$m = intval($m);

$a = explode(' ', getline());
$b = explode(' ', getline());

init_array($a, $n);
init_array($b, $m);

$lower = max($a);
$upper = min($b);

$answer = -1;

while ($lower < $upper) {
  $extra = false;
  for ($i = 0; $i < $n; $i ++) {
    if ($a[$i] *2 <= $lower) {
      $extra = true;
      break;
    }
  }
  if ($extra) {
    $answer = $lower;
    break;
  }
  $lower ++;
}

print $answer;

function init_array(&$array, $size) {
  for ($i = 0; $i < $size; $i ++) {
    $array[$i] = intval($array[$i]);
  }
}

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

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($e[0] < $f[0])
{
    if(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($a == "1")
{
    print "-1";
}
else
{
    if($e[0] < $f[0])
    {
        if(($e[count($e) - 1] * 2) <= $e[0])
        {
            print $e[0];
        }
        else
        {
            print "-1";
        }
    }
    else
    {
        print "-1";
    }
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
if($e[0] < $f[0])
{
    if($a == "1")
    {
        $g = $c[0] * 2;
        if($g < $f[count($f) - 1])
        {
            print $g;
        }
        else
        {
            print "-1";
        }
    }
    elseif(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$d = explode(" ", trim(fgets(STDIN)));
$e = $c;
rsort($e);
$f = $d;
sort($f);
$h = array_unique($c);
if($e[0] < $f[0])
{
    if(($a == "1") || (count($h) == "1"))
    {
        $g = $c[0] * 2;
        if($g < $f[count($f) - 1])
        {
            print $g;
        }
        else
        {
            print "-1";
        }
    }
    elseif(($e[count($e) - 1] * 2) <= $e[0])
    {
        print $e[0];
    }
    else
    {
        print "-1";
    }
}
else
{
    print "-1";
}
?>

<?php

list($n,$m) = explode(" ",trim(fgets(STDIN)));
$V = explode(" ",trim(fgets(STDIN)));
$B = explode(" ",trim(fgets(STDIN)));

$p0 = min($V);
$p1 = max($V);
$p2 = min($B);

if (2*$p0<$p2){
	if ($p1 > 2*$p0){
		echo $p1;
	} else {
		echo (2*$p0);
	}
} else {
	echo "-1";
}

?>


One warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize — big pink plush panda. The king is not good at shooting, so he invited you to help him.The shooting gallery is an infinite vertical plane with Cartesian coordinate system on it. The targets are points on this plane. Each target is described by it's coordinates xi, and yi, by the time of it's appearance ti and by the number pi, which gives the probability that Copa hits this target if he aims at it.A target appears and disappears instantly, so Copa can hit the target only if at the moment ti his gun sight aimed at (xi, yi). Speed of movement of the gun sight on the plane is equal to 1. Copa knows all the information about the targets beforehand (remember, he is a king!). He wants to play in the optimal way, which maximizes the expected value of the amount of hit targets. He can aim at any target at the moment 0.

The first line contains integer n (1 ≤ n ≤ 1000) — amount of targets in the shooting gallery. Then n lines follow, each describing one target. Each description consists of four numbers xi, yi, ti, pi (where xi, yi, ti — integers,  - 1000 ≤ xi, yi ≤ 1000, 0 ≤ ti ≤ 109, real number pi is given with no more than 6 digits after the decimal point, 0 ≤ pi ≤ 1). No two targets may be at the same point.

Output the maximum expected value of the amount of targets that was shot by the king. Your answer will be accepted if it differs from the correct answer by not more than 10 - 6.

<?php

$input;
$buffer = Array();
init();

function getNext() {
  global $buffer;
  if( count($buffer) > 0 ) {
    return array_shift($buffer);
  }
  $line = preg_replace('/[\\r\\n]+$/', '', getLine());
  $buffer = preg_split('/\\s+/', $line);
  return getNext();
}

function getLine() {
  global $input;
  return fgets($input, 4096);
}

function init() {
  global $input;
  $input = fopen("php://stdin", "r");
}

function main() {

  $n = intval(getNext());
  $keys = Array();
  for( $i = 0; $i < $n; ++$i ) {
    $keys[] = Array(floatval(getNext()), floatval(getNext()), floatval(getNext()), floatval(getNext()));
  }

  for( $i = 0; $i < $n; ++$i ) {
    for( $j = $i + 1; $j < $n; ++$j ) {
      if( $keys[$i][2] > $keys[$j][2] ) {
        $tmp = $keys[$i];
        $keys[$i] = $keys[$j];
        $keys[$j] = $tmp;
      }
    }
  }

  $ret = 0.0;
  $dp = Array();
  for( $i = 0; $i < $n; ++$i ) {
    $max = $keys[$i][3];
    for( $j = 0; $j < $i; ++$j ) {
      $d = dist(($keys[$i][0] - $keys[$j][0]), ($keys[$i][1] - $keys[$j][1]));
      $t = $keys[$i][2] - $keys[$j][2];
      if( $d <= $t ) {
        $max = max($max, $dp[$j] + $keys[$i][3]);
      }
    }
    $dp[] = $max;
    $ret = max($ret, $max);
  }

  print $ret . "\n";

}

function dist($x, $y) {
  return sqrt($x * $x + $y * $y);
}

main();

?>


Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.The area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Grasshopper stops immediately if it jumps out of the strip. Now Artem wants to find out if this will ever happen.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — length of the strip.  Next line contains a string of length n which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains n integers di (1 ≤ di ≤ 109) — the length of the jump from the i-th cell.

Print "INFINITE" (without quotes) if grasshopper will continue his jumps forever. Otherwise print "FINITE" (without quotes).

NoteIn the first sample grasshopper starts from the first cell and jumps to the right on the next cell. When he is in the second cell he needs to jump two cells left so he will jump out of the strip.Second sample grasshopper path is 1 - 3 - 2 - 3 - 2 - 3 and so on. The path is infinite.


Initially, you have the array $$$a$$$ consisting of one element $$$1$$$ ($$$a = [1]$$$).In one move, you can do one of the following things:  Increase some (single) element of $$$a$$$ by $$$1$$$ (choose some $$$i$$$ from $$$1$$$ to the current length of $$$a$$$ and increase $$$a_i$$$ by one);  Append the copy of some (single) element of $$$a$$$ to the end of the array (choose some $$$i$$$ from $$$1$$$ to the current length of $$$a$$$ and append $$$a_i$$$ to the end of the array). For example, consider the sequence of five moves:  You take the first element $$$a_1$$$, append its copy to the end of the array and get $$$a = [1, 1]$$$.  You take the first element $$$a_1$$$, increase it by $$$1$$$ and get $$$a = [2, 1]$$$.  You take the second element $$$a_2$$$, append its copy to the end of the array and get $$$a = [2, 1, 1]$$$.  You take the first element $$$a_1$$$, append its copy to the end of the array and get $$$a = [2, 1, 1, 2]$$$.  You take the fourth element $$$a_4$$$, increase it by $$$1$$$ and get $$$a = [2, 1, 1, 3]$$$. Your task is to find the minimum number of moves required to obtain the array with the sum at least $$$n$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the lower bound on the sum of the array.

For each test case, print the answer: the minimum number of moves required to obtain the array with the sum at least $$$n$$$.

<?php
    $j = trim(fgets(STDIN));
    for($i = 0; $i < $j; $i++){
        $r = 0;
        //$a = explode(" ", trim(fgets(STDIN)));
        $a = trim(fgets(STDIN));
        $r = floor(sqrt($a));
        $n = $r - 1;
        $n += ceil($a / $r) - 1;

        if($a <= 1){
            echo "0\n";
        } else {
            echo $n."\n";
        }
    }

?>


There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip candies, she eats them in a row). Bob can eat any number of candies from the right (he can't skip candies, he eats them in a row). Of course, if Alice ate a candy, Bob can't eat it (and vice versa).They want to be fair. Their goal is to eat the same total weight of candies. What is the most number of candies they can eat in total?

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the number of candies on the table. The second line of each test case contains $$$n$$$ integers $$$w_1, w_2, \dots, w_n$$$ ($$$1 \leq w_i \leq 10^4$$$) — the weights of candies from left to right. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$.

For each test case, print a single integer — the maximum number of candies Alice and Bob can eat in total while satisfying the condition.

NoteFor the first test case, Alice will eat one candy from the left and Bob will eat one candy from the right. There is no better way for them to eat the same total amount of weight. The answer is $$$2$$$ because they eat two candies in total.For the second test case, Alice will eat the first three candies from the left (with total weight $$$7$$$) and Bob will eat the first three candies from the right (with total weight $$$7$$$). They cannot eat more candies since all the candies have been eaten, so the answer is $$$6$$$ (because they eat six candies in total).For the third test case, there is no way Alice and Bob will eat the same non-zero weight so the answer is $$$0$$$.For the fourth test case, Alice will eat candies with weights $$$[7, 3, 20]$$$ and Bob will eat candies with weights $$$[10, 8, 11, 1]$$$, they each eat $$$30$$$ weight. There is no better partition so the answer is $$$7$$$.


Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tigers also stood together. The trainer swaps the animals in pairs not to create a mess. He orders two animals to step out of the circle and swap places. As hamsters feel highly uncomfortable when tigers are nearby as well as tigers get nervous when there's so much potential prey around (consisting not only of hamsters but also of yummier spectators), the trainer wants to spend as little time as possible moving the animals, i.e. he wants to achieve it with the minimal number of swaps. Your task is to help him.

The first line contains number n (2 ≤ n ≤ 1000) which indicates the total number of animals in the arena. The second line contains the description of the animals' positions. The line consists of n symbols "H" and "T". The "H"s correspond to hamsters and the "T"s correspond to tigers. It is guaranteed that at least one hamster and one tiger are present on the arena. The animals are given in the order in which they are located circle-wise, in addition, the last animal stands near the first one.

Print the single number which is the minimal number of swaps that let the trainer to achieve his goal.

NoteIn the first example we shouldn't move anybody because the animals of each species already stand apart from the other species. In the second example you may swap, for example, the tiger in position 2 with the hamster in position 5 and then — the tiger in position 9 with the hamster in position 7.

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    for($x = 0; $x < $a; $x++)
    {
        if($b[0] != $b[$a - 1])
        {
            array_unshift($b, $b[$a - 1]);
            unset($b[$a]);
        }
        else
        {
            break;
        }
    }
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    $h = array();
    for($x = 1; $x <= $a - count($d) + 1; $x++)
    {
        $f = range($x, count($d) + $x - 1);
        $g = array_intersect($d, $f);
        array_push($h, count($g));
    }
    $k = array();
    for($x = 1; $x <= $a - count($e) + 1; $x++)
    {
        $i = range($x, count($e) + $x - 1);
        $j = array_diff($e, $i);
        array_push($k, count($j));
    }
    sort($h);
    sort($k);
    print min($h[0], $k[0]);
}
?>

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    for($x = 0; $x < $a; $x++)
    {
        if($b[0] != $b[$a - 1])
        {
            array_unshift($b, $b[$a - 1]);
            unset($b[$a]);
        }
        else
        {
            break;
        }
    }
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    $h = array();
    for($x = 1; $x <= $a - count($d) + 1; $x++)
    {
        $f = range($x, count($d) + $x - 1);
        $g = array_intersect($d, $f);
        array_push($h, count($g));
    }
    $k = array();
    for($x = 1; $x <= $a - count($e) + 1; $x++)
    {
        $i = range($x, count($e) + $x - 1);
        $j = array_intersect($e, $i);
        array_push($k, count($j));
    }
    sort($h);
    sort($k);
    print min($h[0], $k[0]);
}
?>

<?php
$a = trim(fgets(STDIN));
$b = str_split(trim(fgets(STDIN)));
$c = array_unique($b);
if((count($c) == 1) || ($a == 2))
{
    print "0";
}
else
{
    $d = array();
    $e = array();
    for($x = 0; $x < $a; $x++)
    {
        if($b[$x] == "H")
        {
            array_push($d, $x + 1);
        }
        else
        {
            array_push($e, $x + 1);
        }
    }
    if(count($d) <= count($e))
    {
        $h = array();
        for($x = 1; $x <= $a - count($d) + 1; $x++)
        {
            $f = range($x, count($d) + $x - 1);
            $g = array_diff($d, $f);
            array_push($h, count($g));
        }
        sort($h);
        print $h[0];
    }
    else
    {
        $k = array();
        for($x = 1; $x <= $a - count($e) + 1; $x++)
        {
            $i = range($x, count($e) + $x - 1);
            $j = array_diff($e, $i);
            array_push($k, count($j));
        }
        sort($k);
        print $k[0];
    }
}
?>


To stay woke and attentive during classes, Karen needs some coffee!  Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.Karen thinks that a temperature is admissible if at least k recipes recommend it.Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?

The first line of input contains three integers, n, k (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively. The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1 ≤ li ≤ ri ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive. The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.

NoteIn the first test case, Karen knows 3 recipes.  The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.  The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.  The third one recommends brewing the coffee between 97 and 99 degrees, inclusive. A temperature is admissible if at least 2 recipes recommend it.She asks 4 questions.In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.In the second test case, Karen knows 2 recipes.  The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.  The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees. A temperature is admissible if at least 1 recipe recommends it.In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.


Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors.

The first line contains a single integer n (1 ≤ n ≤ 105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0 ≤ hi ≤ 23; 0 ≤ mi ≤ 59), representing the time when the i-th person comes into the cafe.  Note that the time is given in the chronological order. All time is given within one 24-hour period.

Print a single integer — the minimum number of cashes, needed to serve all clients next day.

NoteIn the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away.In the second sample all visitors will come in different times, so it will be enough one cash.

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

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

<?php

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

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

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

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

<?php

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

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

$a = array();

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

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

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

<?php

function FindMinimumCash($visitors, $visiting_time){

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

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

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

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

    if(count($cash)>0){

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

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

echo FindMinimumCash($visitors, $visiting_time);

<?

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

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

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

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

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

echo max($a);

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

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

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

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

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

echo $min;

?>

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

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

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

    echo max(array_count_values($users));

?>

<?php

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

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

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

$a = array();

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

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

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

printf("%d", $max);

?>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

<?php

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

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

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

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

<?php

function FindMinimumCash($visitors, $visiting_time){

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

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

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

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

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

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

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

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

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

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

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

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

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

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

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

echo FindMinimumCash($visitors, $visiting_time);

<?php

function FindMinimumCash($visitors, $visiting_time){

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

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

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

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

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

echo FindMinimumCash($visitors, $visiting_time);

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

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

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

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

echo $min;

?>

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

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

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

    echo max(array_count_values($users));

?>


Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each box vertically down on the first wi stairs of the staircase, that is, the box covers stairs with numbers 1, 2, ..., wi. Each thrown box flies vertically down until at least one of the two following events happen:  the bottom of the box touches the top of a stair;  the bottom of the box touches the top of a box, thrown earlier. We only consider touching of the horizontal sides of stairs and boxes, at that touching with the corners isn't taken into consideration. Specifically, that implies that a box with width wi cannot touch the stair number wi + 1.You are given the description of the staircase and the sequence in which Dima threw the boxes at it. For each box, determine how high the bottom of the box after landing will be. Consider a box to fall after the previous one lands.

The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains a pair of integers wi, hi (1 ≤ wi ≤ n; 1 ≤ hi ≤ 109) — the size of the i-th thrown box. The numbers in the lines are separated by spaces.

Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

NoteThe first sample are shown on the picture.

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

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

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

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

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

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


Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:We will define the distance between two strings s and t of the same length consisting of digits zero and one as the number of positions i, such that si isn't equal to ti. As besides everything else Susie loves symmetry, she wants to find for two strings s and t of length n such string p of length n, that the distance from p to s was equal to the distance from p to t.It's time for Susie to go to bed, help her find such string p or state that it is impossible.

The first line contains string s of length n.  The second line contains string t of length n. The length of string n is within range from 1 to 105. It is guaranteed that both strings contain only digits zero and one.

Print a string of length n, consisting of digits zero and one, that meets the problem statement. If no such string exist, print on a single line "impossible" (without the quotes). If there are multiple possible answers, print any of them.

NoteIn the first sample different answers are possible, namely — 0010, 0011, 0110, 0111, 1000, 1001, 1100, 1101.


You are given n switches and m lamps. The i-th switch turns on some subset of the lamps. This information is given as the matrix a consisting of n rows and m columns where ai, j = 1 if the i-th switch turns on the j-th lamp and ai, j = 0 if the i-th switch is not connected to the j-th lamp.Initially all m lamps are turned off.Switches change state only from "off" to "on". It means that if you press two or more switches connected to the same lamp then the lamp will be turned on after any of this switches is pressed and will remain its state even if any switch connected to this lamp is pressed afterwards.It is guaranteed that if you push all n switches then all m lamps will be turned on.Your think that you have too many switches and you would like to ignore one of them. Your task is to say if there exists such a switch that if you will ignore (not use) it but press all the other n - 1 switches then all the m lamps will be turned on.

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 2000) — the number of the switches and the number of the lamps. The following n lines contain m characters each. The character ai, j is equal to '1' if the i-th switch turns on the j-th lamp and '0' otherwise. It is guaranteed that if you press all n switches all m lamps will be turned on.

Print "YES" if there is a switch that if you will ignore it and press all the other n - 1 switches then all m lamps will be turned on. Print "NO" if there is no such switch.