<?php

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

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

        $result = trim(fgets($handle));
        $arr = explode(' ',$result);
        rsort($arr);
        $count=0;
        for ($h=0;$h<sizeof($arr);$h++)
            if($h<$arr[$h])
                $count++;

        printf("%d\n",$count);

    }

}

solve();
?>

<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++) {
    list($k) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $j = 1;
    $iCount = 0;
    arsort($aArray);
    foreach ($aArray as $sK => $sV){
        if($j > $sV) {
            break;
        } else {
            $iCount++;
            $j++;
        }
    }
    echo $iCount."\n";
}

<?php
// STDIN = fopen('input.txt', 'r');
$q = + trim(fgets(STDIN));

for ($i = 0; $i < $q; $i++){
	$n = + trim(fgets(STDIN));
	$arr = explode(' ', trim(fgets(STDIN)));

	echo calc($n, $arr)."\n";

}

function calc($n, $arr){
	sort($arr);
	$arr = array_reverse($arr);
	for ($i = 0; $i < $n; $i++){
		if($i + 1 > $arr[$i]){
			return $i;
		}
	}
	return $n;

}

<?php
$count = intval(fgets(STDIN));
$i = 0;
while($i < $count)
{
    $n = intval(fgets(STDIN));
    $lens = explode(" ", fgets(STDIN));
    $sorted = array();
    foreach($lens as $len)
    {
        // if(!isset($sorted[$len]))
        //     $sorted[$len] = 0;
        // $sorted[$len]++;
        $sorted[] = intval($len);
    }
    sort($sorted);
    $max = 0;
    foreach($sorted as $k => $len)
    {
        if($n - $k <= $len)
        {
            $max = $n - $k;
            break;
        }
    }
    echo $max."\n";
    $i++;
}
?>

<?php

$t=trim(fgets(STDIN));
while($t--)
{
    $n=trim(fgets(STDIN));
    $a=explode(' ',trim(fgets(STDIN)));
    rsort($a);
    $ind=$n;
    for($i=0;$i<$n;$i++)
    if($i+1>$a[$i])
    {
        $ind=$i;
        break;
    }
    echo "$ind\n";

}

?>

<?php

$n = trim(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $a = trim(fgets(STDIN));
    $t = explode(' ', trim(fgets(STDIN)));
    rsort($t);
    $j = 0;
    foreach($t as $v){
        if($v > $j){
            $j++;
        } else {
            break;
        }
    }
    echo "$j\n";

}

<?php
$k = fgets(STDIN);
for($i = 0; $i < $k; $i++)
{
    $n = fgets(STDIN);
    $lens = explode(" ", fgets(STDIN));
    $sorted = array();
    foreach($lens as $len)
    {
        if(!isset($sorted[$len]))
            $sorted[$len] = 0;
        $sorted[$len]++;
    }
    ksort($sorted);
    $max = 0;
    foreach($sorted as $k => $len)
    {
        if($k == $len)
            $max = $len;
    }
    echo $max."\n";
}
?>

<?php

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

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

        $result = trim(fgets($handle));
        $arr = explode(' ',$result);
        rsort($arr);
        $count=0;
        for ($h=0;$h<sizeof($arr);$h++)
            if($h<$arr[$h])
                $count++;

        printf("%d",$count);

    }

}

<?php

$t = trim(fgets(STDIN));

$ans = "";

for ($o = 0; $o < $t; $o++)
{
	$n = trim(fgets(STDIN));
	$data = explode(" ", trim(fgets(STDIN)));
	sort($data);
	$ans .= (($n >= 3) ? $data[$n-3] : (($n == 2) ? $data[n - 2] : $data[n - 1]))."\n";
}
echo $ans;

?>


<?php

class ArgsHelper
{
	private $useStd;
	private $input;

	public function __construct()
	{
		$this->useStd = stristr($GLOBALS['argv'][0], '.PhpStorm2019.3\config') === false;
	}

	public function calculateResult($input)
	{
		array_shift($input);

		$alexPlace = array_shift($input);

		$alexPlace = explode(' ', trim($alexPlace));
		$alexes = array_fill($alexPlace[0], $alexPlace[1] - $alexPlace[0], 1);
		foreach ($input as $item)
		{
			$item = explode(' ', trim($item));

			if ($item[0] >= $alexPlace[1])
			{
				continue;
			}
			for ($j = $item[0]; $j < $item[1]; $j++)
			{
				if ($j>=$alexPlace[1])
				{
					break;
				}
				unset($alexes[$j]);
			}
		}
		return count($alexes);
	}

	public function readInputLines()
	{
		$this->input = [];
		if ($this->useStd)
		{
			while ($line = fgets(STDIN))
			{
				$this->input[] = $line;
			}
		}
		else
		{
			global $testInput;
			$this->input = explode("\n", trim($testInput));
		}
	}

	public function getInputLines()
	{
		$this->readInputLines();
		return $this->input;
	}

	public function printResult($result)
	{
		if ($this->useStd)
		{
			fwrite(STDOUT, $result);
		}
		else
		{
			var_dump($result);
		}
	}

}

##################################################
$testInput = '3
0 10
1 5
7 15
';

$helper = new ArgsHelper();
$lines = $helper->getInputLines();

$result = '';
#
$result = trim($helper->calculateResult($lines) . "\n");
#

$helper->printResult($result);

<?php

class ArgsHelper
{
	private $useStd;
	private $input;

	public function __construct()
	{
		$this->useStd = stristr($GLOBALS['argv'][0], '.PhpStorm2019.3\config') === false;
	}

	public function calculateResult($input)
	{
		array_shift($input);
		$alexPlace = array_shift($input);
		$alexPlace = explode(' ', $alexPlace);
		$alexes = array_fill($alexPlace[0], $alexPlace[1] - $alexPlace[0], 1);
		foreach ($input as $item)
		{
			$item = explode(' ', $item);
			if ($item[0] >= $alexPlace[1])
			{
				continue;
			}
			for ($j = $item[0]; $j < $item[1]; $j++)
			{
				if ($j>=$alexPlace[1])
				{
					break;
				}
				unset($alexes[$j]);
			}
		}
		return count($alexes);
	}

	public function readInputLines()
	{
		$this->input = [];
		if ($this->useStd)
		{
			while ($line = fgets(STDIN))
			{
				$this->input[] = $line;
			}
		}
		else
		{
			global $testInput;
			$this->input = explode("\n", trim($testInput));
		}
	}

	public function getInputLines()
	{
		$this->readInputLines();
		return $this->input;
	}

	public function printResult($result)
	{
		if ($this->useStd)
		{
			fwrite(STDOUT, $result);
		}
		else
		{
			var_dump($result);
		}
	}

}

##################################################
$testInput = '3
0 10
1 5
7 15
';

$helper = new ArgsHelper();
$lines = $helper->getInputLines();

