One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):   point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y  point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y  point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y  point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.

The first input line contains the only integer n (1 ≤ n ≤ 200) — the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| ≤ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.

Print the only number — the number of supercentral points of the given set.

NoteIn the first sample the supercentral points are only points (1, 1) and (1, 2).In the second sample there is one supercental point — point (0, 0).

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_N = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_N; $i++) {
		$inp_arr[$i][] = (int)$Scanner->Scan();
		$inp_arr[$i][] = (int)$Scanner->Scan();
	}

	$POINT = 0;
	for ($i = 0; $i < $inp_N; $i++) {
		$c_left = 0;
		$c_right = 0;
		$c_upper = 0;
		$c_lower = 0;
		for ($j = 0; $j < $inp_N; $j++) {
			if ($inp_arr[$i][0] > $inp_arr[$j][0] && $inp_arr[$i][1] === $inp_arr[$j][1]) $c_left++;
			elseif ($inp_arr[$i][0] < $inp_arr[$j][0] && $inp_arr[$i][1] === $inp_arr[$j][1]) $c_right++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] < $inp_arr[$j][1]) $c_upper++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] > $inp_arr[$j][1])$c_lower++;
			if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) break;
		}
		if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) $POINT++;
		//echo $POINT;
	}
	print($POINT);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php

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

$data = array();
for ($i=0; $i<$col; $i++)
$data[] = explode(' ', trim(fgets(STDIN)));

$result = 0;
for ($i=0; $i<$col; $i++) {
	$x = $data[$i][0];
	$y = $data[$i][1];

	$tochka = array(
		'left' => 0,
		'right' => 0,
		'up' => 0,
		'down' => 0,
	);

	for($j=0; $j<$col; $j++)
		if ($i != $j) {
			$x_s = $data[$j][0];
			$y_s = $data[$j][1];

			if ($x > $x_s and $y == $y_s) $tochka['right']++;
			elseif ($x < $x_s and $y == $y_s) $tochka['left']++;
			elseif ($x == $x_s and $y > $y_s) $tochka['up']++;
			elseif ($x == $x_s and $y < $y_s) $tochka['down']++;
		}

	if ($tochka['right'] and $tochka['left'] and $tochka['up'] and $tochka['down']) $result++;
}

print $result;

<?php
    $input = array();
    while(($line = fgets(STDIN)) != false)
    {
        $input[] = trim($line);
    }
    $count = (int)$input[0];
    $arr = array();
    $count_input = count($input);
    for ($i = 1; $i < $count_input; $i++)
    {
        $arr[] = explode(" ", $input[$i]);
    }
    $count_main = 0;
    $count_arr = count($arr);
    for ($i = 0; $i < $count_arr; $i++)
    {
        $point = $arr[$i];
        $left = FALSE;
        $right = FALSE;
        $top = FALSE;
        $bottom = FALSE;
        for ($j = 0; $j < $count_arr; $j++)
        {
            $temp = $arr[$j];
            // Левый сосед
            if ($point[0] < $temp[0] && $point[1] == $temp[1])
            {
                $left = TRUE;
            }
            // Правый сосед
            if ($point[0] > $temp[0] && $point[1] == $temp[1])
            {
                $right = TRUE;
            }
            // Верхний сосед
            if ($point[0] == $temp[0] && $point[1] < $temp[1])
            {
                $top = TRUE;
            }
            // Нижний сосед
            if ($point[0] == $temp[0] && $point[1] > $temp[1])
            {
                $bottom = TRUE;
            }
        }
        if ($left and $right and $top and $bottom)
        {
            $count_main++;
        }
    }
    fputs(STDOUT, $count_main);
?>

<?php
$openFile = fopen('php://stdin','r');
$lines = stream_get_contents($openFile);
/*
$lines = '8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3';

$lines = '5
0 0
0 1
1 0
0 -1
-1 0';
*/
$data = explode("\n", trim($lines));
$list = array();
for($i = 1 ; $i < count($data) ; $i++)
{
    $coords = explode(" ", trim($data[$i]));
    $list[] = array("x" => (int)$coords[0] , "y" => (int)$coords[1]);
}

$result = 0;
for($i = 0 ; $i < count($list) ; $i++)
{
    $flagTop = false;
    $flagRight = false;
    $flagBottom = false;
    $flagLeft = false;
    for($j = 0 ; $j < count($list) ; $j++)
    {
        if($i != $j)
        {
            if($list[$i]["x"] < $list[$j]["x"] && $list[$i]["y"] == $list[$j]["y"])
            {
                $flagRight = true;
            }
            if($list[$i]["x"] > $list[$j]["x"] && $list[$i]["y"] == $list[$j]["y"])
            {
                $flagLeft = true;
            }
            if($list[$i]["x"] == $list[$j]["x"] && $list[$i]["y"] > $list[$j]["y"])
            {
                $flagBottom = true;
            }
            if($list[$i]["x"] == $list[$j]["x"] && $list[$i]["y"] < $list[$j]["y"])
            {
                $flagTop = true;
            }
        }
        if($flagTop && $flagRight && $flagBottom && $flagLeft)
        {
            $result++;
            break;
        }
    }
}
echo $result;
?>

<?php

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

$n = trim(fgets($stdin));

$points = array();
for($i = 0; $i < $n; $i++) {
    $points[] = explode(" ", trim(fgets($stdin)));
}

// 0 - x
// 1 - y

$result = 0;
foreach($points as $i=>$point1) {
    $l = false;
    $r = false;
    $t = false;
    $d = false;
    foreach($points as $j=>$point2) {
        if($point2[0] > $point1[0] && $point2[1] == $point1[1]) {
            $l = true;
        }
        if($point2[0] < $point1[0] && $point2[1] == $point1[1]) {
            $r = true;
        }
        if($point2[0] == $point1[0] && $point2[1] > $point1[1]) {
            $t = true;
        }
        if($point2[0] == $point1[0] && $point2[1] < $point1[1]) {
            $d = true;
        }

        if($l && $r && $t && $d) {
            $result++;
            break;
        }
    }
}

echo $result;

//file_put_contents("out.txt", $result);
?>

<?php
$arr = array();
while(($line = fgets(STDIN)) != false)
{
    $arr[] = $line;
}

list($N) = explode(" ", trim($arr[0]));

$count = 0;

$left   = false;
$right  = false;
$top    = false;
$bottom = false;

for ($i=1; $i<=$N; $i++) {
    list($x, $y) = explode(" ", trim($arr[$i]));
    $top    = false;
    $bottom = false;
    $right  = false;
    $left   = false;
    for ($j=1; $j<=$N; $j++) {
        list($x1, $y1) = explode(" ", trim($arr[$j]));
        if ($x1 > $x && $y1 == $y) {
            $right = true;
        } else if ($x1 < $x && $y1 == $y) {
            $left = true;
        } else if ($x1 == $x && $y1 < $y) {
            $bottom = true;
        } else if ($x1 == $x && $y1 > $y) {
            $top = true;
        }

        if ($top && $bottom && $right && $left) {
            $count++;
            break;

        }

    }

}

