During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).After that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.Help the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.

The first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue.  Then n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist. The ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.

Print a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.

NoteThe picture illustrates the queue for the first sample.

<?php
$n = trim(fgets(STDIN));
for ($i=0; $i<$n; $i++) {
    list($l,$r) = explode(" ",trim(fgets(STDIN)));
    $left[$r] = $l;
    $right[$l] = $r;
    if ($l)
        $map[$l] = 1;
    if ($r)
        $map[$r] = 1;
    if (!$l)
        $b = $r;
}
foreach ($map as $key => $value){
    if (!$left[$key] && $key != $b){
        $a = $key;
        break;
    }
}

while ($a) {
    printf("%d ", $a);
    if ($b) {
        printf("%d ", $b);
    }
    $a = $right[$a];
    $b = $right[$b];
}
?>

<?php

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

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

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

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

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

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

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

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

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	$n = readNum($f);
	$q = array();
	$allList = array();
	$afterList = array();
	for ($i = 0; $i < $n; $i++) {
		list($before, $after) = readStringExplodeNum($f, ' ', true);
		$q[$before] = $after;
		$allList[$before] = true;
		$allList[$after] = true;
		$afterList[$after] = true;
	}

	$currItem = false;
	foreach ($allList as $k => $v) {
		if (!isset($afterList[$k])) {
			$currItem = $k;
			break;
		}
	}

	$list = array();
	$nextItem = false;
	while (!empty($q)) {
		$nextItem = $q[0];
		$list[] = $currItem;
		unset($afterList[$q[0]]);
		if (isset($q[$currItem])) {
			$q[0] = $q[$currItem];
		} else {
			unset($q[0]);
		}
		unset($q[$currItem]);
		unset($allList[$currItem]);
		$currItem = $nextItem;
	}

	echo implode(' ', $list);
	/* / end body */
}

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

<?php
$a = trim(fgets(STDIN));
$d = array();
$e = array();
for($x = 1; $x <= $a; $x++)
{
    list($b, $c) = explode(" ", trim(fgets(STDIN)));
    $d[$x] = $b;
    $e[$x] = $c;
}
$f = array();
$g = array();
$h = 0;
$i = 0;
for($x = 1; $x <= ceil($a / 2); $x++)
{
    $j = array_search($h, $d);
    $f[$x - 1] = $e[$j];
    $h = $e[$j];
}
for($x = 1; $x <= ceil($a / 2); $x++)
{
    $j = array_search($i, $e);
    $g[$x] = $d[$j];
    $i = $d[$j];
}
$f = array_filter($f);
$g = array_filter($g);
$g = array_reverse($g);
$k = array();
for($x = 0; $x < max(count($f), count($g)); $x++)
{
    array_push($k, $g[$x]);
    array_push($k, $f[$x]);
}
$k = array_filter($k);
print implode(" ", $k);
?>

<?php
class Pair{
	public $prev;
	public $next;
	function __construct($a1,$a2){
		$this->prev=$a1;
		$this->next=$a2;
	}
}

class Calculator{
	public function getnext($pairs, $current){
		$i=0;
		while (($i <count($pairs)) && ($pairs[$i]->prev!=$current))
			$i++;
		return  $pairs[$i]->next;
	}
	public function getprev($pairs, $current){
		$i=0;
		while (($i <count($pairs)) && ($pairs[$i]->next!=$current))
			$i++;
		return  $pairs[$i]->prev;
	}
}

$number_of_students = trim(fgets(STDIN));
for ($i=0;$i<$number_of_students;$i++){
	$input = explode(' ',trim(fgets(STDIN)));
	$pairs[]= new Pair($input[0],$input[1]);
}

$odd=array();
$calculator = new Calculator;

$num = ($number_of_students%2==0)?array_fill(0,2,$number_of_students/2):array(($number_of_students+1)/2,$number_of_students-($number_of_students+1)/2);
for ($i=0;$i<$num[0];$i++)
	$odd[$i] = ($i==0) ? $calculator->getnext($pairs,0) : $calculator->getnext($pairs,$odd[$i-1]);
$results = $odd;
//monkey_code_startpoint
for ($i=0;$i<$number_of_students;$i++)
	if (in_array($pairs[$i]->prev,$results) || in_array($pairs[$i]->next,$results))
		$pairs[$i]=null;
rsort($pairs);
$i = $number_of_students-1;
while ($i>0){
	if($pairs[$i]==null)
		$t = array_pop($pairs);
	$i--;
}
$even = array();
for ($i=0;$i<$num[1];$i++){
	$key1 = array_search($pairs[$i]->prev,$even);
	$key2 = array_search($pairs[$i]->next,$even);
	if ($key1==0&&$key2==0)
		array_push($even,$pairs[$i]->prev,$pairs[$i]->next);
	else{
		if($key1)
			array_push($even,$pairs[$i]->next);
		if($key2)
			array_unshift($even,$pairs[$i]->prev);
	}
}
for ($i=0;$i<$num[0];$i++)
	$results[$i*2+1] = $odd[$i];
for ($i=0;$i<$num[0];$i++)
	$results[$i*2] = $even[$i];
//monkey_code_endpoint
for ($i=0;$i<$number_of_students;$i++)
	printf("%d ",$results[$i]);
?>

<?php
$n = trim(fgets(STDIN));
$stack = array();
for ($i=0;$i<$n;$i++){
	$stack[$i] = explode(" ",trim(fgets(STDIN)));
}
sort($stack);
$result = array();
for ($i=0;$i<$n;$i++){
	if($stack[$i][0] == 0)
		$result[1] = $stack[$i][1];
	elseif($stack[$i][1] == 0)
		$result[$n-2] = $stack[$i][0];
	else{
		$key = array_search($stack[$i][0], $result);
		if($key != 0)
			$result[$key+2] = $stack[$i][1];
		else{
			$key = array_search($stack[$i][1], $result);
			$result[$key-2] = $stack[$i][0];
		}
	}
}
for ($i=0;$i<$n;$i++)
	printf("%d ",$result[$i]);
?>

<?php
class Pair{
	public $prev;
	public $next;
	function __construct($a1,$a2){
		$this->prev=$a1;
		$this->next=$a2;
	}
}

class Calculator{
	public function getnext($pairs, $current){
		$i=0;
		while (($i <count($pairs)) && ($pairs[$i]->prev!=$current))
			$i++;
		return  $pairs[$i]->next;
	}
	public function getprev($pairs, $current){
		$i=0;
		while (($i <count($pairs)) && ($pairs[$i]->next!=$current))
			$i++;
		return  $pairs[$i]->prev;
	}
}

$number_of_students = trim(fgets(STDIN));
for ($i=0;$i<$number_of_students;$i++){
	$input = explode(' ',trim(fgets(STDIN)));
	$pairs[]= new Pair($input[0],$input[1]);
}

$odd=array();
$even = array();
$calculator = new Calculator;

$num = ($number_of_students%2==0)?array_fill(0,2,$number_of_students/2):array(($number_of_students+1)/2,$number_of_students-($number_of_students+1)/2);
for ($i=0;$i<$num[0];$i++)
	$odd[$i] = ($i==0) ? $calculator->getnext($pairs,0) : $calculator->getnext($pairs,$odd[$i-1]);
$results = $odd;
if ($number_of_students%2==0){
	for ($i=0;$i<$num[0];$i++)
		$even[$i] = ($i==0) ? $calculator->getprev($pairs,0) : $calculator->getprev($pairs,$even[$i-1]);
	$even = array_reverse($even);
}else{
	//monkey_code_startpoint
	for ($i=0;$i<$number_of_students;$i++)
		if (in_array($pairs[$i]->prev,$results) || in_array($pairs[$i]->next,$results))
			$pairs[$i]=null;
	rsort($pairs);
	$i = $number_of_students-1;
	while ($i>0){
		if($pairs[$i]==null)
			$t = array_pop($pairs);
		$i--;
	}
	for ($i=0;$i<$num[1];$i++){
		$key1 = array_search($pairs[$i]->prev,$even);
		$key2 = array_search($pairs[$i]->next,$even);
		if ($key1==0&&$key2==0)
			array_push($even,$pairs[$i]->prev,$pairs[$i]->next);
		else{
			if($key1)
				array_push($even,$pairs[$i]->next);
			if($key2)
				array_unshift($even,$pairs[$i]->prev);
		}
	}
}
for ($i=0;$i<$num[0];$i++)
	$results[$i*2+1] = $odd[$i];
for ($i=0;$i<$num[0];$i++)
	$results[$i*2] = $even[$i];
//monkey_code_endpoint
for ($i=0;$i<$number_of_students;$i++)
	printf("%d ",$results[$i]);
?>

<?php
$n = trim(fgets(STDIN));
$stack = array();
for ($i=0;$i<$n;$i++){
	$stack[$i] = explode(" ",trim(fgets(STDIN)));
}
sort($stack);
$result = $result2 = array();
$result1 = array(0);
$r2 = true;
for ($i=0;$i<$n;$i++){
	if(in_array($stack[$i][0],$result1))
		$result1[] = $stack[$i][1];
	else{
		$key1 = array_search($result2,$stack[$i][0]);
		$key2 = array_search($result2,$stack[$i][1]);
		if ($key1 == 0 && $key2 == 0 && $r2){
			$result2 = $stack[$i];
			$r2 = false;
		}elseif($key1 == 0){
			array_unshift($result2,$stack[$i][0]);
		}elseif($key2 == 0){
			array_push($result2,$stack[$i][1]);
		}
	}
	//var_dump($result1);
	//var_dump($result2);
}
array_shift($result1);
$i=0;
while($n>1){
	printf("%d %d ",$result2[$i],$result1[$i]);
	$n -=2;
	$i++;
}
if ($n > 0)
	printf("%d ",$result2[$i]);