$result = '';
#
$result = trim($helper->calculateResult($lines) . "\n");
#

$helper->printResult($result);


<?php
    $arr = array("purple" => "Power",
    "green" => "Time",
    "blue" => "Space",
    "orange" => "Soul",
    "red" => "Reality",
    "yellow" => "Mind"
    );

    $cnt = array("purple" => 0,
    "green" => 0,
    "blue" => 0,
    "orange" => 0,
    "red" => 0,
    "yellow" => 0
    );

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

    echo 6 - $n . PHP_EOL;

    foreach($cnt as $x => $val)
        if(!$val)
            echo $arr[$x] . PHP_EOL;
?>

<?php
$st = ['purple'=>'Power', 'green'=>'Time', 'red'=>'Reality', 'blue' => 'Space', 'orange' => 'Soul', 'yellow' => 'Mind'];
$n = intval(trim(fgets(STDIN)));
while($n--){
	$clr = trim(fgets(STDIN));
	unset($st[$clr]);
}
print count($st). "\n";
print implode("\n", $st)."\n";

<?php
$a = trim(fgets(STDIN));
$b = array();
for($x = 0; $x < $a; $x++)
{
     $c = trim(fgets(STDIN));
     $b[$x] = $c;
}
$d = array("purple", "green", "blue", "orange", "red", "yellow");
$e = array_diff($d, $b);
$f = array("Power", "Time", "Space", "Soul", "Reality", "Mind");
$g = array_keys($e);
print count($e) . "\n";
for($x = 0; $x < count($e); $x++)
{
     print $f[$g[$x]] . "\n";
}
?>

#include <bits/stdc++.h>

using namespace std;

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);

int execute()
{
    int n, i;

    cin >> n;

    map < string, bool > used;

    string s;

    for(i=0; i<n; i++)
    {
        cin >> s;
        used[s] = true;
    }

    vector < string > a;
    a.push_back("purple");
    a.push_back("green");
    a.push_back("blue");
    a.push_back("orange");
    a.push_back("red");
    a.push_back("yellow");

    map < string, string > assoc;

    assoc[a[0]] = "Power";
    assoc[a[1]] = "Time";
    assoc[a[2]] = "Space";
    assoc[a[3]] = "Soul";
    assoc[a[4]] = "Reality";
    assoc[a[5]] = "Mind";

    cout << 6 - used.size() << endl;

    for(i=0; i<6; i++)
        if(!used[a[i]])
            cout << assoc[a[i]] << endl;

    return 0;
}

char mtest = false;
unsigned short TE = 1;

int main()
{
    //in
    ios_base::sync_with_stdio(false);

    if(mtest)
        cin >> TE;

    while(TE--)
        execute();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);

int execute()
{
    int n, i;
    cin >> n;
    map < string, bool > used;
    string s;
    for(i=0; i<n; i++)
    {
        cin >> s;
        used[s] = true;
    }

    string a[] = {"purple", "green", "blue", "orange", "red", "yellow"};

    map < string, string > assoc;

    assoc[a[0]] = "Power";
    assoc[a[1]] = "Time";
    assoc[a[2]] = "Space";
    assoc[a[3]] = "Soul";
    assoc[a[4]] = "Reality";
    assoc[a[5]] = "Mind";

    cout << 6 - used.size() << endl;

    for(i=0; i<6; i++)
        if(!used[a[i]])
            cout << assoc[a[i]] << endl;

    return 0;
}

char mtest = false;
unsigned short TE = 1;

int main()
{
    //in
    ios_base::sync_with_stdio(false);

    if(mtest)
        cin >> TE;

    while(TE--)
        execute();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);

int execute()
{
    int n;

    int i;

    cin >> n;

    map < string, bool > used;

    string s;

    for(i=0; i<n; i++)
    {
        cin >> s;
        used[s] = true;
    }

    string a[] = {"purple", "green", "blue", "orange", "red", "yellow"};

    map < string, string > assoc;

    assoc[a[0]] = "Power";
    assoc[a[1]] = "Time";
    assoc[a[2]] = "Space";
    assoc[a[3]] = "Soul";
    assoc[a[4]] = "Reality";
    assoc[a[5]] = "Mind";

    cout << 6 - used.size() << endl;

    for(i=0; i<6; i++)
        if(!used[a[i]])
            cout << assoc[a[i]] << endl;

    return 0;
}

char mtest = false;
unsigned short TE = 1;

int main()
{
    //in
    ios_base::sync_with_stdio(false);

    if(mtest)
        cin >> TE;

    while(TE--)
        execute();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);

int execute()
{
    int n, i;

    cin >> n;

    map < string, bool > used;

    string s;

    for(i=0; i<n; i++)
    {
        cin >> s;
        used[s] = true;
    }

    vector < string > a;
    a.push_back("purple");
    a.push_back("green");
    a.push_back("blue");
    a.push_back("orange");
    a.push_back("red");
    a.push_back("yellow");

    map < string, string > assoc;

    assoc[a[0]] = "Power";
    assoc[a[1]] = "Time";
    assoc[a[2]] = "Space";
    assoc[a[3]] = "Soul";
    assoc[a[4]] = "Reality";
    assoc[a[5]] = "Mind";

    cout << 6 - n << endl;

    for(i=0; i<6; i++)
        if(!used[a[i]])
            cout << assoc[a[i]] << endl;

    return 0;
}

char mtest = false;
unsigned short TE = 1;

int main()
{
    in
    ios_base::sync_with_stdio(false);

    if(mtest)
        cin >> TE;

    while(TE--)
        execute();

    return 0;
}


<?php
$n_m = trim(fgets(STDIN));
$nm_arr = explode(" ", $n_m);
$n = $nm_arr[0];
$m = $nm_arr[1];
for ($i = 1; $i <= $n; $i++) {
    $n_l = trim(fgets(STDIN));
    $nl_arr = explode(" ", $n_l);
    for ($j = 1; $j <= $nl_arr[0]; $j++) {
        $m_array[] = $nl_arr[$j];
    }
}
for ($k = 1; $k <= $m; $k++){
    if (in_array($k, $m_array)) {
        $f = true;
    } else {
        $f = false;
        break;
    }
}
if ($f) {
    echo "YES";
} else {
    echo "NO";
}
?>

<?php
/**
 * Author: 七柳先森
 * Date: 2016/1/23  9:08
 */
while(fscanf(STDIN,"%d%d",$n,$m)){
    $bulbStatus = array_fill(0,$m,0);
   // var_dump($bulbStatus);
    for($i = 0 ; $i < $n ; $i++){
        $line = stream_get_line(STDIN,65535,"\n");
        $num = explode(" ",$line);
        for($j = 1 ; $j < count($num); $j++){
            $bulbStatus[ $num[$j] -1 ] = 1;
        }
    }
    if(array_sum($bulbStatus) == $m){
        fprintf(STDOUT,"YES");
    }else{
        fprintf(STDOUT,"NO");
    }
    exit();
}

