According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.You are given a jacket with n buttons. Determine if it is fastened in a right way.

The first line contains integer n (1 ≤ n ≤ 1000) — the number of buttons on the jacket. The second line contains n integers ai (0 ≤ ai ≤ 1). The number ai = 0 if the i-th button is not fastened. Otherwise ai = 1.

In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO".

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

<?php

$n = fgets(STDIN);
$buttons = explode( " ", fgets(STDIN) );

if( $n == 1 )
{
    if( $buttons[0] == 1 )
        echo "YES\n";
    else
        print "NO\n";
}
else{
    if( array_sum($buttons) + 1 == $n )
        print "YES\n";
    else
        print "NO\n";
}

?>

<?php

	$totalButton = readline("");
	$buttons = readline("");

	$buttons = explode(" ", $buttons);
	if($totalButton == 1) {
		if((int)$buttons[0] == 1) {
			echo "YES";
		} else {
			echo "NO";
		}
	} else {
		$count = 0;
		foreach($buttons as $button) {
			if((int)$button == 0) {
				$count += 1;
			}
		}
		if($count == 1) {
			echo "YES";
		} else {
			echo "NO";
		}
	}

?>

<?php
// Input
$in = 'php://stdin';
$input = fopen($in, "r");
$n = fgets($input);
$x = explode(" ", trim(fgets($input)));

// Your code here
//......
$count =0;
if($n==1)
{
    if($x[0]==1)
    {
        $count= 1;

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

            if($x[$i]==0)
            {
                $count++;
            }

    }
}

if($count!=1){
    echo 'NO';
}
else
    echo 'YES';

<?php
/**
 * Created by PhpStorm.
 * User: CPU11316-local
 * Date: 6/19/2019
 * Time: 1:45 PM
 */

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

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

function test($x,$n){
    sort($x);
    if ($x[$n-1] == 0) return false;
    if(array_sum($x) == $n-1) return true;
    if(count($x) == 1) return true;
    return false;
}

if (test($x,$n)){
    echo ("YES");
}
else echo ("NO");

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 1 ){
	echo $arr[0] ? "YES" : "NO";
	die;
}
$count = 0;
foreach ($arr as $number) {
	if($number == 1){
		continue;
	}elseif ($count > 0 )
	{
		echo "NO";die;
	}else {
		$count++;
	}
}
if($count == 0)
{
	echo "NO";
} else {
	echo "YES";
}

?>

<?php
$in = 'php://stdin';
$input = fopen($in, "r");
$n = fgets($input);
$a = explode(" ", trim(fgets($input)));
if ($n == 1) {
    if ($a[0] == 1)
        echo("YES");
    else
        echo("NO");
} else {
    $count = 0;
    for ($i = 0; $i < $n; $i++) {
        if ($a[$i] == 0) {
            $count++;
        }
    }
    if ($count == 1)
        echo("YES");
    else
        echo("NO");
}

<?php
  $n=fgets(STDIN);
  $counterz=0; $counterone=0;
 $arr=explode(" ",trim(fgets(STDIN)));
   for($i=0; $i<count($arr); $i++){
  if($arr[$i]==0) $counterz++;
   else if($arr[$i]==1) $counterone++;
}
 if($counterone==1&& $n==1) {echo "YES"; exit;}
 else if($counterz==1 && $n!=1){echo "YES"; exit;}
 echo"NO";
?>

<?
$stdin = fopen('php://stdin', 'r');
$n =  trim(fgets($stdin));
$buttons = explode(" ",trim(fgets($stdin)));

if(count($buttons)==1){
	if($buttons[0]==1){
		echo "YES";
	}else{
		echo "NO";
	}
}else{
	$r_cnt=0;
	foreach($buttons as $button){
		if($button==0){
			$r_cnt++;
			if($r_cnt>1){
				break;
			}
		}

	}
	if($r_cnt==1){
		echo "YES";
	}else{
		echo "NO";
	}
}

?>

<?php

	$totalButton = readline("");
	$buttons = readline("");

	$buttons = explode(" ", $buttons);
	if((int)$totalButton == 1) {
		if((int)$buttons[0] == 1) {
			echo "YES";
		} else {
			echo "NO";
		}
	} else {
		$count = 0;
		foreach($buttons as $button) {
			if((int)$button == 0) {
				$count += 1;
			}
		}
		if($count > 1) {
			echo "NO";
		} else {
			echo "YES";
		}
	}

?>

<?php

	$totalButton = readline("");
	$buttons = readline("");

	$buttons = explode(" ", $buttons);
	if($totalButton == 1) {
		if((int)$buttons[0] == 1) {
			echo "YES";
		} else {
			echo "NO";
		}
	} else {
		$count = 0;
		foreach($buttons as $button) {
			if((int)$button == 0) {
				$count += 1;
			}
		}
		if($count > 1) {
			echo "NO";
		} else {
			echo "YES";
		}
	}

?>

<?php
// Input
$in = 'php://stdin';
$input = fopen($in, "r");
$n = fgets($input);
$x = explode(" ", trim(fgets($input)));

// Your code here
//......
$count =0;
if($n==1)
{
    if($x[$i]==1)
    {
        $count= 1;

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

            if($x[$i]==0)
            {
                $count++;
            }

    }
}

if($count!=1){
    echo 'no';
}
else
    echo 'yes';

<?php
// Input
$in = 'php://stdin';
$input = fopen($in, "r");
$n = fgets($input);
$x = explode(" ", trim(fgets($input)));

// Your code here
//......
$count =0;
if($n==1)
{
    if($x[$i]==1)
    {
        $count= 1;

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

            if($x[$i]==0)
            {
                $count++;
            }

    }
}

if($count!=1){
    echo 'NO';
}
else
    echo 'YES';

<?php
/**
 * Created by PhpStorm.
 * User: CPU11316-local
 * Date: 6/19/2019
 * Time: 1:45 PM
 */

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

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

function test($x,$n){
    sort($x);
    if ($x[$n-1] == 0) return false;
    if(array_sum($x) >= $n-1) return true;
    return false;
}

if (test($x,$n)){
    echo ("YES");
}
else echo ("NO");

<?php
/**
 * Created by PhpStorm.
 * User: CPU11316-local
 * Date: 6/19/2019
 * Time: 1:45 PM
 */

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

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

function test($x,$n){
    sort($x);
    if ($x[$n-1] == 0) return false;
    if(array_sum($x) == $n-1) return true;
    return false;
}

if (test($x,$n)){
    echo ("YES");
}
else echo ("NO");

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 1 && $arr[0] == 0){
	echo "NO";die;
}
$count = 0;
foreach ($arr as $number) {
	if($number == 1){
		continue;
	}elseif ($count > 0 )
	{
		echo "NO";die;
	}else {
		$count++;
	}
}
echo "YES";
?>

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 1 && $arr[0] == 0){
	echo "NO";die;
}
$count = 0;
foreach ($arr as $number) {
	if($number == 1){
		continue;
	}elseif ($count > 0 )
	{
		echo "NO";die;
	}else {
		$count++;
	}
}
if($count == 0)
{
	echo "NO";
} else {
	echo "YES";
}

?>

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 0 && $arr[0] == 0){
	echo "NO";die;
}
$count = 0;
foreach ($arr as $key => $number) {
	if($number){
		continue;
	}
	if($count >0 )
	{
		echo "NO";die;
	}else{
		$count++;
	}
}
echo "YES";
?>

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 0 && $arr[0] == 0){
	echo "NO";die;
}
$count = 0;
foreach ($arr as $key => $number) {
	if($number == 1){
	}elseif ($count >0 )
	{
		echo "NO";die;
	}else {
		$count++;
	}
}
echo "YES";
?>

<?php
// http://codeforces.com/problemset/problem/691/A
$handle = fopen ("php://stdin", "r");
fscanf($handle, "%i",$n);
$arr_temp = fgets($handle);
$arrInput = explode(" ",$arr_temp);
$arr = array_map('intval', $arrInput);
if ( count($arr) == 0 && $arr[0] == 0){
	echo "NO";die;
}
$count = 0;
foreach ($arr as $key => $number) {
	if($number == 1){
		continue;
	}elseif ($count > 0 )
	{
		echo "NO";die;
	}else {
		$count++;
	}
}
echo "YES";
?>

<?php
  $n=trim(fgets(STDIN));
  $counterz=0;
  for($i=0; $i<$n; $i++){
    $x=trim(fgets(STDIN));
   if($x==0) $counterz++;
}
  if($counterz==0 && n==1) {echo "YES"; exit;}
 else if($counterz==1){echo "YES"; exit;}
 echo"NO";
?>

<?php
  $n=fgets(STDIN);
  $counterz=0; $counterone=0;
  for($i=0; $i<$n; $i++){
    $x=fgets(STDIN);
   if($x==0) $counterz++;
  if($x==1) $counterone++;
}
  if($counterone==1&& n==1) {echo "YES"; exit;}
 else if($counterz==1 && n!=1){echo "YES"; exit;}
 echo"NO";
?>

<?php
  $n=fgets(STDIN);
  $counterz=0; $counterone=0;
  for($i=0; $i<$n; $i++){
    $x=trim(fgets(STDIN));
   if($x==0) $counterz++;
  if($x==1) $counterone++;
}
  if($counterone==1&& $n==1) {echo "YES"; exit;}
 else if($counterz==1 && $n!=1){echo "YES"; exit;}
 echo"NO";
?>

<?php
  $n=fgets(STDIN);
  $counterz=0; $counterone=0;
  for($i=0; $i<$n; $i++){
    $x=fgets(STDIN);
   if($x==0) $counterz++;
  if($x==1) $counterone++;
}
  if($counterone==1&& $n==1) {echo "YES"; exit;}
 else if($counterz==1 && $n!=1){echo "YES"; exit;}
 echo"NO";
?>


People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.Alis is among these collectors. Right now she wants to get one of k-special tables. In case you forget, the table n × n is called k-special if the following three conditions are satisfied:  every integer from 1 to n2 appears in the table exactly once;  in each row numbers are situated in increasing order;  the sum of numbers in the k-th column is maximum possible. Your goal is to help Alice and find at least one k-special table of size n × n. Both rows and columns are numbered from 1 to n, with rows numbered from top to bottom and columns numbered from left to right.

The first line of the input contains two integers n and k (1 ≤ n ≤ 500, 1 ≤ k ≤ n) — the size of the table Alice is looking for and the column that should have maximum possible sum.

First print the sum of the integers in the k-th column of the required table. Next n lines should contain the description of the table itself: first line should contains n elements of the first row, second line should contain n elements of the second row and so on. If there are multiple suitable table, you are allowed to print any.


In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swaps — your task is to find any sequence that is no longer than n.

The first line of the input contains integer n (1 ≤ n ≤ 3000) — the number of array elements. The second line contains elements of array: a0, a1, ..., an - 1 ( - 109 ≤ ai ≤ 109), where ai is the i-th element of the array. The elements are numerated from 0 to n - 1 from left to right. Some integers may appear in the array more than once.