fputs(STDOUT, $count);

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_N = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_N; $i++) {
		$inp_arr[$i][] = (int)$Scanner->Scan();
		$inp_arr[$i][] = (int)$Scanner->Scan();
	}

	$POINT = 0;
	for ($i = 0; $i < $inp_N; $i++) {
		for ($j = 0; $j < $inp_N; $j++) {
			$c_left = 0;
			$c_right = 0;
			$c_upper = 0;
			$c_lower = 0;
			if ($inp_arr[$i][0] > $inp_arr[$j][0] && $inp_arr[$i][1] === $inp_arr[$j][1]) $c_left++;
			elseif ($inp_arr[$i][0] < $inp_arr[$j][0] && $inp_arr[$i][1] > $inp_arr[$j][1]) $c_right++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] < $inp_arr[$j][1]) $c_upper++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] > $inp_arr[$j][1])$c_lower++;
			if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) break;
		}
		if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) $POINT++;
	}
	printf("%d", $POINT);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_N = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_N; $i++) {
		$inp_arr[$i][] = (int)$Scanner->Scan();
		$inp_arr[$i][] = (int)$Scanner->Scan();
	}

	$POINT = 0;
	for ($i = 0; $i < $inp_N; $i++) {
		for ($j = 0; $j < $inp_N; $j++) {
			$c_left = 0;
			$c_right = 0;
			$c_upper = 0;
			$c_lower = 0;
			if ($inp_arr[$i][0] > $inp_arr[$j][0] && $inp_arr[$i][1] === $inp_arr[$j][1]) $c_left++;
			elseif ($inp_arr[$i][0] < $inp_arr[$j][0] && $inp_arr[$i][1] === $inp_arr[$j][1]) $c_right++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] < $inp_arr[$j][1]) $c_upper++;
			elseif ($inp_arr[$i][0] === $inp_arr[$j][0] && $inp_arr[$i][1] > $inp_arr[$j][1])$c_lower++;
			if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) break;
		}
		if ($c_left > 0 && $c_right > 0 && $c_upper > 0 && $c_lower > 0) $POINT++;
	}
	printf("%d", $POINT);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
$arr = array();
while(($line = fgets(STDIN)) != false)
{
    $arr[] = $line;
}

list($N) = explode(" ", trim($arr[0]));

$count = 0;

$left   = false;
$right  = false;
$top    = false;
$bottom = false;

for ($i=1; $i<$N; $i++) {
    for ($j=1; $j<$N; $j++) {
        list($x, $y) = explode(" ", trim($arr[$i]));
        list($x1, $y1) = explode(" ", trim($arr[$j]));
        if ($x1 > $x && $y1 == $y) {
            $right = true;
        } elseif ($x1 < $x && $y1 == $y) {
            $left = true;
        } elseif ($x1 == $x && $y1 < $y) {
            $bottom = true;
        } elseif ($x1 == $x && $y1 > $y) {
            $top = true;
        }

        if ($top && $bottom && $right && $left) {
            $count++;
            $top    = false;
            $bottom = false;
            $right  = false;
            $left   = false;
            break;
        }

    }
}

fputs(STDOUT, $count);

?>

<?php
$arr = array();
while(($line = fgets(STDIN)) != false)
{
    $arr[] = $line;
}

list($N) = explode(" ", trim($arr[0]));

$count = 0;

$left   = false;
$right  = false;
$top    = false;
$bottom = false;

for ($i=1; $i<=$N; $i++) {
    list($x, $y) = explode(" ", trim($arr[$i]));
    for ($j=1; $j<=$N; $j++) {
        list($x1, $y1) = explode(" ", trim($arr[$j]));
        if ($x1 > $x && $y1 == $y) {
            $right = true;
        } else if ($x1 < $x && $y1 == $y) {
            $left = true;
        } else if ($x1 == $x && $y1 < $y) {
            $bottom = true;
        } else if ($x1 == $x && $y1 > $y) {
            $top = true;
        }

        if ($top && $bottom && $right && $left) {
            $count++;
            $top    = false;
            $bottom = false;
            $right  = false;
            $left   = false;

            break;
        }

    }

}

fputs(STDOUT, $count);

?>


So the Beautiful Regional Contest (BeRC) has come to an end! $$$n$$$ students took part in the contest. The final standings are already known: the participant in the $$$i$$$-th place solved $$$p_i$$$ problems. Since the participants are primarily sorted by the number of solved problems, then $$$p_1 \ge p_2 \ge \dots \ge p_n$$$.Help the jury distribute the gold, silver and bronze medals. Let their numbers be $$$g$$$, $$$s$$$ and $$$b$$$, respectively. Here is a list of requirements from the rules, which all must be satisfied:  for each of the three types of medals, at least one medal must be awarded (that is, $$$g>0$$$, $$$s>0$$$ and $$$b>0$$$);  the number of gold medals must be strictly less than the number of silver and the number of bronze (that is, $$$g<s$$$ and $$$g<b$$$, but there are no requirements between $$$s$$$ and $$$b$$$);  each gold medalist must solve strictly more problems than any awarded with a silver medal;  each silver medalist must solve strictly more problems than any awarded a bronze medal;  each bronze medalist must solve strictly more problems than any participant not awarded a medal;  the total number of medalists $$$g+s+b$$$ should not exceed half of all participants (for example, if $$$n=21$$$, then you can award a maximum of $$$10$$$ participants, and if $$$n=26$$$, then you can award a maximum of $$$13$$$ participants). The jury wants to reward with medals the total maximal number participants (i.e. to maximize $$$g+s+b$$$) so that all of the items listed above are fulfilled. Help the jury find such a way to award medals.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. The first line of a test case contains an integer $$$n$$$ ($$$1 \le n \le 4\cdot10^5$$$) — the number of BeRC participants. The second line of a test case contains integers $$$p_1, p_2, \dots, p_n$$$ ($$$0 \le p_i \le 10^6$$$), where $$$p_i$$$ is equal to the number of problems solved by the $$$i$$$-th participant from the final standings. The values $$$p_i$$$ are sorted in non-increasing order, i.e. $$$p_1 \ge p_2 \ge \dots \ge p_n$$$. The sum of $$$n$$$ over all test cases in the input does not exceed $$$4\cdot10^5$$$.

Print $$$t$$$ lines, the $$$j$$$-th line should contain the answer to the $$$j$$$-th test case. The answer consists of three non-negative integers $$$g, s, b$$$.   Print $$$g=s=b=0$$$ if there is no way to reward participants with medals so that all requirements from the statement are satisfied at the same time.  Otherwise, print three positive numbers $$$g, s, b$$$ — the possible number of gold, silver and bronze medals, respectively. The sum of $$$g+s+b$$$ should be the maximum possible. If there are several answers, print any of them.

NoteIn the first test case, it is possible to reward $$$1$$$ gold, $$$2$$$ silver and $$$3$$$ bronze medals. In this case, the participant solved $$$5$$$ tasks will be rewarded with the gold medal, participants solved $$$4$$$ tasks will be rewarded with silver medals, participants solved $$$2$$$ or $$$3$$$ tasks will be rewarded with bronze medals. Participants solved exactly $$$1$$$ task won't be rewarded. It's easy to see, that in this case, all conditions are satisfied and it is possible to reward participants in this way. It is impossible to give more than $$$6$$$ medals because the number of medals should not exceed half of the number of participants. The answer $$$1$$$, $$$3$$$, $$$2$$$ is also correct in this test case.In the second and third test cases, it is impossible to reward medals, because at least one medal of each type should be given, but the number of medals should not exceed half of the number of participants.