<?php
$input = file_get_contents('php://stdin');
$input = explode("\n", $input);
$firstString = $input[0];
$firstString = explode(" ", $firstString );
$n = $firstString[0];
$m = $firstString[1];

unset($input[0]);
$lamps = array();
for($i=1; $i<=$m; $i++) {
    $lamps[$i] = $i;
}

foreach($input as $row) {
   $rLamps = explode(' ', $row);
   unset($rLamps[0]);
   foreach($rLamps as $lamp) {
    $lamp = trim($lamp);
       unset($lamps[$lamp]);
   }
   if (empty($lamps)) {
       echo 'YES';
       die();
   }
}
echo 'NO';
?>

<?
list($n, $m) = explode(' ',trim(fgets(STDIN)));
for($i = 0; $i < $n;  ++$i){
 $arr =explode(' ',trim(fgets(STDIN)));
 for($j = 1; $j <= $arr[0];  ++$j){
  $bulbs[$arr[$j]]++;
 }
}
$flag = true;

for($j = 1; $j <= $m;  ++$j){
  if($bulbs[$j] < 1)
  {
   $flag = false;
   break;
  }
}
echo ($flag)?"YES":"NO";

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = range(1, $b);
$d = array();
for($x = 1; $x <= $a; $x++)
{
    $e = explode(" ", trim(fgets(STDIN)));
    $f = array_slice($e, 1);
    $d = array_merge($d, $f);
}
$g = array_unique($d);
sort($g);
$h = array_diff($c, $g);
if(count($h) == 0)
{
    print "YES";
}
else
{
    print "NO";
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = range(1, 4);
$d = array();
for($x = 1; $x <= $a; $x++)
{
    $e = explode(" ", trim(fgets(STDIN)));
    $f = array_slice($e, 1);
    $d = array_merge($d, $f);
}
$g = array_unique($d);
sort($g);
$h = array_diff($c, $g);
if(count($h) == 0)
{
    print "YES";
}
else
{
    print "NO";
}
?>

<?php
$n_m = trim(fgets(STDIN));
$nm_arr = explode(" ", $n_m);
$n = $nm_arr[0];
$m = $nm_arr[1];
for ($i = 1; $i <= $n; $i++) {
    $n_l = trim(fgets(STDIN));
    $nl_arr = explode(" ", $n_l);
    for ($j = 1; $j <= $nl_arr[0]; $j++) {
        $m_array[] = $nl_arr[$j];
    }
}
for ($k = 1; $k <= $m; $k++){
    if (in_array($k, $m_array)) {
        $f = true;
    } else {
        $f = false;
        break;
    }
}
if (f) {
    echo "YES";
} else {
    echo "NO";
}
?>

<?php
$input = file_get_contents('php://stdin');
$input = explode("\n", $input);
$firstString = $input[0];
$firstString = explode(" ", $firstString );
$n = $firstString[0];
$m = $firstString[1];

unset($input[0]);
$lamps = array();
for($i=1; $i<$m; $i++) {
    $lamps[$i] = $i;
}

foreach($input as $row) {
   $rLamps = explode(' ', $row);
   unset($rLamps[0]);
   foreach($rLamps as $lamp) {
       unset($lamps[$lamp]);
   }
   if (empty($lamps)) {
       echo 'YES';
       die();
   }
}
echo 'NO';
?>

<?php
$input = file_get_contents("php://stdin");
$input = explode("\n", $input);
$firstString = $input[0];
$firstString = explode(" ", $firstString );
$n = $firstString[0];
$m = $firstString[1];

unset($input[0]);
$lamps = array();
for($i=1; $i<$m; $i++) {
    $lamps[$i] = $i;
}

foreach($input as $row) {
   $rLamps = explode(' ', $row);
   unset($rLamps[0]);
   foreach($rLamps as $lamp) {
       unset($lamps[$lamp]);
   }
   if (empty($lamps)) {
       echo 'YES';
       die();
   }
}
echo 'NO';
?>

<?php
$input = file_get_contents('php://stdin');
$input = explode("\n", $input);
$firstString = $input[0];
$firstString = explode(" ", $firstString );
$n = $firstString[0];
$m = $firstString[1];

unset($input[0]);
$lamps = array();
for($i=1; $i<=$m; $i++) {
    $lamps[$i] = $i;
}

foreach($input as $row) {
   $rLamps = explode(' ', $row);
   unset($rLamps[0]);
   foreach($rLamps as $lamp) {
       unset($lamps[$lamp]);
   }
   if (empty($lamps)) {
       echo 'YES';
       die();
   }
}
echo 'NO';
?>


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

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

  $h = pow(2, floor(log($n, 2)));

  if ($n == $h) {
    echo "NO".PHP_EOL;

    continue;
  }

  if ($n[ strlen($n) - 1 ] % 2 != 0) {
    echo "YES".PHP_EOL;

    continue;
  }

  echo "YES".PHP_EOL;
}
?>

<?php
function solve() {
    $n = Read::string();
    while (Bigint::mod($n, '2') == 0) {
        $n = Bigint::div($n, '2');
    }
    return $n == 1 ? "NO" : "YES";
}

#$t = 1;
$t = Read::int();
while ($t--) {
    echo solve();
    echo "\n";
}

class Read
{
    public static function string()
    {
        return trim(fgets(STDIN));
    }

    public static function int()
    {
        return intval(fgets(STDIN));
    }

    public static function array_int($sep = ' ')
    {
        $s = trim(fgets(STDIN));
        return preg_split("/[\s,]+/", $s);
    }

}

