Профиль горного хребта схематично задан в виде прямоугольной таблицы из символов «.» (пустое пространство) и «*» (часть горы). Каждый столбец таблицы содержит хотя бы одну «звёздочку». Гарантируется, что любой из символов «*» либо находится в нижней строке матрицы, либо непосредственно под ним находится другой символ «*».  ....................*..*.......*.**.......*.**..*...**.***********   Пример изображения горного хребта.  Маршрут туриста проходит через весь горный хребет слева направо. Каждый день турист перемещается вправо — в соседний столбец в схематичном изображении. Конечно, каждый раз он поднимается (или опускается) в самую верхнюю точку горы, которая находится в соответствующем столбце.Считая, что изначально турист находится в самой верхней точке в первом столбце, а закончит свой маршрут в самой верхней точке в последнем столбце, найдите две величины:  наибольший подъём за день (равен 0, если в профиле горного хребта нет ни одного подъёма),  наибольший спуск за день (равен 0, если в профиле горного хребта нет ни одного спуска).

В первой строке входных данных записаны два целых числа n и m (1 ≤ n, m ≤ 100) — количество строк и столбцов в схематичном изображении соответственно. Далее следуют n строк по m символов в каждой — схематичное изображение горного хребта. Каждый символ схематичного изображения — это либо «.», либо «*». Каждый столбец матрицы содержит хотя бы один символ «*». Гарантируется, что любой из символов «*» либо находится в нижней строке матрицы, либо непосредственно под ним находится другой символ «*».

Выведите через пробел два целых числа:   величину наибольшего подъёма за день (или 0, если в профиле горного хребта нет ни одного подъёма),  величину наибольшего спуска за день (или 0, если в профиле горного хребта нет ни одного спуска).

ПримечаниеВ первом тестовом примере высоты гор равны: 3, 4, 1, 1, 2, 1, 1, 1, 2, 5, 1. Наибольший подъем равен 3 и находится между горой номер 9 (её высота равна 2) и горой номер 10 (её высота равна 5). Наибольший спуск равен 4 и находится между горой номер 10 (её высота равна 5) и горой номер 11 (её высота равна 1).Во втором тестовом примере высоты гор равны: 1, 2, 3, 4, 5. Наибольший подъём равен 1 и находится, например, между горой номер 2 (ее высота равна 2) и горой номер 3 (её высота равна 3). Так как в данном горном хребте нет спусков, то величина наибольшего спуска равна 0.В третьем тестовом примере высоты гор равны: 1, 7, 5, 3, 4, 2, 3. Наибольший подъём равен 6 и находится между горой номер 1 (её высота равна 1) и горой номер 2 (её высота равна 7). Наибольший спуск равен 2 и находится между горой номер 2 (её высота равна 7) и горой номер 3 (её высота равна 5). Такой же спуск находится между горой номер 5 (её высота равна 4) и горой номер 6 (её высота равна 2).


One day n students come to the stadium. They want to play football, and for that they need to split into teams, the teams must have an equal number of people.We know that this group of people has archenemies. Each student has at most two archenemies. Besides, if student A is an archenemy to student B, then student B is an archenemy to student A.The students want to split so as no two archenemies were in one team. If splitting in the required manner is impossible, some students will have to sit on the bench.Determine the minimum number of students you will have to send to the bench in order to form the two teams in the described manner and begin the game at last.

The first line contains two integers n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of students and the number of pairs of archenemies correspondingly. Next m lines describe enmity between students. Each enmity is described as two numbers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the indexes of the students who are enemies to each other. Each enmity occurs in the list exactly once. It is guaranteed that each student has no more than two archenemies. You can consider the students indexed in some manner with distinct integers from 1 to n.