You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).

The first line contains the integer n (2 ≤ n ≤ 2·105). The second line contains elements of the sequence a1, a2, ..., an (1 ≤ ai ≤ 1000). All the elements are positive integers.

Print on the first line the number of the sought indices. Print on the second line the sought indices in the increasing order. All indices are integers from 1 to n. If the sought elements do not exist, then the first output line should contain number 0. In this case you may either not print the second line or print an empty line.

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


After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from left to right and they are numbered with numbers from 1 to m, correspondingly. The balls are numbered with numbers from 1 to n.Valeric decided to sort the balls in the order of increasing of their numbers by the following scheme. He will put each new ball in the basket with the least number of balls. And if he's got several variants, he chooses the basket which stands closer to the middle. That means that he chooses the basket for which  is minimum, where i is the number of the basket. If in this case Valeric still has multiple variants, he chooses the basket with the minimum number.For every ball print the number of the basket where it will go according to Valeric's scheme.Note that the balls are sorted into baskets in the order of increasing numbers, that is, the first ball goes first, then goes the second ball and so on.

The first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105) — the number of balls and baskets, correspondingly.

Print n numbers, one per line. The i-th line must contain the number of the basket for the i-th ball.

<?php

error_reporting(0);

solve();

function solve(){

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

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

	$r = $m % 2;

	if ($r === 0) {

		$first = intval($m / 2);
		$basket = $first;
		$sum = 2 * $first + 1;

		for ($i = 0; $i < $n; $i++)
		{
			if ($i % 2 === 0)
			{
				print($basket);

			} else {

				print($sum - $basket);

				if ($sum - $basket === $m) $basket = $first;
				else $basket -= 1;
			}

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

	} else {

		$first = intval($m / 2) + 1;
		$basket = $first;
		$sum = 2 * $first;
		$flag = 1;

		for ($i = 0; $i < $n; $i++)
		{
			if ($flag === 1)
			{
				print($sum - $basket);

				if ($sum - $basket === $m) $basket = $first;
				else {
					$basket -= 1;
					$flag = 0;
				}

			} else {

				print($basket);
				$flag = 1;
			}

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

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

		} else {

			$contents = stream_get_contents(STDIN);

		}

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php
// 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 123 Division 2 Problem B
function func($in) {
$balls = $in[0];
$baskets = $in[1];

$str = "";
for ($x = 1; $x <= $baskets; $x++) {
	if ($x % 2 == 0) {
		if ($baskets % 2 == 0) {
			$str .= (($baskets + $x) / 2) . "\n";
		} else {
			$str .= (($baskets - $x + 1) / 2) . "\n";
		}
	} else {
		if ($baskets % 2 == 0) {
			$str .= (($baskets - $x + 1) / 2) . "\n";
		} else {
			$str .= (($baskets + $x) / 2) . "\n";
		}
	}
}

$res = "";
while ($balls >= $baskets) {
	$res .= $str;
	$balls -= $baskets;
}
$strs = explode("\n", $str);
for ($x = 0; $x < $balls; $x++) {
	$res .= $strs[$x] . "\n";
}
return substr($res, 0, strlen($res) - 1);
}

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

<?php

error_reporting(0);

solve();

function solve(){

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

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

	$baskets = array_fill(1, $m, 0);

	for ($i = 0; $i < $n; $i++)
	{
		$min_ball = min($baskets);
		$min_middle = 10E5 + 1;
		$pos = -1;

		for ($j = 1; $j <= $m; $j++)
		{
			if ($baskets[$j] === $min_ball)
			{
				if (abs(intval(($m + 1) / 2)) - $j < $min_middle)
				{
					$pos = $j;
					$min_middle = abs(intval(($m + 1) / 2)) - $j;
				}
			}
		}

		$baskets[$pos]++;

		print($pos);

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

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

		} else {

			$contents = stream_get_contents(STDIN);

		}

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

function solve(){

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

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

	$r = $m % 2;

	if ($r === 0) {

		$first = intval($m / 2);
		$basket = $first;
		$sum = 2 * $first + 1;

		for ($i = 0; $i < $n; $i++)
		{
			if ($i % 2 === 0)
			{
				print($basket);

			} else {

				print($sum - $basket);

				if ($sum - $basket === $m) $basket = $first;
				else $basket -= 1;
			}

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

	} else {

		$first = intval($m / 2) + 1;
		$basket = $first;
		$sum = 2 * $first;

		for ($i = 0; $i < $n; $i++)
		{
			if ($i % 2 === 0)
			{
				print($sum - $basket);

				if ($sum - $basket === $m) $basket = $first;
				else $basket -= 1;

			} else {

				print($basket);
			}

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

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

		} else {

			$contents = stream_get_contents(STDIN);

		}

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

function solve(){

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

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

	$baskets = array_fill(1, $m, 0);

	for ($i = 0; $i < $n; $i++)
	{
		$min_ball = min($baskets);
		$min_middle = 10E5 + 1;
		$pos = -1;

		for ($j = 1; $j <= $m; $j++)
		{
			if ($baskets[$j] === $min_ball)
			{
				if (abs(intval(($m + 1) / 2) - $j) < $min_middle)
				{
					$pos = $j;
					$min_middle = abs(intval(($m + 1) / 2) - $j);
				}
			}
		}

		$baskets[$pos]++;

		print($pos);

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

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

		} else {

			$contents = stream_get_contents(STDIN);

		}

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

function solve(){

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

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

	$r = $m % 2;

	if ($r === 0) {

		$first = intval($m / 2);
		$basket = $first;
		$sum = 2 * $first + 1;

		for ($i = 0; $i < $n; $i++)
		{
			if ($i % 2 === 0)
			{
				print($basket);

			} else {

				print($sum - $basket);
				$basket -= 1;

				if ($basket === 0) $basket = $first;
			}

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

	} else {

		$first = intval($m / 2) + 1;
		$basket = $first;
		$sum = 2 * $first;

		for ($i = 0; $i < $n; $i++)
		{
			if ($i % 2 === 0)
			{
				print($sum - $basket);
				$basket -= 1;

				if ($basket === 0) $basket = $first;

			} else {

				print($basket);
			}

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

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

		} else {

			$contents = stream_get_contents(STDIN);

		}

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php
// 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 123 Division 2 Problem B
function func($in) {
$balls = $in[0];
$baskets = $in[1];

$str = "";
for ($x = 1; $x <= $baskets; $x++) {
	if ($x % 2 == 0) {
		if ($baskets % 2 == 0) {
			$str .= (($baskets + $x) / 2) . "\n";
		} else {
			$str .= (($baskets - $x + 1) / 2) . "\n";
		}
	} else {
		if ($baskets & 2 == 0) {
			$str .= (($baskets - $x + 1) / 2) . "\n";
		} else {
			$str .= (($baskets + $x) / 2) . "\n";
		}
	}
}

$res = "";
while ($balls >= $baskets) {
	$res .= $str;
	$balls -= $baskets;
}
$strs = explode("\n", $str);
for ($x = 0; $x < $balls; $x++) {
	$res .= $strs[$x] . "\n";
}
return substr($res, 0, strlen($res) - 1);
}

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


There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below:There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (a·b = 12), after that he makes a table of size a × b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses.Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win.

The first line of the input contains integer t (1 ≤ t ≤ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start.

For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces.

4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO


You have array of $$$n$$$ numbers $$$a_{1}, a_{2}, \ldots, a_{n}$$$. Rearrange these numbers to satisfy $$$|a_{1} - a_{2}| \le |a_{2} - a_{3}| \le \ldots \le |a_{n-1} - a_{n}|$$$, where $$$|x|$$$ denotes absolute value of $$$x$$$. It's always possible to find such rearrangement.Note that all numbers in $$$a$$$ are not necessarily different. In other words, some numbers of $$$a$$$ may be same.You have to answer independent $$$t$$$ test cases.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$) — the number of test cases. The first line of each test case contains single integer $$$n$$$ ($$$3 \le n \le 10^{5}$$$) — the length of array $$$a$$$. It is guaranteed that the sum of values of $$$n$$$ over all test cases in the input does not exceed $$$10^{5}$$$. The second line of each test case contains $$$n$$$ integers $$$a_{1}, a_{2}, \ldots, a_{n}$$$ ($$$-10^{9} \le a_{i} \le 10^{9}$$$).

For each test case, print the rearranged version of array $$$a$$$ which satisfies given condition. If there are multiple valid rearrangements, print any of them.

NoteIn the first test case, after given rearrangement, $$$|a_{1} - a_{2}| = 0 \le |a_{2} - a_{3}| = 1 \le |a_{3} - a_{4}| = 2 \le |a_{4} - a_{5}| = 2 \le |a_{5} - a_{6}| = 10$$$. There are other possible answers like "5 4 5 6 -2 8".In the second test case, after given rearrangement, $$$|a_{1} - a_{2}| = 1 \le |a_{2} - a_{3}| = 2 \le |a_{3} - a_{4}| = 4$$$. There are other possible answers like "2 4 8 1".

<?php
for ($t = intval(fgets(STDIN)); $t > 0; $t--){
    $size = intval(fgets(STDIN));
    $array = explode(" ", trim(fgets(STDIN)));
    sort($array);
    if($size % 2 == 0){
        for($i = $size / 2; $i < $size; $i++){

            echo $array[$i]." ".$array[$size - $i - 1]." ";
        }
        echo "\n";
    }

    else{
        echo $array[floor($size / 2)]." ";
        for($i = floor($size / 2) + 1; $i < $size; $i++){

            echo $array[$i]." ".$array[$size - $i - 1]." ";
        }
        echo "\n";
    }

}

<?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))) ;

        $numbers = explode(" ", trim(fgets(STDIN))) ;

        for($i = 0; $i < $n; $i ++) $numbers[$i] = intval($numbers[$i]) ;
        sort($numbers) ;

        $ans = array() ;

        if($n & 1)
        {
            $l = $n / 2 - 1 ;
            $r = $n / 2 + 1 ;

            array_push($ans, $numbers[$n/2]) ;
        }
        else
        {
            $l = $n / 2 - 1 ;
            $r = $n / 2 ;
        }

        while($l >= 0)
        {
            array_push($ans, $numbers[$l], $numbers[$r]) ;

            $l -- ;
            $r ++ ;
        }

        echo implode(" ", $ans) . "\n" ;
    }
?>

<?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))) ;

        $numbers = explode(" ", trim(fgets(STDIN))) ;

        for($i = 0; $i < $n; $i ++) $numbers[$i] = intval($numbers[$i]) ;
        sort($numbers) ;

        $min_pos = 1 ;
        $min_val = $numbers[1] - $numbers[0] ;

        for($i = 1; $i < $n; $i ++)
        {
            if($numbers[$i] - $numbers[$i - 1] < $min_val)
            {
                $min_val = $numbers[$i] - $numbers[$i - 1] ;
                $min_pos = $i ;
            }
        }

        $ans = array() ;
        array_push($ans, $numbers[$min_pos - 1], $numbers[$min_pos]) ;

        $l = $min_pos - 2 ;
        $r = $min_pos + 1 ;
        $len = 2 ;

        for($i = 2; $i < $n; $i ++)
        {
            $tmp_a = PHP_INT_MAX ;
            $tmp_b = PHP_INT_MAX ;

            if($l >= 0)
            {
                $tmp_a = $ans[$len - 1] - $numbers[$l] ;
                if($tmp_a < 0) $tmp_a = -$tmp_a ;
            }
            if($r < $n)
            {
                $tmp_b = $ans[$len - 1] - $numbers[$r] ;
                if($tmp_b < 0) $tmp_b = -$tmp_b ;
            }

            if($tmp_a < $tmp_b)
            {
                array_push($ans, $numbers[$l]) ;
                $l -- ;
                $len ++ ;
            }
            else
            {
                array_push($ans, $numbers[$r]) ;
                $r ++ ;
                $len ++ ;
            }
        }

        echo implode(" ", $ans) . "\n" ;
    }
?>


Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.

In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.

If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1. Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.


You are given an array $$$a$$$ consisting of $$$n$$$ positive integers.You are allowed to perform this operation any number of times (possibly, zero):   choose an index $$$i$$$ ($$$2 \le i \le n$$$), and change $$$a_i$$$ to $$$a_i - a_{i-1}$$$. Is it possible to make $$$a_i=0$$$ for all $$$2\le i\le n$$$?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 100$$$)  — the number of test cases. The description of the test cases follows. The first line contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le 10^9$$$).

For each test case, print "YES" (without quotes), if it is possible to change $$$a_i$$$ to $$$0$$$ for all $$$2 \le i \le n$$$, and "NO" (without quotes) otherwise. You can print letters in any case (upper or lower).

NoteIn the first test case, the initial array is $$$[5,10]$$$. You can perform $$$2$$$ operations to reach the goal:  Choose $$$i=2$$$, and the array becomes $$$[5,5]$$$.  Choose $$$i=2$$$, and the array becomes $$$[5,0]$$$. In the second test case, the initial array is $$$[1,2,3]$$$. You can perform $$$4$$$ operations to reach the goal:   Choose $$$i=3$$$, and the array becomes $$$[1,2,1]$$$.  Choose $$$i=2$$$, and the array becomes $$$[1,1,1]$$$.  Choose $$$i=3$$$, and the array becomes $$$[1,1,0]$$$.  Choose $$$i=2$$$, and the array becomes $$$[1,0,0]$$$. In the third test case, you can choose indices in the order $$$4$$$, $$$3$$$, $$$2$$$.

<?php

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

function readInt() {
  return (int) read() ;
}

function readStrs() {
  return explode(" ",read()) ;
}

function readIntArray() {
  return array_map('intval', readStrs());
}

function readAsArray() {
  return str_split(read()) ;
}

function printLine($arg) {
  if($arg === false) {
    print_r("false") ;
  }
  elseif($arg === true) {
    print_r("true") ;
  }
  else {
    print_r($arg) ;
  }
  print_r("\n") ;
}

$t = readInt() ;

while($t--) {

	$n = readInt() ;
	$arr = readIntArray() ;
	$k = $arr[0] ;
	$mark = true ;
	for ($i=1; $i < $n; $i++) {
		if($arr[$i] % $k != 0) {
			$mark = false ;
		}
	}
	if($mark) {
		printLine("YES");
	}
	else {
		printLine("NO") ;
	}
}


Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.The pasture is a rectangle consisting of R × C cells. Each cell is either empty, contains a sheep, a wolf or a dog. Sheep and dogs always stay in place, but wolves can roam freely around the pasture, by repeatedly moving to the left, right, up or down to a neighboring cell. When a wolf enters a cell with a sheep, it consumes it. However, no wolf can enter a cell with a dog.Initially there are no dogs. Place dogs onto the pasture in such a way that no wolf can reach any sheep, or determine that it is impossible. Note that since you have many dogs, you do not need to minimize their number.

First line contains two integers R (1 ≤ R ≤ 500) and C (1 ≤ C ≤ 500), denoting the number of rows and the numbers of columns respectively. Each of the following R lines is a string consisting of exactly C characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' an empty cell.

If it is impossible to protect all sheep, output a single line with the word "No". Otherwise, output a line with the word "Yes". Then print R lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a sheep or a wolf. If there are multiple solutions, you may print any of them. You don't have to minimize the number of dogs.

NoteIn the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.In the second example, there are no empty spots to put dogs that would guard the lone sheep.In the third example, there are no wolves, so the task is very easy. We put a dog in the center to observe the peacefulness of the meadow, but the solution would be correct even without him.


Given an integer $$$n$$$, find the maximum value of integer $$$k$$$ such that the following condition holds:  $$$n$$$ & ($$$n-1$$$) & ($$$n-2$$$) & ($$$n-3$$$) & ... ($$$k$$$) = $$$0$$$  where & denotes the bitwise AND operation.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^4$$$). Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

For each test case, output a single integer — the required integer $$$k$$$.

NoteIn the first testcase, the maximum value for which the continuous & operation gives 0 value, is 1.In the second testcase, the maximum value for which the continuous & operation gives 0 value, is 3. No value greater then 3, say for example 4, will give the & sum 0.   $$$5 \, \& \, 4 \neq 0$$$,  $$$5 \, \& \, 4 \, \& \, 3 = 0$$$. Hence, 3 is the answer.

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

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

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $d = decbin($n);
  $b = ''; $c ='';

  for ($j = 1; $j < strlen($d); $j++) { $b .= '1'; }

  $b = bindec($b);
  echo $b.PHP_EOL;
}