class Bigint
{
    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 / $bigint2
     */
    public static function div($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);
            case 'floor':
                return bcdiv($bigint1, $bigint2);
            case 'round':
                $sResult = bcdiv($bigint1, $bigint2);
                return bcsub(bcdiv($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcdiv($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 + $bigint2
     */
    public static function add($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcadd($bigint1, $bigint2);
            case 'round':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcadd($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 - $bigint2
     */
    public static function sub($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcsub($bigint1, $bigint2);
            case 'round':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsub($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 * $bigint2
     */
    public static function mul($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcmul($bigint1, $bigint2);
            case 'round':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcmul ($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @return string $bigint1 % $bigint2
     */
    public static function mod($bigint1, $bigint2) {
        return bcmod($bigint1, $bigint2);
    }

    /**
     * @param string $bigint
     * @param string $scale (ceil or floor or round)
     * @return string sqrt($bigint)
     */
    public static function sqrt($bigint, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcadd(bcsqrt ($bigint), 1);
            case 'floor':
                return bcsqrt($bigint);
            case 'round':
                $sResult = bcsqrt($bigint);
                return bcsub(bcsqrt($bigint, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsqrt($bigint);
        }
    }

    /**
     * @param string $bigint
     * @param string $exponent
     * @param string $scale (ceil or floor or round)
     * @return string pow($bigint, $exponent)
     */
    public static function pow($bigint, $exponent, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcpow($bigint, $exponent);
            case 'round':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcpow ($bigint, $exponent);
        }
    }
}

class Algorithms
{

    /** Факторизация - Разложение числа на простые множители
     * @param int $n
     * @return array
     */
    public static function factorization($n)
    {
        $a = [];
        for ($i = 2; $i * $i <= $n; ++$i) {
            $cnt = 0;
            while (bcmod($n, $i) == 0) {
                ++$cnt;
                $n = bcdiv($n, $i);
            }
            if ($cnt > 0) {
                $a[$i] = $cnt;
            }
        }
        if ($n > 1) {
            $a[$n] = 1;
        }

        return $a;
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наибольший общий делитель (НОД)
     */
    public static function gcd($a, $b)
    {
        if ($b == 0) {
            return $a;
        } else {
            $a = $a % $b;
            return self::gcd($b, $a);
        }
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наименьшее общее кратное (НОК)
     */
    public static function lcm($a, $b)
    {
        return abs($a * $b) / self::gcd($a, $b);
    }

    /**Последовательность Фибоначчи =  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
     * return Фибоначчи{n}
     * @param int $n
     * @return int
     */
    public static function fibonacci($n)
    {
        $a = [0, 1];

        for ($i = 2; $i <= $n; $i++) {
            $a[$i] = $a[$i-1] + $a[$i-2];
        }

        return $a[$n];
    }

}

?>

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

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

  $f = log($n, 2);
  $k = (string) $n;
  $h = pow(2, floor($f));

  if ($f == 1) { echo 'NO'.PHP_EOL; }
  else {
    if ($k[strlen($k) - 1] % 2 != 0) { echo 'YES'.PHP_EOL; }
    else {
      if ($h == $n) { echo 'NO'.PHP_EOL; }
      else { echo 'YES'.PHP_EOL; }
    }
  }
}
?>

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

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

  $f = log($n, 2);
  $f1 = ceil($f);

  if ($f == 1) { echo 'NO'.PHP_EOL; }
  else {
    if ($f1 == $f) { echo 'NO'.PHP_EOL; }
    else { echo 'YES'.PHP_EOL; }
  }
}
?>

<?php
function solve() {
    $n = Read::string();
    $power = log($n, '2');
    return $power == floor($power) ? "NO" : "YES";
}

#$t = 1;
$t = Read::int();
while ($t--) {
    echo solve();
    echo "\n";
}

class Read
{
    public static function string()
    {
        return trim(fgets(STDIN));
    }

    public static function int()
    {
        return intval(fgets(STDIN));
    }

    public static function array_int($sep = ' ')
    {
        $s = trim(fgets(STDIN));
        return preg_split("/[\s,]+/", $s);
    }

}

class Bigint
{
    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 / $bigint2
     */
    public static function div($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);
            case 'floor':
                return bcdiv($bigint1, $bigint2);
            case 'round':
                $sResult = bcdiv($bigint1, $bigint2);
                return bcsub(bcdiv($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcdiv($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 + $bigint2
     */
    public static function add($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcadd($bigint1, $bigint2);
            case 'round':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcadd($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 - $bigint2
     */
    public static function sub($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcsub($bigint1, $bigint2);
            case 'round':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsub($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 * $bigint2
     */
    public static function mul($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcmul($bigint1, $bigint2);
            case 'round':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcmul ($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @return string $bigint1 % $bigint2
     */
    public static function mod($bigint1, $bigint2) {
        return bcmod($bigint1, $bigint2);
    }

    /**
     * @param string $bigint
     * @param string $scale (ceil or floor or round)
     * @return string sqrt($bigint)
     */
    public static function sqrt($bigint, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcadd(bcsqrt ($bigint), 1);
            case 'floor':
                return bcsqrt($bigint);
            case 'round':
                $sResult = bcsqrt($bigint);
                return bcsub(bcsqrt($bigint, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsqrt($bigint);
        }
    }

    /**
     * @param string $bigint
     * @param string $exponent
     * @param string $scale (ceil or floor or round)
     * @return string pow($bigint, $exponent)
     */
    public static function pow($bigint, $exponent, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcpow($bigint, $exponent);
            case 'round':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcpow ($bigint, $exponent);
        }
    }
}

class Algorithms
{

    /** Факторизация - Разложение числа на простые множители
     * @param int $n
     * @return array
     */
    public static function factorization($n)
    {
        $a = [];
        for ($i = 2; $i * $i <= $n; ++$i) {
            $cnt = 0;
            while (bcmod($n, $i) == 0) {
                ++$cnt;
                $n = bcdiv($n, $i);
            }
            if ($cnt > 0) {
                $a[$i] = $cnt;
            }
        }
        if ($n > 1) {
            $a[$n] = 1;
        }

        return $a;
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наибольший общий делитель (НОД)
     */
    public static function gcd($a, $b)
    {
        if ($b == 0) {
            return $a;
        } else {
            $a = $a % $b;
            return self::gcd($b, $a);
        }
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наименьшее общее кратное (НОК)
     */
    public static function lcm($a, $b)
    {
        return abs($a * $b) / self::gcd($a, $b);
    }

    /**Последовательность Фибоначчи =  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
     * return Фибоначчи{n}
     * @param int $n
     * @return int
     */
    public static function fibonacci($n)
    {
        $a = [0, 1];

        for ($i = 2; $i <= $n; $i++) {
            $a[$i] = $a[$i-1] + $a[$i-2];
        }

        return $a[$n];
    }

}

?>

<?php
function solve() {
    $n = Read::int();
    while (Bigint::mod($n, 2) == 0) {
        $n = Bigint::div($n, 2);
    }

    return $n == 1 ? "NO" : "YES";
}

#$t = 1;
$t = Read::int();
while ($t--) {
    echo solve();
    echo "\n";
}

class Read
{
    public static function string()
    {
        return trim(fgets(STDIN));
    }

    public static function int()
    {
        return intval(fgets(STDIN));
    }

    public static function array_int($sep = ' ')
    {
        $s = trim(fgets(STDIN));
        return preg_split("/[\s,]+/", $s);
    }

}

class Bigint
{
    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 / $bigint2
     */
    public static function div($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);
            case 'floor':
                return bcdiv($bigint1, $bigint2);
            case 'round':
                $sResult = bcdiv($bigint1, $bigint2);
                return bcsub(bcdiv($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcdiv($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 + $bigint2
     */
    public static function add($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcadd($bigint1, $bigint2);
            case 'round':
                $sResult = bcadd($bigint1, $bigint2);
                return bcsub(bcadd($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcadd($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 - $bigint2
     */
    public static function sub($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcsub($bigint1, $bigint2);
            case 'round':
                $sResult = bcsub($bigint1, $bigint2);
                return bcsub(bcsub($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsub($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @param string $scale (ceil or floor or round)
     * @return string $bigint1 * $bigint2
     */
    public static function mul($bigint1, $bigint2, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcmul($bigint1, $bigint2);
            case 'round':
                $sResult = bcmul($bigint1, $bigint2);
                return bcsub(bcmul($bigint1, $bigint2, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcmul ($bigint1, $bigint2);
        }
    }

    /**
     * @param string $bigint1
     * @param string $bigint2
     * @return string $bigint1 % $bigint2
     */
    public static function mod($bigint1, $bigint2) {
        return bcmod($bigint1, $bigint2);
    }

    /**
     * @param string $bigint
     * @param string $scale (ceil or floor or round)
     * @return string sqrt($bigint)
     */
    public static function sqrt($bigint, $scale = '') {
        switch ($scale) {
            case 'ceil':
                return bcadd(bcsqrt ($bigint), 1);
            case 'floor':
                return bcsqrt($bigint);
            case 'round':
                $sResult = bcsqrt($bigint);
                return bcsub(bcsqrt($bigint, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcsqrt($bigint);
        }
    }

    /**
     * @param string $bigint
     * @param string $exponent
     * @param string $scale (ceil or floor or round)
     * @return string pow($bigint, $exponent)
     */
    public static function pow($bigint, $exponent, $scale = '') {
        switch ($scale) {
            case 'ceil':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);
            case 'floor':
                return bcpow($bigint, $exponent);
            case 'round':
                $sResult = bcpow($bigint, $exponent);
                return bcsub(bcpow($bigint, $exponent, 2),  $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;
            default:
                return bcpow ($bigint, $exponent);
        }
    }
}

class Algorithms
{

    /** Факторизация - Разложение числа на простые множители
     * @param int $n
     * @return array
     */
    public static function factorization($n)
    {
        $a = [];
        for ($i = 2; $i * $i <= $n; ++$i) {
            $cnt = 0;
            while (bcmod($n, $i) == 0) {
                ++$cnt;
                $n = bcdiv($n, $i);
            }
            if ($cnt > 0) {
                $a[$i] = $cnt;
            }
        }
        if ($n > 1) {
            $a[$n] = 1;
        }

        return $a;
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наибольший общий делитель (НОД)
     */
    public static function gcd($a, $b)
    {
        if ($b == 0) {
            return $a;
        } else {
            $a = $a % $b;
            return self::gcd($b, $a);
        }
    }

    /**
     * @param int $a
     * @param int $b
     * @return int Наименьшее общее кратное (НОК)
     */
    public static function lcm($a, $b)
    {
        return abs($a * $b) / self::gcd($a, $b);
    }

    /**Последовательность Фибоначчи =  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
     * return Фибоначчи{n}
     * @param int $n
     * @return int
     */
    public static function fibonacci($n)
    {
        $a = [0, 1];

        for ($i = 2; $i <= $n; $i++) {
            $a[$i] = $a[$i-1] + $a[$i-2];
        }

        return $a[$n];
    }

}

?>


<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }
        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);//存储无向边
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;//统计节点的度
    $friends_num[$id_y]++;
    $count_num[$id_x]++;//和上面一样，这个作用是方便知道当前点连的边的，不用再每次去count
    $count_num[$id_y]++;
}
//$suitable_id = array();
$flag        = array();//标记点是否在符合要求
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}//将不符合要求的点加入队列，并标记
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}//有不符合要求的点去更新其它点
$answer         = array();//结果数组
$n_cnt          = count($flag);//统计不符合要求的点
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]||isset($flag[$person_y])) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }//将度小的交换到前面
    //echo $person_x . "    ".$person_y ."\n";
    //当前边去掉，两个点减度（假设当前两点都符合要求）
    if (isset($flag[$person_x])) {//度数小的点在连这边之后也不会符合要求，那么这条边不会影响第二个点，所以加上度数，而第一个点已经不合要求，所以度数减去无影响
    } else {//第一个点在去除当前边前符合要求，减去后不符合
        if ($friends_num[$person_x] <= $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
          //在后面的队列中会减，所以这里加上，否则会多减
        } else {//两点在去除当前边后都符合要求，将当前边从存储的边中移除，因为是从后往前，所以是顺序的减边这块复杂度O(m)
            $friends_num[$person_x]--;
            $friends_num[$person_y]--;
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}

<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }

        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;
    $friends_num[$id_y]++;
    $count_num[$id_x]++;
    $count_num[$id_y]++;
}
$suitable_id = array();
$flag        = array();
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}
$answer         = array();
$n_cnt          = count($flag);
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;
    if (isset($flag[$person_x])) {
        $friends_num[$person_y]++;
    } else {
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_y]++;
        } else {
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    //echo $i . "    ".$friends_num[4] . "\n";
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}

<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }
        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);//存储无向边
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;//统计节点的度
    $friends_num[$id_y]++;
    $count_num[$id_x]++;//和上面一样，这个作用是方便知道当前点连的边的，不用再每次去count
    $count_num[$id_y]++;
}
//$suitable_id = array();
$flag        = array();//标记点是否在符合要求
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}//将不符合要求的点加入队列，并标记
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}//有不符合要求的点去更新其它点
$answer         = array();//结果数组
$n_cnt          = count($flag);//统计不符合要求的点
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]||isset($flag[$person_y])) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }//将度小的交换到前面
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;//当前边去掉，两个点减度（假设当前两点都符合要求）
    if (isset($flag[$person_x])) {//度数小的点在连这边之后也不会符合要求，那么这条边不会影响第二个点，所以加上度数，而第一个点已经不合要求，所以度数减去无影响
        $friends_num[$person_y]++;
        $friends_num[$person_x]++;
    } else {//第一个点在去除当前边前符合要求，减去后不符合
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_x]++;
            $friends_num[$person_y]++;//在后面的队列中会减，所以这里加上，否则会多减
        } else {//两点在去除当前边后都符合要求，将当前边从存储的边中移除，因为是从后往前，所以是顺序的减边这块复杂度O(m)
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}

<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num = 0;
        $this->head = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }

        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num = array();
$person_node = array();
$edge_x = array();
$edge_y = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i] = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;
    $friends_num[$id_y]++;
    $count_num[$id_x]++;
    $count_num[$id_y]++;
}
$suitable_id = array();
$flag = array();
$que = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        if (!isset($flag[$s_id])) {
            $friends_num[$s_id]--;
        }
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}
$answer = array();
$n_cnt = count($flag);
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;
    if (isset($flag[$person_x])) {
        $friends_num[$person_y]++;
        $friends_num[$person_x]++;
    } else {
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_y]++;
        } else {
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x] - 1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
                //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y] - 1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                } else {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                    break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            if (!isset($flag[$s_id])) {
                $friends_num[$s_id]--;
            }
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    //echo $i . "    ".$friends_num[4] . "\n";
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}

<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }
        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);//存储无向边
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;//统计节点的度
    $friends_num[$id_y]++;
    $count_num[$id_x]++;//和上面一样，这个作用是方便知道当前点连的边的，不用再每次去count
    $count_num[$id_y]++;
}
//$suitable_id = array();
$flag        = array();//标记点是否在符合要求
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}//将不符合要求的点加入队列，并标记
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}//有不符合要求的点去更新其它点
$answer         = array();//结果数组
$n_cnt          = count($flag);//统计不符合要求的点
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }//将度小的交换到前面
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;//当前边去掉，两个点减度（假设当前两点都符合要求）
    if (isset($flag[$person_x])) {//度数小的点不在连这边之后也不会符合要求，那么这条边不会影响第二个点，所以加上度数，而第一个点已经不合要求，所以度数减去无影响
        $friends_num[$person_y]++;
    } else {//第一个点在去除当前边前符合要求，减去后不符合
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_y]++;//在后面的队列中会减，所以这里加上，否则会多减
        } else {//两点在去除当前边后都符合要求，将当前边从存储的边中移除，因为是从后往前，所以是顺序的减边这块复杂度O(m)
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}

class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }

        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;
    $friends_num[$id_y]++;
    $count_num[$id_x]++;
    $count_num[$id_y]++;
}
$suitable_id = array();
$flag        = array();
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    $num = count($person_node[$id]);
    for ($i = 0; $i < $num; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !issest($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}
$answer         = array();
$n_cnt          = count($flag);
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;
    if (isset($flag[$person_x])) {
        $friends_num[$person_y]++;
    } else {
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_y]++;
        } else {
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        $num = count($person_node[$id]);
        for ($j = 0; $j < $num; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    //echo $i . "    ".$friends_num[4] . "\n";
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}
/*4 4 2
2 3
1 2
1 3
1 4*/

<?php
class QueStruct
{
    public $data;
    public $next;
    public function __construct($data)
    {
        $this->data = $data;
        $this->next = null;
    }
}
class Queue
{
    protected $head;
    protected $trail;
    protected $num;
    public function __construct()
    {
        $this->num   = 0;
        $this->head  = null;
        $this->trail = null;
    }
    public function push($data)
    {
        $this->num++;
        if ($this->head == null) {
            $this->head = $this->trail = new QueStruct($data);
        } else {
            $this->trail->next = new QueStruct($data);
            $this->trail       = $this->trail->next;
        }
    }
    public function front()
    {
        return $this->head->data;
    }
    public function pop()
    {
        $this->num--;
        $p          = &$this->head;
        $this->head = $this->head->next;
        if ($this->num == 0) {
            $this->trail = $this->head = null;
        }

        unset($p);
    }
    public function size()
    {
        return $this->num;
    }
    public function isEmpty()
    {
        if ($this->num == 0) {
            return true;
        }
        return false;
    }
}
fscanf(STDIN, "%d %d %d", $n, $m, $k);
$friends_num = array();
$count_num   = array();
$person_node = array();
$edge_x      = array();
$edge_y      = array();
for ($i = 0; $i <= $n; $i++) {
    $friends_num[$i] = 0;
    $count_num[$i]   = 0;
}
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $id_x, $id_y);
    $edge_x[$i] = $id_x;
    $edge_y[$i] = $id_y;
    if (!isset($person_node[$id_x])) {
        $person_node[$id_x] = array();
    }
    if (!isset($person_node[$id_y])) {
        $person_node[$id_y] = array();
    }
    array_push($person_node[$id_x], $id_y);//存储无向边
    array_push($person_node[$id_y], $id_x);
    $friends_num[$id_x]++;//统计节点的度
    $friends_num[$id_y]++;
    $count_num[$id_x]++;//和上面一样，这个作用是方便知道当前点连的边的，不用再每次去count
    $count_num[$id_y]++;
}
//$suitable_id = array();
$flag        = array();//标记点是否在符合要求
$que         = new queue();
for ($i = 1; $i <= $n; $i++) {
    if ($friends_num[$i] < $k) {
        $que->push($i);
        $flag[$i] = true;
    }
}//将不符合要求的点加入队列，并标记
while (!$que->isEmpty()) {
    $id = $que->front();
    $que->pop();
    for ($i = 0; $i < $count_num[$id]; $i++) {
        $s_id = $person_node[$id][$i];
        $friends_num[$s_id]--;
        if ($friends_num[$s_id] < $k && !isset($flag[$s_id])) {
            $flag[$s_id] = true;
            $que->push($s_id);
        }
    }
}//有不符合要求的点去更新其它点
$answer         = array();//结果数组
$n_cnt          = count($flag);//统计不符合要求的点
$answer[$m - 1] = $n - $n_cnt;
for ($i = $m - 1; $i >= 1; $i--) {
    $person_x = $edge_x[$i];
    $person_y = $edge_y[$i];
    //echo $person_x . "    ".$person_y."\n";
    if ($friends_num[$person_y] < $friends_num[$person_x]) {
        $person_x ^= $person_y;
        $person_y ^= $person_x;
        $person_x ^= $person_y;
    }//将度小的交换到前面
    //echo $person_x . "    ".$person_y ."\n";
    $friends_num[$person_x]--;
    $friends_num[$person_y]--;//当前边去掉，两个点减度（假设当前两点都符合要求）
    if (isset($flag[$person_x])) {//度数小的点在连这边之后也不会符合要求，那么这条边不会影响第二个点，所以加上度数，而第一个点已经不合要求，所以度数减去无影响
        $friends_num[$person_y]++;
        $friends_num[$person_x]++;
    } else {//第一个点在去除当前边前符合要求，减去后不符合
        if ($friends_num[$person_x] < $k) {
            $flag[$person_x] = true;
            $que->push($person_x);
            $n_cnt++;
            $friends_num[$person_x]++;
            $friends_num[$person_y]++;//在后面的队列中会减，所以这里加上，否则会多减
        } else {//两点在去除当前边后都符合要求，将当前边从存储的边中移除，因为是从后往前，所以是顺序的减边这块复杂度O(m)
            while ($count_num[$person_x]) {
                if ($person_node[$person_x][$count_num[$person_x]-1] != $person_y) {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                } else {
                    array_pop($person_node[$person_x]);
                    $count_num[$person_x]--;
                    break;
                }
            }
            while ($count_num[$person_y]) {
              //var_dump($count_num[$person_y]);
                if ($person_node[$person_y][$count_num[$person_y]-1] != $person_x) {
                    array_pop($person_node[$person_y]);
                    $count_num[$person_y]--;
                }else {
                  array_pop($person_node[$person_y]);
                  $count_num[$person_y]--;
                  break;
                }
            }
        }
    }
    while (!$que->isEmpty()) {
        $id = $que->front();
        // var_dump($id);
        $que->pop();
        for ($j = 0; $j < $count_num[$id]; $j++) {
            $s_id = $person_node[$id][$j];
            $friends_num[$s_id]--;
            if (!isset($flag[$s_id]) && $friends_num[$s_id] < $k) {
                $que->push($s_id);
                $flag[$s_id] = true;
                $n_cnt++;
            }
        }
    }
    $answer[$i - 1] = $n - $n_cnt;
}
for ($i = 0; $i < $m; $i++) {
    echo $answer[$i] . "\n";
}