In the first line print k (0 ≤ k ≤ n) — the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0 ≤ i, j ≤ n - 1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are performed in the order they appear in the output, from the first to the last. It is allowed to print i = j and swap the same pair of elements multiple times. If there are multiple answers, print any of them. It is guaranteed that at least one answer exists.


The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).You are given a sequence $$$a$$$ consisting of $$$n$$$ integers.You are making a sequence of moves. During each move you must take either the leftmost element of the sequence or the rightmost element of the sequence, write it down and remove it from the sequence. Your task is to write down a strictly increasing sequence, and among all such sequences you should take the longest (the length of the sequence is the number of elements in it).For example, for the sequence $$$[1, 2, 4, 3, 2]$$$ the answer is $$$4$$$ (you take $$$1$$$ and the sequence becomes $$$[2, 4, 3, 2]$$$, then you take the rightmost element $$$2$$$ and the sequence becomes $$$[2, 4, 3]$$$, then you take $$$3$$$ and the sequence becomes $$$[2, 4]$$$ and then you take $$$4$$$ and the sequence becomes $$$[2]$$$, the obtained increasing sequence is $$$[1, 2, 3, 4]$$$).

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$.

In the first line of the output print $$$k$$$ — the maximum number of elements in a strictly increasing sequence you can obtain. In the second line print a string $$$s$$$ of length $$$k$$$, where the $$$j$$$-th character of this string $$$s_j$$$ should be 'L' if you take the leftmost element during the $$$j$$$-th move and 'R' otherwise. If there are multiple answers, you can print any.

NoteThe first example is described in the problem statement.


The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city.For this reason, he made the n prisoners to stand in a line, with a number written on their chests. The number is the severity of the crime he/she has committed. The greater the number, the more severe his/her crime was.Then, the mayor told you to choose the c prisoners, who will be transferred to the other prison. He also imposed two conditions. They are,  The chosen c prisoners has to form a contiguous segment of prisoners.  Any of the chosen prisoner's crime level should not be greater then t. Because, that will make the prisoner a severe criminal and the mayor doesn't want to take the risk of his running away during the transfer. Find the number of ways you can choose the c prisoners.

The first line of input will contain three space separated integers n (1 ≤ n ≤ 2·105), t (0 ≤ t ≤ 109) and c (1 ≤ c ≤ n). The next line will contain n space separated integers, the ith integer is the severity ith prisoner's crime. The value of crime severities will be non-negative and will not exceed 109.

Print a single integer — the number of ways you can choose the c prisoners.

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

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

list($n,$t,$c) = explode(" ",$s);

$s = explode(" ",trim(fgets($f)));

$a = array();
$f = false;
$temp =array();
foreach($s as $i){
    if ($i>$t) {
        if (count($temp)>0)
            $a[] = $temp;
        $temp = array();
    } else {
        $temp[] = $i;
    }
}
$a[] = $temp;

$result = 0;
foreach($a as $i){
    if (count($i)>=$c)
        $result = $result+(count($i)-$c)+1;
}

echo $result;

<?php
$input = "php://stdin";
$text = str_replace("\r", "", file_get_contents($input));
list($s1, $s2) = explode("\n", $text);
list($n, $t, $c) = explode(" ", $s1);
$list = explode(" ", $s2);

$t = (int)$t;
$result = 0;
$startFrom = null;
for ($i = 0; $i < $n; $i++) {
	$val = (int)$list[$i];
    if ($val <= $t) {
		if ($startFrom === null) {
			$startFrom = $i;
		}
	} else {
		if ($startFrom !== null) {
			$len = $i - $startFrom;
			if ($len >= $c) {
				$result += $len-$c+1;
			}
		}
		$startFrom = null;
	}
}

if ($startFrom !== null) {
    $len = $i - $startFrom;
    if ($len >= $c) {
        $result += $len-$c+1;
    }
}

echo $result;

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

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

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

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

	$size = 0;
	$possibles = 0;

	for($i=0;$i<=$n;$i++) {
		if ($a[$i] <= $t) {$size++;}
		else {
			if ($c<=$size) $possibles += ($size-$c)+1;
			$size = 0;
		}
	}

	echo $possibles
?>

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

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

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

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

	$size = 0;
	$possibles = 0;

	for($i=0;$i<=$n;$i++) {
		if ($a[$i] <= $t) {$size++;}
		else {
			if ($c<=$size) $possibles += ($size-$c)+1;
			$size = 0;
		}
	}

	echo $possibles
?>

<?php

$input = rtrim(fgets(STDIN));
$raw = explode(' ', $input);

$n = (int)$raw[0];
$t = (int)$raw[1];
$c = (int)$raw[2];

$rawData = rtrim(fgets(STDIN));
$rawData = explode(' ', $rawData);

$data = array_pad([], $n + 1, 0);
for ($i = 1; $i <= $n; $i++) {
    $data[$i] = (int) $rawData[$i - 1];
}

$answer = 0;
$dp = array_pad([], $n, 0);
for ($i = 1; $i <= $n; $i++) {
    if ($data[$i] <= $t) {
        $dp[$i] = $dp[$i - 1] + 1;
    } else {
        $dp[$i] = 0;
    }

    if ($dp[$i] >= $c) {
        $answer++;
    }
}

echo $answer . PHP_EOL;

<?php
list($n, $t, $c) = explode(" ", trim(fgets(STDIN)));
$a = explode(" ", trim(fgets(STDIN)));
$ans = 0;
for ($i = 0; $i < count($a); )
{
    if ($a[$i] > $t)
        ++$i;
    $j = $i;
    while ($j < count($a) && $a[$j] <= $t)
        ++$j;
    $ans += max($j - $c - $i + 1, 0);
    $i = $j;
}
print $ans;
?>

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

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

	list($n, $t, $c) = explode(" ", fgets($input));

	$a = explode(" ", fgets($input));
	$a[] = 1000000001;

	$size = 0;
	$possibles = 0;

	for($i=0;$i<=$n;$i++) {
		if ($a[$i] <= $t) {$size++;}
		else {
			if ($c<=$size) $possibles += ($size-$c)+1;
			$size = 0;
		}
	}

	echo $possibles
?>


Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:(1n + 2n + 3n + 4n) mod 5for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).

The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes.

Print the value of the expression without leading zeros.

NoteOperation x mod y means taking remainder after division x by y.Note to the first sample:

<?php
$a = trim(fgets(STDIN));
if(bcmod($a, 4) == 0)
{
    print "4";
}
else
{
    print "0";
}
?>


Polycarp has $$$26$$$ tasks. Each task is designated by a capital letter of the Latin alphabet.The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then he must solve it to the end, without being distracted by another task. After switching to another task, Polycarp cannot return to the previous task.Polycarp can only solve one task during the day. Every day he wrote down what task he solved. Now the teacher wants to know if Polycarp followed his advice.For example, if Polycarp solved tasks in the following order: "DDBBCCCBBEZ", then the teacher will see that on the third day Polycarp began to solve the task 'B', then on the fifth day he got distracted and began to solve the task 'C', on the eighth day Polycarp returned to the task 'B'. Other examples of when the teacher is suspicious: "BAB", "AABBCCDDEEBZZ" and "AAAAZAAAAA".If Polycarp solved the tasks as follows: "FFGZZZY", then the teacher cannot have any suspicions. Please note that Polycarp is not obligated to solve all tasks. Other examples of when the teacher doesn't have any suspicious: "BA", "AFFFCC" and "YYYYY".Help Polycarp find out if his teacher might be suspicious.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$). Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of days during which Polycarp solved tasks. The second line contains a string of length $$$n$$$, consisting of uppercase Latin letters, which is the order in which Polycarp solved the tasks.

For each test case output:    "YES", if the teacher cannot be suspicious;  "NO", otherwise.  You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB

<?php
    $t = trim(fgets(STDIN));
    $arr = [];
    $result = 0;
    for($i = 0; $i < $t*2; $i++){
        $num = trim(fgets(STDIN));
        if($i % 2 != 0){
            array_push($arr,$num);
        }
    }

    function getAnswer($str){
        if(strlen($str) == 1 || strlen($str) == 2){
            echo "YES" . "\n";
            return;
        }
        $charsOk = [];
        for($i = 0; $i < strlen($str); $i++){
            if(in_array($str[$i], $charsOk)){
                continue;
            }
            for($j = 0; $j < strlen($str); $j++){
                if($i == $j){continue;}
                if($str[$i] == $str[$j] && $str[$j] != $str[$j - 1]){
                    echo "NO" . "\n";
                    return;
                }
            }
            array_push($charsOk, $str[$i]);
        }
        echo "YES" . "\n";
    }

    foreach($arr as $val){
        getAnswer($val);
    }
?>

<?php

function isPrime($number)
{

    if ($number == 2 || $number == 3)
        return true;

    if ($number % 2 == 0 || $number % 3 == 0)
        return false;

    $divisor = 6;
    while ($divisor * $divisor - 2 * $divisor + 1 <= $number)
    {

        if ($number % ($divisor - 1) == 0)
            return false;

        if ($number % ($divisor + 1) == 0)
            return false;

        $divisor += 6;
    }

    return true;

}

function nextPrime($n)
{
    $n = $n + 1;
    while(!isPrime($n)){
        $n++;
    }

    return $n;
}

function gcd($a, $b)
{
    while($b != 0){
        $t = $a % $b;
        $a = $b;
        $b = $t;
    }
    return $a;
}

for($t = intval(trim(fgets(STDIN))); $t > 0; $t --){
    $n = intval(trim(fgets(STDIN)));

    $string = str_split(trim(fgets(STDIN)));
    $occurrences = [];
    $flag = 1;

    foreach ($string as $i => $char){
        if(isset($occurrences[$char])){
            if($string[$i] !== $string[$i - 1]){
                echo "NO\n";
                $flag = 0;
                break;
            }
        }

        $occurrences[$char] = 1;
    }

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

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

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

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $s = trim(fgets($file));
  $v = array();

  $f = $s[0]; $v[$s[0]] = 1;
  for ($j = 0; $j < $n; $j++) {
    if ($s[$j] != $f) { $f = $s[$j]; $v[$s[$j]]++; }
  }
  rsort($v);

  if ($v[0] > 1) { echo 'NO'.PHP_EOL; }
  else { echo 'YES'.PHP_EOL; }
}

?>

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

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

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

$t = IO::str();
$cnt = 0;
while ($t--) {
    $res = array();
    $n = IO::str();
    $s = IO::str();
    $s = str_split($s);

    for ($i = 0; $i < $n-1; $i++){
        if ($i == $n - 1) break;
        if ($s[$i] != $s[$i+1]) {
            if (isset($res[$s[$i]]) || isset($res[$s[$i+1]])) {
                $f[$cnt] = 'NO';
                break;
            }
            $res[$s[$i]] = 1;
        }
    }
    if (!isset($f[$cnt])) {
        $f[$cnt] = 'YES';
    }
    $cnt++;
}