?>

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

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

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $d = decbin($n);
  $b = ''; $c ='';

  for ($j = 0; $j < strlen($d); $j++) {
    if ($d[$j] == '0') { $b .= '1'; }
    else { $b .= '0'; }
  }
  $b = ltrim($b, "0");
  $b = bindec($b);
  if ($n > 3) echo $b + 1;
  else echo $b;
  echo PHP_EOL;
}

?>

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

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

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $d = decbin($n);
  $b = ''; $c ='';

  for ($j = 0; $j < strlen($d); $j++) {
    if ($d[$j] == '0') { $b .= '1'; }
    else { $b .= '0'; }
  }
  $b = ltrim($b, "0");
  $b = bindec($b);
  if ($b != 1) echo $b + 1;
  else echo 1;
  echo PHP_EOL;
}

?>


The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.The Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital. The capital's main detective Polycarpus took a map and marked there the districts where the first three robberies had been committed as asterisks. Deduction tells Polycarpus that the fourth robbery will be committed in such district, that all four robbed districts will form the vertices of some rectangle, parallel to the sides of the map. Polycarpus is good at deduction but he's hopeless at math. So he asked you to find the district where the fourth robbery will be committed.

The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 100) — the number of rows and columns in the table, correspondingly. Each of the next n lines contains m characters — the description of the capital's map. Each character can either be a "." (dot), or an "*" (asterisk). A character equals "*" if the corresponding district has been robbed. Otherwise, it equals ".". It is guaranteed that the map has exactly three characters "*" and we can always find the fourth district that meets the problem requirements.