<?php

$cnt = -1;
while($f = fgets(STDIN)){
    if ($cnt == -1) {
        $cnt = intval($f);
    } else if ($cnt > 0) {
        $arr = explode(" ", trim($f));
        $s = $arr[0];
        $a = $arr[1];
        $b = $arr[2];
        $c = $arr[3];

        $ret = cal($s, $a, $b, $c);
        echo $ret . "\n";

        $cnt--;
        if ($cnt == 0) {
            break;
        }
    } else {
        break;
    }
}

function cal($s, $a, $b, $c) {
    $d = bcmul($a, $c);
    $num = 0;

    $m = bcdiv($s, $d);
    $num = bcadd($num, $m);
    $num = bcadd($num, bcmul($m, $b));
    $left = $s - bcmul($m, $c);
    $num = bcadd($num, bcdiv($left,  $c));

    return $num;
}

//1000000000 1
//1000000000 1

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d, $e) = explode(" ", trim(fgets(STDIN)));
     $f = floor($b / $e);
     if($f < $c)
     {
          print $f . "\n";
     }
     else
     {
          $g = floor($f / $c);
          $h = $f % $c;
          $i = bcadd($h, bcadd(bcmul($g, $c), bcmul($g, $d)));
          print $i . "\n";
     }
}
?>