IO::res($f);

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

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

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $n = IO::str();
    $s = IO::str();
    $d = str_split($s);
    $last = $d[0];
    $res = [];
    $bool = true;
    foreach ($d as $v) {
        if ($v !== $last && isset($res[$v])) {
            $bool = false;
            break;
        }
        $last = $v;
        $res[$v] = 1;
    }
    if ($bool) {
        IO::yes();
    } else {
        IO::no();
    }

}

?>


Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then a new chat is simply inserted to the top of the list.Assuming that the chat list is initially empty, given the sequence of Polycaprus' messages make a list of chats after all of his messages are processed. Assume that no friend wrote any message to Polycarpus.

The first line contains integer n (1 ≤ n ≤ 200 000) — the number of Polycarpus' messages. Next n lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most 10.

Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.

NoteIn the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows:   alex Then Polycarpus writes to friend by name "ivan" and the list looks as follows:  ivan  alex Polycarpus writes the third message to friend by name "roman" and the list looks as follows:  roman  ivan  alex Polycarpus writes the fourth message to friend by name "ivan", to who he has already sent a message, so the list of chats changes as follows:  ivan  roman  alex

<?php
$a = trim(fgets(STDIN));
$b = array();
for($x = $a - 1; $x >= 0; $x--)
{
     $c = trim(fgets(STDIN));
     $b[$x] = $c;
}
ksort($b);
$d = array_unique($b);
$e = array_keys($d);
for($x = 0; $x < count($e) - 1; $x++)
{
     print $d[$e[$x]] . "\n";
}
print $d[$e[$x]];
?>

<?php
    $n = fgets(STDIN);
    $name = array();
    for ($i = 0; $i < $n; $i++) $name[] = trim(fgets(STDIN));
    $ans = ""; $cur = array();
    while (count($name) > 0){
        $s = "";
        if (!isset($cur[$s = array_pop($name)])) {
            $ans .= $s . "\n";
            $cur[$s] = 1;
        }
    }
    echo $ans;

<?php
$num = intval(fgets(STDIN));
for ($i = 0; $i < $num; $i++) {
	$to[trim(fgets(STDIN))] = $i;
}
arsort($to);
foreach ($to as $k => $v) echo $k . PHP_EOL;

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

$chats = [];
for ($i = 0; $i < $n; $i++) {
  $name = trim(fgets(STDIN));
  $chats[$name] = $i;
}
arsort($chats);
echo implode("\n", array_keys($chats)), "\n";

<?php

$n = trim(fgets(STDIN));
$arr = array();
for ($i = 0; $i < $n; $i++)
{
    $arr[] = trim(fgets(STDIN));
}
krsort($arr);
$arr = array_unique($arr);
foreach ($arr as $value)
{
        echo $value."\r";
}

<?

$n = (int) fgets(STDIN);

$list = [];
for ($i = 0; $i < $n; $i++) {
    $title = trim(fgets(STDIN));
    $list[$title] = $i;
}

arsort($list);

echo implode(chr(10), array_keys($list));

<?
	$count = fgets(STDIN);
	$items = [];

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

	$users = [];

	for ($i = 0; $i < $count; ++$i) {
		$user = $items[$i];
		$users[$user] = $i;
	}

	arsort($users);

	foreach ($users as $user => $i) {
		echo $user . PHP_EOL;
	}

?>

<?
$stdin = fopen('php://stdin', 'r');
$num = trim(fgets($stdin));
$arr = array();
$arr2 = array();
$max = 0;
for($i = 0; $i < $num; $i++){
    $k = trim(fgets($stdin));
    $arr[$i] = $k;
    if($arr2[$arr[$i]] != 1){
         $arr2[$arr[$i]] = 1;
         $max++;
    }
}
$j = 0;
$stdout = fopen('php://stdout', 'w');
for($i = $num - 1; $i >= 0; $i--){
    if($arr2[$arr[$i]] != 2){
         $arr2[$arr[$i]] = 2;
         fwrite($stdout, $arr[$i]."\n");
         $j++;
         if($max == $j) break;
    }
}
fclose($stdout);

?>

<?php

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

$map = [];
while ($n--) {
    fscanf(STDIN, '%s', $key);

    if (isset($map[$key])) {
        unset($map[$key]);
    }

    $map[$key] = 1;
}

$value = end($map);
while ($key = key($map)) {
    echo $key . PHP_EOL;
    $value = prev($map);
}

<?php
$lenght = trim(fgets(STDIN));
$array = [];
while($line = fgets(STDIN)){
    $array[] = trim($line);
}
$array_r = array_reverse($array);
$length = count($array_r);
for($i=0; $i<$length; $i++){
    $newArray[$array_r[$i]] = '';
}
foreach($newArray as $key => $v)echo $key."\n";
?>

<?
fgets(STDIN);
$a = [];
while(!feof(STDIN)) $a[] = trim(fgets(STDIN));
print implode("\n", array_unique(array_reverse($a), SORT_STRING));

<?php

$num = intval(fgets(STDIN));
for ($i = 0; $i < $num; $i++) {
	$to[trim(fgets(STDIN))] = $i;
}

foreach ($to as $k => $v) echo $k . PHP_EOL;

<?php

$str = '8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina';

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

for ($i = 1; $i < count($arr); $i++) $to[$arr[$i]] = $i;

foreach ($to as $k => $v) echo $k . PHP_EOL;

<?
$stdin = fopen('php://stdin', 'r');
$num = trim(fgets($stdin));
$arr = array();

for($i = 0; $i < $num; $i++){
    $k = trim(fgets($stdin));
    $key = array_search($k, $arr);
    if($key !== false){
        array_splice($arr, $key, 1);
    }
    array_unshift($arr, $k);
}

$stdout = fopen('php://stdout', 'w');
for($i = 0; $i < count($arr); $i++){
    fwrite($stdout, $arr[$i]);
}
fclose($stdout);

?>


There are $$$n$$$ logs, the $$$i$$$-th log has a length of $$$a_i$$$ meters. Since chopping logs is tiring work, errorgorn and maomao90 have decided to play a game.errorgorn and maomao90 will take turns chopping the logs with errorgorn chopping first. On his turn, the player will pick a log and chop it into $$$2$$$ pieces. If the length of the chosen log is $$$x$$$, and the lengths of the resulting pieces are $$$y$$$ and $$$z$$$, then $$$y$$$ and $$$z$$$ have to be positive integers, and $$$x=y+z$$$ must hold. For example, you can chop a log of length $$$3$$$ into logs of lengths $$$2$$$ and $$$1$$$, but not into logs of lengths $$$3$$$ and $$$0$$$, $$$2$$$ and $$$2$$$, or $$$1.5$$$ and $$$1.5$$$.The player who is unable to make a chop will be the loser. Assuming that both errorgorn and maomao90 play optimally, who will be the winner?

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$)  — the number of logs. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$)  — the lengths of the logs. Note that there is no bound on the sum of $$$n$$$ over all test cases.

For each test case, print "errorgorn" if errorgorn wins or "maomao90" if maomao90 wins. (Output without quotes).

NoteIn the first test case, errorgorn will be the winner. An optimal move is to chop the log of length $$$4$$$ into $$$2$$$ logs of length $$$2$$$. After this there will only be $$$4$$$ logs of length $$$2$$$ and $$$1$$$ log of length $$$1$$$.After this, the only move any player can do is to chop any log of length $$$2$$$ into $$$2$$$ logs of length $$$1$$$. After $$$4$$$ moves, it will be maomao90's turn and he will not be able to make a move. Therefore errorgorn will be the winner.In the second test case, errorgorn will not be able to make a move on his first turn and will immediately lose, making maomao90 the winner.