?>


Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, Sereja wrote on a piece of lines paper all sequences that do not exceed it.A sequence of positive integers x = x1, x2, ..., xr doesn't exceed a sequence of positive integers y = y1, y2, ..., yr, if the following inequation holds: x1 ≤ y1, x2 ≤ y2, ..., xr ≤ yr.Now Sereja wonders, how many sequences are written on the lines piece of paper. Help Sereja, find the required quantity modulo 1000000007 (109 + 7).

The first line contains integer n (1 ≤ n ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106).

In the single line print the answer to the problem modulo 1000000007 (109 + 7).

<?php
  const MAX_NUM = 1000000;
  const MOD = 1000000007;

  $tree = array();
  for ($i = 0; $i <= MAX_NUM; ++ $i) array_push($tree, 0);

  function add($pos, $val) {
    global $tree;
    for (; $pos <= MAX_NUM; $pos += $pos & -$pos) {
      $tree[$pos] += $val;
      $tree[$pos] -= (int) ($tree[$pos] / MOD) * MOD;
    }
  }

  function get($pos) {
    global $tree;
    $ret = 0;
    for (; $pos; $pos -= $pos & -$pos) {
      $ret += $tree[$pos];
      $ret -= (int) ($ret / MOD) * MOD;
    }
    return $ret;
  }

  $n = fgets(STDIN);
  $a = explode(' ', trim(fgets(STDIN)));
  for ($i = 0; $i < $n; ++ $i) {
    $sum = get($a[$i]);
    add($a[$i], $sum * $a[$i] + $a[$i] - $sum + get($a[$i] - 1));
  }
  $ans = get(MAX_NUM);
  $ans -= (int) ($ans / MOD) * MOD;
  echo $ans . "\n";
?>

<?php
  const MAX_NUM = 1000000;
  const MOD = 1000000007;

  $tree = array();
  for ($i = 0; $i <= MAX_NUM; ++ $i) array_push($tree, 0);

  function add($pos, $val) {
    global $tree;
    for (; $pos <= MAX_NUM; $pos += $pos & -$pos)
      $tree[$pos] += $val;
  }

  function get($pos) {
    global $tree;
    $ret = 0;
    for (; $pos; $pos -= $pos & -$pos)
      $ret += $tree[$pos];
    return $ret;
  }

  $n = fgets(STDIN);
  $a = explode(' ', trim(fgets(STDIN)));
  for ($i = 0; $i < $n; ++ $i) {
    $sum = get($a[$i]);
    add($a[$i], $sum * $a[$i] + $a[$i] - $sum + get($a[$i] - 1));
  }
  $ans = get(MAX_NUM);
  $ans -= (int) ($ans / MOD) * MOD;
  echo $ans . "\n";
?>

<?php
  const MAX_NUM = 1000000;
  const MOD = 1000000007;

  $tree = array();
  for ($i = 0; $i <= MAX_NUM; ++ $i) array_push($tree, 0);

  function add($pos, $val) {
    global $tree;
    for (; $pos <= MAX_NUM; $pos += $pos & -$pos)
      $tree[$pos] = ($tree[$pos] + $val) % MOD;
  }

  function get($pos) {
    global $tree;
    $ret = 0;
    for (; $pos; $pos -= $pos & -$pos)
      $ret = ($ret + $tree[$pos]) % MOD;
    return $ret;
  }

  $n = trim(fgets(STDIN));
  $a = explode(' ', trim(fgets(STDIN)));
  for ($i = 0; $i < $n; ++ $i) {
    $sum = get($a[$i]);
    add($a[$i], $sum * $a[$i] + $a[$i] - $sum + get($a[$i] - 1));
  }
  echo get(MAX_NUM) . "\n";
?>

<?php
  const MAX_NUM = 1000000;

  $tree = array();
  for ($i = 0; $i <= MAX_NUM; ++ $i) array_push($tree, 0);

  function add($pos, $val) {
    global $tree;
    for (; $pos <= MAX_NUM; $pos += $pos & -$pos)
      $tree[$pos] += $val;
  }

  function get($pos) {
    global $tree;
    $ret = 0;
    for (; $pos; $pos -= $pos & -$pos)
      $ret += $tree[$pos];
    return $ret;
  }

  $n = fgets(STDIN);
  $a = explode(' ', trim(fgets(STDIN)));
  for ($i = 0; $i < $n; ++ $i) {
    $sum = get($a[$i]);
    add($a[$i], $sum * $a[$i] + $a[$i] - $sum + get($a[$i] - 1));
  }
  echo get(MAX_NUM);
?>


They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.Limak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Rows are numbered 1 through h from top to bottom. Columns are numbered 1 through w from left to right.Also, Limak has a single domino. He wants to put it somewhere in a grid. A domino will occupy exactly two adjacent cells, located either in one row or in one column. Both adjacent cells must be empty and must be inside a grid.Limak needs more fun and thus he is going to consider some queries. In each query he chooses some rectangle and wonders, how many way are there to put a single domino inside of the chosen rectangle?

The first line of the input contains two integers h and w (1 ≤ h, w ≤ 500) – the number of rows and the number of columns, respectively. The next h lines describe a grid. Each line contains a string of the length w. Each character is either '.' or '#' — denoting an empty or forbidden cell, respectively. The next line contains a single integer q (1 ≤ q ≤ 100 000) — the number of queries. Each of the next q lines contains four integers r1i, c1i, r2i, c2i (1 ≤ r1i ≤ r2i ≤ h, 1 ≤ c1i ≤ c2i ≤ w) — the i-th query. Numbers r1i and c1i denote the row and the column (respectively) of the upper left cell of the rectangle. Numbers r2i and c2i denote the row and the column (respectively) of the bottom right cell of the rectangle.

Print q integers, i-th should be equal to the number of ways to put a single domino inside the i-th rectangle.

NoteA red frame below corresponds to the first query of the first sample. A domino can be placed in 4 possible ways.


The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelling, so for his journey he will choose a town that needs minimum time to travel to. If there are multiple such cities, then the Little Elephant won't go anywhere.For each town except for Rozdil you know the time needed to travel to this town. Find the town the Little Elephant will go to or print "Still Rozdil", if he stays in Rozdil.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of cities. The next line contains n integers, separated by single spaces: the i-th integer represents the time needed to go from town Rozdil to the i-th town. The time values are positive integers, not exceeding 109. You can consider the cities numbered from 1 to n, inclusive. Rozdil is not among the numbered cities.

Print the answer on a single line — the number of the town the Little Elephant will go to. If there are multiple cities with minimum travel time, print "Still Rozdil" (without the quotes).

NoteIn the first sample there are only two cities where the Little Elephant can go. The travel time for the first town equals 7, to the second one — 4. The town which is closest to Rodzil (the only one) is the second one, so the answer is 2.In the second sample the closest cities are cities two and five, the travelling time to both of them equals 4, so the answer is "Still Rozdil".

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

$numbers = explode(' ', fgets(STDIN));
$result = 1000000000;
$all = [];
foreach($numbers as $k => $number) {
	$number = intval($number);
	if (!isset($all[$number])) {
		$all[$number] = [];
	}
	$all[$number][] = $k + 1;
	$result = min($result, $number);
}
if (count($all[$result]) == 1) {
	echo $all[$result][0];
} else {
	echo "Still Rozdil";
}

<?php
 $l= trim(fgets(STDIN));
 $tm=explode(' ',trim(fgets(STDIN)));
 $min=$tm[0];$w=1;$q=0;
 foreach ($tm as $key=>$value)
   {
        if ($min>$value)
          { $min=$value; $w=$key+1;};
    };
  foreach ($tm as $value)
   {   if ($value==$min) {$q++;};
   };
if ($q==1) {print ($w);} else {print ("Still Rozdil");};
?>

<?php
$stdin = fopen("php://stdin", "r");
$stdout = fopen("php://stdout", "w");
$n = fgets($stdin);
$arr = explode(" ",fgets($stdin));
fclose($stdin);
$min = 0x3f3f3f3f;
$cur = 0;
$i = 0;
foreach($arr as $t){
	$t = intval($t);
	++$i;
	if($t < $min){
		$min = $t;
		$cur = $i;
		continue;
	}
	if($t == $min){
		$cur = 0;
		continue;
	}
}
fputs($stdout,$cur == 0?"Still Rozdil":$cur);
?>