<?php

$cnt = -1;
while($f = fgets(STDIN)){
    if ($cnt == -1) {
        $cnt = intval($f);
    } else if ($cnt > 0) {
        $arr = explode(" ", trim($f));
        $s = $arr[0];
        $a = $arr[1];
        $b = $arr[2];
        $c = $arr[3];

        $ret = cal($s, $a, $b, $c);
        echo $ret . "\n";

        $cnt--;
        if ($cnt == 0) {
            break;
        }
    } else {
        break;
    }
}

function cal($s, $a, $b, $c) {
    $d = bcmul($a, $c);
    $num = 0;

    $m = bcdiv($s, $d);
    $num = bcadd($num, $m);
    echo $num . "\n";
    $num = bcadd($num, bcmul($m, $b));
    echo $num . "\n";
    $left = $s - bcmul($m, $c);
    $num = bcadd($num, bcdiv($left,  $c));
    echo $num . "\n";

    return (string)$num;
}

//1000000000 1
//1000000000 1


<?php
list($n, $a, $b) = fscanf(STDIN, '%d %d %d');
$as = rtrim(fgets(STDIN));

if ($as[$a-1] == $as[$b-1]) {
    echo 0;
} else {
    echo 1;
}

<?php

function findMinCost($nab,$company)
{
    $nab = explode(" ",$nab);
    $n   = $nab[0];
    $a   = $nab[1];
    $b   = $nab[2];

    $company = str_split($company);

    $minCost = 0;

    if($company[$a-1]==$company[$b-1]){
        $minCost = 0;
    }else{
        if($a>$b){
            for($i=$a-1;$i>$b-1;$i--){

                if($company[$i]==$company[$i-1]){
                    $minCost += 0;
                }else{
                    $minCost +=abs($company[$i]-$company[$i-1]);
                }

                if($company[$i-1]==$company[$b-1]){
                    $minCost +=0;
                    break;
                } //echo $i."::".$minCost.'\n';
            }
        }else{
            for($i=$a-1;$i<$b-1;$i++){
                if($company[$i]==$company[$i+1]){
                    $minCost += 0;
                }else{
                    $minCost +=abs($company[$i]-$company[$i+1]);
                }

                if($company[$i+1]==$company[$b-1]){
                    $minCost +=0;
                    break;
                }
            }
        }
    }

    return $minCost;
}