<?php class InputReader{protected $_fh;public function __construct($fileHandler = STDIN)   {$this->_fh = $fileHandler;}
    public function readInt(){$d = trim(fgets($this->_fh));return (int)$d;}
    public function readArrayOfInt($separator = ' ', $indexFrom = 0){$a = [];$ind = $indexFrom;foreach (explode($separator, fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
    public function readArrayOfFloat($separator = ' ', $indexFrom = 0) { $a = []; $ind = $indexFrom; foreach (explode($separator, fgets($this->_fh)) as $item) {  $a[$ind++] = (float)$item; } return $a; }
    public function readArrayOfString($separator = ' ', $indexFrom = 0) { $a = []; $ind = $indexFrom; foreach (explode($separator, fgets($this->_fh)) as $item) {  $a[$ind++] = $item; } return $a; }
}
/* Perform action N times. Can return values in array */
function ntimes($n, $func, $returnResults = false){ $a = []; for ($i = 1; $i <= $n; $i++) { $result = $func(); if ($returnResults) {  $a[$i] = $result; } } return $a;}
/* Integral. Keys preserved. By reference. */
function cumsum(&$a){ $sum = 0; foreach ($a as $k => $v) { $a[$k] += $sum; $sum = $a[$k]; }}
/* Difference. Keys preserved. By reference. */
function diff(&$a){ $prev = 0; foreach ($a as $k => $v) { $buf = $a[$k]; $a[$k] -= $prev; $prev = $buf; }}
function bitCount($n){ $cnt = 0; for ($j = $n; $j; $j >>= 1) { $cnt += $j & 1; } return $cnt;}
/*****************************************/
$ir = new InputReader();

/* TASK */

$ts = $ir->readInt();

for ($t=0; $t<$ts; $t++) {
	$n = $ir->readInt();
	$a = $ir->readArrayOfInt();

	$sum = array_sum($a);
	$cnt = $sum - $n;

	echo (($cnt&1) ? 'errorgorn' : 'maomao90').PHP_EOL;
}


Nikolay lives in a two-storied house. There are $$$n$$$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $$$1$$$ and $$$n$$$). If Nikolay is currently in some room, he can move to any of the neighbouring rooms (if they exist). Rooms with numbers $$$i$$$ and $$$i+1$$$ on each floor are neighbouring, for all $$$1 \leq i \leq n - 1$$$. There may also be staircases that connect two rooms from different floors having the same numbers. If there is a staircase connecting the room $$$x$$$ on the first floor and the room $$$x$$$ on the second floor, then Nikolay can use it to move from one room to another.     The picture illustrates a house with $$$n = 4$$$. There is a staircase between the room $$$2$$$ on the first floor and the room $$$2$$$ on the second floor, and another staircase between the room $$$4$$$ on the first floor and the room $$$4$$$ on the second floor. The arrows denote possible directions in which Nikolay can move. The picture corresponds to the string "0101" in the input.  Nikolay wants to move through some rooms in his house. To do this, he firstly chooses any room where he starts. Then Nikolay moves between rooms according to the aforementioned rules. Nikolay never visits the same room twice (he won't enter a room where he has already been). Calculate the maximum number of rooms Nikolay can visit during his tour, if:  he can start in any room on any floor of his choice,  and he won't visit the same room twice.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of two lines. The first line contains one integer $$$n$$$ $$$(1 \le n \le 1\,000)$$$ — the number of rooms on each floor. The second line contains one string consisting of $$$n$$$ characters, each character is either a '0' or a '1'. If the $$$i$$$-th character is a '1', then there is a staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. If the $$$i$$$-th character is a '0', then there is no staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

For each test case print one integer — the maximum number of rooms Nikolay can visit during his tour, if he can start in any room on any floor, and he won't visit the same room twice.

NoteIn the first test case Nikolay may start in the first room of the first floor. Then he moves to the second room on the first floor, and then — to the third room on the first floor. Then he uses a staircase to get to the third room on the second floor. Then he goes to the fourth room on the second floor, and then — to the fifth room on the second floor. So, Nikolay visits $$$6$$$ rooms.There are no staircases in the second test case, so Nikolay can only visit all rooms on the same floor (if he starts in the leftmost or in the rightmost room).In the third test case it is possible to visit all rooms: first floor, first room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room $$$\rightarrow$$$ second floor, third room $$$\rightarrow$$$ second floor, fourth room $$$\rightarrow$$$ first floor, fourth room $$$\rightarrow$$$ first floor, fifth room $$$\rightarrow$$$ second floor, fifth room.In the fourth test case it is also possible to visit all rooms: second floor, third room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ first floor, first room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room.


Alice and Bob play a game. Alice has $$$n$$$ cards, the $$$i$$$-th of them has the integer $$$a_i$$$ written on it. Bob has $$$m$$$ cards, the $$$j$$$-th of them has the integer $$$b_j$$$ written on it.On the first turn of the game, the first player chooses one of his/her cards and puts it on the table (plays it). On the second turn, the second player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the first turn, and plays it. On the third turn, the first player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the second turn, and plays it, and so on — the players take turns, and each player has to choose one of his/her cards with greater integer than the card played by the other player on the last turn.If some player cannot make a turn, he/she loses.For example, if Alice has $$$4$$$ cards with numbers $$$[10, 5, 3, 8]$$$, and Bob has $$$3$$$ cards with numbers $$$[6, 11, 6]$$$, the game may go as follows:  Alice can choose any of her cards. She chooses the card with integer $$$5$$$ and plays it.  Bob can choose any of his cards with number greater than $$$5$$$. He chooses a card with integer $$$6$$$ and plays it.  Alice can choose any of her cards with number greater than $$$6$$$. She chooses the card with integer $$$10$$$ and plays it.  Bob can choose any of his cards with number greater than $$$10$$$. He chooses a card with integer $$$11$$$ and plays it.  Alice can choose any of her cards with number greater than $$$11$$$, but she has no such cards, so she loses. Both Alice and Bob play optimally (if a player is able to win the game no matter how the other player plays, the former player will definitely win the game).You have to answer two questions:  who wins if Alice is the first player?  who wins if Bob is the first player?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case consists of four lines. The first line of a test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of cards Alice has. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 50$$$) — the numbers written on the cards that Alice has. The third line contains one integer $$$m$$$ ($$$1 \le m \le 50$$$) — the number of Bob's cards. The fourth line contains $$$m$$$ integers $$$b_1, b_2, \dots, b_m$$$ ($$$1 \le b_i \le 50$$$) — the numbers on Bob's cards.

For each test case, print two lines. The first line should be Alice if Alice wins when she is the first player; otherwise, the first line should be Bob. The second line should contain the name of the winner if Bob is the first player, in the same format.

NoteLet's consider the first test case of the example.Alice has one card with integer $$$6$$$, Bob has two cards with numbers $$$[6, 8]$$$.If Alice is the first player, she has to play the card with number $$$6$$$. Bob then has to play the card with number $$$8$$$. Alice has no cards left, so she loses.If Bob is the first player, then no matter which of his cards he chooses on the first turn, Alice won't be able to play her card on the second turn, so she will lose.

<?php

function run(){
    $n = trim(fgets(STDIN));
    $arr = explode(' ', trim(fgets(STDIN)));
    $m = trim(fgets(STDIN));
    $brr = explode(' ', trim(fgets(STDIN)));
    rsort($arr); rsort($brr);
    if($arr[0] > $brr[0]){
         echo "Alice\nAlice\n";
    }
    else if($arr[0] < $brr[0]){
         // echo "Bob\nBob\n";
         echo str_repeat("Bob\n", 2);
    }
    else{
         echo "Alice\nBob\n";
    }
}

$test_cases = trim(fgets(STDIN));
while($test_cases--){
    run();
}
?>

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

        $m = trim(fgets(STDIN));
        $b = explode(' ', trim(fgets(STDIN)));

        $maxA = max($a);
        $maxB = max($b);

        if ($maxA >= $maxB) {
            echo 'Alice' . PHP_EOL;
        } else {
            echo 'Bob' . PHP_EOL;
        }

        if ($maxB >= $maxA) {
            echo 'Bob' . PHP_EOL;
        } else {
            echo 'Alice' . PHP_EOL;
        }

    }
?>

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

   $t = IO::getInt();
//   $point = ord('a') + ord('b') ;

   for($q=0; $q <$t; $q++) {
       $ans = 0;
       $n = IO::getInt();
       $a = IO::getArray();
       $m = IO::getInt();
       $b = IO::getArray();

       $aMax = max($a);
       $bMax = max($b);
       //Alice
       if($aMax > $bMax) {
            IO::pr('Alice');
            IO::pr('Alice');
       } elseif($aMax == $bMax) {
           IO::pr('Alice');
           IO::pr('Bob');

       }else {
            IO::pr('Bob');
            IO::pr('Bob');
       }

   }

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

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

 class Algor {
    public static function isPrime($n) {
         $d = 2;
         while ($n % $d != 0) {
         $d += 1;
         }

        return $d == $n;
    }

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

         return $a[$n];
     }

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

}

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

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

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

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

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

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

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

        return $aResult;

    }
}

class SolveArchive
{

}


Let's define $$$f(x)$$$ for a positive integer $$$x$$$ as the length of the base-10 representation of $$$x$$$ without leading zeros. I like to call it a digital logarithm. Similar to a digital root, if you are familiar with that.You are given two arrays $$$a$$$ and $$$b$$$, each containing $$$n$$$ positive integers. In one operation, you do the following:   pick some integer $$$i$$$ from $$$1$$$ to $$$n$$$;  assign either $$$f(a_i)$$$ to $$$a_i$$$ or $$$f(b_i)$$$ to $$$b_i$$$. Two arrays are considered similar to each other if you can rearrange the elements in both of them, so that they are equal (e. g. $$$a_i = b_i$$$ for all $$$i$$$ from $$$1$$$ to $$$n$$$).What's the smallest number of operations required to make $$$a$$$ and $$$b$$$ similar to each other?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of the testcase contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in each of the arrays. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i < 10^9$$$). The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_j < 10^9$$$). The sum of $$$n$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$.

For each testcase, print the smallest number of operations required to make $$$a$$$ and $$$b$$$ similar to each other.

NoteIn the first testcase, you can apply the digital logarithm to $$$b_1$$$ twice.In the second testcase, the arrays are already similar to each other.In the third testcase, you can first apply the digital logarithm to $$$a_1$$$, then to $$$b_2$$$.

<?php
  $inp = preg_split('#\s+#', trim(file_get_contents("php://stdin")));
  $p = 0;
  $tests = intval($inp[$p++]);
  for($test=0;$test<$tests;$test++)
  {
    $ans = 0;
    $n = intval($inp[$p++]);
    $a = array();
    $b = array();
    for($i=0;$i<$n;$i++) $a[] = intval($inp[$p++]);
    for($i=0;$i<$n;$i++) $b[] = intval($inp[$p++]);
    $a = a2l($a);
    $b = a2l($b);
    foreach($a as $val=>$cnt)
    {
      if (!isset($b[$val])) continue;
      $c = min($cnt, $b[$val]);
      $a[$val] -= $c; if ($a[$val] === 0) unset($a[$val]);
      $b[$val] -= $c; if ($b[$val] === 0) unset($b[$val]);
    }

    $a2 = array();
    foreach($a as $val=>$cnt)
    {
      if ($val < 10)
      {
        if (!isset($a2[$val])) $a2[$val] = $cnt;
        else $a2[$val] += $cnt;
        continue;
      }
      $v2 = strlen("{$val}");
      $ans += $cnt;
      unset($a[$val]);

        if (!isset($a2[$v2])) $a2[$v2] = $cnt;
        else $a2[$v2] += $cnt;
    }
    $a = $a2;

    $b2 = array();
    foreach($b as $val=>$cnt)
    {
      if ($val < 10)
      {
        if (!isset($b2[$val])) $b2[$val] = $cnt;
        else $b2[$val] += $cnt;
        continue;
      }
      $v2 = strlen("{$val}");
      $ans += $cnt;
      unset($b[$val]);

        if (!isset($b2[$v2])) $b2[$v2] = $cnt;
        else $b2[$v2] += $cnt;
    }
    $b = $b2;

    foreach($a as $val=>$cnt)
    {
      if (!isset($b[$val])) continue;
      $c = min($cnt, $b[$val]);
      $a[$val] -= $c; if ($a[$val] === 0) unset($a[$val]);
      $b[$val] -= $c; if ($b[$val] === 0) unset($b[$val]);
    }

    foreach($a as $val=>$cnt) if ($val != 1) $ans += $cnt;
    foreach($b as $val=>$cnt) if ($val != 1) $ans += $cnt;
    echo $ans."\n";
  }

  function a2l($a)
  {
    $b = array();
    foreach($a as $x)
      if (isset($b[$x])) $b[$x] ++;
      else $b[$x] = 1;
    return $b;
  }


Little Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1), (2, y2), ..., (2n + 1, y2n + 1), with the i-th segment connecting the point (i, yi) and the point (i + 1, yi + 1). For any even i (2 ≤ i ≤ 2n) the following condition holds: yi - 1 < yi and yi > yi + 1. We shall call a vertex of a polyline with an even x coordinate a mountain peak.   The figure to the left shows the initial picture, the figure to the right shows what the picture looks like after Bolek's actions. The affected peaks are marked red, k = 2.  Bolek fancied a little mischief. He chose exactly k mountain peaks, rubbed out the segments that went through those peaks and increased each peak's height by one (that is, he increased the y coordinate of the corresponding points). Then he painted the missing segments to get a new picture of mountain peaks. Let us denote the points through which the new polyline passes on Bolek's new picture as (1, r1), (2, r2), ..., (2n + 1, r2n + 1).Given Bolek's final picture, restore the initial one.

The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100). The next line contains 2n + 1 space-separated integers r1, r2, ..., r2n + 1 (0 ≤ ri ≤ 100) — the y coordinates of the polyline vertices on Bolek's picture. It is guaranteed that we can obtain the given picture after performing the described actions on some picture of mountain peaks.

Print 2n + 1 integers y1, y2, ..., y2n + 1 — the y coordinates of the vertices of the polyline on the initial picture. If there are multiple answers, output any one of them.

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