Print two integers — the number of the row and the number of the column of the city district that is the fourth one to be robbed. The rows are numbered starting from one from top to bottom and the columns are numbered starting from one from left to right.

<?php

error_reporting(0);

solve();

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

	$N = (int)$Input->in();
	$M = (int)$Input->in();

	for ($i = 0; $i < $N; $i++) {
		$temp = $Input->in();
		$len = strlen($temp);

		for ($j = 0; $j < $len; $j++) {
			if ($temp[$j] === "*") {
				$posX[] = $i;
				$posY[] = $j;
			}
		}
	}

	for ($i = 0; $i < count($posX) - 1; $i++) {
		if ($posX[$i]!== $posX[$i + 1] && $posY[$i] !== $posY[$i + 1] && $flag !== 1) {
			$dia_pos[] = $i;
			$dia_pos[] = $i + 1;
			$flag = 1;
		}
	}

	if (count($dia_pos) !== 2) {
		$no_dia_pos = 1;
		$dia_pos[] = 0;
		$dia_pos[] = 2;
	} else {
		$no_dia_pos = 3 - array_sum($dia_pos);
	}
	$ans[0] = $posX[$dia_pos[0]] + $posX[$dia_pos[1]] - $posX[$no_dia_pos] + 1;
	$ans[1] = $posY[$dia_pos[0]] + $posY[$dia_pos[1]] - $posY[$no_dia_pos] + 1;
	print($ans[0]. " ". $ans[1]);
}

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

			if (!feof($this->handle)) $contents = stream_get_contents($this->handle);
		} else $contents = stream_get_contents(STDIN);

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

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

	$N = (int)$Input->in();
	$M = (int)$Input->in();

	for ($i = 0; $i < $N; $i++) {
		$temp = $Input->in();
		$len = strlen($temp);
		for ($j = 0; $j < $len; $j++) {
			if ($temp[$j] === "*") $pos[] = $i. $j;
		}
	}

	for ($i = 0; $i < count($pos); $i++) {
		if ($pos[$i][0] !== $pos[$i + 1][0] && $pos[$i][1] !== $pos[$i + 1][1] && $flag !== 1) {
			$dia_pos[] = $i;
			$dia_pos[] = $i + 1;
			$flag = 1;
		}
	}

	if (count($dia_pos) !== 2) {
		$no_dia_pos = 1;
		$dia_pos[] = 0;
		$dia_pos[] = 2;
	} else {
		$no_dia_pos = 3 - array_sum($dia_pos);
	}
	$ans[0] = $pos[$dia_pos[0]][0] + $pos[$dia_pos[1]][0] - $pos[$no_dia_pos][0] + 1;
	$ans[1] = $pos[$dia_pos[0]][1] + $pos[$dia_pos[1]][1] - $pos[$no_dia_pos][1] + 1;
	print($ans[0]. " ". $ans[1]);
}

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

			if (!feof($this->handle)) $contents = stream_get_contents($this->handle);
		} else $contents = stream_get_contents(STDIN);

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

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

	$N = (int)$Input->in();
	$M = (int)$Input->in();

	for ($i = 0; $i < $N; $i++) {
		$temp = $Input->in();
		$len = strlen($temp);
		for ($j = 0; $j < $len; $j++) {
			if ($temp[$j] === "*") $pos[] = $i. $j;
		}
	}

	for ($i = 0; $i < count($pos); $i++) {
		if ($pos[$i][0] !== $pos[$i + 1][0] && $pos[$i][1] !== $posos[$i + 1][1] && $flag !== 1) {
			$dia_pos[] = $i;
			$dia_pos[] = $i + 1;
			$flag = 1;
		}
	}

	if (count($dia_pos) !== 2) {
		$no_dia_pos = 1;
		$dia_pos[] = 0;
		$dia_pos[] = 2;
	} else {
		$no_dia_pos = 3 - array_sum($dia_pos);
	}
	$ans[0] = $pos[$dia_pos[0]][0] + $pos[$dia_pos[1]][0] - $pos[$no_dia_pos][0] + 1;
	$ans[1] = $pos[$dia_pos[0]][1] + $pos[$dia_pos[1]][1] - $pos[$no_dia_pos][1] + 1;
	print(implode($ans). " ");
}

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

			if (!feof($this->handle)) $contents = stream_get_contents($this->handle);
		} else $contents = stream_get_contents(STDIN);

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

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

	$N = (int)$Input->in();
	$M = (int)$Input->in();

	for ($i = 0; $i < $N; $i++) {
		$temp = $Input->in();
		$len = strlen($temp);
		for ($j = 0; $j < $len; $j++) {
			if ($temp[$j] === "*") $pos[] = $i. $j;
		}
	}

	for ($i = 0; $i < count($pos); $i++) {
		if ($pos[$i][0] !== $pos[$i + 1][0] && $pos[$i][1] !== $posos[$i + 1][1] && $flag !== 1) {
			$dia_pos[] = $i;
			$dia_pos[] = $i + 1;
			$flag = 1;
		}
	}

	if (count($dia_pos) !== 2) {
		$no_dia_pos = 1;
		$dia_pos[] = 0;
		$dia_pos[] = 2;
	} else {
		$no_dia_pos = 3 - array_sum($dia_pos);
	}
	$ans[0] = $pos[$dia_pos[0]][0] + $pos[$dia_pos[1]][0] - $pos[$no_dia_pos][0] + 1;
	$ans[1] = $pos[$dia_pos[0]][1] + $pos[$dia_pos[1]][1] - $pos[$no_dia_pos][1] + 1;
	print($ans[0]. " ". $ans[1]);
}

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

			if (!feof($this->handle)) $contents = stream_get_contents($this->handle);
		} else $contents = stream_get_contents(STDIN);

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>