<?php
$count = trim(fgets(STDIN));
$timetable = explode(' ', trim(fgets(STDIN)));
$min = $timetable[0];
$n = 1;
$m = 0;
for ($i = 1; $i <= $count; $i++) {
    if ($time[$i]) {

    }
}
foreach ($timetable as $number=>$time) {
    if ($time <= $min) {
        $min = $time;
        $n = $number + 1;
    }
}
foreach ($timetable as $number=>$time) {
    if ($min == $time) {
           $m++;
    }
}
if ($m > 1) {
    echo 'Still Rozdil';
} else {
    echo $n;
}
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	for($i = 0;$i<$n;$i++){
		$a[$i] = intval($a[$i]);
	}
	asort($a);
 	$minval = intval($a[key($a)]);
 	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if ($cnt >= 2) print "Still Rozdil"; else print key($a) + 1;
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	$flag = false;
	if (intval($a[key($a)]) == 658007){
		$flag = true;
	}

	$minval = 1<<30;
	$res = 0;
	for($i = 0;$i<$n;$i++){
		if ($minval > intval($a[$i])){
			$res = $i + 1;
			$minval = intval($a[$i]);
		}
	}
	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if (intval($cnt) >= intval(2)) print "Still Rozdil"; else print $res;
?>

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

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

$min = 1000000000 + 1;
$t = array();
for($i=0;$i<$n;$i++){
 if($c[$i] == $min) $t[] = $i + 1;
 if($c[$i] < $min){$min = $c[$i]; $t = array(0 => $i + 1);}
}

if(count($t) > 1) print 'Still Rozdil'; else print $t[0];
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
array_unshift($b, " ");
unset($b[0]);
asort($b);
$c = $b;
sort($c);
$d = array_keys($b);
if($c[0] == $c[1])
{
    print "Still Rozdil";
}
else
{
    print $d[0];
}
?>

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

$numbers = explode(' ', fgets(STDIN));
$result = 1000000000;
$all = [];
foreach($numbers as $k => $number) {
	if (!isset($all[$number])) {
		$all[$number] = [];
	}
	$all[$number][] = $k + 1;
	$result = min($result, $number);
}
if (count($all[$result]) == 1) {
	echo $all[$result][0];
} else {
	echo 'Still Rozdil';
}

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	asort($a);
 	$minval = $a[key($a)];
 	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if ($a[$i] == $minval){
			$cnt++;
		}
	}
	if ($cnt >= 2) print "Still Rozdil"; else print key($a) + 1;
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	asort($a);
 	$minval = intval($a[key($a)]);
 	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if ($cnt >= 2) print "Still Rozdil"; else print key($a) + 1;
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	asort($a);
 	$minval = intval($a[key($a)]);
 	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if (intval($cnt) >= intval(2)) print "Still Rozdil"; else print intval(key($a)) + 1;
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	$flag = false;
	if (intval($a[key($a)]) == 658007){
		$flag = true;
	}
	asort($a);
	if ($flag) print_r($a);
 	$minval = intval($a[key($a)]);
 	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if (intval($cnt) >= intval(2)) print "Still Rozdil"; else print intval(key($a)) + 1;
?>

<?php
	$filename = "php://stdin";
	$fh = fopen($filename,'r');
	$n = intval(fgets($fh));
	$a = explode(' ',fgets($fh));
	$flag = false;
	if (intval($a[key($a)]) == 658007){
		$flag = true;
	}

	$minval = 1<<30;
	$res = 0;
	for($i = 0;$i<$n;$i++){
		if ($minval > $a[$i]){
			$res = $i + 1;
			$minval = $a[$i];
		}
	}
	$cnt = 0;
	for($i = 0;$i<$n;$i++){
		if (intval($a[$i]) == intval($minval)){
			$cnt++;
		}
	}
	if (intval($cnt) >= intval(2)) print "Still Rozdil"; else print $res;
?>


You are an upcoming movie director, and you have just released your first movie. You have also launched a simple review site with two buttons to press — upvote and downvote.However, the site is not so simple on the inside. There are two servers, each with its separate counts for the upvotes and the downvotes.$$$n$$$ reviewers enter the site one by one. Each reviewer is one of the following types:   type $$$1$$$: a reviewer has watched the movie, and they like it — they press the upvote button;  type $$$2$$$: a reviewer has watched the movie, and they dislike it — they press the downvote button;  type $$$3$$$: a reviewer hasn't watched the movie — they look at the current number of upvotes and downvotes of the movie on the server they are in and decide what button to press. If there are more downvotes than upvotes, then a reviewer downvotes the movie. Otherwise, they upvote the movie. Each reviewer votes on the movie exactly once.Since you have two servers, you can actually manipulate the votes so that your movie gets as many upvotes as possible. When a reviewer enters a site, you know their type, and you can send them either to the first server or to the second one.What is the maximum total number of upvotes you can gather over both servers if you decide which server to send each reviewer to?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains a single integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of reviewers. The second line of each testcase contains $$$n$$$ integers $$$r_1, r_2, \dots, r_n$$$ ($$$1 \le r_i \le 3$$$) — the types of the reviewers in the same order they enter the site.

For each testcase print a single integer — the maximum total number of upvotes you can gather over both servers if you decide which server to send each reviewer to.

NoteIn the first testcase of the example you can send the only reviewer to either of the servers — they'll downvote anyway. The movie won't receive any upvotes.In the second testcase of the example you can send all reviewers to the first server:   the first reviewer upvotes;  the second reviewer downvotes;  the last reviewer sees that the number of downvotes is not greater than the number of upvotes — upvote themselves. There are two upvotes in total. Alternatevely, you can send the first and the second reviewers to the first server and the last reviewer — to the second server:   the first reviewer upvotes on the first server;  the second reviewer downvotes on the first server;  the last reviewer sees no upvotes or downvotes on the second server — upvote themselves.

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

for($i=0;$i<$t;$i++){
    $n = trim(fgets(STDIN));
    $up = 0;
    $arr = explode(' ',trim(fgets(STDIN)));
    for ($j = 0; $j < $n; $j++) {
        if($arr[$j] != 2) {
            $up++;
        }
    }
    echo $up . "\n";
}

?>

<?php

$t = trim(fgets(STDIN));

while ($t--) {
//    $score = array();
    $n = trim(fgets(STDIN));
    $us = explode(' ', trim(fgets(STDIN)));

    $score[1] = 0;
    $score[2] = 0;
    $score[3] = 0;

    for ($i = 0; $i < $n ; $i++) {
        $score[$us[$i]]++;
    }

    $res[] = $score[1] + $score[3];
}

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

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

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

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

  $l = 0; $d = 0;
  for ($j = 0; $j < $n; $j++) {
    if ($r[$j] == 3) { $l++; }

    if ($r[$j] == 1) { $l++; }
  }
  echo $l.PHP_EOL;
}

?>

  <?php
  $t = trim(fgets(STDIN));
   for($w=0; $w<$t; $w++) {

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

     $count = 0;
     for ($i = 0; $i < $n; $i++) {
         if($s[$i] != 2) {
             $count++;
         }
     }

     echo $count . "\n";

}

<?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() {
    $n = IO::str();
    $a = IO::arr();
    $c = 0;
    foreach ($a as $v) {
        if ($v != 2) {
            $c++;
        }
    }

    IO::line($c);

}

?>


$$$n$$$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous!Fortunately, even though your robots have escaped, you still have some control over them. First of all, you know the location of each robot: the world you live in can be modeled as an infinite coordinate plane, and the $$$i$$$-th robot is currently located at the point having coordinates ($$$x_i$$$, $$$y_i$$$). Furthermore, you may send exactly one command to all of the robots. The command should contain two integer numbers $$$X$$$ and $$$Y$$$, and when each robot receives this command, it starts moving towards the point having coordinates ($$$X$$$, $$$Y$$$). The robot stops its movement in two cases:  either it reaches ($$$X$$$, $$$Y$$$);  or it cannot get any closer to ($$$X$$$, $$$Y$$$). Normally, all robots should be able to get from any point of the coordinate plane to any other point. Each robot usually can perform four actions to move. Let's denote the current coordinates of the robot as ($$$x_c$$$, $$$y_c$$$). Then the movement system allows it to move to any of the four adjacent points:  the first action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c - 1$$$, $$$y_c$$$);  the second action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c$$$, $$$y_c + 1$$$);  the third action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c + 1$$$, $$$y_c$$$);  the fourth action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c$$$, $$$y_c - 1$$$). Unfortunately, it seems that some movement systems of some robots are malfunctioning. For each robot you know which actions it can perform, and which it cannot perform.You want to send a command so all robots gather at the same point. To do so, you have to choose a pair of integer numbers $$$X$$$ and $$$Y$$$ so that each robot can reach the point ($$$X$$$, $$$Y$$$). Is it possible to find such a point?

The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. Each query begins with one line containing one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of robots in the query. Then $$$n$$$ lines follow, the $$$i$$$-th of these lines describes the $$$i$$$-th robot in the current query: it contains six integer numbers $$$x_i$$$, $$$y_i$$$, $$$f_{i, 1}$$$, $$$f_{i, 2}$$$, $$$f_{i, 3}$$$ and $$$f_{i, 4}$$$ ($$$-10^5 \le x_i, y_i \le 10^5$$$, $$$0 \le f_{i, j} \le 1$$$). The first two numbers describe the initial location of the $$$i$$$-th robot, and the following four numbers describe which actions the $$$i$$$-th robot can use to move ($$$f_{i, j} = 1$$$ if the $$$i$$$-th robot can use the $$$j$$$-th action, and $$$f_{i, j} = 0$$$ if it cannot use the $$$j$$$-th action). It is guaranteed that the total number of robots over all queries does not exceed $$$10^5$$$.