// Codeforces Problem 218A
// Codeforces Contest 134 Div 2 Problem A
$raw = g();
$n = $raw[0];
$k = $raw[1];
$raw = g();
for ($x = 0; $x < $n; $x++) {
	$lo[$x] = $raw[2 * $x];
	$hi[$x] = $raw[2 * $x + 1];
}
$lo[$n] = $raw[2 * $n];

$ct = $k;
$res = "";
for ($x = 0; $x < $n; $x++) {
	$res .= $lo[$x] . " ";
	if (($hi[$x] > $lo[$x] + 1) && ($hi[$x] > $lo[$x + 1] + 1) && ($ct > 0)) {
		$res .= ($hi[$x] - 1) . " ";
		$ct--;
	} else {
		$res .= $hi[$x] . " ";
	}
}
$res .= $lo[$n];

echo $res;

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


God's Blessing on This PermutationForces!A Random PebbleYou are given a permutation $$$p_1,p_2,\ldots,p_n$$$ of length $$$n$$$ and a positive integer $$$k \le n$$$. In one operation you can choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i < j \le n$$$) and swap $$$p_i$$$ with $$$p_j$$$.Find the minimum number of operations needed to make the sum $$$p_1 + p_2 + \ldots + p_k$$$ as small as possible.A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 100$$$). The second line of each test case contains $$$n$$$ integers $$$p_1,p_2,\ldots,p_n$$$ ($$$1 \le p_i \le n$$$). It is guaranteed that the given numbers form a permutation of length $$$n$$$.

For each test case print one integer — the minimum number of operations needed to make the sum $$$p_1 + p_2 + \ldots + p_k$$$ as small as possible.

NoteIn the first test case, the value of $$$p_1 + p_2 + \ldots + p_k$$$ is initially equal to $$$2$$$, but the smallest possible value is $$$1$$$. You can achieve it by swapping $$$p_1$$$ with $$$p_3$$$, resulting in the permutation $$$[1, 3, 2]$$$.In the second test case, the sum is already as small as possible, so the answer is $$$0$$$.

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

$t; $n; $k; $arr;
fscanf($cin, "%d\n", $t);
for ($T = 0; $T < $t; $T++) {
    fscanf($cin, "%d %d\n", $n, $k);
    $perm = explode(" ", trim(fgets($cin)));
    $ans = 0;
    for ($i = 1; $i <= $k; $i++) {
        if ($perm[$i-1] > $k) $ans++;
    }
    fprintf($cout, "%d\n", $ans);
} ?>

<?php
function read() {
  return trim(fgets($GLOBALS['file'])) ;
}
function readInt() {
  return (int) read() ;
}
function readStrs() {
  return explode(" ",read()) ;
}
function readIntArray() {
  return array_map('intval', readStrs());
}
function readAsArray() {
  return str_split(read()) ;
}
function puts($arg) {
  if($arg === true) print_r("true");
  elseif($arg === false) print_r("false");
  else {
    print_r($arg) ;
  }
  print_r("\n") ;
}
$file = (file_exists("input.txt")) ? fopen("input.txt","r") : STDIN ;

//-----------------------------------//

function fi($arr, $ele) {
    for($i=0;$i<count($arr);$i++) {
        if($arr[$i] == $ele) {
            return $i ;
        }
    }
}

$t = readInt() ;
while($t--) {
    [$n,$k] = readIntArray();
    $arr = readIntArray();
    $brr = [] ;
    foreach ($arr as $e) {
        $brr[] = $e ;
    }
    $swapa = 0 ;
    sort($brr) ;
    for($i=0;$i<$k;$i++) {
        $ind = fi($arr,$brr[$i]);
        if($ind > $k-1) {
            $swapa += 1 ;
        }
    }
    puts($swapa);
}


Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handkerchief pattern should look like that:           0        0 1 0      0 1 2 1 0    0 1 2 3 2 1 0  0 1 2 3 4 3 2 1 00 1 2 3 4 5 4 3 2 1 0  0 1 2 3 4 3 2 1 0    0 1 2 3 2 1 0      0 1 2 1 0        0 1 0          0Your task is to determine the way the handkerchief will look like by the given n.

The first line contains the single integer n (2 ≤ n ≤ 9).

Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.

<?php

// https://codeforces.com/problemset/problem/118/B

/*
 Example: (input=2)

    0
  0 1 0
0 1 2 1 0
  0 1 0
    0
*/

/*
 Example: (input=3)

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

function getRowData(int $number): array
{
    $numberOfColumns = (($number * 2) + 1);
    $rowData = [];
    $clonedNumber = $number - 1;

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

        if ($i <= $number) {
            array_push($rowData, $i);
        } else {
            array_push($rowData, $clonedNumber);
            $clonedNumber--;
        }
    }

    return $rowData;
}

function getRowDataAccordingToRowPosition(int $number, int $rowPosition): array
{
    if ($rowPosition <= $number)
        return getRowData($rowPosition);

    return getRowData((($number * 2)) - $rowPosition);
}

function getNumberOfNeededSpaces(int $number, int $rowPosition): int
{
    if ($rowPosition === $number)
        return 0;

    if ($rowPosition < $number)
        return ($number - $rowPosition) * 2;

    return ($rowPosition - $number) * 2;
}

function getUserInput(): int
{
    $handle = fopen("php://stdin","r");
    return (int) fgets($handle);
}

$number = getUserInput();
$numberOfRows = (($number * 2) + 1);
$matrix = [];

/**
 * Filling the matrix with row data
 * Ex: [[0], [0, 1, 0],..]
 */
for ($i=0;$i<$numberOfRows;$i++) {
    array_push($matrix, getRowDataAccordingToRowPosition($number, $i));
}

/**
 * Printing the matrix data based on needed spaces
 */
foreach ($matrix as $rowPosition => $rowData) {
    echo str_repeat(" ", getNumberOfNeededSpaces($number, $rowPosition));
    echo implode(' ', $rowData);
    echo "\n";
}

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

$max=$lines;

for ($l=0; $l<=$max; $l++)
{
    $line=str_repeat(" ", ($max-$l)*2);
    $line.=($l==0)?0:(implode(" ", range(0, $l))." ".implode(" ", range($l-1, 0)));
    $res[]=$line;
}
for ($l=$lines-1; $l>=0; $l--)
{
    $line=str_repeat(" ", ($max-$l)*2);
    $line.=($l==0)?0:(implode(" ", range(0, $l))." ".implode(" ", range($l-1, 0)));
    $res[]=$line;
}
echo implode("\n", $res);

?>

<?php
error_reporting("off");
//118B: Present from Lena
$n = trim(fgets(STDIN)); //$n = 3;
$rows = array();
for ($i = 0; $i <= $n; $i++) {
    $um = $n - $i;
    $numpadding = $um * 2;
    $padding = "";
    for ($er = 0; $er < $numpadding; $er++) {
        $padding .= " ";
    }
    $rows[$i] .= $padding;
    for ($j = 0; $j <= $i; $j++) {
        $rows[$i] .= $j." ";
    }
    for ($k = $i - 1; $k >= 0; $k--) {
        $rows[$i] .= $k." ";
    }
    $rows[$i] = substr($rows[$i], 0, -1);
}
for ($j = $n - 1; $j >= 0; $j--) {
    $rows[] = $rows[$j];
}
foreach ($rows as $value) {
    echo $value."\n";
}
?>

<?php

$n = (int)fgets(STDIN);

$lines = array();

for ($i=0; $i<=$n; $i++)
{
    $sl = str_pad ('', ($n - $i)*2, ' ', STR_PAD_LEFT);
    for ($j=0; $j<=$i; $j++)
    {
        $sl.= $j.' ';
    }

    $sl = rtrim($sl);
    $sr = substr($sl, 0, strlen($sl) - 1);
    $sr = trim(strrev($sr));
    $s = $sl.' '.$sr;
    $s = rtrim($s);

    $lines[] = $s;

    echo $s.PHP_EOL;
}

for ($i=$n-1; $i>=0; $i--)
{
    echo $lines[$i];
    if ($i !== 0)
        echo PHP_EOL;
}

<?php
error_reporting("off");
//118B: Present from Lena
$n = trim(fgets(STDIN)); //$n = 3;
$rows = array();
for ($i = 0; $i <= $n; $i++) {
    $um = $n - $i;
    $numpadding = $um * 2;
    $padding = "";
    for ($er = 0; $er < $numpadding; $er++) {
        $padding .= " ";
    }
    echo $padding;
    $rows[$i] .= $padding;
    for ($j = 0; $j <= $i; $j++) {
        $rows[$i] .= $j." ";
    }
    for ($k = $i - 1; $k >= 0; $k--) {
        $rows[$i] .= $k." ";
    }
    $rows[$i] = substr($rows[$i], 0, -1);
}
for ($j = $n - 1; $j >= 0; $j--) {
    $rows[] = $rows[$j];
}
foreach ($rows as $value) {
    echo $value."\n";
}
?>

<?php
error_reporting("off");
//118B: Present from Lena
$n = trim(fgets(STDIN)); //$n = 3;
$rows = array();
for ($i = 0; $i <= $n; $i++) {
    $um = $n - $i;
    $numpadding = $um * 2;
    $padding = "";
    for ($er = 0; $er < $numpadding; $er++) {
        $padding .= " ";
    }
    echo $padding;
    $rows[$i] .= $padding;
    for ($j = 0; $j <= $i; $j++) {
        $rows[$i] .= $j." ";
    }
    for ($k = $i - 1; $k >= 0; $k--) {
        $rows[$i] .= $k." ";
    }
    $rows[$i] .= substr($padding, 1);
}
for ($j = $n - 1; $j >= 0; $j--) {
    $rows[] = $rows[$j];
}
foreach ($rows as $value) {
    echo $value."\n";
}
?>


You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it possible to make all $$$n$$$ strings equal?

The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths of all strings in all test cases does not exceed $$$1000$$$.

If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.

4
2
caa
cbb
3
cba
cba
cbb
4
ccab
cbac
bca
acbcc
4
acb
caf
c
cbafc

NoteIn the first test case, you can do the following:   Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the first string, making both strings equal to "cab". In the second test case, it is impossible to make all $$$n$$$ strings equal.

<?php
fscanf(STDIN, "%d", $t);
while($t--){
    fscanf(STDIN, "%d", $n);
    $nc = $n;
    $strings = '';
    while($n-- and $strings .= trim(fgets(STDIN), "\r|\n"));
    $strings = str_split($strings);
    $charCounts = [];
    foreach ($strings as $key)
        $charCounts[$key] = 0;
    foreach($strings as $char)
        $charCounts[$char]++;
    foreach($charCounts as $key => $count)
        if($count % $nc != 0) {echo "NO\n"; continue 2;}
    echo "YES\n";
}