$nab = trim(fgets(STDIN));
$company = trim(fgets(STDIN));

print_r(findMinCost($nab,$company));

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

<?php

fscanf(STDIN, '%d %d %d', $n, $a, $b);
$way = trim(fgets(STDIN));

if($way[$b-1] == $way[$a-1])  {print "0\n";}
else  {print "1";}

?>

<?php

fscanf(STDIN, '%d %d %d', $n, $a, $b);
$way = explode(trim(fgets(STDIN)));

if($way[$b-1] == $way[$a-1])  {print "0\n";}
else  {print "1";}

?>

<?php

function findMinCost($nab,$company)
{
    $nab = explode(" ",$nab);
    $n   = $nab[0];
    $a   = $nab[1];
    $b   = $nab[2];

    $company = str_split($company);

    $minCost = 0;

    if($company[$a-1]==$company[$b-1]){
        $minCost = 0;
    }else{
        for($i=0;$i<$n-1;$i++){
            if($company[$i]==$company[$i+1]){
                $minCost += 0;
            }else{
                $minCost +=abs($company[$i]-$company[$i+1]);
            }

            if($company[$i+1]==$company[$b-1]){
                $minCost +=0;
                break;
            }
        }
    }

    return $minCost;
}

$nab = trim(fgets(STDIN));
$company = trim(fgets(STDIN));

print_r(findMinCost($nab,$company));

<?php

function findMinCost($nab,$company)
{
    $nab = explode(" ",$nab);
    $n   = $nab[0];
    $a   = $nab[1];
    $b   = $nab[2];

    $company = str_split($company);

    $minCost = 0;

    if($company[$a-1]==$company[$b-1]){
        $minCost = 0;
    }else{
        if($a>$b){
            for($i=$a-1;$i>$b-1;$i--){
                if($company[$i]==$company[$i+1]){
                    $minCost += 0;
                }else{
                    $minCost +=abs($company[$i]-$company[$i+1]);
                }

                if($company[$i+1]==$company[$b-1]){
                    $minCost +=0;
                    break;
                }
            }
        }else{
            for($i=$a-1;$i<$b-1;$i++){
                if($company[$i]==$company[$i+1]){
                    $minCost += 0;
                }else{
                    $minCost +=abs($company[$i]-$company[$i+1]);
                }

                if($company[$i+1]==$company[$b-1]){
                    $minCost +=0;
                    break;
                }
            }
        }
    }

    return $minCost;
}