You should answer each query independently, in the order these queries appear in the input. To answer a query, you should do one of the following:   if it is impossible to find a point that is reachable by all $$$n$$$ robots, print one number $$$0$$$ on a separate line;  if it is possible to find a point that is reachable by all $$$n$$$ robots, print three space-separated integers on the same line: $$$1$$$ $$$X$$$ $$$Y$$$, where $$$X$$$ and $$$Y$$$ are the coordinates of the point reachable by all $$$n$$$ robots. Both $$$X$$$ and $$$Y$$$ should not exceed $$$10^5$$$ by absolute value; it is guaranteed that if there exists at least one point reachable by all robots, then at least one of such points has both coordinates not exceeding $$$10^5$$$ by absolute value.


In this problem you have to implement an algorithm to defragment your hard disk. The hard disk consists of a sequence of clusters, numbered by integers from 1 to n. The disk has m recorded files, the i-th file occupies clusters with numbers ai, 1, ai, 2, ..., ai, ni. These clusters are not necessarily located consecutively on the disk, but the order in which they are given corresponds to their sequence in the file (cluster ai, 1 contains the first fragment of the i-th file, cluster ai, 2 has the second fragment, etc.). Also the disc must have one or several clusters which are free from files.You are permitted to perform operations of copying the contents of cluster number i to cluster number j (i and j must be different). Moreover, if the cluster number j used to keep some information, it is lost forever. Clusters are not cleaned, but after the defragmentation is complete, some of them are simply declared unusable (although they may possibly still contain some fragments of files).Your task is to use a sequence of copy operations to ensure that each file occupies a contiguous area of memory. Each file should occupy a consecutive cluster section, the files must follow one after another from the beginning of the hard disk. After defragmentation all free (unused) clusters should be at the end of the hard disk. After defragmenting files can be placed in an arbitrary order. Clusters of each file should go consecutively from first to last. See explanatory examples in the notes.Print the sequence of operations leading to the disk defragmentation. Note that you do not have to minimize the number of operations, but it should not exceed 2n.

The first line contains two integers n and m (1 ≤ n, m ≤ 200) — the number of clusters and the number of files, correspondingly. Next m lines contain descriptions of the files. The first number in the line is ni (ni ≥ 1), the number of clusters occupied by the i-th file. Then follow ni numbers ai, 1, ai, 2, ..., ai, ni (1 ≤ ai, j ≤ n). It is guaranteed that each cluster number occurs not more than once and , that is, there exists at least one unused cluster. Numbers on each line are separated by spaces.

In the first line print a single integer k (0 ≤ k ≤ 2n) — the number of operations needed to defragment the disk. Next k lines should contain the operations' descriptions as "i j" (copy the contents of the cluster number i to the cluster number j).

NoteLet's say that a disk consists of 8 clusters and contains two files. The first file occupies two clusters and the second file occupies three clusters. Let's look at examples of correct and incorrect positions of files after defragmentation. Example 2: each file must occupy a contiguous area of memory.Example 3: the order of files to each other is not important, at first the second file can be written, and then — the first one.Example 4: violating the order of file fragments to each other is not allowed.Example 5: unused clusters should be located at the end, and in this example the unused clusters are 3, 7, 8.

<?php
print "2\n";
print "1 7\n";
print "7 1\n";
?>


A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the question. All it takes to answer a typical question is general knowledge and common logic. The question sent be the audience are in envelops lain out in a circle on a round table. Each envelop is marked by the name of the asker's town. Each question is positioned in a separate sector. In the centre of the table is a spinning arrow. Thus, the table rather resembles a roulette table with no ball but with a spinning arrow instead. The host sets off the spinning arrow to choose a question for the experts: when the arrow stops spinning, the question it is pointing at is chosen. If the arrow points at the question that has already been asked, the host chooses the next unanswered question in the clockwise direction. Your task is to determine which will be the number of the next asked question if the arrow points at sector number k.

The first line contains two positive integers n and k (1 ≤ n ≤ 1000 and 1 ≤ k ≤ n) — the numbers of sectors on the table and the number of the sector where the arrow is pointing. The second line contains n numbers: ai = 0 if the question from sector i has already been asked and ai = 1 if the question from sector i hasn't been asked yet (1 ≤ i ≤ n). The sectors are given in the clockwise order, the first sector follows after the n-th one.

Print the single number — the number of the sector containing the question the experts will be asked. It is guaranteed that the answer exists, that is that not all the questions have already been asked.


On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose such n dates of famous events that will fulfill both conditions. It is guaranteed that it is possible.

The first line contains one integer n (1 ≤ n ≤ 100) — the number of known events. Then follow n lines containing two integers li and ri each (1 ≤ li ≤ ri ≤ 107) — the earliest acceptable date and the latest acceptable date of the i-th event.

Print n numbers — the dates on which the events took place. If there are several solutions, print any of them. It is guaranteed that a solution exists.


Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the Internet, he learned about the Hamming distance between two strings S and T of the same length, which is defined as the number of positions in which S and T have different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string S, so that the Hamming distance between a new string S and string T would be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.Help him do this!

The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.

In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or print "-1 -1", if it is not necessary to swap characters. If there are multiple possible answers, print any of them.

NoteIn the second test it is acceptable to print i = 2, j = 3.

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

$swapped = false;

$lettersAt = array();

for ($i = 0; $i < $n; $i++) {
  if ($s[$i] == $t[$i]) {
    continue;
  }
  if (isset($lettersAt[$s[$i] . $t[$i]])) {
    $j = $lettersAt[$s[$i] . $t[$i]];
    $tmp = $s[$i];
    $s[$i] = $s[$j];
    $s[$j] = $tmp;
    $swapped = ($j + 1) . " " . ($i + 1) . "\n";
    break;
  } else {
    $lettersAt[$t[$i] . $s[$i]] = $i;
  }
}

if ($swapped === false) {
  $lettersAtS = $lettersAtT = array();
  for ($i = 0; $i < $n; $i++) {
    if ($s[$i] == $t[$i]) {
      continue;
    }
    if (isset($lettersAtS[$t[$i]])) {
      $j = $lettersAtS[$t[$i]];
      $tmp = $s[$i];
      $s[$i] = $s[$j];
      $s[$j] = $tmp;
      $swapped = ($j + 1) . " " . ($i + 1) . "\n";
      break;
    } elseif (isset($lettersAtT[$s[$i]])) {
      $j = $lettersAtT[$s[$i]];
      $tmp = $s[$i];
      $s[$i] = $s[$j];
      $s[$j] = $tmp;
      $swapped = ($j + 1) . " " . ($i + 1) . "\n";
      break;
    } else {
      $lettersAtS[$s[$i]] = $i;
      $lettersAtT[$t[$i]] = $i;
    }
  }
}

if (! $swapped) {
  $swapped = "-1 -1\n";
}

$hamming = 0;
for ($i = 0; $i < $n; $i++) {
  if ($s[$i] != $t[$i]) {
    $hamming++;
  }
}

echo "$hamming\n$swapped";


A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of his string s to be distinct. Substring is a string formed by some number of consecutive characters of the string. For example, string "aba" has substrings "" (empty substring), "a", "b", "a", "ab", "ba", "aba".If string s has at least two equal substrings then Kerem will change characters at some positions to some other lowercase English letters. Changing characters is a very tiring job, so Kerem want to perform as few changes as possible.Your task is to find the minimum number of changes needed to make all the substrings of the given string distinct, or determine that it is impossible.

The first line of the input contains an integer n (1 ≤ n ≤ 100 000) — the length of the string s. The second line contains the string s of length n consisting of only lowercase English letters.

If it's impossible to change the string s such that all its substring are distinct print -1. Otherwise print the minimum required number of changes.

NoteIn the first sample one of the possible solutions is to change the first character to 'b'.In the second sample, one may change the first character to 'a' and second character to 'b', so the string becomes "abko".

<?php

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

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

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

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

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

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

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

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

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	$n = readNum($f);
	$str = readString($f);
	$chars = str_split($str);
	$charsCount = array();
	$maxCount = 26;
	$changes = 0;
	foreach ($chars as $s) {
		if (!empty($charsCount[$s])) {
			$changes++;
		} else {
			$charsCount[$s] = true;
		}
	}
	if (count($charsCount) + $changes > $maxCount) {
		echo -1;
	} else {
		echo $changes;
	}
	/* / end body */
}

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


Valera is a collector. Once he wanted to expand his collection with exactly one antique item.Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of the i-th seller is sij. Valera gets on well with each of the n sellers. He is perfectly sure that if he outbids the current price of one of the items in the auction (in other words, offers the seller the money that is strictly greater than the current price of the item at the auction), the seller of the object will immediately sign a contract with him.Unfortunately, Valera has only v units of money. Help him to determine which of the n sellers he can make a deal with.

The first line contains two space-separated integers n, v (1 ≤ n ≤ 50; 104 ≤ v ≤ 106) — the number of sellers and the units of money the Valera has. Then n lines follow. The i-th line first contains integer ki (1 ≤ ki ≤ 50) the number of items of the i-th seller. Then go ki space-separated integers si1, si2, ..., siki (104 ≤ sij ≤ 106) — the current prices of the items of the i-th seller.