There is a matrix A of size x × y filled with integers. For every ,  Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cell containing the number a1, then moved to the cell with the number a2, and so on.From the cell located in i-th line and j-th column (we denote this cell as (i, j)) you can move into one of the following cells: (i + 1, j) — only if i < x;  (i, j + 1) — only if j < y;  (i - 1, j) — only if i > 1;  (i, j - 1) — only if j > 1.Notice that making a move requires you to go to an adjacent cell. It is not allowed to stay in the same cell. You don't know x and y exactly, but you have to find any possible values for these numbers such that you could start in the cell containing the integer a1, then move to the cell containing a2 (in one step), then move to the cell containing a3 (also in one step) and so on. Can you choose x and y so that they don't contradict with your sequence of moves?

The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.

If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be positive integers not exceeding 109.

NoteThe matrix and the path on it in the first test looks like this:  Also there exist multiple correct answers for both the first and the third examples.


The Berland Armed Forces System consists of n ranks that are numbered using natural numbers from 1 to n, where 1 is the lowest rank and n is the highest rank.One needs exactly di years to rise from rank i to rank i + 1. Reaching a certain rank i having not reached all the previous i - 1 ranks is impossible.Vasya has just reached a new rank of a, but he dreams of holding the rank of b. Find for how many more years Vasya should serve in the army until he can finally realize his dream.

The first input line contains an integer n (2 ≤ n ≤ 100). The second line contains n - 1 integers di (1 ≤ di ≤ 100). The third input line contains two integers a and b (1 ≤ a < b ≤ n). The numbers on the lines are space-separated.

Print the single number which is the number of years that Vasya needs to rise from rank a to rank b.

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
list($c, $d) = explode(" ", trim(fgets(STDIN)));
$e = array_slice($b, $c - 1);
$f = array_slice($e, 0, $d - 1 - ($c - 1));
$g = array_sum($f);
print $g;
?>

<?php
    $fp = fopen('php://stdin', 'r');
    $n = rtrim(fgets($fp));
    $years = explode(' ', rtrim(fgets($fp)));
    list($from, $to) = explode(' ', rtrim(fgets($fp)));
    $cnt = 0;
    for($i = $from; $i < $to; $i++) {
        $cnt += $years[$i-1];
    }
    echo $cnt;
?>

<?php
    //$handle = @fopen("input.txt", "r");
    $n = trim(fgets(STDIN));
    $t = explode(' ', trim(fgets(STDIN)));

    list($a, $b) = explode(' ', trim(fgets(STDIN)));

    $res = 0;
    for ($i = $a - 1; $i < $b - 1; $i++) {
        $res += $t[$i];
    }
    echo "{$res}\n";

<?php
$file=STDIN;
$n=fgets($file);
$a=explode(" ",fgets($file));
list($st,$fn)=fscanf($file,"%d %d");
--$st;--$fn;
$ans=0;
for($i=$st;$i<$fn;++$i)
    $ans+=$a[$i];
printf("%d\n",$ans);
?>

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

    $n = fgets($stdin);
    $weights = explode(" ", preg_replace("/\s+/", " ", fgets($stdin)));
    $wants = explode(" ", preg_replace("/\s+/", " ", fgets($stdin)));

    $verdict = 0;
    for($i=$wants[0];$i<$wants[1];++$i){
        $verdict+=$weights[$i-1];
    }

    fputs($stdout, $verdict);
?>

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

for ($i = $a; $i < $b; $i++)
{
    $k += $mas[$i - 1];
}
echo $k;
?>

<?php

fscanf(STDIN, "%d\n", $ranks);
$years = trim(fgets(STDIN));
$position = trim(fgets(STDIN));

$years = explode(' ', $years);
$position = explode(' ', $position);
$sum = 0;

for ($i = $position[0] - 1; $i < $position[1] - 1; $i++) {
    $sum = $years[$i] + $sum;
}

echo $sum;

?>

<?php
$stdout = fopen('php://stdout', 'w');
//fputs(STDOUT, "Vhodnie dannie:  ");
$h = fopen('php://stdin', 'r');
$n =(int)trim(fgets($h));
$s = trim(fgets($h));
$s1 = trim(fgets($h));
$len = strlen($s);
$len1 = strlen($s1);
if ($n>=2 && $n<=100)
    {
        $f=true;
for ($i=1; $i<=$n-2; $i++)
{
    $r=stripos($s,' ');
    $mas[$i]=substr($s, 0, $r);
    if (($mas[$i]<1) || ($mas[$i]>100))
    {$f=false;}
    $s=substr($s, $r+1, $len-$r-1);
    }
    $mas[$n-1]=$s;
    if (($mas[$n-1]<1) || ($mas[$n-1]>100))
    {$f=false;}
$r=stripos($s1,' ');
$a=substr($s1, 0, $r);
$b=substr($s1, $r+1, $len1-$r-1);
if (($a<1)||($b<=$a)||($b>$n)){$f=false;}
    if ($f)
    {

    $count=0;
    for ($i=$a; $i<=$b-1; $i++)
    {
        $count=$count+$mas[$i];
        }
fputs(STDOUT, "$count");
    }
    /*else
    {fputs(STDOUT, "Nevernii diapozon");}*/
    }
/*else
    {fputs(STDOUT, "Число должно быть из диапозона 2<=n<=100");}*/
?>

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

for ($i=$a;$i<$b;$i++)
  $cnt += $items[$i-1];

echo $cnt;
?>

<?php
$n=fgets(STDIN);
$arr=array();
$arr=explode(' ',trim(fgets(STDIN)));
$arr2=explode(' ',trim(fgets(STDIN)));
$count=0;
for($i=$arr2[0];$i<$arr2[1];$i++){
    $count+=$arr[$i-1];
}
printf ('%.0f',$count);
?>

<?php

$n = trim(fgets(STDIN));
$d = explode(' ',trim(fgets(STDIN)));
list($a,$b) = explode(' ',trim(fgets(STDIN)));

$r = 0;
for($i=$a;$i<$b;$i++) $r+=$d[$i-1];

print $r;
?>

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

<?php
$file=fopen("input.txt","r");//STDIN;
$n=fgets($file);
$a=explode(" ",fgets($file));
list($st,$fn)=fscanf($file,"%d %d");
--$st;--$fn;
$ans=0;
for($i=$st;$i<$fn;++$i)
    $ans+=$a[$i];
printf("%d\n",$ans);
?>

<?php

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

    $n = fgets($stdin);
    $weights = explode(" ", fgets($stdin));
    $wants = explode(" ", fgets($stdin));

    $verdict = 0;
    for($i=$wants[0];$i<$wants[1];++$i){
        $verdict+=$weights[$i-1];
    }

    fputs($stdout, $verdict);
?>

<?php
$stdout = fopen('php://stdout', 'w');
fputs(STDOUT, "Vhodnie dannie:  ");
$h = fopen('php://stdin', 'r');
$n = trim(fgets($h));
$s = trim(fgets($h));
$s1 = trim(fgets($h));
$len = strlen($s);
$len1 = strlen($s1);
if ($n>=2 && $n<=100)
	{
		$f=true;
for ($i=1; $i<=$n-2; $i++)
{
	$r=stripos($s,' ');
	$mas[$i]=substr($s, 0, $r);
	if (($mas[$i]<1) || ($mas[$i]>100))
	{$f=false;}
	$s=substr($s, $r+1, $len-$r-1);
	}
	$mas[$n-1]=$s;
	if (($mas[$n-1]<1) || ($mas[$n-1]>100))
	{$f=false;}
	if ($f)
	{
$r=stripos($s1,' ');
$a=substr($s1, 0, $r);
$b=substr($s1, $r+1, $len1-$r-1);
fputs(STDOUT, "Vihodnie dannie:  ");
	$count=0;
	for ($i=$a; $i<=$b-1; $i++)
	{
		$count=$count+$mas[$i];
		}
fputs(STDOUT, "$count");
	}
	else
	{fputs(STDOUT, "Nevernii diapozon");}
	}
else
	{fputs(STDOUT, "����� ������ ���� �� ��������� 2<=n<=100");}
?>


Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece, and each piece contains positive integer amount of squares. Would you help Bob solve this problem?

The first input line contains integer n (1 ≤ n ≤ 105) — amount of squares in the stripe. The second line contains n space-separated numbers — they are the numbers written in the squares of the stripe. These numbers are integer and do not exceed 10000 in absolute value.

Output the amount of ways to cut the stripe into two non-empty pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece. Don't forget that it's allowed to cut the stripe along the squares' borders only.

<?php
fscanf(STDIN, "%d", $n);
$a = array_map("intval", explode(' ', fgets(STDIN)));
$s = array_sum($a);
$pref = 0;
$ans = 0;
for ($i = 0; $i < $n - 1; $i++) {
	$pref += $a[$i];
	if ($pref * 2 == $s)
		$ans++;
}
print($ans."\n");
?>


Bajtek, known for his unusual gifts, recently got an integer array $$$x_0, x_1, \ldots, x_{k-1}$$$.Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website another array $$$a$$$ of length $$$n + 1$$$. As a formal description of $$$a$$$ says, $$$a_0 = 0$$$ and for all other $$$i$$$ ($$$1 \le i \le n$$$) $$$a_i = x_{(i-1)\bmod k} + a_{i-1}$$$, where $$$p \bmod q$$$ denotes the remainder of division $$$p$$$ by $$$q$$$.For example, if the $$$x = [1, 2, 3]$$$ and $$$n = 5$$$, then:  $$$a_0 = 0$$$,  $$$a_1 = x_{0\bmod 3}+a_0=x_0+0=1$$$,  $$$a_2 = x_{1\bmod 3}+a_1=x_1+1=3$$$,  $$$a_3 = x_{2\bmod 3}+a_2=x_2+3=6$$$,  $$$a_4 = x_{3\bmod 3}+a_3=x_0+6=7$$$,  $$$a_5 = x_{4\bmod 3}+a_4=x_1+7=9$$$. So, if the $$$x = [1, 2, 3]$$$ and $$$n = 5$$$, then $$$a = [0, 1, 3, 6, 7, 9]$$$.Now the boy hopes that he will be able to restore $$$x$$$ from $$$a$$$! Knowing that $$$1 \le k \le n$$$, help him and find all possible values of $$$k$$$ — possible lengths of the lost array.

The first line contains exactly one integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the length of the array $$$a$$$, excluding the element $$$a_0$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^6$$$). Note that $$$a_0$$$ is always $$$0$$$ and is not given in the input.

The first line of the output should contain one integer $$$l$$$ denoting the number of correct lengths of the lost array. The second line of the output should contain $$$l$$$ integers — possible lengths of the lost array in increasing order.