Print a single integer — the minimum number of students you will have to send to the bench in order to start the game.

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			$even = true;
			do {
				$changed = false;
				for ($y = 0; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							} else if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$even = !$even;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += ($even ? 0 : 1);
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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

<?php

$row = explode(" ", trim(fgets(STDIN)));
$n = $row[0];
$m = $row[1];
$cantuse = 0;
$graph = array();
$visited = array();
for ($i = 0; $i < $m; $i++) {
	$row = explode(" ", trim(fgets(STDIN)));
	$a = $row[0];
	$b = $row[1];
	$graph[$a][$b] = 1;
	$graph[$b][$a] = 1;
}
//print_r($graph);
for ($i = 1; $i <= $n; $i++) {
	if (!isset($visited[$i])) {
		dfs($i, null);
	}
}
$canuse = $n - $cantuse;
if($canuse % 2 == 1) {
	$cantuse++;
}
echo $cantuse;

function cycle($vert) {
	global $graph, $cantuse, $visited;
	$pending = array($vert);
	$all = array($vert => 1);
	while ($pending) {
		$curr = array_pop($pending);
		$visited[$curr]  = 1;
		$adj = $graph[$curr];
		foreach ($adj as $key => $val) {
			if (!isset($all[$key])) {
				$all[$key] = 1;
				$pending[] = $key;
			}
		}
	}
	//echo "cycle\n";
	//print_r($all);
	if(count($all) % 2 == 1) {
		$cantuse++;
	}
}

function dfs($vert, $parent) {
	global $graph, $visited;
	if(isset($visited[$vert]) || !isset($graph[$vert])) {
		return;
	}
	$visited[$vert] = 1;
	$adj = $graph[$vert];
	foreach ($adj as $nbr => $val) {
		if ($parent && isset($visited[$nbr]) && $nbr != $parent) {
			cycle($vert);
		} else {
			dfs($nbr, $vert);
		}
	}
}

?>

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			$even = true;
			do {
				$changed = false;
				for ($y = $x; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							}
							if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += ($even ? 0 : 1);
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			$even = true;
			do {
				$changed = false;
				for ($y = $x; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							}
							if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$even = !$even;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += ($even ? 0 : 1);
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			do {
				$changed = false;
				for ($y = $x; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							}
							if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += 1;
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			$even = true;
			do {
				$changed = false;
				for ($y = 0; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							}
							if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$even = !$even;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += ($even ? 0 : 1);
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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

<?php
// Retrieve input and show output
$stream = fopen('php://stdin', 'r');
$input = stream_get_contents($stream);
$inputs = preg_split("/[\s]+/", $input);
echo func($inputs);

// Codeforces Contest 133 - Problem B
function func($in) {
	$n = $in[0];
	$m = $in[1];
	for ($x = 0; $x < $m; $x++) {
		$pair[$x][0] = $in[2 * $x + 2];
		$pair[$x][1] = $in[2 * $x + 3];
		$pair[$x]["used"] = false;
	}

	$ct = 0;
	for ($x = 0; $x < $m; $x++) {
		if (!$pair[$x]["used"]) {
			$start = $pair[$x][0];
			$now = $pair[$x][0];
			$even = true;
			do {
				$changed = false;
				for ($y = $x; $y < $m; $y++) {
					if (($start != $now) || ($y != $x)) {
						if ((!$pair[$y]["used"]) && (($pair[$y][0] == $now) || ($pair[$y][1] == $now))) {
							if ($pair[$y][0] == $now) {
								$now = $pair[$y][1];
							}
							if ($pair[$y][1] == $now) {
								$now = $pair[$y][0];
							}
							$changed = true;
							$even != $even;
							$pair[$y]["used"] = true;
							if ($now == $start) {
								$ct += ($even ? 0 : 1);
								break;
							}
						}
					}
				}
			} while ($changed);
		}
	}

	if (($n - $ct) % 2 == 1) {$ct += 1;}
	return $ct;
}

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


Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:Given two binary numbers $$$a$$$ and $$$b$$$ of length $$$n$$$. How many different ways of swapping two digits in $$$a$$$ (only in $$$a$$$, not $$$b$$$) so that bitwise OR of these two numbers will be changed? In other words, let $$$c$$$ be the bitwise OR of $$$a$$$ and $$$b$$$, you need to find the number of ways of swapping two bits in $$$a$$$ so that bitwise OR will not be equal to $$$c$$$.Note that binary numbers can contain leading zeros so that length of each number is exactly $$$n$$$.Bitwise OR is a binary operation. A result is a binary number which contains a one in each digit if there is a one in at least one of the two numbers. For example, $$$01010_2$$$ OR $$$10011_2$$$ = $$$11011_2$$$.Well, to your surprise, you are not Rudolf, and you don't need to help him$$$\ldots$$$ You are the security staff! Please find the number of ways of swapping two bits in $$$a$$$ so that bitwise OR will be changed.

The first line contains one integer $$$n$$$ ($$$2\leq n\leq 10^5$$$) — the number of bits in each number. The second line contains a binary number $$$a$$$ of length $$$n$$$. The third line contains a binary number $$$b$$$ of length $$$n$$$.

Print the number of ways to swap two bits in $$$a$$$ so that bitwise OR will be changed.

<?php

$n = fgets(STDIN);
$n = (int)$n;

// A
$sBitA = fgets(STDIN);
$aBitA = str_split((trim($sBitA)));
// B
$sBitB = fgets(STDIN);
$aBitB = str_split((trim($sBitB)));

$iDifferentOneBits = 0;
$iDifferentZeroBits = 0;
$iOneBits  = 0;
$iZeroBits = 0;
for($i = 0; $i < $n; $i++) {
    if($aBitA[$i] == $aBitB[$i]) {
        if($aBitA[$i] == '1') {
            $iOneBits++;
        } else {
            $iZeroBits++;
        }
    } else {
        if($aBitA[$i] == '1') {
            $iDifferentOneBits++;
        } else {
            $iDifferentZeroBits++;
        }
    }
}
//print_r($aDifferentOneBits);
# onebits  -  2
# zerobits -  1
# difzero  -  1
# difone   -  1
$iCount =  $iOneBits * $iZeroBits;          # 2
$iCount += $iZeroBits * $iDifferentOneBits; # 1
$iCount += $iDifferentZeroBits * $iDifferentOneBits; # 1

echo $iCount;
?>

<?php

$n = fgets(STDIN);
$n = (int)$n;

// A
$sBitA = fgets(STDIN);
$aBitA = str_split((trim($sBitA)));
// B
$sBitB = fgets(STDIN);
$aBitB = str_split((trim($sBitB)));

$aDifferentOneBits = array();
$aDifferentZeroBits = array();
$aOneBits  = array();
$aZeroBits = array();
for($i = 0; $i < $n; $i++) {
    if($aBitA[$i] == $aBitB[$i]) {
        if($aBitA[$i] == '1') {
            $aOneBits[$i]  = $aBitA[$i];
        } else {
            $aZeroBits[$i] = $aBitA[$i];
        }
    } else {
        if($aBitA[$i] == '1') {
            $aDifferentOneBits[$i] = $aBitA[$i];
        } else {
            $aDifferentZeroBits[$i] = $aBitA[$i];
        }

    }
}
//print_r($aDifferentOneBits);
# onebits  -  2
# zerobits -  1
# difzero  -  1
# difone   -  1
$iCount =  (count($aOneBits) * count($aZeroBits));          # 2
$iCount += (count($aZeroBits) * count($aDifferentOneBits)); # 1
$iCount += (count($aDifferentZeroBits) * count($aDifferentOneBits)); # 1

echo $iCount;
?>


The only difference between easy and hard versions is the size of the input.You are given a string $$$s$$$ consisting of $$$n$$$ characters, each character is 'R', 'G' or 'B'.You are also given an integer $$$k$$$. Your task is to change the minimum number of characters in the initial string $$$s$$$ so that after the changes there will be a string of length $$$k$$$ that is a substring of $$$s$$$, and is also a substring of the infinite string "RGBRGBRGB ...".A string $$$a$$$ is a substring of string $$$b$$$ if there exists a positive integer $$$i$$$ such that $$$a_1 = b_i$$$, $$$a_2 = b_{i + 1}$$$, $$$a_3 = b_{i + 2}$$$, ..., $$$a_{|a|} = b_{i + |a| - 1}$$$. For example, strings "GBRG", "B", "BR" are substrings of the infinite string "RGBRGBRGB ..." while "GR", "RGR" and "GGG" are not.You have to answer $$$q$$$ independent queries.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 2000$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2000$$$) — the length of the string $$$s$$$ and the length of the substring. The second line of the query contains a string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B'. It is guaranteed that the sum of $$$n$$$ over all queries does not exceed $$$2000$$$ ($$$\sum n \le 2000$$$).

For each query print one integer — the minimum number of characters you need to change in the initial string $$$s$$$ so that after changing there will be a substring of length $$$k$$$ in $$$s$$$ that is also a substring of the infinite string "RGBRGBRGB ...".

NoteIn the first example, you can change the first character to 'R' and obtain the substring "RG", or change the second character to 'R' and obtain "BR", or change the third, fourth or fifth character to 'B' and obtain "GB".In the second example, the substring is "BRG".


Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be nested in a matryoshka with a higher number, two matryoshkas can not be directly nested in the same doll, but there may be chain nestings, for example, 1 → 2 → 4 → 5. In one second, you can perform one of the two following operations:  Having a matryoshka a that isn't nested in any other matryoshka and a matryoshka b, such that b doesn't contain any other matryoshka and is not nested in any other matryoshka, you may put a in b;  Having a matryoshka a directly contained in matryoshka b, such that b is not nested in any other matryoshka, you may get a out of b. According to the modern aesthetic norms the matryoshka dolls on display were assembled in a specific configuration, i.e. as several separate chains of nested matryoshkas, but the criminal, following the mysterious plan, took out all the dolls and assembled them into a single large chain (1 → 2 → ... → n). In order to continue the investigation Andrewid needs to know in what minimum time it is possible to perform this action.

The first line contains integers n (1 ≤ n ≤ 105) and k (1 ≤ k ≤ 105) — the number of matryoshkas and matryoshka chains in the initial configuration. The next k lines contain the descriptions of the chains: the i-th line first contains number mi (1 ≤ mi ≤ n), and then mi numbers ai1, ai2, ..., aimi — the numbers of matryoshkas in the chain (matryoshka ai1 is nested into matryoshka ai2, that is nested into matryoshka ai3, and so on till the matryoshka aimi that isn't nested into any other matryoshka). It is guaranteed that m1 + m2 + ... + mk = n, the numbers of matryoshkas in all the chains are distinct, in each chain the numbers of matryoshkas follow in the ascending order.

In the single line print the minimum number of seconds needed to assemble one large chain from the initial configuration.

NoteIn the first sample test there are two chains: 1 → 2 and 3. In one second you can nest the first chain into the second one and get 1 → 2 → 3.In the second sample test you need to disassemble all the three chains into individual matryoshkas in 2 + 1 + 1 = 4 seconds and then assemble one big chain in 6 seconds.


Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence ai. Let us remind you that the subsegment of the sequence is its continuous fragment. A subsegment of numbers is called non-decreasing if all numbers in it follow in the non-decreasing order.Help Kefa cope with this task!

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

Print a single integer — the length of the maximum non-decreasing subsegment of sequence a.

NoteIn the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one.

<?php
//$file = fopen('input.in', 'r');
$file = STDIN;
$n = trim(fgets($file));
$aArray = explode(" ", trim(fgets($file)));
$result = 1;
$temp = 1;
$c = $aArray[0];
for ($i = 1; $i < $n; $i++) {
    if ($aArray[$i]<$c) {
        $result = max($result, $temp);
        $temp = 1;
        $c = $aArray[$i];
    } else {
        $c = $aArray[$i];
        $temp++;
    }
}
$result = max($result, $temp);
echo $result;

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

	$count = 1;
	$arr_result = array();
	for($i=0;$i<$n;$i++)
	{
		if($i < ($n-1))
		{
			if($money[$i] <= $money[$i+1])
			{
				$count = $count + 1;
			}
			else
			{
				array_push($arr_result, $count);
				$count = 1;
			}
		}
		else
		{
			array_push($arr_result, $count);
			$count = 1;
		}
	}
	echo max($arr_result);
?>

<?php
  $n = fgets(STDIN);
  $a = explode(' ', trim(fgets(STDIN)));
  $bef = $cnt = $res = 0;
  for ($i = 0; $i < $n; $i++) {
    if ($a[$i] >= $bef)
      $cnt++;
    else
      $cnt = 1;
    $bef = $a[$i];
    $res = max($cnt, $res);
  }
  print($res);
?>

<?php

$n = (int) readline();
$arr = array_map('intval', explode(' ', fgets(STDIN)));
$max = 1;
$start_index = 0;
$prev = 0;
$cur_max = 1;
for($i =1;$i< $n ;$i++){
    if($arr[$i] < $arr[$i -1]){
        $cur_max = $i - $start_index;
        if($cur_max > $max){
            $max = $cur_max;
        }
        $start_index = $i;
    }
    if($i == $n-1){
        $cur_max = $i - $start_index +1;
        if($cur_max > $max){
            $max = $cur_max;
        }
    }
}

echo $max;

<?php
$n = trim(fgets(STDIN));
$progression= explode(" ",trim(fgets(STDIN)));
$d=array(0);$k=0;$mul=0;
for ($i=0;$i<$n-1;$i++)
{
    if ($progression[$i]<=$progression[$i+1])
    {
        $mul++;
    }
    else
    {
        $d[$k]=$mul;
        $k++;
        $mul=0;
    }
}
$d[]=$mul;
rsort($d);
echo $d[0]+1;

<?php

$n = fgets(STDIN);
$num = fgets(STDIN);

$numbers = explode(' ', $num);

$max = 1;
$currentNum = $numbers[0];
$currentLenth = 1;

for ($i = 1; $i < $n; $i++)
{
	if ((int)$currentNum <= (int)$numbers[$i])
	{
		$currentLenth += 1;
	}
	else
	{
		if ($currentLenth > $max)
		{
			$max = $currentLenth;
		}

		$currentLenth = 1;
	}

	$currentNum = $numbers[$i];
}

if ($currentLenth > $max)
{
	$max = $currentLenth;
}

// $max = 0;
// $currentLenth = 0;

// for ($i = 0; $i < $n; $i++)
// {
// 	if (isset($numbers[$i + 1]))
// 	{
// 		if ($numbers[$i] <= $numbers[$i + 1])
// 		{
// 			$currentLenth += 1;
// 		}
// 		else
// 		{
// 			$
// 		}
// 	}
// }

echo $max;

<?php

$arr = array();
$tmp; // string
$n;
$i; // index
$ans; // answer

while(fgets(STDIN)){
    $tmp = fgets(STDIN);
    $arr = explode(' ',$tmp);
    //var_dump($arr);
    $n = str_word_count($tmp,0,' ') + 1;
    for($i = $tmp = $ans = 0 ; $i < $n ; $i ++){
        if( $i > 0 && (int)$arr[$i] < (int)$arr[$i-1] ){
            $ans = $tmp > $ans ? $tmp : $ans;
            $tmp = 1;
        }
        else{
            $tmp ++ ;
        }
    }
    echo $tmp > $ans ? $tmp : $ans;
}

?>

<?php
$n = fgets(STDIN);
settype($n,'int');
$input=explode(' ',trim(fgets(STDIN)));
$result=[];
$j=0;
for ($i=0; $i < $n-1 ; $i++) {
     if($input[$i] <= $input[$i+1])
     {
      @$result[$j]+=1;
     }else{
           $j++;
     }
}
echo max($result)+1;

<?php

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

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

$nums = explode(" ", trim(fgets($stdin)));

$i = 0;
$max = 1;

foreach ($nums as $key => $num) {
    if ($i > $max) {
        $max = $i;
    }
    $i++;
    if ($key == 0) {
        continue;
    }
    if ($nums[$key - 1] <= $num) {
        continue;
    }
    $i = 1;
}
if ($i > $max) {
    $max = $i;
}

echo $max;

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

for ($i=0; $i < $n-1 ; $i++) {
	if ($a[$i] <= $a[$i+1]) {
		$temp1++;
	}else{
		if ($temp2 < $temp1)
			$temp2=$temp1;
		$temp1=1;
	}
}

if ($temp1 < $temp2) {
	echo $temp2;
}else{
	echo $temp1;
}

?>

<?php

$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	$oneString = 1;
	while ($line[$i+1] >= $line[$i]) {
		$oneString++;
		$i++;
	}
	$result[] = $oneString;
}

echo max($result);

<?php

error_reporting(0);
$n = (int) fgets(STDIN);
$arr = array_map('intval', preg_split('/ /', fgets(STDIN)));
$res = array();
$counter = 1;
for($i=0; $i < count($arr); $i++) {
	if($arr[$i] <= $arr[$i+1]) {
		$counter += 1;
	} else {
		array_push($res, $counter);
		$counter = 1;
	}
}

echo max($res);

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

$val = $arr[0];
$count = 1;
$max  = 1;
for($i=1;$i < $n; $i++)
{
  if($arr[$i]<$val)
   $count = 1;
  else
    $count++;
  $val = $arr[$i];
  $max = max($max,$count);
}
echo $max;

<?php

$a =(int)readline();
$ab = trim(fgets(STDIN));
$b = explode(" ", $ab);
$nrcount = 1;
$count= 1;
$pozitia = 1;

for($i=0; $i<$a-1;$i++) {
	if($b[$i] <= $b[$pozitia]){
		$nrcount++;
	}else{
		$nrcount = 1 ;
		 }
 	if((int)$count < (int)$nrcount){
		$count = $nrcount;
	}
	$pozitia ++;
}

echo $count;

<?php

$num = (int)readline();

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

$counter = 1;

$max = 1;

for ($i = 1; $i < $num; $i++) {
    if($i >= $num) break;

    if ($array[$i - 1] <= $array[$i]) {
        $counter++;
    } elseif ($i + $max < $num && $array[$i + $max - 1] <= $array[$i + $max]) {

        // echo "i => $i; max => $max; counter => $counter\n";
        $i += $max;
        $counter = 1;
        $j = $i - 1;
        $k = $i + 1;

        while (($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) || ($k < $num && $array[$k - 1] <= $array[$k])) {
            // echo "j => $j; k => $k;";

            if ($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) {
                $counter++;
                $j--;
            }

            if ($k < $num && $array[$k - 1] <= $array[$k]) {
                $counter++;
                $k++;
            }

            // echo " count => $counter\n";
        }

        $i = $k + 1;

        if ($max < $counter) {
            $max = $counter;
        }

        $counter = 0;
        // $counter = 0;
        // $i = $i + $max;
        // $j = $i;
        // while($j > $max) {
        //     if($j >= $num) break;

        //     if($array[$j] >= $array[$j-1]) {
        //         $counter++;

        //     } else break;

        //     $j--;

        // }

        /* for($j = $i;$j > $max ;$j--) {
            if($array[$j] >= $array[$j-1]) {
                $counter++;

            } else break;

        }*/

    } else {
        $counter = 0;
        $i += $max - 1;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

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

$counter = 1;

$new_arr = array(1);

$max = 1;

for ($i = 0; $i < $num - 1; $i++) {
    if ($array[$i] <= $array[$i+1]) {
        $counter++;
    } else  {
        $counter = 1;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$n = (int) readline();
$arr = explode(' ', fgets(STDIN));
$max = 1;
$start_index = 0;
$prev = 0;
$cur_max = 1;
for($i =1;$i< $n ;$i++){
    if($arr[$i] < $arr[$i -1]){
        $cur_max = $i - $start_index;
        if($cur_max > $max){
            $max = $cur_max;
        }
        $start_index = $i;
    }
    if($i == $n-1){
        $cur_max = $i - $start_index +1;
        if($cur_max > $max){
            $max = $cur_max;
        }
    }
}

echo $max;

<?php

$n = fgets(STDIN);
$num = fgets(STDIN);

$numbers = explode(' ', $num);

$max = 1;
$currentNum = $numbers[0];
$currentLenth = 1;

for ($i = 1; $i < $n; $i++)
{
	if ($currentNum <= $numbers[$i])
	{
		$currentLenth += 1;
	}
	else
	{
		if ($currentLenth > $max)
		{
			$max = $currentLenth;
		}

		$currentLenth = 1;
	}

	$currentNum = $numbers[$i];
}

if ($currentLenth > $max)
{
	$max = $currentLenth;
}

// $max = 0;
// $currentLenth = 0;

// for ($i = 0; $i < $n; $i++)
// {
// 	if (isset($numbers[$i + 1]))
// 	{
// 		if ($numbers[$i] <= $numbers[$i + 1])
// 		{
// 			$currentLenth += 1;
// 		}
// 		else
// 		{
// 			$
// 		}
// 	}
// }

echo $max;

<?php

$n = fgets(STDIN);
$num = fgets(STDIN);

$numbers = explode(' ', $num);

$max = 1;
$currentNum = $numbers[0];
$currentLenth = 1;

for ($i = 1; $i < $n; $i++)
{
	if ($currentNum <= $numbers[$i])
	{
		$currentLenth += 1;
	}
	else
	{
		if ($currentLenth > $max)
		{
			$max = $currentLenth;
			$currentLenth = 1;
		}
	}

	$currentNum = $numbers[$i];
}

if ($currentLenth > $max)
{
	$max = $currentLenth;
}

// $max = 0;
// $currentLenth = 0;

// for ($i = 0; $i < $n; $i++)
// {
// 	if (isset($numbers[$i + 1]))
// 	{
// 		if ($numbers[$i] <= $numbers[$i + 1])
// 		{
// 			$currentLenth += 1;
// 		}
// 		else
// 		{
// 			$
// 		}
// 	}
// }

echo $max;

<?php

$arr = array();
$tmp; // string
$n;
$i; // index
$ans; // answer

while(fgets(STDIN)){
    $tmp = fgets(STDIN);
    $arr = explode(' ',$tmp);
    //var_dump($arr);
    $n = str_word_count($tmp,0,' ') + 1;
    for($i = $tmp = $ans = 0 ; $i < $n ; $i ++){
        if( $i > 0 && (int)$arr[i] < (int)$arr[i-1] ){
            $ans = $tmp > $ans ? $tmp : $ans;
            $tmp = 1;
        }
        else{
            $tmp ++ ;
        }
    }
    echo $tmp > $ans ? $tmp : $ans;
}

?>

<?php

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

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

$nums = explode(" ", trim(fgets($stdin)));

$i = 0;
$max = 1;

foreach ($nums as $key => $num) {
    $i++;
    if ($key == 0) {
        continue;
    }
    if ($nums[$key - 1] <= $num) {
        continue;
    }
    if ($i > $max) {
        $max = $i;
    }
    $i = 0;
}
if ($i > $max) {
    $max = $i;
}

echo $max;

<?php

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

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

$nums = explode(" ", trim(fgets($stdin)));

$i = 0;
$max = 1;

foreach ($nums as $key => $num) {
    $i++;
    if ($key == 0) {
        continue;
    }
    if ($nums[$key - 1] <= $num) {
        continue;
    }
    if ($i > $max) {
        $max = $i;
    }
    echo $key . PHP_EOL;
    $i = 0;
}
if ($i > $max) {
    $max = $i;
}

echo $max;

<?php

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

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

$nums = explode(" ", trim(fgets($stdin)));

$i = 0;
$max = 1;

foreach ($nums as $key => $num) {
    $i++;
    if ($key == 0) {
        continue;
    }
    if ($nums[$key - 1] <= $num) {
        continue;
    }
    if ($i > $max) {
        $max = $i;
    }
    $i = 1;
}
if ($i > $max) {
    $max = $i;
}

echo $max;

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$arr=array();
$j=0;

while ($i < $n-1) {
	if ($a[$i]>=$a[$i+1]) {
		$j++;
	}else{
		$j++;
		array_push($arr, $j);
		$j=0;
	}
	$i++;
}

rsort($arr);
echo $arr[0];

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=1;
$ada=false;
while ($i <= count($a)) {
	if ($ada) {
		if ($a[$i]==$a[$i-1]) {
			$ada=true;
		}else{
			break;
		}
	}else{
		if ($a[$i]==$a[$i-1]) {
			$ada=true;
		}
	}
	$i++;
}

if ($ada) {
	echo $i;
}else{
	echo 0;
}

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$ada=false;
while ($i < count($a)) {
	if ($ada) {
		if ($a[$i] == $a[$i+1]) {
			$ada=true;
		}else{
			break;
		}
	}else{
		if ($a[$i] == $a[$i+1]) {
			$ada=true;
		}
	}
	$i++;
}

if ($ada) {
	echo $i+1;
}else{
	echo 0;
}

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$temp1=1;
$temp2=1;

while ($i < $n-1) {
	if ($n[$i] <= $n[$i+1]) {
		$temp1++;
	}else{
		if ($temp2 < $temp1) {
			$temp2=$temp1;
		}else{
			$temp1=1;
		}
	}
	$i++;
}

if ($temp1 < $temp2) {
	echo $temp2;
}else{
	echo $temp1;
}

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$temp1=1;
$temp2=1;

while ($i < $n-1) {
	if ($n[$i] <= $n[$i+1]) {
		$temp1++;
	}else{
		if ($temp2 < $temp1)
			$temp2=$temp1;
		$temp1=1;
	}
	$i++;
}

if ($temp1 < $temp2) {
	echo $temp2;
}else{
	echo $temp1;
}

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$temp1=1;
$temp2=1;

while ($i < $n-1) {
	if ($n[$i] <= $n[$i+1]) {
		$temp1++;
	}else{
		if ($temp2 < $temp1) {
			$temp2=$temp1;
		}
		$temp1=1;
	}
	$i++;
}

if ($temp1 < $temp2) {
	echo $temp2;
}else{
	echo $temp1;
}

?>

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

for ($i=0; $i < $n-1 ; $i++) {
	if ($n[$i] <= $n[$i+1]) {
		$temp1++;
	}else{
		if ($temp2 < $temp1)
			$temp2=$temp1;
		$temp1=1;
	}
}

if ($temp1 < $temp2) {
	echo $temp2;
}else{
	echo $temp1;
}

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$arr=array();
$j=0;

while ($i < $n) {
	if ($a[$i]>=$a[$i+1]) {
		$j++;
	}else{
		$j++;
		array_push($arr, $j);
		$j=0;
	}
	$i++;
}

rsort($arr);
echo $arr[0];

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$arr=array();
$j=1;

while ($i < $n) {
	if ($a[$i]>=$a[$i+1]) {
		$j++;
	}else{
		array_push($arr, $j);
		$j=1;
	}
	$i++;
}

rsort($arr);
echo $arr[0];

?>

<?php
$n=trim(fgets(STDIN));
$a=explode(" ", trim(fgets(STDIN)));
$i=0;
$arr=array();
$j=0;

while ($i < $n-1) {
	if ($a[$i]>=$a[$i+1]) {
		$j++;
	}else{
		$j++;
		array_push($arr, $j);
	}
	$i++;
}

rsort($arr);
echo $arr[0];

?>

<?php

$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	if ($line[$i+1] >= $line[$i]) {
		$oneString = 1;
		while ($line[$i+1] >= $line[$i]) {
			$oneString++;
			$i++;
		}
		$result[] = $oneString;
	} elseif ((count($line) == 1) ||(count($line) == 0)) {
		print_r(1);
	}
}

echo max($result);

<?php

$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	if ($line[$i+1] >= $line[$i]) {
		$oneString = 1;
		while ($line[$i+1] >= $line[$i]) {
			$oneString++;
			$i++;
		}
		$result[] = $oneString;
	} elseif (count($line) == 1) {
		print_r(1);
	}
}

echo max($result);

<?php

$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	if ($line[$i+1] >= $line[$i]) {
		$oneString = 1;
		while ($line[$i+1] >= $line[$i]) {
			$oneString++;
			$i++;
		}
		$result[] = $oneString;
	}
}

if((max($line) == 1) || (max($line) == 0)) {
	print_r(1);
}

echo max($result);

<?php
$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	if ($line[$i+1] >= $line[$i]) {
		$oneString = 1;
		while ($line[$i+1] >= $line[$i]) {
			$oneString++;
			$i++;
		}
		$result[] = $oneString;
	}
}

echo max($result);

<?php
$number = fgets(STDIN);
$line = fgets(STDIN);

$line = trim($line);
$line = explode(' ', $line);	  	// cоздаем массив из строки
$result = [];

for ($i=0; $i < $number; $i++) {
	if ($line[$i+1] >= $line[$i]) {
		$oneString = 1;
		while ($line[$i+1] >= $line[$i]) {
			$oneString++;
			$i++;
		}
		$result[] = $oneString;
	}
}

if((count($line) == 1) || (count($line) == 0)) {
	print_r(1);
}

echo max($result);

<?php

error_reporting(0);
$n = (int) fgets(STDIN);
$arr = array_map('intval', preg_split('/ /', fgets(STDIN)));
$counter = 1;
for($i=0; $i < count($arr); $i++) {
	if($arr[$i] <= $arr[$i+1]) {
		$counter += 1;
		$temp = $counter;
	} else {
		$till_now = $temp;
		$counter = 1;
	}
}

if($till_now > $temp) {
	echo $till_now;
} else {
	echo $temp;
}

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array(1);

$max = 0;

for ($i = 0; $i < $num - 1; $i++) {
    if ($array[$i] <= $array[$i+1]) {
        $counter++;
    } else  {
        $counter = 1;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array();

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;
        array_push($new_arr , $counter);
    } else {
        echo true;
        $counter = 0;
    }

}

echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array();

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;
        array_push($new_arr , $counter);
    } else {

        $counter = 1;
    }

}

echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array();
if($num == 1) echo '';
else {
for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;
        array_push($new_arr , $counter);
    } else {

        $counter = 1;
    }

}
}
echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array(1);

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;

    } else {

        $counter = 1;
    }

}
array_push($new_arr , $counter);

echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$max = 1;

for ($i = 1; $i < $num; $i++) {
    if($i >= $num) break;

    if ($array[$i - 1] <= $array[$i]) {
        $counter++;
    } elseif ($i + $max < $num && $array[$i + $max - 1] <= $array[$i + $max]) {
        $i += $max;
        $counter = 1;
        $j = $i - 1;
        $k = $i + 1;

        while (($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) || ($k < $num && $array[$k - 1] <= $array[$k])) {
            if ($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) {
                $counter++;
                $j--;
            }

            if ($k < $num && $array[$k - 1] <= $array[$k]) {
                $counter++;
                $k++;
            }
        }

        $i = $k;

        // $counter = 0;
        // $i = $i + $max;
        // $j = $i;
        // while($j > $max) {
        //     if($j >= $num) break;

        //     if($array[$j] >= $array[$j-1]) {
        //         $counter++;

        //     } else break;

        //     $j--;

        // }

        /* for($j = $i;$j > $max ;$j--) {
            if($array[$j] >= $array[$j-1]) {
                $counter++;

            } else break;

        }*/

    } else {
        $i += $max;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array(1);

$max = -9999;

for ($i = 0; $i < $num - 1; $i++) {
    if ($array[$i] <= $array[$i+1]) {
        $counter++;
    } else  {
        $counter = 1;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

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

$counter = 1;

$max = 1;

for ($i = 1; $i < $num; $i++) {
    if($i >= $num) break;

    if ($array[$i - 1] <= $array[$i]) {
        $counter++;
    } elseif ($i + $max < $num && $array[$i + $max - 1] <= $array[$i + $max]) {

        // echo "i => $i; max => $max; counter => $counter\n";
        $i += $max;
        $counter = 1;
        $j = $i - 1;
        $k = $i + 1;

        while (($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) || ($k < $num && $array[$k - 1] <= $array[$k])) {
            // echo "j => $j; k => $k;";

            if ($j > $i - $max - 2 && $array[$j] <= $array[$j + 1]) {
                $counter++;
                $j--;
            }

            if ($k < $num && $array[$k - 1] <= $array[$k]) {
                $counter++;
                $k++;
            }

            // echo " count => $counter\n";
        }

        $i = $k + 1;

        if ($max < $counter) {
            $max = $counter;
        }

        $counter = 0;
        // $counter = 0;
        // $i = $i + $max;
        // $j = $i;
        // while($j > $max) {
        //     if($j >= $num) break;

        //     if($array[$j] >= $array[$j-1]) {
        //         $counter++;

        //     } else break;

        //     $j--;

        // }

        /* for($j = $i;$j > $max ;$j--) {
            if($array[$j] >= $array[$j-1]) {
                $counter++;

            } else break;

        }*/

    } else {
        $counter = 0;
        $i += $max;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array();

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] >= $array[$i+1]) {
        $counter++;
    } else {
        array_push($new_arr , $counter);
        $counter = 0;
    }

}

echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$max = 1;

for ($i = 1; $i < $num; $i++) {
    if($i >= $num) break;

    if ($array[$i - 1] <= $array[$i]) {
        $counter++;
    } elseif ($i + $max < $num && $array[$i + $max - 1] < $array[$i + $max]) {
        $i += $max;
        $counter = 1;
        $j = $i - 1;
        $k = $i + 1;

        while (($j > $i - $max - 2 && $array[$j] < $array[$j + 1]) || ($k < $num && $array[$k - 1] < $array[$k])) {
            if ($j > $i - $max - 2 && $array[$j] < $array[$j + 1]) {
                $counter++;
                $j--;
            }

            if ($k < $num && $array[$k - 1] < $array[$k]) {
                $counter++;
                $k++;
            }
        }

        $i = $k;

        // $counter = 0;
        // $i = $i + $max;
        // $j = $i;
        // while($j > $max) {
        //     if($j >= $num) break;

        //     if($array[$j] >= $array[$j-1]) {
        //         $counter++;

        //     } else break;

        //     $j--;

        // }

        /* for($j = $i;$j > $max ;$j--) {
            if($array[$j] >= $array[$j-1]) {
                $counter++;

            } else break;

        }*/

    } else {
        $i += $max;
    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$max = 0;

for ($i = 0; $i < $num - 1; $i++) {
    if($i >= $num) break;

    if ($array[$i] <= $array[$i+1]) {
        $counter++;
    } else {
        $i = $i + $max;
        $j = $i;
        while($j > $max) {
            if($j >= $num) break;
            if($array[$j] >= $array[$j-1]) {
                $counter++;

            } else break;

            $j--;

        }

    }

    if ($max < $counter) {
        $max = $counter;
    }

}

echo $max;

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array(1);

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;

    } else {
        array_push($new_arr , $counter);
        $counter = 1;
    }

}

echo max($new_arr);

<?php

$num = (int)readline();

$array = explode(' ', readline());

$counter = 1;

$new_arr = array();

for($i = 0;$i < $num - 1;$i++) {
    if($array[$i] <= $array[$i+1]) {
        $counter++;
        array_push($new_arr , $counter);
    } else {

        $counter = 0;
    }

}

echo max($new_arr);


Vasya is choosing a laptop. The shop has n laptops to all tastes.Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.If all three properties of a laptop are strictly less than those properties of some other laptop, then the first laptop is considered outdated by Vasya. Among all laptops Vasya does not consider outdated, he chooses the cheapest one.There are very many laptops, which is why Vasya decided to write a program that chooses the suitable laptop. However, Vasya doesn't have his own laptop yet and he asks you to help him.

The first line contains number n (1 ≤ n ≤ 100). Then follow n lines. Each describes a laptop as speed ram hdd cost. Besides,    speed, ram, hdd and cost are integers  1000 ≤ speed ≤ 4200 is the processor's speed in megahertz  256 ≤ ram ≤ 4096 the RAM volume in megabytes  1 ≤ hdd ≤ 500 is the HDD in gigabytes  100 ≤ cost ≤ 1000 is price in tugriks  All laptops have different prices.

Print a single number — the number of a laptop Vasya will choose. The laptops are numbered with positive integers from 1 to n in the order in which they are given in the input data.

NoteIn the third sample Vasya considers the first and fifth laptops outdated as all of their properties cannot match those of the third laptop. The fourth one is the cheapest among the laptops that are left. Thus, Vasya chooses the fourth laptop.

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = array();
$d = array();
$e = array();
for($x = 1; $x <= $a; $x++)
{
    list($f, $g, $h, $i) = explode(" ", trim(fgets(STDIN)));
    array_push($b, $f); // скорость процессора
    array_push($c, $g); // объем памяти
    array_push($d, $h); // размер диска
    array_push($e, $i); // цена
}
asort($e);
$j = array_keys($e);
$k = 0;
for($x = 0; $x < $a; $x++)
{
    $k = 0;
    for($y = 0; $y < $a; $y++)
    {
        if(($b[$j[$x]] < $b[$y]) && ($c[$j[$x]] < $c[$y]) && ($d[$j[$x]] < $d[$y]))
        {
            $k = 1;
            continue;
        }
    }
    if($k == 0)
    {
        break;
    }
}
print $j[$x] + 1;
?>

<?php

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

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

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

function foo($notebooks, $n)
{
    $answer = 1;
    $min = 1001;

    for ($i = 0; $i < $n; $i++) {
        for ($j = $n - 1; $j >= 0; $j--) {
            if (
                $notebooks[$i]['speed'] < $notebooks[$j]['speed'] &&
                $notebooks[$i]['ram'] < $notebooks[$j]['ram'] &&
                $notebooks[$i]['hdd'] < $notebooks[$j]['hdd']
            ) {
                $notebooks[$i]['cost'] = 1001;
            }
        }

        if ($notebooks[$i]['cost'] < $min) {
            $min = $notebooks[$i]['cost'];
            $answer = $i;
        }
    }

    return $answer;
}

$r = 0;
$notebooks = [];

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

for ($i = 0; $i < $n; $i++) {
    list(
        $notebooks[$i]['speed'],
        $notebooks[$i]['ram'],
        $notebooks[$i]['hdd'],
        $notebooks[$i]['cost']
    ) = fscanf($input, "%d %d %d %d\n");
}

$r = foo($notebooks, $n);

fwrite($output, $r + 1);

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = array();
$d = array();
$e = array();
for($x = 1; $x <= $a; $x++)
{
    list($f, $g, $h, $i) = explode(" ", trim(fgets(STDIN)));
    array_push($b, $f); // скорость процессора
    array_push($c, $g); // объем памяти
    array_push($d, $h); // размер диска
    array_push($e, $i); // цена
}
asort($e);
$j = array_keys($e);
$k = 0;
for($x = 0; $x < $a; $x++)
{
    for($y = 0; $y < $a; $y++)
    {
        if(($b[$j[$x]] < $b[$y]) && ($c[$j[$x]] < $c[$y]) && ($d[$j[$x]] < $d[$y]))
        {
            continue;
        }
        else
        {
            $k = 1;
            break;
        }
    }
    if($k == 1)
    {
        break;
    }
}
print $j[$x];
?>


You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.The building consists of n towers, h floors each, where the towers are labeled from 1 to n, the floors are labeled from 1 to h. There is a passage between any two adjacent towers (two towers i and i + 1 for all i: 1 ≤ i ≤ n - 1) on every floor x, where a ≤ x ≤ b. It takes exactly one minute to walk between any two adjacent floors of a tower, as well as between any two adjacent towers, provided that there is a passage on that floor. It is not permitted to leave the building. The picture illustrates the first example. You have given k pairs of locations (ta, fa), (tb, fb): floor fa of tower ta and floor fb of tower tb. For each pair you need to determine the minimum walking time between these locations.

The first line of the input contains following integers:   n: the number of towers in the building (1 ≤ n ≤ 108),  h: the number of floors in each tower (1 ≤ h ≤ 108),  a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h),  k: total number of queries (1 ≤ k ≤ 104).  Next k lines contain description of the queries. Each description consists of four integers ta, fa, tb, fb (1 ≤ ta, tb ≤ n, 1 ≤ fa, fb ≤ h). This corresponds to a query to find the minimum travel time between fa-th floor of the ta-th tower and fb-th floor of the tb-th tower.

For each query print a single integer: the minimum walking time between the locations in minutes.

<?php
// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d %d %d %d", $n, $h, $a, $b, $k);
for ($i = 0; $i < $k; $i++) {
	fscanf(STDIN, "%d %d %d %d", $ta, $fa, $tb, $fb);
	if ($ta == $tb) {
		$answer = abs($fa - $fb);
	} else {
		$flag_a = false;
		$flag_b = false;
		$cost_a = $cost_b = 0;

		if ($fa <= $a && $b <= $fa) {

		} else {
			if ($fa < $a) {
				$cost_a = $a - $fa;
			} elseif ($fa > $b) {
				$cost_a = $b - $fa;
			}
		}
		if ($fb <= $a && $b <= $fb) {

		} else {
			if ($fb < $a) {
				$cost_b = $a - $fb;
			} elseif ($fb > $b) {
				$cost_b = $b - $fb;
			}
		}

		if (DEBUG) {
			echo $cost_a, "!", $cost_b, PHP_EOL;
		}

		if ($cost_a * $cost_b <= 0) {
			// $cost_a = $cost_b = 0;
			$cost_a = abs($fb - $fa);
			$cost_b = 0;
		}
		if (DEBUG) {
			echo $cost_a, "*", $cost_b, PHP_EOL;
		}

		$answer = abs($cost_a) + abs($cost_b) + abs($ta - $tb);
	}
	echo $answer . PHP_EOL;
}

<?php
// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d %d %d %d", $n, $h, $a, $b, $k);
for ($i = 0; $i < $k; $i++) {
	fscanf(STDIN, "%d %d %d %d", $ta, $fa, $tb, $fb);
	$a_cost = 0;
	$b_cost = 0;
	$f_cost = 0;
	$t_cost = 0;
	if ($ta != $tb) {
		if ($fa > $b) {
			$a_cost = $fa - $b;
		} elseif ($fa < $a) {
			$a_cost = $fa - $a;
		} else {
			$a_cost = 0;
		}
		if ($fb > $b) {
			$b_cost = $fb - $b;
		} elseif ($fb < $a) {
			$b_cost = $fb - $a;
		} else {
			$b_cost = 0;
		}
		if (DEBUG) {
			echo $a_cost, "*", $b_cost . PHP_EOL;
		}

		if ($a_cost * $b_cost < 0) {
			$a_cost = $b_cost = 0;
		} else {
			$a_cost = abs($a_cost);
			$b_cost = abs($b_cost);
		}
		$f_cost = abs($fa - $fb);
		$t_cost = abs($ta - $tb);
	} else {
		$f_cost = abs($fa - $fb);
	}
	if (DEBUG) {
		echo "{$a_cost} {$b_cost}\n";
	}

	$cost = $a_cost + $b_cost + $f_cost + $t_cost;

	echo $cost . PHP_EOL;
}

<?php
// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d %d %d %d", $n, $h, $a, $b, $k);
for ($i = 0; $i < $k; $i++) {
	fscanf(STDIN, "%d %d %d %d", $ta, $fa, $tb, $fb);
	$a_cost = 0;
	$b_cost = 0;
	$f_cost = 0;
	$t_cost = 0;
	if ($ta != $tb) {
		if ($fa > $b) {
			$a_cost = $fa - $b;
		} elseif ($fa < $a) {
			$a_cost = $fa - $a;
		} else {
			$a_cost = 0;
		}
		if ($fb > $b) {
			$b_cost = $fb - $b;
		} elseif ($fb < $a) {
			$b_cost = $fb - $a;
		} else {
			$b_cost = 0;
		}
		if (DEBUG) {
			echo $a_cost, "*", $b_cost . PHP_EOL;
		}

		if ($a_cost * $b_cost <= 0) {
			$a_cost = $b_cost = 0;
		} else {
			$a_cost = abs($a_cost);
			$b_cost = abs($b_cost);
		}
		$f_cost = abs($fa - $fb);
		$t_cost = abs($ta - $tb);
	} else {
		$f_cost = abs($fa - $fb);
	}
	if (DEBUG) {
		echo "{$a_cost} {$b_cost}\n";
	}

	$cost = $a_cost + $b_cost + $f_cost + $t_cost;

	echo $cost . PHP_EOL;
}


The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times. When he came to the fruit stall of Ashot, he saw that the seller hadn't distributed price tags to the goods, but put all price tags on the counter. Later Ashot will attach every price tag to some kind of fruits, and Valera will be able to count the total price of all fruits from his list. But Valera wants to know now what can be the smallest total price (in case of the most «lucky» for him distribution of price tags) and the largest total price (in case of the most «unlucky» for him distribution of price tags).

The first line of the input contains two integer number n and m (1 ≤ n, m ≤ 100) — the number of price tags (which is equal to the number of different kinds of fruits that Ashot sells) and the number of items in Valera's list. The second line contains n space-separated positive integer numbers. Each of them doesn't exceed 100 and stands for the price of one fruit of some kind. The following m lines contain names of the fruits from the list. Each name is a non-empty string of small Latin letters which length doesn't exceed 32. It is guaranteed that the number of distinct fruits from the list is less of equal to n. Also it is known that the seller has in stock all fruits that Valera wants to buy.

Print two numbers a and b (a ≤ b) — the minimum and the maximum possible sum which Valera may need to buy all fruits from his list.

6 5
3 5 1 6 8 1
peach
grapefruit
banana
orange
orange

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = array();
$g = 0;
$h = array();
$i = array();
$l = array();
for($x = 1; $x <= $b; $x++)
{
    $e = trim(fgets(STDIN));
    array_push($d, $e);
}
$f = array_unique($d);
sort($f);
for($x = 0; $x < count($f); $x++)
{
    for($y = 0; $y < count($d); $y++)
    {
        if($f[$x] == $d[$y])
        {
            $g++;
        }
    }
    array_push($h, $g);
    $g = 0;
}
rsort($h);
for($x = 0; $x < count($h); $x++)
{
    $j = $h[$x] * $c[$x];
    array_push($i, $j);
}
$j = array_sum($i);
rsort($c);
for($x = 0; $x < count($h); $x++)
{
    $k = $h[$x] * $c[$x];
    array_push($l, $k);
}
$k = array_sum($l);
print $j . " " . $k;
?>

<?php

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

$data = file($in);

array_shift($data);

$prices = explode(' ', array_shift($data));

while (!$data[count($data) - 1]) {
	array_pop($data);
}

$mprices = $prices;

sort($prices, SORT_NUMERIC);
rsort($mprices, SORT_NUMERIC);

$fruits = array_count_values($data);
rsort($fruits, SORT_NUMERIC);

$a = $b = 0;
foreach ($fruits as $num) {
	$a += $num * array_shift($prices);
	$b += $num * array_shift($mprices);
}

echo "$a $b";

<?php
$nFruits = explode(' ', trim(fgets(STDIN)));
$nFruits = $nFruits[1];
$prices = explode(' ', trim(fgets(STDIN)));
$pricesDESC = $prices;

sort($prices, SORT_NUMERIC);
rsort($pricesDESC, SORT_NUMERIC);

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

$fruits = array_count_values($fruits);
rsort($fruits, SORT_NUMERIC);

$a = $b = 0;
foreach ($fruits as $num) {
    $a += $num * array_shift($prices);
    $b += $num * array_shift($pricesDESC);
}

echo "$a $b";
?>

<?php

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

$data = file($in);

array_shift($data);

$prices = explode(' ', array_shift($data));

if (!$data[count($data) - 1]) {
	array_pop($data);
}

$mprices = $prices;

sort($prices);
rsort($mprices);

$fruits = array_count_values($data);
rsort($fruits);

$a = $b = 0;
foreach ($fruits as $num) {
	$a += $num * array_shift($prices);
	$b += $num * array_shift($mprices);
}

echo "$a $b";

<?php

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

$data = file($in);

array_shift($data);

$prices = explode(' ', array_shift($data));

while (!$data[count($data) - 1]) {
	array_pop($data);
}

$mprices = $prices;

sort($prices);
rsort($mprices);

$fruits = array_count_values($data);
rsort($fruits);

$a = $b = 0;
foreach ($fruits as $num) {
	$a += $num * array_shift($prices);
	$b += $num * array_shift($mprices);
}

echo "$a $b";

<?php
$nFruits = explode(' ', trim(fgets(STDIN)));
$nFruits = $nFruits[1];
$prices = explode(' ', trim(fgets(STDIN)));
$pricesDESC = $prices;

sort($prices, SORT_NUMERIC);
rsort($pricesDESC, SORT_NUMERIC);

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

$fruits = array_count_values($fruits);
rsort($fruits, SORT_NUMERIC);

print_r($fruits);

$a = $b = 0;
foreach ($fruits as $num) {
    $a += $num * array_shift($prices);
    $b += $num * array_shift($pricesDESC);
}

echo "$a $b";
?>

<?php
trim(fgets(STDIN));
$prices = explode(' ', trim(fgets(STDIN)));
$pricesDESC = $prices;

sort($prices, SORT_NUMERIC);
rsort($pricesDESC, SORT_NUMERIC);

while ($fruits[] = trim(fgets(STDIN)))

$fruits = array_count_values($fruits);
rsort($fruits, SORT_NUMERIC);

$a = $b = 0;
foreach ($fruits as $num) {
    $a += $num * array_shift($prices);
    $b += $num * array_shift($pricesDESC);
}

echo "$a $b";
?>

<?php
trim(fgets(STDIN));
$prices = explode(' ', trim(fgets(STDIN)));
$pricesDESC = $prices;

sort($prices, SORT_NUMERIC);
rsort($pricesDESC, SORT_NUMERIC);

while ($fruits[] = trim(fgets(STDIN)))

$fruits = array_count_values($fruits);
rsort($fruits, SORT_NUMERIC);

print_r($fruits);

$a = $b = 0;
foreach ($fruits as $num) {
    $a += $num * array_shift($prices);
    $b += $num * array_shift($pricesDESC);
}

echo "$a $b";
?>


Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way roads. Because of the recent financial crisis, the Berland Government is strongly pressed for money, so to build a new road it has to close some of the existing ones. Every day it is possible to close one existing road and immediately build a new one. Your task is to determine how many days would be needed to rebuild roads so that from each city it became possible to reach all the others, and to draw a plan of closure of old roads and building of new ones.

The first line contains integer n (2 ≤ n ≤ 1000) — amount of cities in Berland and neighboring countries. Next n - 1 lines contain the description of roads. Each road is described by two space-separated integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — pair of cities, which the road connects. It can't be more than one road between a pair of cities. No road connects the city with itself.

Output the answer, number t — what is the least amount of days needed to rebuild roads so that from each city it became possible to reach all the others. Then output t lines — the plan of closure of old roads and building of new ones. Each line should describe one day in the format i j u v — it means that road between cities i and j became closed and a new road between cities u and v is built. Cities are numbered from 1. If the answer is not unique, output any.

<?php

class DSU {
	function __construct($n) {
		$this->p = range(0, $n - 1);
	}
	function get($i) {
		if ($i == $this->p[$i])
			return $i;
		return ($this->p[$i] = $this->get($this->p[$i]));
	}
	function join($a, $b) {
		$a = $this->get($a);
		$b = $this->get($b);
		if ($a == $b)
			return false;
		$this->p[$a] = $b;
		return true;
	}
}

fscanf(STDIN, "%d", $n);
$dsu = new DSU($n);
$bad = array();
for ($i = 1; $i < $n; $i++) {
	fscanf(STDIN, "%d%d", $a, $b);
	$a--; $b--;
	if (!$dsu->join($a, $b)) {
		array_push($bad, array($a, $b));
	}
}
printf("%d\n", count($bad));
for ($i = 1; $i < $n; $i++) {
	if ($dsu->join($i - 1, $i)) {
		$p = array_pop($bad);
		printf("%d %d %d %d\n", $p[0] + 1, $p[1] + 1, $i, $i + 1);
	}
}

?>


Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!The only thing Mrs. Smith remembered was that any permutation of $$$n$$$ can be a secret phone number. Only those permutations that minimize secret value might be the phone of her husband.The sequence of $$$n$$$ integers is called a permutation if it contains all integers from $$$1$$$ to $$$n$$$ exactly once.The secret value of a phone number is defined as the sum of the length of the longest increasing subsequence (LIS) and length of the longest decreasing subsequence (LDS). A subsequence $$$a_{i_1}, a_{i_2}, \ldots, a_{i_k}$$$ where $$$1\leq i_1 < i_2 < \ldots < i_k\leq n$$$ is called increasing if $$$a_{i_1} < a_{i_2} < a_{i_3} < \ldots < a_{i_k}$$$. If $$$a_{i_1} > a_{i_2} > a_{i_3} > \ldots > a_{i_k}$$$, a subsequence is called decreasing. An increasing/decreasing subsequence is called longest if it has maximum length among all increasing/decreasing subsequences.For example, if there is a permutation $$$[6, 4, 1, 7, 2, 3, 5]$$$, LIS of this permutation will be $$$[1, 2, 3, 5]$$$, so the length of LIS is equal to $$$4$$$. LDS can be $$$[6, 4, 1]$$$, $$$[6, 4, 2]$$$, or $$$[6, 4, 3]$$$, so the length of LDS is $$$3$$$.Note, the lengths of LIS and LDS can be different.So please help Mrs. Smith to find a permutation that gives a minimum sum of lengths of LIS and LDS.

The only line contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of permutation that you need to build.

Print a permutation that gives a minimum sum of lengths of LIS and LDS.  If there are multiple answers, print any.

NoteIn the first sample, you can build a permutation $$$[3, 4, 1, 2]$$$. LIS is $$$[3, 4]$$$ (or $$$[1, 2]$$$), so the length of LIS is equal to $$$2$$$. LDS can be ony of $$$[3, 1]$$$, $$$[4, 2]$$$, $$$[3, 2]$$$, or $$$[4, 1]$$$. The length of LDS is also equal to $$$2$$$. The sum is equal to $$$4$$$. Note that $$$[3, 4, 1, 2]$$$ is not the only permutation that is valid.In the second sample, you can build a permutation $$$[2, 1]$$$. LIS is $$$[1]$$$ (or $$$[2]$$$), so the length of LIS is equal to $$$1$$$. LDS is $$$[2, 1]$$$, so the length of LDS is equal to $$$2$$$. The sum is equal to $$$3$$$. Note that permutation $$$[1, 2]$$$ is also valid.

<?php
$a = trim(fgets(STDIN));
$b = range(1, $a);
$c = floor(count($b) / 2);
$d = array_slice($b, 0, $c);
$e = array_slice($b, $c);
$f = array_merge($e, $d);
print implode(" ", $f);
?>


Let's consider all integers in the range from $$$1$$$ to $$$n$$$ (inclusive).Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of $$$\mathrm{gcd}(a, b)$$$, where $$$1 \leq a < b \leq n$$$.The greatest common divisor, $$$\mathrm{gcd}(a, b)$$$, of two positive integers $$$a$$$ and $$$b$$$ is the biggest integer that is a divisor of both $$$a$$$ and $$$b$$$.

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 only line of each test case contains a single integer $$$n$$$ ($$$2 \leq n \leq 10^6$$$).

For each test case, output the maximum value of $$$\mathrm{gcd}(a, b)$$$ among all $$$1 \leq a < b \leq n$$$.

NoteIn the first test case, $$$\mathrm{gcd}(1, 2) = \mathrm{gcd}(2, 3) = \mathrm{gcd}(1, 3) = 1$$$.In the second test case, $$$2$$$ is the maximum possible value, corresponding to $$$\mathrm{gcd}(2, 4)$$$.

<?php
    define("MAXN", 1024) ;
    define("GAP_VAL", 1e-7) ;

    function gap($n)
    {
        return $n < GAP_VAL ;
    }

    $t = intval(trim(fgets(STDIN))) ;
    while($t --)
    {
        $n = intval(trim(fgets(STDIN))) ;

        echo intval($n / 2) . "\n" ;
    }
?>

<?php declare(strict_types = 1);
    $stdin = fopen('php://stdin', 'r');
    $test = fgets($stdin);
    for ($itest = 0; $itest < $test; $itest++) {
        $n = (int)fgets($stdin);
        $res = (int)($n / 2);
        echo $res."\n";
    }
?>

<?php declare(strict_types = 1);
    $stdin = fopen('php://stdin', 'r');
    $test = fgets($stdin);
    for ($itest = 0; $itest < $test; $itest++) {
        $n = (int)fgets($stdin);
        $res = (int)($n / 2);
        echo "$res<br>";
    }
?>


You are given an array of n integer numbers a0, a1, ..., an - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.

The first line contains positive integer n (2 ≤ n ≤ 105) — size of the given array. The second line contains n integers a0, a1, ..., an - 1 (1 ≤ ai ≤ 109) — elements of the array. It is guaranteed that in the array a minimum occurs at least two times.

Print the only number — distance between two nearest minimums in the array.

<?php

$num = trim(fgets(STDIN));
$aList = explode(' ', trim(fgets(STDIN)));

$count = 0;
$minCount = PHP_INT_MAX;
$minValue = PHP_INT_MAX;
foreach ($aList as $value)
{
    $value = (int)$value;
    if ($minValue > $value)
    {
        $minValue = $value;
        $minCount = PHP_INT_MAX;
        $count = 0;
    }
    else if ($minValue === $value)
    {
        $count++;
        $minCount = min($count, $minCount);
        $count = 0;
    }
    else
    {
        $count++;
    }

}

echo $minCount;


Nauuo is a girl who loves playing chess.One day she invented a game by herself which needs $$$n$$$ chess pieces to play on a $$$m\times m$$$ chessboard. The rows and columns are numbered from $$$1$$$ to $$$m$$$. We denote a cell on the intersection of the $$$r$$$-th row and $$$c$$$-th column as $$$(r,c)$$$.The game's goal is to place $$$n$$$ chess pieces numbered from $$$1$$$ to $$$n$$$ on the chessboard, the $$$i$$$-th piece lies on $$$(r_i,\,c_i)$$$, while the following rule is satisfied: for all pairs of pieces $$$i$$$ and $$$j$$$, $$$|r_i-r_j|+|c_i-c_j|\ge|i-j|$$$. Here $$$|x|$$$ means the absolute value of $$$x$$$.However, Nauuo discovered that sometimes she couldn't find a solution because the chessboard was too small.She wants to find the smallest chessboard on which she can put $$$n$$$ pieces according to the rules.She also wonders how to place the pieces on such a chessboard. Can you help her?

The only line contains a single integer $$$n$$$ ($$$1\le n\le 1000$$$) — the number of chess pieces for the game.

The first line contains a single integer — the minimum value of $$$m$$$, where $$$m$$$ is the length of sides of the suitable chessboard. The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$r_i$$$ and $$$c_i$$$ ($$$1\le r_i,c_i\le m$$$) — the coordinates of the $$$i$$$-th chess piece. If there are multiple answers, print any.

NoteIn the first example, you can't place the two pieces on a $$$1\times1$$$ chessboard without breaking the rule. But you can place two pieces on a $$$2\times2$$$ chessboard like this:In the second example, you can't place four pieces on a $$$2\times2$$$ chessboard without breaking the rule. For example, if you place the pieces like this:then $$$|r_1-r_3|+|c_1-c_3|=|1-2|+|1-1|=1$$$, $$$|1-3|=2$$$, $$$1<2$$$; and $$$|r_1-r_4|+|c_1-c_4|=|1-2|+|1-2|=2$$$, $$$|1-4|=3$$$, $$$2<3$$$. It doesn't satisfy the rule.However, on a $$$3\times3$$$ chessboard, you can place four pieces like this:

<?php
#1173B
$n = (int)trim(fgets(STDIN));
$size = 2;
while ((2 * $size - 1) < $n) {
    $size++;
}
echo $size . PHP_EOL;
for ($i = 1; $i <= $size; $i++) {
    echo '1 ' . $i . PHP_EOL;
}
for ($i = 2, $j = $size + 1; $j <= $n; $i++, $j++) {
    echo $i . ' ' . $size . PHP_EOL;
}


In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length li.Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that maximizes their total area. Each stick is used in making at most one rectangle, it is possible that some of sticks remain unused. Bending sticks is not allowed.Sticks with lengths a1, a2, a3 and a4 can make a rectangle if the following properties are observed:  a1 ≤ a2 ≤ a3 ≤ a4  a1 = a2  a3 = a4 A rectangle can be made of sticks with lengths of, for example, 3 3 3 3 or 2 2 4 4. A rectangle cannot be made of, for example, sticks 5 5 5 7.Ilya also has an instrument which can reduce the length of the sticks. The sticks are made of a special material, so the length of each stick can be reduced by at most one. For example, a stick with length 5 can either stay at this length or be transformed into a stick of length 4.You have to answer the question — what maximum total area of the rectangles can Ilya get with a file if makes rectangles from the available sticks?

The first line of the input contains a positive integer n (1 ≤ n ≤ 105) — the number of the available sticks. The second line of the input contains n positive integers li (2 ≤ li ≤ 106) — the lengths of the sticks.

The first line of the output must contain a single non-negative integer — the maximum total area of the rectangles that Ilya can make from the available sticks.


Vasya has found a piece of paper with a coordinate system written on it. There are n distinct squares drawn in this coordinate system. Let's number the squares with integers from 1 to n. It turned out that points with coordinates (0, 0) and (ai, ai) are the opposite corners of the i-th square.Vasya wants to find such integer point (with integer coordinates) of the plane, that belongs to exactly k drawn squares. We'll say that a point belongs to a square, if the point is located either inside the square, or on its boundary. Help Vasya find a point that would meet the described limits.

The first line contains two space-separated integers n, k (1 ≤ n, k ≤ 50). The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). It is guaranteed that all given squares are distinct.

In a single line print two space-separated integers x and y (0 ≤ x, y ≤ 109) — the coordinates of the point that belongs to exactly k squares. If there are multiple answers, you are allowed to print any of them.  If there is no answer, print "-1" (without the quotes).

<?php
list($n, $k)=explode(' ', trim(fgets(STDIN)));
$a=explode(' ', trim(fgets(STDIN)));
foreach($a as $i=>$b) $c[$i]=(int)$b;
sort($c, SORT_NUMERIC);
if($k<=$n) echo $c[$n-$k].' 0';
else echo -1;
?>

<?php
fscanf(STDIN,"%d%d",$n,$k);
$a=explode(" ", trim(fgets(STDIN)));
foreach($a as $i=>$b) $c[$i]=(int)$b;
sort($c, SORT_NUMERIC);
echo ($k>$n)?-1:$c[$n-$k]." 0";
?>

<?php
$params = explode(' ', trim(fgets(STDIN)));
$n = $params[0];
$k = $params[1];
unset($params);

$squares = explode(' ', trim(fgets(STDIN)));
foreach ($squares as $i => $square){
	$squares[$i] = (int)$square;
}
sort($squares, SORT_NUMERIC);

if ($k <= $n){
	fputs(STDOUT, $squares[$n - $k].' 0');
}else{
	fputs(STDOUT, '-1');
}

<?// BismiLahi Rahmani Rahim ?>

<?php

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

sort($a);

if ($k > $n) {
	printf("-1");
} else {
	printf("%d 0", $a[$n-$k]);
}

?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
rsort($c);
if($b > count($c))
{
    print "-1";
}
else
{
    if($c[$b] != $c[$b + 1])
    {
        print $c[$b - 1] . " " . $c[$b - 1];
    }
    else
    {
        print "-1";
    }
}
?>

<?php
list($n, $k)=explode(' ', trim(fgets(STDIN)));
$a=explode(' ', trim(fgets(STDIN)));
array_multisort($a, SORT_NUMERIC, SORT_ASC);
for($i=0; $i<count($a); $i++) {
if(($i+1==$k) && ($a[$i+1]!=$a[$i])) {
  echo "{$a[$i]} 0"; exit(); }
}
echo -1;
?>


Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins.If the sequences of the awarded points coincide, the wrestler who performed the last technique wins. Your task is to determine which wrestler won.

The first line contains number n — the number of techniques that the wrestlers have used (1 ≤ n ≤ 2·105).  The following n lines contain integer numbers ai (|ai| ≤ 109, ai ≠ 0). If ai is positive, that means that the first wrestler performed the technique that was awarded with ai points. And if ai is negative, that means that the second wrestler performed the technique that was awarded with ( - ai) points. The techniques are given in chronological order.

If the first wrestler wins, print string "first", otherwise print "second"

NoteSequence x  =  x1x2... x|x| is lexicographically larger than sequence y  =  y1y2... y|y|, if either |x|  >  |y| and x1  =  y1,  x2  =  y2, ... ,  x|y|  =  y|y|, or there is such number r (r  <  |x|, r  <  |y|), that x1  =  y1,  x2  =  y2,  ... ,  xr  =  yr and xr  +  1  >  yr  +  1.We use notation |a| to denote length of sequence a.

<?php
$a = trim(fgets(STDIN));
$c = 0;
$d = 0;
$e = array();
$f = array();
for($x = 1; $x <= $a; $x++)
{
    $b = trim(fgets(STDIN));
    if($b > 0)
    {
        $c += $b;
        array_push($e, $b);
    }
    elseif($b < 0)
    {
        $d += abs($b);
        array_push($f, abs($b));
    }
}
if($c > $d)
{
    print "first";
}
elseif($c < $d)
{
    print "second";
}
elseif($c == $d)
{
    $h = max(count($e), count($f));
    $g = 0;
    for($x = 0; $x < $h; $x++)
    {
        if($e[$x] != $f[$x])
        {
            $g = 1;
            if($e[$x] > $f[$x])
            {
                print "first";
                break;
            }
            elseif($e[$x] < $f[$x])
            {
                print "second";
                break;
            }
        }
    }
    if($g == 0)
    {
        if($b > 0)
        {
            print "first";
        }
        else
        {
            print "second";
        }
    }
}
?>

<?php
$a = trim(fgets(STDIN));
$c = 0;
$d = 0;
$e = array();
$f = array();

for ($i=1; $i<=$a; $i++) {
    $b = trim(fgets(STDIN));
    if ($b > 0) {
        $c += $b;
        array_push($e, $b);
    } else if($b < 0) {
        $d += abs($b);
        array_push($f, abs($b));
    }
}
if ($c > $d) {
    echo "first";
} else if ($c < $d) {
    echo "second";
} else if ($c == $d) {
    $h = max(count($e), count($f));
    $g = 0;
    for ($i=0; $i<$h; $i++) {
        if ($e[$i] != $f[$i]) {
            $g = 1;
            if ($e[$i] > $f[$i]) {
                echo "first";
                break;
            } else if ($e[$i] < $f[$i]) {
                echo "second";
                break;
            }
        }
    }
    if ($g == 0) {
        if ($b > 0) {
            echo "first";
        } else {
            echo "second";
        }
    }
}
?>

<?php
$a = trim(fgets(STDIN));
$c = 0;
$d = 0;
$e = array();
$f = array();
for($x = 1; $x <= $a; $x++)
{
    $b = trim(fgets(STDIN));
    if($b > 0)
    {
        $c += $b;
        array_push($e, $b);
    }
    elseif($b < 0)
    {
        $d += abs($b);
        array_push($f, abs($b));
    }
}
if($c > $d)
{
    print "first";
}
elseif($c < $d)
{
    print "second";
}
elseif($c == $d)
{
    $e = max(count($e), count($f));
    $g = 0;
    for($x = 0; $x < $e; $x++)
    {
        if($e[$x] != $f[$x])
        {
            $g = 1;
            if($e[$x] > $f[$x])
            {
                print "first";
                break;
            }
            elseif($e[$x] < $f[$x])
            {
                print "second";
                break;
            }
        }
    }
    if($g == 0)
    {
        if($b > 0)
        {
            print "first";
        }
        else
        {
            print "second";
        }
    }
}
?>

<?php
$a = trim(fgets(STDIN));
$c = 0;
$d = 0;
$e = array();
$f = array();
for($x = 1; $x <= $a; $x++)
{
    $b = trim(fgets(STDIN));
    if($b > 0)
    {
        $c += $b;
        array_push($e, $b);
    }
    elseif($b < 0)
    {
        $d += abs($b);
        array_push($f, abs($b));
    }
}
if($c > $d)
{
    print "first";
}
elseif($c < $d)
{
    print "second";
}
elseif($c == $d)
{
    $e = max(count($e), count($f));
    $f = 0;
    for($x = 0; $x < $e; $x++)
    {
        if($e[$x] != $f[$x])
        {
            $f = 1;
            if($e[$x] > $f[$x])
            {
                print "first";
                break;
            }
            elseif($e[$x] < $f[$x])
            {
                print "second";
                break;
            }
        }
    }
    if($f == 0)
    {
        if($b > 0)
        {
            print "first";
        }
        else
        {
            print "second";
        }
    }
}
?>