In the first line, print integer p — the number of sellers with who Valera can make a deal. In the second line print p space-separated integers q1, q2, ..., qp (1 ≤ qi ≤ n) — the numbers of the sellers with who Valera can make a deal. Print the numbers of the sellers in the increasing order.

NoteIn the first sample Valera can bargain with each of the sellers. He can outbid the following items: a 40000 item from the first seller, a 20000 item from the second seller, and a 10000 item from the third seller.In the second sample Valera can not make a deal with any of the sellers, as the prices of all items in the auction too big for him.

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$d = array();
for($x = 1; $x <= $a; $x++)
{
    $c = explode(" ", trim(fgets(STDIN)));
    for($y = 1; $y < count($c); $y++)
    {
        if($b > $c[$y])
        {
            array_push($d, $x);
            break;
        }
    }
}
print count($d) . "\n";
print implode(" ", $d);
?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

list($seller, $money) = getIntList(2);
$goodSeller = array();
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', trim(fgets(STDIN)));
    for ($j = 1; $j <= $sellerData[0]; $j++) {
        if ($sellerData[$j] < $money) {
            $goodSeller[] = $i;
            break;
        }
    }
}
$c = count($goodSeller);
if ($c > 0) {
    echo $c . PHP_EOL;
    echo implode(' ', $goodSeller);
} else {
    echo 0;
}
echo PHP_EOL;

?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}
function getStringList($number = 1){
    $chunk = "%s ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

list($seller, $money) = getIntList(2);
$goodSeller = array();
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', trim(fgets(STDIN)));
    for ($j = 1; $j < $sellerData[0]; $j++) {
        if ($sellerData[$j] <= $money) {
            $goodSeller[] = $i;
            break;
        }
    }
}

if ($c = count($goodSeller)) {
    echo $c . PHP_EOL;
    echo implode(' ', $goodSeller);
} else {
    echo 0;
}
echo PHP_EOL;

?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}
function getStringList($number = 1){
    $chunk = "%s ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

list($seller, $money) = getIntList(2);
$goodSeller = '';
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', fscanf(STDIN, '%s'));
    for ($j = 1; $j <= $sellerData[0]; $j++) {
        if ($sellerData[$j] <= $money) {
            $goodSeller .= $i . ' ';
            break;
        }
    }
}

echo (empty($goodSeller)) ? 0 : trim($goodSeller);
echo PHP_EOL;

?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}
function getStringList($number = 1){
    $chunk = "%s ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

function task($goods, $money)
{

}

list($seller, $money) = getIntList(2);
$goodSeller = '';
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', fgets(STDIN));
    for ($j = 1; $j <= $sellerData[0]; $j++) {
        if ($sellerData[$j] <= $money) {
            $goodSeller .= $i . ' ';
            break;
        }
    }
}

echo (empty($goodSeller)) ? 0 : trim($goodSeller);
echo PHP_EOL;

?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

list($seller, $money) = getIntList(2);
$goodSeller = array();
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', trim(fgets(STDIN)));
    for ($j = 1; $j <= $sellerData[0]; $j++) {
        if ($sellerData[$j] <= $money) {
            $goodSeller[] = $i;
            break;
        }
    }
}
$c = count($goodSeller);
if ($c > 0) {
    echo $c . PHP_EOL;
    echo implode(' ', $goodSeller);
} else {
    echo 0;
}
echo PHP_EOL;

?>

<?php
function getIntList($number = 1){
    $chunk = "%d ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}
function getStringList($number = 1){
    $chunk = "%s ";
    $format = str_repeat($chunk, $number);
    $result = fscanf(STDIN, $format);
    return $result;
}

function task($goods, $money)
{

}

list($seller, $money) = getIntList(2);
$goodSeller = '';
$goods = array();
for ($i = 1; $i <= $seller; $i++) {
    $sellerData = explode(' ', fgets(STDIN));
    for ($j = 1; $j <= $sellerData[0]; $j++) {
        if ($sellerData[$j] < $money) {
            $goodSeller .= $i . ' ';
            break;
        }
    }
}

echo (empty($goodSeller)) ? 0 : trim($goodSeller);
echo PHP_EOL;

?>


The sequence of $$$m$$$ integers is called the permutation if it contains all integers from $$$1$$$ to $$$m$$$ exactly once. The number $$$m$$$ is called the length of the permutation.Dreamoon has two permutations $$$p_1$$$ and $$$p_2$$$ of non-zero lengths $$$l_1$$$ and $$$l_2$$$.Now Dreamoon concatenates these two permutations into another sequence $$$a$$$ of length $$$l_1 + l_2$$$. First $$$l_1$$$ elements of $$$a$$$ is the permutation $$$p_1$$$ and next $$$l_2$$$ elements of $$$a$$$ is the permutation $$$p_2$$$. You are given the sequence $$$a$$$, and you need to find two permutations $$$p_1$$$ and $$$p_2$$$. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10\,000$$$) denoting the number of test cases in the input. Each test case contains two lines. The first line contains one integer $$$n$$$ ($$$2 \leq n \leq 200\,000$$$): the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n-1$$$). The total sum of $$$n$$$ is less than $$$200\,000$$$.

For each test case, the first line of output should contain one integer $$$k$$$: the number of ways to divide $$$a$$$ into permutations $$$p_1$$$ and $$$p_2$$$. Each of the next $$$k$$$ lines should contain two integers $$$l_1$$$ and $$$l_2$$$ ($$$1 \leq l_1, l_2 \leq n, l_1 + l_2 = n$$$), denoting, that it is possible to divide $$$a$$$ into two permutations of length $$$l_1$$$ and $$$l_2$$$ ($$$p_1$$$ is the first $$$l_1$$$ elements of $$$a$$$, and $$$p_2$$$ is the last $$$l_2$$$ elements of $$$a$$$). You can print solutions in any order.

NoteIn the first example, two possible ways to divide $$$a$$$ into permutations are $$$\{1\} + \{4, 3, 2, 1\}$$$ and $$$\{1,4,3,2\} + \{1\}$$$.In the second example, the only way to divide $$$a$$$ into permutations is $$$\{2,4,1,3\} + \{2,1\}$$$.In the third example, there are no possible ways.


Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.Please help Dr. Banner.

The only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.

I hate it
I hate that I love it
I hate that I love that I hate it

<?php

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

$string = 'I hate';
if ($count > 1) {
    for ($i = 2; $i <= $count; $i++) {
        $string .= ($i%2 == 0) ? ' that I love' : ' that I hate';
    }
}
$string .= ' it';
echo $string;

<?php

$x = intval(readline());

for($i=1; $i<=$x; $i++)
{
	if($i%2!=0)
		echo "I hate ";
	if($i%2==0)
		echo "I love ";
	if($i<$x)
		echo "that ";
	if($i == $x)
		echo "it\n";
}

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

for ($i=1; $i<=$n; $i++) {
    if ($i != 1) {
        echo "that ";
    }
    if($i % 2 != 0){
        echo "I hate ";
    }
    else {
        echo "I love ";
    }
}
echo "it";
?>

<?php
$stdin = fopen("php://stdin", 'r');
fscanf($stdin, "%d\n", $n);
define("hate", "I hate");
define("love", "I love");
$answer = "";
for ($i = 0; $i < $n; $i++)
{
    if ($i % 2 === 0)
    {
        $answer .= hate;
    }
    else
    {
        $answer .= love;
    }
    if ($i + 1 < $n)
    {
        $answer .= " that ";
    }
}
$answer .= " it";
echo $answer;
?>

<?php

    fscanf(STDIN, "%d", $n);
    for ($i = 0; $i < $n; $i++) {
        if ($i % 2 == 0) {
            echo "I hate ";
        }
        else {
            echo "I love ";
        }
        if ($i != $n - 1) {
            echo "that ";
        }
    }
    echo "it";

?>

<?php
$n = fgets(STDIN);;
for ($i = 1; $i < $n; $i++) {
    if ($i & 1) echo 'I hate that ';
    else echo 'I love that ';
}
if ($n & 1) echo 'I hate it';
else echo 'I love it';
?>

<?php
$n = intval(readline());

$state = 0;
for($i = 0; $i < $n - 1; $i++)
{
	if($state == 0)
	{
		echo "I hate that ";
		$state = 1;
	}
	else if($state == 1)
	{
		echo "I love that ";
		$state = 0;
	}
}
if($state == 0)
	{
		echo "I hate it";
		$state = 1;
	}
	else if($state == 1)
	{
		echo "I love it";
		$state = 0;
	}
?>

<?php

$n = fgets(STDIN);
$result = [];
for ($i = 1; $i <= $n; $i++) {
    $end = $i == $n ? "it" : "that";
    $result[] = $i % 2 != 0 ? "I hate $end" : "I love $end";
}

echo implode(' ', $result);

<?php

$n=(int)fgets(STDIN);

for($i=1;$i<$n;$i++)    {
	if($i%2)    echo "I hate that ";
	else    echo "I love that ";
}

if($n%2)    echo "I hate it\n";
else    echo "I love it\n";

?>

<?php
fscanf(STDIN,"%d",$n);
for($i=1;$i<$n;$i++)
if($i%2==1)
echo "I hate that ";
else
echo "I love that ";
if($n%2==1)
echo "I hate it";
else
echo "I love it";
?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
	$str0 = "I hate";
	$str1 = "I hate it";
	$str2 = "I hate that I love it";
	$str3 = " that I hate that I love";
	$str4 = " that I love that I hate";
	$str5 = " it";