<?php

error_reporting(0);

solve();

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

	$N = (int)$Input->in();
	$M = (int)$Input->in();

	for ($i = 0; $i < $N; $i++) {
		$temp = $Input->in();
		$len = strlen($temp);
		for ($j = 0; $j < $len; $j++) {
			if ($temp[$j] === "*") $pos[] = $i. $j;
		}
	}

	for ($i = 0; $i < count($pos) - 1; $i++) {
		if ($pos[$i][0] !== $pos[$i + 1][0] && $pos[$i][1] !== $pos[$i + 1][1] && $flag !== 1) {
			$dia_pos[] = $i;
			$dia_pos[] = $i + 1;
			$flag = 1;
		}
	}

	if (count($dia_pos) !== 2) {
		$no_dia_pos = 1;
		$dia_pos[] = 0;
		$dia_pos[] = 2;
	} else {
		$no_dia_pos = 3 - array_sum($dia_pos);
	}
	$ans[0] = $pos[$dia_pos[0]][0] + $pos[$dia_pos[1]][0] - $pos[$no_dia_pos][0] + 1;
	$ans[1] = $pos[$dia_pos[0]][1] + $pos[$dia_pos[1]][1] - $pos[$no_dia_pos][1] + 1;
	print($ans[0]. " ". $ans[1]);
}

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

	public function __construct($localfile){

		if (is_file($localfile)) {

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

			if (!feof($this->handle)) $contents = stream_get_contents($this->handle);
		} else $contents = stream_get_contents(STDIN);

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

	public function in(){

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

	}

	public function close(){

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

	}
}

?>


One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.Help Timofey to color his rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color, or determine that it is impossible.Two rectangles intersect if their intersection has positive area. Two rectangles touch by sides if there is a pair of sides such that their intersection has non-zero length    The picture corresponds to the first example

The first line contains single integer n (1 ≤ n ≤ 5·105) — the number of rectangles. n lines follow. The i-th of these lines contains four integers x1, y1, x2 and y2 ( - 109 ≤ x1 < x2 ≤ 109,  - 109 ≤ y1 < y2 ≤ 109), that means that points (x1, y1) and (x2, y2) are the coordinates of two opposite corners of the i-th rectangle. It is guaranteed, that all sides of the rectangles have odd lengths and rectangles don't intersect each other.

Print "NO" in the only line if it is impossible to color the rectangles in 4 different colors in such a way that every two rectangles touching each other by side would have different color. Otherwise, print "YES" in the first line. Then print n lines, in the i-th of them print single integer ci (1 ≤ ci ≤ 4) — the color of i-th rectangle.


Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the first student with the second one as well as the second student with the first one.To restore order, Anna and Maria do the following. First, for each student Anna finds out what other students he is tied to. If a student is tied to exactly one other student, Anna reprimands him. Then Maria gathers in a single group all the students who have been just reprimanded. She kicks them out from the club. This group of students immediately leaves the club. These students takes with them the laces that used to tie them. Then again for every student Anna finds out how many other students he is tied to and so on. And they do so until Anna can reprimand at least one student.Determine how many groups of students will be kicked out of the club.

The first line contains two integers n and m — the initial number of students and laces (). The students are numbered from 1 to n, and the laces are numbered from 1 to m. Next m lines each contain two integers a and b — the numbers of students tied by the i-th lace (1 ≤ a, b ≤ n, a ≠ b). It is guaranteed that no two students are tied with more than one lace. No lace ties a student to himself.

Print the single number — the number of groups of students that will be kicked out from the club.

NoteIn the first sample Anna and Maria won't kick out any group of students — in the initial position every student is tied to two other students and Anna won't be able to reprimand anyone.In the second sample four students are tied in a chain and two more are running by themselves. First Anna and Maria kick out the two students from both ends of the chain (1 and 4), then — two other students from the chain (2 and 3). At that the students who are running by themselves will stay in the club.In the third sample Anna and Maria will momentarily kick out all students except for the fourth one and the process stops at that point. The correct answer is one.

<?php
$count=explode(' ',trim(fgets(STDIN)));
$link_count = intval(trim($count[1]));
$child_count = intval(trim($count[0]));
$link = array();
for($i=0;$i<$link_count;$i++) {
    $input=explode(' ',trim(fgets(STDIN)));
    $n1=intval(trim($input[0]));
    $n2=intval(trim($input[1]));
    $link[$n1][]=$n2;
    $link[$n2][]=$n1;
}
$result = 0;
$completed = false;
while($completed === false) {
    $excl = array();
    foreach($link as $k => $v) {
        if(count($v) === 1) {
            $excl[$k] = reset($v);
        }
    }
    if(count($excl) > 0) {
        foreach($excl as $k => $v) {
            if(isset($link[$v])) {
                sort($link[$v]);
                for($i=0;$i<count($link[$v]);$i++) {
                    if($link[$v][$i] === $k) {
                        unset($link[$v][$i]);
                        if(count($link[$v]) < 1) {
                            unset($link[$v]);
                            break;
                        }
                    }
                }
            }
            if(isset($link[$k])) {
                unset($link[$k]);
            }
        }
        $result ++;
    }
    else {
        $completed = true;
    }
}

echo( $result );