NoteIn the first example, any $$$k$$$ is suitable, since $$$a$$$ is an arithmetic progression.Possible arrays $$$x$$$:  $$$[1]$$$ $$$[1, 1]$$$ $$$[1, 1, 1]$$$ $$$[1, 1, 1, 1]$$$  $$$[1, 1, 1, 1, 1]$$$In the second example, Bajtek's array can have three or five elements.Possible arrays $$$x$$$:  $$$[1, 2, 2]$$$ $$$[1, 2, 2, 1, 2]$$$For example, $$$k = 4$$$ is bad, since it leads to $$$6 + x_0 = 8$$$ and $$$0 + x_0 = 1$$$, which is an obvious contradiction.In the third example, only $$$k = n$$$ is good.Array $$$[1, 4, -2]$$$ satisfies the requirements.Note that $$$x_i$$$ may be negative.

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array();
for($x = $a - 1; $x > 0; $x--)
{
     $d = $b[$x] - $b[$x - 1];
     $c[count($c)] = $d;
}
$e = array_unique($c);
if(count($e) == 1)
{
     print $a . "\n";
     $f = range(1, $a);
     print implode(" ", $f);
}
else
{
     $g = array();
     $h = 3;
     while(TRUE)
     {
          if($h <= $a)
          {
               $g[count($g)] = $h;
               $h += 2;
          }
          else
          {
               break;
          }
     }
     if(count($g) == 0)
     {
          print "0\n0";
     }
     else
     {
          print count($g) . "\n";
          print implode(" ", $g);
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array();
for($x = $a - 1; $x > 0; $x--)
{
     $d = $b[$x] - $b[$x - 1];
     $c[count($c)] = $d;
}
$e = array_unique($c);
if(count($e) == 1)
{
     print $a . "\n";
     $f = range(1, $a);
     print implode(" ", $f);
}
else
{
     $g = array();
     $h = 3;
     while(TRUE)
     {
          if($h <= $a)
          {
               $g[count($g)] = $h;
               $h += 2;
          }
          else
          {
               break;
          }
     }
     if(count($g) == 0)
     {
          print "1\n1";
     }
     else
     {
          print count($g) . "\n";
          print implode(" ", $g);
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array();
for($x = $a - 1; $x > 0; $x--)
{
     $d = $b[$x] - $b[$x - 1];
     $c[count($c)] = $d;
}
$e = array_unique($c);
if(count($e) == 1)
{
     print $a . "\n";
     $f = range(1, $a);
     print implode(" ", $f);
}
else
{
     $g = array();
     $h = 3;
     while(TRUE)
     {
          if($h <= $a)
          {
               $g[count($g)] = $h;
               $h += 2;
          }
          else
          {
               break;
          }
     }
     if(count($g) == 0)
     {
          print "0";
     }
     else
     {
          print count($g) . "\n";
          print implode(" ", $g);
     }
}
?>


Polycarp is practicing his problem solving skill. He has a list of $$$n$$$ problems with difficulties $$$a_1, a_2, \dots, a_n$$$, respectively. His plan is to practice for exactly $$$k$$$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $$$n$$$ problems in exactly $$$k$$$ days.Thus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $$$k$$$ days he will solve all the $$$n$$$ problems.The profit of the $$$j$$$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $$$j$$$-th day (i.e. if he solves problems with indices from $$$l$$$ to $$$r$$$ during a day, then the profit of the day is $$$\max\limits_{l \le i \le r}a_i$$$). The total profit of his practice is the sum of the profits over all $$$k$$$ days of his practice.You want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $$$n$$$ problems between $$$k$$$ days satisfying the conditions above in such a way, that the total profit is maximum.For example, if $$$n = 8, k = 3$$$ and $$$a = [5, 4, 2, 6, 5, 1, 9, 2]$$$, one of the possible distributions with maximum total profit is: $$$[5, 4, 2], [6, 5], [1, 9, 2]$$$. Here the total profit equals $$$5 + 6 + 9 = 20$$$.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2000$$$) — the number of problems and the number of days, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2000$$$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).

In the first line of the output print the maximum possible total profit. In the second line print exactly $$$k$$$ positive integers $$$t_1, t_2, \dots, t_k$$$ ($$$t_1 + t_2 + \dots + t_k$$$ must equal $$$n$$$), where $$$t_j$$$ means the number of problems Polycarp will solve during the $$$j$$$-th day in order to achieve the maximum possible total profit of his practice. If there are many possible answers, you may print any of them.

NoteThe first example is described in the problem statement.In the second example there is only one possible distribution.In the third example the best answer is to distribute problems in the following way: $$$[1, 2000], [2000, 2]$$$. The total profit of this distribution is $$$2000 + 2000 = 4000$$$.

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

fscanf(STDIN, "%d %d", $n, $k);
$a = explode(" ", trim(fgets(STDIN)));

arsort($a);
// var_dump($a);

$cnt = 0;
foreach ($a as $key => $val) {
	$cnt++;
	$score += $val;
	$pos[] = $key;
	if ($cnt == $k) {
		break;
	}

}
// echo "pos:";
sort($pos);
// var_dump($pos);
$s[0] = -1;
for ($i = 0; $i < $k - 1; $i++) {
	$s[$i + 1] = $pos[$i];
}
$s[$k] = $n - 1;
for ($i = 0; $i < $k; $i++) {
	$ans[] = $s[$i + 1] - $s[$i];
}
// var_dump($s);
echo $score . PHP_EOL;
echo implode(" ", $ans);


Recently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more useful thing. He decided to calculate what folder contains most subfolders (including nested folders, nested folders of nested folders, and so on) and what folder contains most files (including the files in the subfolders).More formally, the subfolders of the folder are all its directly nested folders and the subfolders of these nested folders. The given folder is not considered the subfolder of itself. A file is regarded as lying in a folder, if and only if it either lies directly in this folder, or lies in some subfolder of the folder.For a better understanding of how to count subfolders and files for calculating the answer, see notes and answers to the samples.You are given a few files that Petya has managed to create. The path to each file looks as follows:diskName:\folder1\folder2\...\ foldern\fileName  diskName is single capital letter from the set {C,D,E,F,G}. folder1, ..., foldern are folder names. Each folder name is nonempty sequence of lowercase Latin letters and digits from 0 to 9. (n ≥ 1) fileName is a file name in the form of name.extension, where the name and the extension are nonempty sequences of lowercase Latin letters and digits from 0 to 9. It is also known that there is no file whose path looks like diskName:\fileName. That is, each file is stored in some folder, but there are no files directly in the root. Also let us assume that the disk root is not a folder.Help Petya to find the largest number of subfolders, which can be in some folder, and the largest number of files that can be in some folder, counting all its subfolders.

Each line of input data contains the description of one file path. The length of each line does not exceed 100, and overall there are no more than 100 lines. It is guaranteed, that all the paths are correct and meet the above rules. It is also guaranteed, that there are no two completely equal lines. That is, each file is described exactly once. There is at least one line in the input data.

Print two space-separated numbers. The first one is the maximal number of possible subfolders in a folder (including nested folders, nested folders of nested folders, and so on). The second one is the maximal number of files in a folder (including nested files in subfolders). Note that the disks are not regarded as folders.

C:
\
folder1
\
folder2
\
folder3
\
file1.txt
C:
\
folder1
\
folder2
\
folder4
\
file1.txt
D:
\
folder1
\
file1.txt

C:
\
file
\
file
\
file
\
file
\
file.txt
C:
\
file
\
file
\
file
\
file2
\
file.txt

NoteIn the first sample we have one folder on the "C" disk. It has no subfolders, which is why the first number in the answer is 0. But this folder contains one file, so the second number of the answer is 1.In the second sample we have several different folders. Consider the "folder1" folder on the "C" disk. This folder directly contains one folder, "folder2". The "folder2" folder contains two more folders — "folder3" and "folder4". Thus, the "folder1" folder on the "C" drive has exactly 3 subfolders. Also this folder contains two files, even though they do not lie directly in the folder, but they are located in subfolders of "folder1".In the third example we see that the names of some folders and some subfolders are identical. Consider the "file" folder, which lies directly on the "C" disk. That folder contains another "file" folder, which in turn contains another "file" folder, which contains two more folders, "file" and "file2". Thus, the "file" folder, which lies directly on the "C" disk, contains 4 subfolders.


There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors want to split problems between two division according to the following rules:   Problemset of each division should be non-empty.  Each problem should be used in exactly one division (yes, it is unusual requirement).  Each problem used in division 1 should be harder than any problem used in division 2.  If two problems are similar, they should be used in different divisions. Your goal is count the number of ways to split problem between two divisions and satisfy all the rules. Two ways to split problems are considered to be different if there is at least one problem that belongs to division 1 in one of them and to division 2 in the other.Note, that the relation of similarity is not transitive. That is, if problem i is similar to problem j and problem j is similar to problem k, it doesn't follow that i is similar to k.

The first line of the input contains two integers n and m (2 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000) — the number of problems prepared for the round and the number of pairs of similar problems, respectively. Each of the following m lines contains a pair of similar problems ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi). It's guaranteed, that no pair of problems meets twice in the input.

Print one integer — the number of ways to split problems in two divisions.

NoteIn the first sample, problems 1 and 2 should be used in division 2, while problems 4 and 5 in division 1. Problem 3 may be used either in division 1 or in division 2.In the second sample, all pairs of problems are similar and there is no way to split problem between two divisions without breaking any rules.Third sample reminds you that the similarity relation is not transitive. Problem 3 is similar to both 1 and 2, but 1 is not similar to 2, so they may be used together.


This is the easy version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting of symbols $$$0$$$ and $$$1$$$). In an operation, you select a prefix of $$$a$$$, and simultaneously invert the bits in the prefix ($$$0$$$ changes to $$$1$$$ and $$$1$$$ changes to $$$0$$$) and reverse the order of the bits in the prefix.For example, if $$$a=001011$$$ and you select the prefix of length $$$3$$$, it becomes $$$011011$$$. Then if you select the entire string, it becomes $$$001001$$$.Your task is to transform the string $$$a$$$ into $$$b$$$ in at most $$$3n$$$ operations. It can be proved that it is always possible.

The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$3t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$)  — the length of the binary strings. The next two lines contain two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

For each test case, output an integer $$$k$$$ ($$$0\le k\le 3n$$$), followed by $$$k$$$ integers $$$p_1,\ldots,p_k$$$ ($$$1\le p_i\le n$$$). Here $$$k$$$ is the number of operations you use and $$$p_i$$$ is the length of the prefix you flip in the $$$i$$$-th operation.

NoteIn the first test case, we have $$$01\to 11\to 00\to 10$$$.In the second test case, we have $$$01011\to 00101\to 11101\to 01000\to 10100\to 00100\to 11100$$$.In the third test case, the strings are already the same. Another solution is to flip the prefix of length $$$2$$$, which will leave $$$a$$$ unchanged.


We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name $$$s$$$ can transform to another superhero with name $$$t$$$ if $$$s$$$ can be made equal to $$$t$$$ by changing any vowel in $$$s$$$ to any other vowel and any consonant in $$$s$$$ to any other consonant. Multiple changes can be made.In this problem, we consider the letters 'a', 'e', 'i', 'o' and 'u' to be vowels and all the other letters to be consonants.Given the names of two superheroes, determine if the superhero with name $$$s$$$ can be transformed to the Superhero with name $$$t$$$.

The first line contains the string $$$s$$$ having length between $$$1$$$ and $$$1000$$$, inclusive. The second line contains the string $$$t$$$ having length between $$$1$$$ and $$$1000$$$, inclusive. Both strings $$$s$$$ and $$$t$$$ are guaranteed to be different and consist of lowercase English letters only.