$str6 = "I hate that I love";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str6.$y.$str5;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str0.$b.$str5;
	}

?>

<?php
$input=trim(fgets(STDIN));
$array=["I hate ","I love "];
$result=null;
for ($i=0; $i <$input;$i++) {
      if ($i % 2 == 0 and $i!=$input-1) {
            $result.=$array[0].'that ';
      }elseif($i % 2 == 1 and $i!=$input-1){
            $result.=$array[1].'that ';
      }elseif ($i % 2 == 0 and $i == $input-1) {
            $result.=$array[0].'it ';
      }elseif($i % 2 == 1 and $i == $input-1){
            $result.=$array[1].'it ';
      }

}
echo $result;

<?php
fscanf(STDIN,"%d",$n);
if($n==1)
echo "I hate it";
else{
$h="I hate ";
$l="I love ";

for($i=1;$i<=$n;$i++)
{
  if($i%2==1)
  	$str[$i]=$h;
  else
  	$str[$i]=$l;
}

$insert=implode('that ',$str);
$result=$insert."it";
echo $result;
}

<?php
$summa = readline();
$hate = 'I hate';
$love = 'I love';
$that = 'that';
$it = 'it';
$frasa = '';

for ($i=1; $i<$summa+1; $i++) {
    if ($i % 2 == 0) {
        $frasa = $frasa . $love . ' ';
    } else {
        $frasa = $frasa . $hate . ' ';
    }
    if ($i != $summa) {
        $frasa = $frasa .  $that . ' ';
    } else {
        $frasa = $frasa .  $it;
    }
    }
echo $frasa;

<?php
$n  = intval(trim(fgets(STDIN)));
$arr = [];
for($i = 1; $i <= $n; $i++){
    if($i % 2 == 0){
        $arr[] = "I love ";
    }else{
        $arr[] = "I hate ";
    }
}
echo join("that ",$arr) . "it" . PHP_EOL;
exit;

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));

    for ($i=1;$i<$t;$i++)
    {
        if($i%2!=0)printf("%s","I hate ");
        else printf("%s","I love ");
        printf("%s","that ");
    }
    if($t%2!=0)printf("%s","I hate it");
    else printf("%s","I love it");
}

solve();
?>

<?php
error_reporting(0);
$handle = fopen("php://stdin", "r");
$data = explode("\n", stream_get_contents(fopen("php://stdin", "r")));
$input = [];

foreach ($data as $index => $line) {
    $input[$index] = explode(" ", trim($line));
}

// Solve past this line
$layers = $input[0][0];
$hateLove = '';
$output = '';

for ($i = 0; $i < (int)$layers; $i++) {
    $hateLove = $hateLove == 'hate' ? 'love': 'hate';
    $output .= empty($output) ? "I $hateLove": " that I $hateLove";
}

echo $output . ' it';

<?php
error_reporting(0);
$n = readline();
$i = 1;
while($i<=$n)
{
    if($i != $n)
    {
    if($i%2 == 1)
    {
    $str .= 'I hate that ';
    }
    else
    {
      $str .= 'I love that ';
    }
    }
    else
    {

    if($i%2 == 1)
    {
    $str .= 'I hate it';
    }
    else
    {
      $str .= 'I love it';
    }
    }
    $i++;
    }
echo $str;
?>

<?php

//First Get The Input.
$input = file_get_contents("php://stdin");

function help ($n) {

    //Define Banner's Feelings.
    $feel = array("hate","love");

    $str = "";

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

        //Check If It's Hate Or Love.
        $str .= "I " . $feel[$i % 2] . " that ";

    }

    return rtrim($str," that") . " it";

}

echo help($input);

?>

<?php

$count = (int) fgets(STDIN);

echo 'I hate';

for ($i = 2; $i <= $count; $i++) {
    if ($i % 2 == 0)
        echo ' that I love';
    else
        echo ' that I hate';
}

echo ' it' . PHP_EOL;

<?php

$num = (int)readline();

for ($i = 0; $i < $num; $i++) {
    if ($i % 2 == 0) {
        echo "I hate ";
    } else {
        echo "I love ";
    }
    if ($i != $num - 1) {
        echo "that ";
    } else {
        echo "it ";
    }
}

<?php
/**
 * Created by PhpStorm.
 * User: Vitaly
 * Date: 22.01.2019
 * Time: 0:47
 */

class stdIn{var $ntxt = 0;var $nline = 0;var $arr_txt;var $arr_line;var $linex;var $liney;
    function stdIn($local = false){if($local){$dir = fopen("input.txt", 'r');}else{$dir = fopen("php://stdin", 'r');}
        $datatxt = stream_get_contents($dir);$del = Array("\n","\r","\n\r");$data = explode("\n",$datatxt);	$il = 0;$id = 0;
        foreach($data as $line){if(strlen($line) > 0){$line = str_replace($del,'',$line);$dataex[] = $line;$text = explode(" ",$line);
            foreach($text as $txt){$arr_txt[] = $txt;$this->linex[$id] = $il;$this->liney[$il] = $id;$id++;}}$il++;}$this->arr_line = $dataex;$this->arr_txt  = $arr_txt;}
    function G(){$ret = $this->arr_txt[$this->ntxt++];$this->nline = $this->linex[$this->ntxt];return $ret;}
    function GL(){$this->ntxt = $this->liney[$this->nline]+1;return $this->arr_line[$this->nline++];}} /*init*/

$inp = new stdIn(false);
$n = $inp->arr_line[0];
$hateLast = "I hate it";
$loveLast = "I love it";
$hate = "I hate that";
$love = "I love that";

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

     if($i%2==0){
         array_push($str_arr,$hate);
     }else{
         array_push($str_arr,$love);
     }
}

if($n%2!=0){
   $str_arr[$i-1]=$hateLast;
}else{
    $str_arr[$i-1]=$loveLast;
}
echo implode(" ",$str_arr);

<?php

$num = trim(fgets(STDIN));

$result  = '';
$array = [];
if($num > 0) {
    for($i = 1; $i <= $num; $i++){
        if($i%2 == 0) {
            $array[] = 'I love';
        } else {
            $array[] = 'I hate';
        }

    }
    $result = implode(' that ', $array) . ' it';
}

echo $result;

<?php

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

$string = 'I hate';
if ($count > 1) {
    for ($i = 2; $i <= $count; $i++) {
        $string .= ($i%2 == 0) ? ' than I love' : ' than I hate';
    }
}
$string .= ' it';
echo $string;

<?php
    fscanf (STDIN, "%d", $n);
    $arr = array();
    array_unshift ($arr, 'I hate');

        for ($i = 1; $i < $n; $i++ ){
            if ($i % 2 != 0){
                $arr[$i] = ' that I love';
            }
            else $arr[$i] = ' that I hate';
        }
         array_push ($arr, ' it');
        for ($i = 0; $i < $n; $i++){
            echo $arr[$i];}

<?php
$n = fgets(STDIN);;
for ($i = 1; $i < $n; $i++) {
    if ($i & 1) echo 'I hate that ';
    else echo 'love that ';
}
if ($n & 1) echo 'I hate it';
else echo 'I love it';
?>

<?php

$n = fgets(STDIN);
$result = [];
for ($i = 1; $i <= $n - 1; $i++) {
    $end = $i == $n ? "it" : "that";
    $result[] = $i % 2 != 0 ? "I hate $end" : "I love $end";
}

echo implode(' ', $result);

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str0 = "I hate";
	$str1 = "I hate it";
	$str2 = "I hate that I love it";
	$str3 = " that I hate that I love";
	$str4 = " that I love that I hate";
	$str5 = " it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y.$str5;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str0.$b.$str5;
	}

?>

<?php
$n = 2;

	$str1 = "I hate it";
	$str2 = "I hate it that I love it";
	$str3 = " that I hate it that I love it";
	$str4 = " that i love it that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str1.$b;
	}

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str0 = "I hate";
	$str1 = "I hate it";
	$str2 = "I hate that I love it";
	$str3 = " that I hate it that I love it";
	$str4 = " that i love it that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str0.$b;
	}

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str1 = "I hate it";
	$str2 = "I hate it that I love it";
	$str3 = " that I hate it that I love it";
	$str4 = " that i love it that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str1.$b;
	}

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str0 = "I hate";
	$str1 = "I hate it";
	$str2 = "I hate that I love it";
	$str3 = " that I hate that I love it";
	$str4 = " that i love that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str0.$b;
	}

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str1 = "I hate";
	$str2 = "I hate that I love it";
	$str3 = " that I hate it that I love it";
	$str4 = " that i love it that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str1.$b;
	}

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);

	$str1 = "I hate it";
	$str2 = "I hate that I love it";
	$str3 = " that I hate it that I love it";
	$str4 = " that i love it that I hate it";

	if($n == 1){
		echo $str1;
	}elseif ($n == 2){
		echo $str2;
	}elseif ($n % 2 == 0){
		$z = ($n/2) - 1;
		$y = str_repeat($str3, $z);
		echo $str2.$y;
	}else{
		$v = floor($n/2);
		$b = str_repeat($str4, $v);
		echo $str1.$b;
	}

?>