<?php
$n = explode(' ', trim(fgets(STDIN)));
$link = array();
for($i=0; $i<$n[1];$i++) {
    $in = explode(' ',trim(fgets(STDIN)));
    $link[$in[0]][] = $in[1];
    $link[$in[1]][] = $in[0];
}
$r = 0;

while (1) {
    $dissmiss = array();
    foreach ($link as $key => $val) {
        if(count($val) == 1) {
            $dissmiss[] = $key;
        }
    }
    if(count($dissmiss) == 0) {
        break;
    }
    foreach ($dissmiss as $child) {
        if(!isset($link[$child])) {
            continue;
        }
        $pair = implode('',$link[$child]);
        if(!isset($link[$pair])) {
            continue;
        }
        $key  = array_search($child, $link[$pair]);
        if($key === FALSE) {
            continue;
        }
        if(count($link[$pair]) == 1) {
            unset($link[$pair]);
        }
        else {
            unset($link[$pair][$key]);
        }

        unset($link[$child]);
    }
    $r++;
}
echo($r);

<?php

$s = fgets(STDIN, 1024);
$t = explode(' ', $s);
$n = intval($t[0]);
$m = intval($t[1]);
$ban = $all = $links = array();

for($i = 0; $i < $m; $i++) {
	$s = fgets(STDIN, 1024);
	$t = explode(' ', $s);
	$links[] = array(intval($t[0]), intval($t[1]));
}

$ans = 0;
while (true) {
	$bad = false;
	$a = array();
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) $a[$v[0]] = 0;
		if(!isset($a[$v[1]])) $a[$v[1]] = 0;
		$a[$v[0]]++;
		$a[$v[1]]++;
	}
	foreach($a AS $k => $v) {
		if ($v >= 2) continue;
		$bad = true;
		$ban[] = $k;
		unset($a[$k]);
	}
	if (!$bad) break;
	$ans++;
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) unset($links[$k]);
		if(!isset($a[$v[1]])) unset($links[$k]);
	}
}
echo($ans);
?>

<?php

$s = fgets(STDIN, 1024);
list($n, $m) = explode(' ', $s);
$ban = $links = array();

for($i = 0; $i < $m; $i++) {
	$s = fgets(STDIN, 1024);
	$t = explode(' ', $s);
	$links[] = array(intval($t[0]), intval($t[1]));
}

while (true) {
	//var_export($links);
	$bad = false;
	$a = array();
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) $a[$v[0]] = 0;
		if(!isset($a[$v[1]])) $a[$v[1]] = 0;
		$a[$v[0]]++;
		$a[$v[1]]++;
	}
	foreach($a AS $k => $v) {
		if ($v >= 2) continue;
		$bad = true;
		$ban[] = $k;
		unset($a[$k]);
	}
	if (!$bad) break;
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) unset($links[$k]);
		if(!isset($a[$v[1]])) unset($links[$k]);
	}
}
echo($n - count($ban));
?>

<?php

$s = fgets(STDIN, 1024);
list($n, $m) = explode(' ', $s);
$ban = $links = array();

for($i = 0; $i < $m; $i++) {
	$s = fgets(STDIN, 1024);
	$t = explode(' ', $s);
	$links[] = array(intval($t[0]), intval($t[1]));
}

while (true) {
	//var_export($links);
	$bad = false;
	$a = array();
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) $a[$v[0]] = 0;
		if(!isset($a[$v[1]])) $a[$v[1]] = 0;
		$a[$v[0]]++;
		$a[$v[1]]++;
	}
	foreach($a AS $k => $v) {
		if ($v >= 2) continue;
		$bad = true;
		$ban[] = $k;
		unset($a[$k]);
	}
	if (!$bad) break;
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) unset($links[$k]);
		if(!isset($a[$v[1]])) unset($links[$k]);
	}
}
if(count($ban) > 0) echo('0'); else echo($n - count($ban));
?>

<?php

$s = fgets(STDIN, 1024);
$t = explode(' ', $s);
$n = intval($t[0]);
$m = intval($t[1]);
$ban = $all = $links = array();

for($i = 0; $i < $m; $i++) {
	$s = fgets(STDIN, 1024);
	$t = explode(' ', $s);
	$links[] = array(intval($t[0]), intval($t[1]));
}

while (true) {
	$bad = false;
	$a = array();
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) $a[$v[0]] = 0;
		if(!isset($a[$v[1]])) $a[$v[1]] = 0;
		$a[$v[0]]++;
		$a[$v[1]]++;
	}
	foreach($a AS $k => $v) {
		if ($v >= 2) continue;
		$bad = true;
		$ban[] = $k;
		unset($a[$k]);
	}
	if (!$bad) break;
	foreach($links AS $k => $v) {
		if(!isset($a[$v[0]])) unset($links[$k]);
		if(!isset($a[$v[1]])) unset($links[$k]);
	}
}
if ($m == $n) {
	echo(count($ban));
} else {
	echo($n - count($ban));
}
?>


Given a string $$$s$$$ of length $$$n$$$ and integer $$$k$$$ ($$$1 \le k \le n$$$). The string $$$s$$$ has a level $$$x$$$, if $$$x$$$ is largest non-negative integer, such that it's possible to find in $$$s$$$:  $$$x$$$ non-intersecting (non-overlapping) substrings of length $$$k$$$,  all characters of these $$$x$$$ substrings are the same (i.e. each substring contains only one distinct character and this character is the same for all the substrings). A substring is a sequence of consecutive (adjacent) characters, it is defined by two integers $$$i$$$ and $$$j$$$ ($$$1 \le i \le j \le n$$$), denoted as $$$s[i \dots j]$$$ = "$$$s_{i}s_{i+1} \dots s_{j}$$$".For example, if $$$k = 2$$$, then:  the string "aabb" has level $$$1$$$ (you can select substring "aa"),  the strings "zzzz" and "zzbzz" has level $$$2$$$ (you can select two non-intersecting substrings "zz" in each of them),  the strings "abed" and "aca" have level $$$0$$$ (you can't find at least one substring of the length $$$k=2$$$ containing the only distinct character). Zuhair gave you the integer $$$k$$$ and the string $$$s$$$ of length $$$n$$$. You need to find $$$x$$$, the level of the string $$$s$$$.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the length of the string and the value of $$$k$$$. The second line contains the string $$$s$$$ of length $$$n$$$ consisting only of lowercase Latin letters.

Print a single integer $$$x$$$ — the level of the string.

NoteIn the first example, we can select $$$2$$$ non-intersecting substrings consisting of letter 'a': "(aa)ac(aa)bb", so the level is $$$2$$$.In the second example, we can select either substring "a" or "b" to get the answer $$$1$$$.

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

   $A = array();
   $sx = 0;
   while($sx<$n) {
      $cc = $s[$sx];
      $cn = 1;
      $ex = $sx;
      if($k>1) {
         for($ex=$sx+1; $ex<$n; $ex++) {
            if($cc!=$s[$ex]) break;
            $cn++;
            if($cn==$k) break;
         }
      }
      if($cn==$k) {
         if(array_key_exists($cc, $A)) $A[$cc]++;
         else $A[$cc] = 1;
         $sx = $ex+1;
      }
      else $sx = $ex;
   }
   if(count($A)==0) echo "0";
   else {
      arsort($A, SORT_NUMERIC);
      //print_r($A);
      reset($A);
      echo current($A);
   }
?>