$nab = trim(fgets(STDIN));
$company = trim(fgets(STDIN));

print_r(findMinCost($nab,$company));

<?php

function findMinCost($nab,$company)
{
    $nab = explode(" ",$nab);
    $n   = $nab[0];
    $a   = $nab[1];
    $b   = $nab[2];

    $company = str_split($company);

    $minCost = 0;

    if($company[$a-1]==$company[$b-1]){
        $minCost = 0;
    }else{
        for($i=0;$i<$n-1;$i++){
            if($company[$i]==$company[$i+1]){
                $minCost += 0;
            }else{
                $minCost +=abs($company[$i]-$company[$i+1]);
            }

            if($company[$i+1]==$company[$b-1]){
                $minCost +=0;
                break;
            }
        }
    }

    return $minCost;
}

$nab = trim(fgets(STDIN));
$company = trim(fgets(STDIN));

findMinCost($nab,$company);


<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c, $d) = explode(" ", trim(fgets(STDIN)));
     $e = 1;
     $f = 1;
     while(TRUE)
     {
          if($b % 2 == 0)
          {
               $e *= 2;
               $b /= 2;
          }
          else
          {
               break;
          }
     }
     while(TRUE)
     {
          if($c % 2 == 0)
          {
               $f *= 2;
               $c /= 2;
          }
          else
          {
               break;
          }
     }
     if($e * $f >= $d)
     {
          print "YES\n";
     }
     else
     {
          print "NO\n";
     }
}
?>

<?php
function isEven($a)
{
	return ($a % 2 == 0) ? 1 : 0;
}

$arr = array();
$t = readline();
for($i=0;$i<$t;$i++)
{
	$str = readline();
	$param = explode(" ", $str);	// 0 - w; 1 - h; 2 - n;
	$w = $param[0];
	$h = $param[1];
	$ans = 1;
	while(true)
	{
		if($ans >= $param[2])
			break;
		if(isEven($w))
		{
			$w = $w / 2;
			$ans = $ans * 2;
		}
		elseif(isEven($h))
		{
			$h = $h / 2;
			$ans = $ans * 2;
		}
		else
			break;
	}
	if($ans >= $param[2])
		array_push($arr, "YES\r\n");
	else
		array_push($arr, "NO\r\n");
}
foreach($arr as $key => $value)
	print($value);

$end = readline();
?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $count_str = readline();
	//$count_str =  count($conten);

	for($j = 0; $j < $count_str; $j++)
	{
		$str = readline();
		$n = explode(' ', $str);

		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result.'</br>';
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $count_str = readline();
	//$count_str =  count($conten);

	for($j = 0; $j < $count_str; $j++)
	{
		$str = readline();
		$n = explode(' ', $str);

		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result;
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $count_str = readline();
	//$count_str =  count($conten);

	for($j = 0; $j < $count_str; $j++)
	{
		$str = readline();
		print_r($str);
		die();
		$n = explode(' ', $conten[$j]);

		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result;
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $conten = readline();
	//$count_str =  count($conten);
	print_r($conten);
		die();
	for($j = 1; $j < $count_str; $j++)
	{
		$n = explode(' ', $conten[$j]);

		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result;
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $conten = fgets(STDIN);
	$count_str =  count($conten);
	print_r($conten);
		die();
	for($j = 1; $j < $count_str; $j++)
	{
		$n = explode(' ', $conten[$j]);

		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result;
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $conten = fgets(STDIN);
	$count_str =  count($conten);

	for($j = 1; $j < $count_str; $j++)
	{
		$n = explode(' ', $conten[$j]);
		print_r($conten);
		die();
		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result.'</br>';
	}

?>

<?php
	//$str = '1 4 4';
	//$n = explode(' ', $str);

    $conten = fgets(STDIN);
	$count_str =  count($conten);

	for($j = 1; $j < $count_str; $j++)
	{
		$n = explode(' ', $conten[$j]);
		print_r($n);
		die();
		$arr = [];
		$flag = true;

		$arr[0] = 	[	'w'	=>	$n[0],
						'h'	=>	$n[1]
					];

		if(count($arr) != $n[2])
		{
			if($arr[0]['w'] % 2 == 0 || $arr[0]['h'] % 2 == 0)
			{
				while($flag)
				{
					$stop = 0;

					for($i = 0; $i < $count = count($arr); $i++)
					{
						if($arr[$i]['w'] % 2 == 0)
						{
							$arr[$i]['w'] = $arr[$i]['w']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2])
							break;

						if($arr[$i]['h'] % 2 == 0)
						{
							$arr[$i]['h'] = $arr[$i]['h']/2;
							$arr[count($arr)] = $arr[$i];
						}
						else
							$stop += 0.5;

						if(count($arr) == $n[2] || count($arr) == $stop)
							break;

					}
					if(count($arr) == $n[2] || count($arr) == $stop)
						break;
				}

				if(count($arr) == $n[2])
					$result = 'YES';
				else
					$result = 'NO';
			}
			else
				$result = 'NO';
		}
		else
			$result = 'YES';

		echo $result.'</br>';
	}

?>


<?php
// 432A     Выбор команд
$in = fopen("php://stdin", 'r');

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

$input_line = fgets($in);
list($n, $k) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$input_line = fgets($in);
$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$max = 5 - (int) $k;
$col = 0;

foreach ($arr as $key => $value) {
    if ((int) $value <= $max) {
        $col ++;
    }
}

echo intval($col / 3);

?>

<?php
$n=readline();
$kol_vo = readline();
//$n = '6 4';
$uchastniki = $n[0];
$sostav = $n[-1];
//$kol_vo = '0 0 0 0 0 0';
$kol_vo = explode(' ', $kol_vo);
$yes = 0;
foreach ($kol_vo as $v) {
 if ($v <= 5-$sostav) {
     $yes++;
}
}
if ($yes > 3);
echo floor($yes/3);

<?php

function ChooseTeam($n,$k,$y){

    $y     = explode(" ", $y);
    $team  = 0;
    $count = 0;

    for($i=0;$i<$n;$i++){
        if(($y[$i]+$k)<=5){
            $count++;
            if($count==3){
                $team++;
                $count=0;
            }
        }
    }

    echo $team;
}

$nk = trim(fgets(STDIN));
$nk = explode(" ", $nk);
$n  = $nk[0];
$k  = $nk[1];
$y = trim(fgets(STDIN));

ChooseTeam($n,$k,$y);

<?php
error_reporting("off");
//432A: Choosing Teams
list($n, $k) = explode(" ", trim(fgets(STDIN)));
$y = explode(" ", trim(fgets(STDIN)));
$valids = array();
foreach ($y as $value) {
  if ($value <= 5 - $k) {
    $valids[] = $value;
  }
}
$count = count($valids);
echo floor($count / 3);
?>