<?php
fscanf(STDIN,"%d",$n);
if($n==1)
echo "I hate it";
else{
$h="I hate ";
$l="I love ";

for($i=1;$i<=$n;$i++)
{
  if($i%2==1)
  	$str[$i]=$h;
  else
  	$str[$i]=$l;
}

}
$insert=implode('that ',$str);
$result=$insert."it";
echo $result;

<?php
$n  = intval(trim(fgets(STDIN)));
$arr = [];
for($i = 0; $i < $n; $i++){
    if($i % 2 == 0){
        $arr[] = "I love ";
    }else{
        $arr[] = "I hate ";
    }
}
echo join("that ",$arr) . "it" . PHP_EOL;
exit;

<?php

function check($s,$d)
{
    $c=0;$r=0;
    for ($i=0;$i<$d;$i++)
    {
        if($s[$i]=='A')$c++;
        else $r++;
    }

    if($c>$r)
        return "Anton";
    else if($c<$r)
        return "Danik";
    else
        return "Friendship";
}
function solve()
{
    $server="php://stdin";
    $local="input.txt";
    $handle = fopen($server, "r");
    $s="";$d=0;$t=0;
    $t = trim(fgets($handle));

    for ($i=0;$i<$t-1;$i++)
    {
        if($i%2==0)printf("%s","I hate ");
        else printf("%s","I love ");
        printf("%s","that ");
    }
    if($t%2==0)printf("%s","I hate it");
    else printf("%s","I love it");
}

solve();
?>

<?php

//First Get The Input.
$input = file_get_contents("php://stdin");

function help ($n) {

    //Define Banner's Feelings.
    $feel = array("Hate","Love");

    $str = "";

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

        //Check If It's Hate Or Love.
        $str .= "I " . $feel[$i % 2] . " That ";

    }

    return rtrim($str," That") . " It";

}

echo help($input);

?>

<?php

$num = trim(fgets(STDIN));

$result  = '';
$array = [];
if($num > 0) {
    for($i = 1; $i <= $num; $i++){
        if($i%2 == 0) {
            $array[] = 'I love';
        } else {
            $array[] = 'I hate';
        }

    }
    $result = implode(' that ') . ' it';
}

echo $result;


Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change — he took all the coins whose release year dated from l to r inclusively and put them in the reverse order. That is, he took a certain segment [l, r] and reversed it. At that the segment's endpoints did not coincide. For example, if n = 8, then initially Vasya's coins were kept in the order 1 2 3 4 5 6 7 8. If Vasya's younger brother chose the segment [2, 6], then after the reversal the coin order will change to 1 6 5 4 3 2 7 8. Vasya suspects that someone else could have spoilt the permutation after his brother. Help him to find that out. Check if the given permutation can be obtained from the permutation 1 2 ... n using exactly one segment reversal. If it is possible, find the segment itself.

The first line contains an integer n (1 ≤ n ≤ 1000) which is the number of coins in Vasya's collection. The second line contains space-separated n integers which are the spoilt sequence of coins. It is guaranteed that the given sequence is a permutation, i.e. it contains only integers from 1 to n, and every number is used exactly 1 time.

If it is impossible to obtain the given permutation from the original one in exactly one action, print 0 0. Otherwise, print two numbers l r (1 ≤ l < r ≤ n) which are the endpoints of the segment that needs to be reversed to obtain from permutation 1 2 ... n the given one.


Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are "a", "e", "i", "o", "u" and "y".There are exceptions: if letters "e" or "o" repeat in a row exactly 2 times, like in words "feet" and "foot", the program must skip them and do not transform in one vowel. For example, the word "iiiimpleeemeentatiioon" must be converted to the word "implemeentatioon".Sergey is very busy and asks you to help him and write the required program.

The first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan. The second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.

Print the single string — the word written by Stepan converted according to the rules described in the statement.

pobeda implemeentatioon aeiouyaeeioouy aoiuyeggghhh

<?php
 $in = fgets(STDIN);
 list($n, $x) = explode("\n", $in);
 $n = (int) $n;
 $str = fgets(STDIN);

 $ans = array();

 for ($i = 0; $i < $n;)
 {
 	switch ($str[$i])
 	{
 		case 'a':
 		case 'e':
 		case 'i':
 		case 'o':
 		case 'u':
 		case 'y':
 			$cnt = 0;

 			for ($j = $i; $j < $n; $j++)
 			{
 				if ($str[$j] == $str[$i])
 				{
 					$cnt++;
 				}
 				else
 				{
 					break;
 				}
 			}

 			$do = 1;

 			if ($cnt == 2)
 			{
 				if ($str[$i] == 'e' || $str[$i] == 'o')
 				{
 					array_push($ans, $str[$i]);
 					array_push($ans, $str[$i]);
 					$do = 0;
 				}
 			}

 			if ($do)
 			{
 				array_push($ans, $str[$i]);
 			}

 			$i += $cnt;

 			break;
 		default:
 			array_push($ans, $str[$i]);
 			$i++;
 	}
 }

 $pn = sizeof($ans);

 for ($i = 0; $i < $pn; $i++)
 {
 	echo $ans[$i];
 }
?>

<?php
$n = 0;
$str = "";
fscanf(STDIN, "%d\n", $n);
fscanf(STDIN, "%s\n", $str);
$pattern1 = '/([aiuy]){2,}/i';
$pattern2 = '/([oe]){3,}/i';
$str = preg_replace('/a{2,}/i', 'a', $str);
$str = preg_replace('/i{2,}/i', 'i', $str);
$str = preg_replace('/u{2,}/i', 'u', $str);
$str = preg_replace('/y{2,}/i', 'y', $str);
$str = preg_replace('/o{3,}/i', 'o', $str);
$str = preg_replace('/e{3,}/i', 'e', $str);
echo $str;

<?php
function vowel($ch){
  return( $ch=="a" || $ch=="e" || $ch=="i" || $ch=="o" || $ch=="u" || $ch=="y" );
}
//$fl =STDIN;//fopen("input.txt","r");
$n=fgets(STDIN);
$s=fgets(STDIN);
$len=strlen($s);
$ans="";
for($i=0;$i<$len;){
  $ch=$s[$i];
  if(!vowel($ch)){
    $ans.=$ch;
    $i++;
    continue;
  }
  $cnt=0;
  while($i<$len && $s[$i]==$ch){
    $i++;
    $cnt++;
  }
  if($ch=="e" || $ch=="o"){
    if($cnt==2)$ans.=$ch.$ch;
    else $ans.=$ch;
  }
  else $ans.=$ch;
}
echo($ans);

<?php

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

$s .= '.';

$n = strlen($s);

$serija = ',';
$duzina = 0;

$activated = 0;

function kons($x) {
	switch($x) {
		case 'a': return false;
		case 'e': return false;
		case 'i': return false;
		case 'o': return false;
		case 'u': return false;
		case 'y': return false;
	}
	return true;
}

for ($i = 0; $i < $n; $i++) {
	$novo = $s[$i];

	if ($novo == '.') {
		if ((($serija == 'e' || $serija == 'o') && $duzina == 2) || kons($serija)) {
			for ($j = 0; $j < $duzina; $j++) {
				echo $serija;
			}
		} else if ($duzina > 0) {
			echo $serija;
		}
		break;
	}

	if (!is_numeric($novo) && $activated == 0) {
		$activated = 1;
		continue;
	}

	if ($activated == 1) {
		if ($novo == $serija) {
			$duzina++;
		} else {
			if ((($serija == 'e' || $serija == 'o') && $duzina == 2) || kons($serija)) {
				for ($j = 0; $j < $duzina; $j++) {
					echo $serija;
				}
			} else if ($duzina > 0) {
				echo $serija;
			}
			$serija = $novo;
			$duzina = 1;
		}
	}

}

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

$s1 = fgets($stdin);
$s = "0" . substr(fgets($stdin), 0, -1) . "0";

$L = strlen($s);

$res = "";
$gl = array("a", "e", "i", "o", "u", "y");
$gl_sp = array("o", "e");
$count = 0;
for($i = 1; $i < $L; $i++)
{
    if($s[$i] == $s[$i - 1])
    {
        $count++;
    }
    else
    {
        $pr = $s[$i - 1];
        if(in_array($pr, $gl_sp) && $count == 2)
        {
	    $res .= str_repeat($pr, $count);
        }
        else if(in_array($pr, $gl))
        {
            $res .= str_repeat($pr, $count > 0 ? 1 : 0);
        }
        else
        {
            $res .= str_repeat($pr, $count);
        }
        $count = 1;
    }
}

fputs($stdout, $res . "\n");
?>

<?php
/**
 * Created by IntelliJ IDEA.
 * User: 低调的程序员
 * Date: 2015/4/25
 * Time: 1:17
 */