Output "Yes" (without quotes) if the superhero with name $$$s$$$ can be transformed to the superhero with name $$$t$$$ and "No" (without quotes) otherwise. You can print each letter in any case (upper or lower).

NoteIn the first sample, since both 'a' and 'u' are vowels, it is possible to convert string $$$s$$$ to $$$t$$$.In the third sample, 'k' is a consonant, whereas 'a' is a vowel, so it is not possible to convert string $$$s$$$ to $$$t$$$.

<?php

$s = fgets(STDIN);
$t = fgets(STDIN);

$a1111 = new A1111($s, $t);
echo $a1111->handle();

class A1111{

    private $s;
    private $t;

    public function __construct($s, $t){
        $this->s = $s;
        $this->t = $t;
    }

    public function handle(){
        if($this->isLengthDifferent()){
            return "No";
        }

        for($i = 0; $i < strlen($this->s); $i++){
            if($this->isVowel($this->s[$i]) && $this->isConsonent($this->t[$i])){
                return 'No';
            }
            if($this->isConsonent($this->s[$i]) && $this->isVowel($this->t[$i])){
                return 'No';
            }
        }

        return 'Yes';
    }

    private function isLengthDifferent(){
        return strlen($this->s) !== strlen($this->t);
    }

    private function isVowel($c){
        return in_array($c, ['a', 'e', 'i', 'o', 'u']);
    }

    private function isConsonent($c){
        return ! $this->isVowel($c);
    }
}

<?php
	static $va = array('a', 'e', 'i', 'o', 'u');
	//$va = "aeiou";
	fscanf(STDIN, "%s", $s);
	fscanf(STDIN, "%s", $t);
	if(strlen($s)!=strlen($t)) {
		echo 'No';
		exit(0);
	}
	$l = strlen($s);
	for($i=0;$i<$l;$i++) {
		if(in_array($s[$i], $va) && in_array($t[$i], $va)) continue;
		if(!in_array($s[$i], $va) && !in_array($t[$i], $va)) continue;
		echo 'No';
		exit(0);
	}
	echo 'Yes';
?>

<?php
    function check($c){
        $arr = ['a','e','i','o','u'];
        foreach ($arr as $a) {
            if ($c == $a) return 1;
        }
        return 0;
    }

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

    if (strlen($s) != strlen($t)){
        echo 'No';
        return;
    }

    for($i = 0; $i < strlen($s); $i++){
        if (check($s[$i]) != check($t[$i])) {
            echo 'No';
            return;
        }
    }

    echo 'Yes';

<?php

class Main
{
    protected const VOWELS = [
        'a', 'e', 'i', 'o', 'u',
    ];

    public function run(string $stdin): string
    {
        [$s, $t] = array_map('trim', explode("\n", trim($stdin)));
        $length = strlen($s);

        if ($length !== strlen($t)) {
            return 'No';
        }

        for ($i = 0; $i < $length; $i++) {
            if (!self::charCompare($s[$i], $t[$i])) {
                return 'No';
            }
        }

        return 'Yes';
    }

    protected static function charCompare(string $a, string $b): bool
    {
        return in_array($a, self::VOWELS, true) === in_array($b, self::VOWELS, true);
    }
}

echo (new Main)->run(file_get_contents('php://stdin'));

<?
$stdin = fopen('php://stdin', 'r');
ini_set('display_errors', '1');
function read() {
    return trim(fgets(STDIN));
}
$t1 = microtime(true);
$debag = 0;
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
$str1 = str_split(read());
$str2 = str_split(read());
$gl = ['a', 'e', 'i', 'o', 'u'];
$arr1 = [];
$arr2 = [];

$l1 = count($str1);
$l2 = count($str2);
if ($l1 === $l2) {
    for ($i = 0; $i < $l2; $i++) {
        if (in_array($str1[$i], $gl)) {
            $arr1[] = 0;
        } else {
            $arr1[] = 1;
        }

        if (in_array($str2[$i], $gl)) {
            $arr2[] = 0;
        } else {
            $arr2[] = 1;
        }

    }
    if ($arr1 === $arr2) {
       echo 'Yes';
    } else {
        echo 'No';
    }

} else {
    echo 'No';
}

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

<?php
fscanf(STDIN,"%s",$s);
$lenS=strlen($s);
fscanf(STDIN,"%s",$t);
$lenT=strlen($t);
$decision=false;
if($lenS==$lenT)
{
	$vowel="aeiou";
	$count=0;
	for ($i=0; $i <$lenS; $i++)
	 {
		if((substr_count($vowel,$s[$i])==1&&substr_count($vowel,$t[$i])==1)||(substr_count($vowel,$s[$i])!=1&&substr_count($vowel,$t[$i])!=1))
			$count++;
		if($count==$lenS)
			$decision=true;
	 }
}
echo $decision?"YES":"NO";

<?php

function check($c)
{
if($c=='a' || $c=='e' || $c=='i' || $c=='o' || $c=='u')
return 1;
else
return 0;
}

$a=trim(fgets(STDIN));
$b=trim(fgets(STDIN));
$A=strlen($a);
$B=strlen($b);
if($A!=$B)
echo "No";
else
{
for($i=0;$i<$A;$i++)
{
if(check($a[$i])!=check($b[$i]))
{
echo "No";
return;
}
}
echo "Yes";
}
?>

<?php

$a = trim(fgets(STDIN)); //"ua";
$b = trim(fgets(STDIN)); //"akm";

if(strlen($a) != strlen($b)) {
    echo "No";
    die;
}

$vowels = [ 'a', 'e', 'i', 'o' , 'u' ];

for($i = 0; $i < strlen($a); $i++) {
    if( in_array($a[$i], $vowels) && in_array($b[$i], $vowels)) {
        continue;
    }

    if(!in_array($a[$i], $vowels) && !in_array($b[$i], $vowels)) {
        continue;
    }

    echo "No";
    die;
}

echo "Yes";

<?php

// run on php 7.2.13

function println($s)
{
    print $s . PHP_EOL;
}

function main()
{
    $s = trim(fgets(STDIN));
    $t = trim(fgets(STDIN));

    $ans = solve($s, $t);
    println($ans);
}

function solve(string $s, string $t)
{
    // http://php.net/manual/ja/function.preg-replace.php

    $c = '/[^aeiou]/';
    $v = '/[aeiou]/';
    $normalizedS = preg_replace($v, 'V', preg_replace($c, 'C', $s));
    $normalizedT = preg_replace($v, 'V', preg_replace($c, 'C', $t));
    if ($normalizedS === $normalizedT) {
        return 'Yes';
    } else {
        return 'No';
    }
}

main();

<?php

$s = fgets(STDIN);
$t = fgets(STDIN);

$a1111 = new A1111($s, $t);
echo $a1111->handle();

class A1111{

    private $s;
    private $t;

    public function __construct($s, $t){
        $this->s = $s;
        $this->t = $t;
    }

    public function handle(){
        if($this->isLengthDifferent()){
            return "No";
        }

        for($i = 0; $i < strlen($this->s); $i++){
            if($this->isVowel($this->s[$i]) && $this->isConsonent($this->t[$i])){
                return 'No';
            }
            if($this->isConsonent($this->s[$i]) && $this->isVowel($this->t[$i])){
                return 'No';
            }

            return 'Yes';
        }
    }

    private function isLengthDifferent(){
        return strlen($this->s) !== strlen($this->t);
    }

    private function isVowel($c){
        return in_array($c, ['a', 'e', 'i', 'o', 'u']);
    }

    private function isConsonent($c){
        return ! $this->isVowel($c);
    }
}

<?php
	static $va = array('a', 'e', 'i', 'o', 'u');
	//$va = "aeiou";
	fscanf(STDIN, "%s", $s);
	fscanf(STDIN, "%s", $t);
	$l = min(strlen($s), strlen($t));
	for($i=0;$i<$l;$i++) {
		if(in_array($s[$i], $va) && in_array($t[$i], $va)) continue;
		if(!in_array($s[$i], $va) && !in_array($t[$i], $va)) continue;
		echo 'No';
		exit(0);
	}
	echo 'Yes';
?>

<?php
    function check($c){
        $arr = ['a','e','i','o','u'];
        foreach ($arr as $a) {
            if ($c == $a) return 1;
        }
        return 0;
    }

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

    if (strlen($s) != strlen($t)){
        echo 'No';
        return;
    }

    for($i = 0; $i < strlen($s); $i++){
        if (check($s[$i]) != check($s[$i])) {
            echo 'No';
            return;
        }
    }

    echo 'Yes';

<?php

class main
{
    protected const VOWELS = [
        'a', 'e', 'i', 'o', 'u',
    ];

    public function run(string $stdin)
    {
        var_dump($stdin);die();
        [$s, $t] = explode("\n", trim($stdin));
        $length = strlen($s);

        if ($length !== strlen($t)) {
            return 'No';
        }

        for ($i = 0; $i < $length; $i++) {
            if (!$this->charCompare($s[$i], $t[$i])) {
                return 'No';
            }
        }

        return 'Yes';
    }

    public function charCompare(string $a, string $b): bool
    {
        return in_array($a, self::VOWELS, true) === in_array($b, self::VOWELS, true);
    }
}

echo (new main)->run(file_get_contents('php://stdin'));

<?php

class main
{
    protected $vowels = [
        'a', 'e', 'i', 'o', 'u',
    ];

    public function run(string $stdin)
    {
        [$s, $t] = explode("\n", trim($stdin));
        $length = strlen($s);

        if ($length !== strlen($t)) {
            return 'No';
        }

        for ($i = 0; $i < $length; $i++) {
            if (!$this->charCompare($s[$i], $t[$i])) {
                return 'No';
            }
        }

        return 'Yes';
    }

    public function charCompare(string $a, string $b): bool
    {
        return in_array($a, $this->vowels, true) === in_array($b, $this->vowels, true);
    }
}

echo (new main)->run(file_get_contents('php://stdin'));

<?php

function check($c)
{
if($c=='a' || $c=='e' || $c=='i' || $c=='o' || $c=='u')
return 1;
else
return 0;
}

$a=trim(fgets(STDIN));
$b=trim(fgets(STDIN));
$A=strlen($a);
$B=strlen($b);
if($A!=$B)
echo "No";
else
{
for($i=0;$i<$A;$i++)
{
if(check(a[$i])!=check(b[$i]))
{
echo "No";
return;
}
}
echo "Yes";
}
?>

<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

$msl = min(strlen($a), strlen($b));
$vowels = [ 'a', 'e', 'i', 'o' , 'u' ];

for($i = 0; $i < $msl; $i++) {
    if( in_array($a[$i], $vowels) && in_array($b[$i], $vowels)) {
        continue;
    }

    if(!in_array($a[$i], $vowels) && !in_array($b[$i], $vowels)) {
        continue;
    }

    echo "No";
    die;
}

echo "Yes";