<?php
fscanf(STDIN,"%d %d",$strSize,$k);
fscanf(STDIN,"%s",$str);
$alpha='abcdefghijklmnopqrstuvwxyz';
$ans=array();
//$ans[]=0;
$max=0;
for ($i=0; $i <26 ; $i++)
{  $cnt=0;
    $ans[$i]=0;
    for ($j=0; $j <$strSize ; $j++)
    {
        if($str[$j]==$alpha[$i])
         {
            $cnt++;
            if($cnt==$k)
             {
                $ans[$i]++;
                $cnt=0;
             }
         }
         else
            $cnt=0;
    }
    if($ans[$i]>$max)
        $max=$ans[$i];

}
echo $max;
//print_r($ans);

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

   $A = array();
   $sx = 0;
   while($sx<$n) {
      $cc = $s[$sx];
      $cn = 1;
      for($ex=$sx+1; $ex<$n; $ex++) {
         if($cn==$k) {
            if(array_key_exists($cc, $A)) $A[$cc]++;
            else $A[$cc] = 1;
            $ex++;
            break;
         }
         if($cc!=$s[$ex]) break;
         $cn++;
      }
      $sx = $ex;
   }
   if(count($A)==0) echo "0";
   else {
      arsort($A, SORT_NUMERIC);
      //print_r($A);
      reset($A);
      echo current($A);
   }
?>

<?php
fscanf(STDIN,"%d %d",$n,$k);
fscanf(STDIN,"%s",$str);
$splitByOne=str_split($str);
//print_r($splitByOne);
$splitByK=str_split($str,$k);
//print_r($splitByK)
$uniqueAlph=array_values(array_unique($splitByOne));
$max=0;
for ($l=0; $l <count($uniqueAlph) ; $l++)
 { $lcount=0;
	for ($i=0; $i <count($splitByK) ; $i++)
		{     $count=0;
			for ($j=0; $j <$k ; $j++)
			{
				if($splitByK[$i][$j]==$uniqueAlph[$l])
				{
					$count++;
					if($count==$k)
                      $lcount++;

				}
			}
		}
		if($lcount>$max)
			$max=$lcount;
}
echo "$max";

<?php
fscanf(STDIN,"%d %d",$n,$k);
fscanf(STDIN,"%s",$str);
$lcount=array();
$str1=str_split($str,$k);
//print_r($str1);
$a=array();
for ($i=0; $i <26 ; $i++)
 {
	$a[$i]=0;
 }
 //print_r($a);
for ($i=0; $i <count($str1); $i++)
 {
    if(count(array_unique(str_split($str1[$i])))==1)
    {

			     if(implode(array_unique(str_split($str1[$i])))=='a'&&strlen($str1[$i])==$k)
			     {
			            $a[0]++;
			     }
			     if(implode(array_unique(str_split($str1[$i])))=='b' &&strlen($str1[$i])==$k)
			      {
			        	$a[1]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='c'&&strlen($str1[$i])==$k)
			      {
			        	$a[2]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='d'&&strlen($str1[$i])==$k)
			      {
			        	$a[3]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='e'&&strlen($str1[$i])==$k)
			      {
			        	$a[4]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='f'&&strlen($str1[$i])==$k)
			      {
			        	$a[5]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='g'&&strlen($str1[$i])==$k)
			      {
			        	$a[6]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='h'&&strlen($str1[$i])==$k)
			      {
			        	$a[7]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='i'&&strlen($str1[$i])==$k)
			      {
			        	$a[8]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='j'&&strlen($str1[$i])==$k)
			      {
			        	$a[9]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='k'&&strlen($str1[$i])==$k)
			      {
			        	$a[10]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='l'&&strlen($str1[$i])==$k)
			      {
			        	$a[11]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='m'&&strlen($str1[$i])==$k)
			      {
			        	$a[12]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='n'&&strlen($str1[$i])==$k)
			      {
			        	$a[13]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='o'&&strlen($str1[$i])==$k)
			      {
			        	$a[14]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='p'&&strlen($str1[$i])==$k)
			      {
			        	$a[15]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='q'&&strlen($str1[$i])==$k)
			      {
			        	$a[16]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='r'&&strlen($str1[$i])==$k)
			      {
			        	$a[17]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='s'&&strlen($str1[$i])==$k)
			      {
			        	$a[18]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='t'&&strlen($str1[$i])==$k)
			      {
			        	$a[19]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='u'&&strlen($str1[$i])==$k)
			      {
			        	$a[20]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='v'&&strlen($str1[$i])==$k)
			      {
			        	$a[21]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='w'&&strlen($str1[$i])==$k)
			      {
			        	$a[22]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='x'&&strlen($str1[$i])==$k)
			      {
			        	$a[23]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='y'&&strlen($str1[$i])==$k)
			      {
			        	$a[24]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='z'&&strlen($str1[$i])==$k)
			         $a[25]++;
    }

 }
echo max($a);

<?php
fscanf(STDIN,"%d %d",$strSize,$k);
fscanf(STDIN,"%s",$str);
$splitedStr=str_split($str,$k);
$ara=array();
for ($i=0; $i <count($splitedStr) ; $i++)
 {
	if(array_key_exists($splitedStr[$i],$ara))
		   $ara[$splitedStr[$i]]+=1;
		else
		{
			if(count(array_unique(str_split($splitedStr[$i])))==1)
			     $ara[$splitedStr[$i]]=1;
		}
 }
 if(count($ara)==0)
 	echo "0";

else
 echo max($ara);

<?php
fscanf(STDIN,"%d %d",$n,$k);
fscanf(STDIN,"%s",$str);
$lcount=array();
$str1=str_split($str,$k);
//print_r($str1);
$a=array();
for ($i=0; $i <26 ; $i++)
 {
	$a[$i]=0;
 }
 //print_r($a);
for ($i=0; $i <count($str1); $i++)
 {
    if(count(array_unique(str_split($str1[$i])))==1)
    {

			     if(implode(array_unique(str_split($str1[$i])))=='a')
			     {
			            $a[0]++;
			     }
			     if(implode(array_unique(str_split($str1[$i])))=='b')
			      {
			        	$a[1]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='c')
			      {
			        	$a[2]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='d')
			      {
			        	$a[3]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='e')
			      {
			        	$a[4]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='f')
			      {
			        	$a[5]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='g')
			      {
			        	$a[6]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='h')
			      {
			        	$a[7]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='i')
			      {
			        	$a[8]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='j')
			      {
			        	$a[9]++;
			      }
			     if(implode(array_unique(str_split($str1[$i])))=='k')
			      {
			        	$a[10]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='l')
			      {
			        	$a[11]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='m')
			      {
			        	$a[12]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='n')
			      {
			        	$a[13]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='o')
			      {
			        	$a[14]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='p')
			      {
			        	$a[15]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='q')
			      {
			        	$a[16]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='r')
			      {
			        	$a[17]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='s')
			      {
			        	$a[18]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='t')
			      {
			        	$a[19]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='u')
			      {
			        	$a[20]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='v')
			      {
			        	$a[21]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='w')
			      {
			        	$a[22]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='x')
			      {
			        	$a[23]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='y')
			      {
			        	$a[24]++;
			      }
			      if(implode(array_unique(str_split($str1[$i])))=='z')
			         $a[25]++;
    }

 }
echo max($a);