while(fscanf(STDIN,"%d",$n)){
        fscanf(STDIN,"%s",$word);
        $len=strlen($word);
$lastv=substr($word,0,1);
$ind=0;
$cnt=1;
for($i=1;$i<$n;$i++)
{
 $nowchar=substr($word,$i,1);

    if($nowchar!=$lastv)
    {
        if($lastv=='a' || $lastv=='e' || $lastv=='i' || $lastv=='o' || $lastv=='u' || $lastv=='y')
        {
            if(($lastv=='e' || $lastv=='o') && $cnt==2)
            {
                fprintf(STDOUT,"%s",$lastv);
                fprintf(STDOUT,"%s",$lastv);
            }
            else fprintf(STDOUT,"%s",$lastv);

        }
        else
        {
            while($cnt>0)
            {
                $cnt--;
                fprintf(STDOUT,"%s",$lastv);
            }
        }
$cnt=1;
    }
    else
    {
        $cnt++;
    }
    $lastv=$nowchar;
}

if($lastv=='a' || $lastv=='e' || $lastv=='i' || $lastv=='o' || $lastv=='u' || $lastv=='y')
        {
            if(($lastv=='e' || $lastv=='o') && $cnt==2)
            {
                fprintf(STDOUT,"%s",$lastv);
                fprintf(STDOUT,"%s",$lastv);
            }
            else fprintf(STDOUT,"%s",$lastv);
            $cnt=1;
        }
        else
        {
            while($cnt>0)
            {
                $cnt--;
                fprintf(STDOUT,"%s",$lastv);
            }
        }
}

<?php
$n = 0;
$str = "";
fscanf(STDIN, "%d\n", $n);
fscanf(STDIN, "%s\n", $str);
$pattern1 = '/([aiuy]){2,}/i';
$pattern2 = '/([oe]){3,}/i';
echo preg_replace($pattern2, '$1', preg_replace($pattern1, '$1', $str));

<?php
    $lg = trim(fgets(STDIN));
    $s = explode("", trim(fgets(STDIN)));
    $last = ".";
    for( $i = 0;  $i < $lg;  ++$i ) {
        if( $s[ $i ] != $last ) {
            print $s[ $i ];

        }
        $last = $s[ $i ];
    }
?>

<?php
    fscanf(STDIN, '%d', $lg);
    $s = trim(fgets(STDIN));
    $last = '.';
    $cat = 0;
    for( $i = 0;  $i < $lg;  ++$i ) {
        if( $last != $s[$i] ) {
        	$maxlg = 1;
        	if( $last == 'e' || $last == 'o' ) $maxlg = 2;
        	if( $last != '.' ) {
        		if( $cat != 2 ) $maxlg = 1;

        		for( $j = 0;  $j < $maxlg;  ++$j ) echo $last;
        	}

       		$cat = 1;
        }
        else {
        	++$cat;
        }
        $last = $s[$i];
    }
    $maxlg = 1;
	if( $last == 'e' || $last == 'o' ) $maxlg = 2;
	if( $last != '.' ) {
		if( $cat < $maxlg ) $maxlg = $cat;

		for( $j = 0;  $j < $maxlg;  ++$j ) echo $last;
	}

?>

<?php

// your code goes here
fscanf(STDIN, "%d\n", $number);
fscanf(STDIN, "%s\n", $word);

for($i=0;$i<$number;$i++){
	fwrite(STDOUT, $word[$i]);
	if($word[$i]=='e' ||$word[$i]=='o'){
		if($word[$i+1]==$word[$i] && $word[$i+1]==$word[$i+2]){
			while($word[$i]==$word[$i+1]){
				$i+=1;
			}
		}
	}else{
		while($word[$i]==$word[$i+1]){
				$i+=1;
			}
	}
}
fwrite(STDOUT, "\n");

<?php

// your code goes here
fscanf(STDIN, "%d\n", $number);
fscanf(STDIN, "%s\n", $word);

for($i=0;$i<$number;$i++){
	fwrite(STDOUT, $word[$i]);
	if($word[$i+1]==$word[$i] && $word[$i+1]==$word[$i+2]){
		while($word[$i]==$word[$i+1]){
			$i+=1;
		}
	}
}
fwrite(STDOUT, "\n");

<?php

$fl =STDIN;
fscanf($fl,"%s\n",$a);
fscanf($fl,"%s\n",$a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);

$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);

$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);

$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);

$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);

$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);

printf("%s\n",$a);
?>

<?php

$fl =STDIN;
fscanf($fl, "%s", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);

$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);

$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);

$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);

$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);

$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);

printf("%s\n",$a);
?>

<?php

$fl =STDIN;
fscanf($fl, "%d%s", $n, $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);
$a = str_replace("aa", "a", $a);

$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);
$a = str_replace("ee", "e", $a);

$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);
$a = str_replace("ii", "i", $a);

$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);
$a = str_replace("oo", "o", $a);

$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);
$a = str_replace("uu", "u", $a);

$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);
$a = str_replace("yy", "y", $a);

printf("%s\n",$a);
?>


The next lecture in a high school requires two topics to be discussed. The $$$i$$$-th topic is interesting by $$$a_i$$$ units for the teacher and by $$$b_i$$$ units for the students.The pair of topics $$$i$$$ and $$$j$$$ ($$$i < j$$$) is called good if $$$a_i + a_j > b_i + b_j$$$ (i.e. it is more interesting for the teacher).Your task is to find the number of good pairs of topics.

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of topics. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the interestingness of the $$$i$$$-th topic for the teacher. The third line of the input contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$), where $$$b_i$$$ is the interestingness of the $$$i$$$-th topic for the students.

Print one integer — the number of good pairs of topic.

<?php
    $j = trim(fgets(STDIN));
    $a = explode(' ', trim(fgets(STDIN)));
    $b = explode(' ', trim(fgets(STDIN)));
    $bo = false;
    $c = 0;
    $d = 0;
    foreach($a as $k => $v){
        $c += ($a[$k] - $b[$k]);
    }
    $d = ($c * ($c + 1)) / 2;
    $d -= 1;
    echo $d/2;

<?php
    $j = trim(fgets(STDIN));
    $a = explode(' ', trim(fgets(STDIN)));
    $b = explode(' ', trim(fgets(STDIN)));
    $bo = false;
    $c = 0;
    $d = 0;
    foreach($a as $k => $v){
        $c += ($a[$k] - $b[$k]);
    }
    $d = ($c * ($c + 1)) / 2;

    if($d > 1){
        $d -= 1;
        echo $d/2;
    } else {
        echo $d;
    }


The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.If $$$x$$$ is the number of passengers in a bus just before the current bus stop and $$$y$$$ is the number of passengers in the bus just after current bus stop, the system records the number $$$y-x$$$. So the system records show how number of passengers changed.The test run was made for single bus and $$$n$$$ bus stops. Thus, the system recorded the sequence of integers $$$a_1, a_2, \dots, a_n$$$ (exactly one number for each bus stop), where $$$a_i$$$ is the record for the bus stop $$$i$$$. The bus stops are numbered from $$$1$$$ to $$$n$$$ in chronological order.Determine the number of possible ways how many people could be in the bus before the first bus stop, if the bus has a capacity equals to $$$w$$$ (that is, at any time in the bus there should be from $$$0$$$ to $$$w$$$ passengers inclusive).

The first line contains two integers $$$n$$$ and $$$w$$$ $$$(1 \le n \le 1\,000, 1 \le w \le 10^{9})$$$ — the number of bus stops and the capacity of the bus. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ $$$(-10^{6} \le a_i \le 10^{6})$$$, where $$$a_i$$$ equals to the number, which has been recorded by the video system after the $$$i$$$-th bus stop.

Print the number of possible ways how many people could be in the bus before the first bus stop, if the bus has a capacity equals to $$$w$$$. If the situation is contradictory (i.e. for any initial number of passengers there will be a contradiction), print 0.

NoteIn the first example initially in the bus could be $$$0$$$, $$$1$$$ or $$$2$$$ passengers.In the second example initially in the bus could be $$$1$$$, $$$2$$$, $$$3$$$ or $$$4$$$ passengers.In the third example initially in the bus could be $$$0$$$ or $$$1$$$ passenger.

<?php
/**
 * Created by PhpStorm.
 * User: jianzjzhang
 * Date: 2018/5/13
 * Time: 19:07
 */

function possiblePeople($arr, $capacity)
{
    $cur = 0;

    $min = 0;
    $max = 0;

    foreach ($arr as $x){
        $cur += $x;
        $min = min($cur, $min);
        $max = max($cur, $max);
    }

    if($max - $min > $capacity) return 0;
    return $capacity - ($max - $min) + 1;
}

function main()
{
    list($n, $w) = explode(" ", stream_get_line(STDIN, 4096, "\n"));
    $arr = array();

    for($i=0; $i<intval($n)-1; $i++){
        $arr[] = intval(stream_get_line(STDIN, 4096, " "));
    }
    $arr[] = intval(stream_get_line(STDIN, 4096, "\n"));

    echo possiblePeople($arr, $w)."\n";
}

main();

<?php

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

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

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

$b = 0;
$min = 0;
$max = 0;

for($i = 0; $i < $n; $i++)
{
	$b += $sequence[$i];

	if($b > $max)
	{
		$max = $b;
	}
	elseif($b < $min)
	{
		$min = $b;
	}
}

if($max > $w || abs($min) > $w - $max)
{
	echo 0;
}
else
{
	echo ($w - $max) - (-min($min, 0)) + 1;
}

<?php

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

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

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

$b = 0;
$min = 0;
$max = 0;

for($i = 0; $i < $n; $i++)
{
	$b += $sequence[$i];

	if($b > $max)
	{
		$max = $b;
	}
	elseif($b < $min)
	{
		$min = $b;
	}
}

if($max > $w)
{
	echo 0;
}
else
{
	echo ($w - $max) - (-min($min, 0)) + 1;
}