{"nl": {"description": "The main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: \u00ab[date:time]: message\u00bb, where for each \u00ab[date:time]\u00bb value existed not more than 10 lines. All the files were encoded in a very complicated manner, and only one programmer \u2014 Alex \u2014 managed to decode them. The code was so complicated that Alex needed four weeks to decode it. Right after the decoding process was finished, all the files were deleted. But after the files deletion, Alex noticed that he saved the recordings in format \u00ab[time]: message\u00bb. So, information about the dates was lost. However, as the lines were added into the log in chronological order, it's not difficult to say if the recordings could appear during one day or not. It is possible also to find the minimum amount of days during which the log was written.So, to make up for his mistake Alex has to find the minimum amount of days covered by the log. Note that Alex doesn't have to find the minimum amount of days between the beginning and the end of the logging, he has to find the minimum amount of dates in which records could be done. (See Sample test 2 for further clarifications).We should remind you that the process made not more than 10 recordings in a minute. Consider that a midnight belongs to coming day.", "input_spec": "The first input line contains number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). The following n lines contain recordings in format \u00ab[time]: message\u00bb, where time is given in format \u00abhh:mm x.m.\u00bb. For hh two-digit numbers from 01 to 12 are used, for mm two-digit numbers from 00 to 59 are used, and x is either character \u00aba\u00bb or character \u00abp\u00bb. A message is a non-empty sequence of Latin letters and/or spaces, it doesn't start or end with a space. The length of each message doesn't exceed 20.", "output_spec": "Output one number \u2014 the minimum amount of days covered by the log.", "sample_inputs": ["5\n[05:00 a.m.]: Server is started\n[05:00 a.m.]: Rescan initialized\n[01:13 p.m.]: Request processed\n[01:10 p.m.]: Request processed\n[11:40 p.m.]: Rescan completed", "3\n[09:00 a.m.]: User logged in\n[08:00 a.m.]: User logged in\n[07:00 a.m.]: User logged in"], "sample_outputs": ["2", "3"], "notes": "NoteFormally the 12-hour time format is described at: http://en.wikipedia.org/wiki/12-hour_clock. The problem authors recommend you to look through these descriptions before you start with the problem."}, "positive_code": [{"source_code": "\n $time) {\n\t\t$num = 1;\n\t\t++$day;\n\t}\n\telse if ($last_time == $time)\n\t\t++$num;\n\telse\n\t\t$num = 1;\n\n\tif ($num == 11) {\n\t\t++$day;\n\t\t$num = 1;\n\t}\n\n\t$last_time = $time;\n}\n\necho $day.\"\\n\";\n\nfclose($handle);\n\n?>\n"}], "negative_code": [{"source_code": "\n $time) {\n\t\t$num = 1;\n\t\t++$day;\n\t}\n\telse if ($last_time == $time)\n\t\t++$num;\n\telse\n\t\t$num = 1;\n\t\t\n\tif ($num == 10) {\n\t\t++$day;\n\t\t$num = 1;\n\t}\n\t\n\t$last_time = $time;\n}\n\necho $day.\"\\n\";\n\nfclose($handle);\n\n?>\n"}, {"source_code": " $time) {\n\t\t$num = 1;\n\t\t++$day;\n\t}\n\telse if ($last_time == $time)\n\t\t++$num;\n\telse\n\t\t$num = 1;\n\t\n\t$last_time = $time;\n}\n\necho $day.\"\\n\";\n\nfclose($handle);\n\n?>\n"}, {"source_code": "= 1440)\n\t\t$time -= 1440;\n\t\n\tif ($last_time > $time) {\n\t\t$num = 1;\n\t\t++$day;\n\t}\n\telse if ($last_time == $time)\n\t\t++$num;\n\telse\n\t\t$num = 1;\n\t\t\n\tif ($num == 10) {\n\t\t++$day;\n\t\t$num = 1;\n\t}\n\t\n\t$last_time = $time;\n}\n\necho $day.\"\\n\";\n\nfclose($handle);\n\n?>\n"}, {"source_code": " $time) {\n\t\t$num = 1;\n\t\t++$day;\n\t}\n\telse if ($last_time == $time)\n\t\t++$num;\n\telse\n\t\t$num = 1;\n\t\t\n\tif ($num == 10) {\n\t\t++$day;\n\t\t$num = 1;\n\t}\n\t\n\t$last_time = $time;\n}\n\necho $day.\"\\n\";\n\nfclose($handle);\n\n?>\n"}], "src_uid": "54f8b8e6711ff5c69e0bc38a6e2f4999"} {"nl": {"description": "Salem gave you $$$n$$$ sticks with integer positive lengths $$$a_1, a_2, \\ldots, a_n$$$.For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $$$a$$$ to $$$b$$$ is $$$|a - b|$$$, where $$$|x|$$$ means the absolute value of $$$x$$$.A stick length $$$a_i$$$ is called almost good for some integer $$$t$$$ if $$$|a_i - t| \\le 1$$$.Salem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $$$t$$$ and the total cost of changing is minimum possible. The value of $$$t$$$ is not fixed in advance and you can choose it as any positive integer. As an answer, print the value of $$$t$$$ and the minimum cost. If there are multiple optimal choices for $$$t$$$, print any of them.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 1000$$$)\u00a0\u2014 the number of sticks. The second line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \\le a_i \\le 100$$$)\u00a0\u2014 the lengths of the sticks.", "output_spec": "Print the value of $$$t$$$ and the minimum possible cost. If there are multiple optimal choices for $$$t$$$, print any of them.", "sample_inputs": ["3\n10 1 4", "5\n1 1 2 2 3"], "sample_outputs": ["3 7", "2 0"], "notes": "NoteIn the first example, we can change $$$1$$$ into $$$2$$$ and $$$10$$$ into $$$4$$$ with cost $$$|1 - 2| + |10 - 4| = 1 + 6 = 7$$$ and the resulting lengths $$$[2, 4, 4]$$$ are almost good for $$$t = 3$$$.In the second example, the sticks lengths are already almost good for $$$t = 2$$$, so we don't have to do anything."}, "positive_code": [{"source_code": " $x)\n {\n $e += $b[$y] - ($x + 1);\n }\n }\n if($e < $d)\n {\n $c = $x;\n $d = $e;\n }\n}\nprint $c . \" \" . $d;\n?>"}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\nini_set('display_errors', '1');\nfunction read() {\n return trim(fgets(STDIN));\n}\n$t1 = microtime(true);\n$debag = 0;\n/*\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013*/\nfunction arr($arr, $num) {\n $sum = 0;\n foreach($arr as $val) {\n $s = abs($val-$num);\n $sum += $s;\n if ($s > 0) {\n $sum--;\n }\n }\n return $sum;\n}\n$n = read();\n$arr = explode(' ', read());\n$t = null;\n$cst = null;\n$min = min($arr);\n$max = max($arr);\nif ($n == 1 || $max-$min === 0) {\n $t = $arr[0];\n $cst = 0;\n} elseif ($max - $min <= 2 && array_search($max-1, $arr)) {\n $t = $max-1;\n $cst = 0;\n} else {\n for ($i = $min; $i < $max; $i++) {\n $r = arr($arr, $i);\n if ($cst == null || $r < $cst) {\n $t = $i;\n $cst = $r;\n }\n }\n}\n\necho $t.' '.$cst;\n/*\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013*/\nif ($debag === 1) {\n echo '
\u8fd9\u6570\u636e\u4e5f\u592a\u5751\u4e86\u3002\u3002\u3002\u3002
\n\n
@author: Zyzsdy
\n@Website: http://www.namido.net
\n@date: 2014/1/18 15:02 (UTC+8)
\n\n
\u611f\u60f3\uff1a \u8fd9\u6b21CF\u5c31\u8fc7\u4e00\u9898\u5c45\u7136\u6ca1\u6263\u5206\u3002\u3002\u3002\u3002\u3002\u3002
\n\u4e0d\u8fc7\u6211\u8fd9\u9898\u5dee\u4e00\u70b9\u5c31\u505a\u51fa\u6765\u4e86\u3002\u3002\u3002
\n\u3002\u3002\u3002\u3002\u3002\u3002\u3002
\n\u5509\u3002\u3002\u3002\u3002
\n \n\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "=2){\n\techo 0;\n\texit();\n} \nelse if($errorcount==1){\n\tif($error[0][1]-$deim!=$deim){\n\t\techo 0;\n\t\texit();\n\t} \n\telse{\n\t\techo \"1\\n\";\n\t\techo $n2[$error[0][0]]-$deim;\n\t\texit();\n\t}\n}\nelse if($errorcount==0){\n\t$result=array();\n\tarray_push($result,$n2[0]-$deim,$n2[$ct-1]+$deim);\n\t$result=array_unique($result);\n\tsort($result);\n\techo count($result);\n\techo \"\\n\";\n\tforeach ($result as $v) {\n\t\techo $v.\" \";\n\t}\n\texit();\n\n}\n\n?>"}, {"source_code": "=2){\n\techo 0;\n\texit();\n} \nelse if($errorcount==1){\n\tif($error[0][1]-$deim!=$deim){\n\t\techo 0;\n\t\texit();\n\t} \n\telse{\n\t\techo \"1\\n\";\n\t\techo $n2[$error[0][0]]-$deim;\n\t\texit();\n\t}\n}\nelse if($errorcount==0){\n\t$result=array();\n\tarray_push($result,$n2[0]-$deim,$n2[$ct-1]+$deim);\n\t$result=array_unique($result);\n\tsort($result);\n\techo count($result);\n\techo \"\\n\";\n\tforeach ($result as $v) {\n\t\techo $v.\" \";\n\t}\n\texit();\n\n}\n\n?>"}], "src_uid": "e3ca8338beb8852c201be72650e9aabd"} {"nl": {"description": "Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string \"aba\" has six substrings: \"a\", \"b\", \"a\", \"ab\", \"ba\", \"aba\".Dr. Moriarty plans to take string s and cut out some substring from it, let's call it t. Then he needs to change the substring t zero or more times. As a result, he should obtain a fixed string u (which is the string that should be sent to Sherlock Holmes). One change is defined as making one of the following actions: Insert one letter to any end of the string. Delete one letter from any end of the string. Change one letter into any other one. Moriarty is very smart and after he chooses some substring t, he always makes the minimal number of changes to obtain u. Help Moriarty choose the best substring t from all substrings of the string s. The substring t should minimize the number of changes Moriarty should make to obtain the string u from it.", "input_spec": "The first line contains a non-empty string s, consisting of lowercase Latin letters. The second line contains a non-empty string u, consisting of lowercase Latin letters. The lengths of both strings are in the range from 1 to 2000, inclusive.", "output_spec": "Print the only integer \u2014 the minimum number of changes that Dr. Moriarty has to make with the string that you choose.", "sample_inputs": ["aaaaa\naaa", "abcabc\nbcd", "abcdef\nklmnopq"], "sample_outputs": ["0", "1", "7"], "notes": "NoteIn the first sample Moriarty can take any substring of length 3, and it will be equal to the required message u, so Moriarty won't have to make any changes.In the second sample you should take a substring consisting of characters from second to fourth (\"bca\") or from fifth to sixth (\"bc\"). Then you will only have to make one change: to change or to add the last character.In the third sample the initial string s doesn't contain any character that the message should contain, so, whatever string you choose, you will have to make at least 7 changes to obtain the required message."}, "positive_code": [{"source_code": "= count($b))\n{\n $c = array_fill(0, count($b), \".\");\n $a = array_merge($c, $a, $c);\n $d = 0;\n for($x = 0; $x < count($a) + 1 - count($b); $x++)\n {\n $e = array_slice($a, $x, count($b));\n $f = count(array_intersect_assoc($b, $e));\n $d = max($d, $f);\n }\n print count($b) - $d;\n}\nelse\n{\n $c = array_fill(0, count($a), \".\");\n $b = array_merge($c, $b, $c);\n $d = 0;\n for($x = 0; $x < count($b) + 1 - count($a); $x++)\n {\n $e = array_slice($b, $x, count($a));\n $f = count(array_intersect_assoc($a, $e));\n $d = max($d, $f);\n }\n print $b2 - $d;\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_u_arr = str_split($inp_u);\t\n\t$lu = count($inp_u_arr);\n\t\n\t$str = str_repeat(\"*\", $lu);\n\t$inp_s = $str.$inp_s.$str;\n\t$inp_s_arr = str_split($inp_s);\n\t$ls = count($inp_s_arr);\n\t\n\t$c = 0;\n\t$max = 0;\n\tfor ($i = 1; $i < $ls - $lu; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\tif ($max < $c) $max = $c;\n\t\tif ($max === $lu) break;\n\t\t$c = 0;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\tfor ($k = 0; $k < $lu - 1; $k++) {\n \t $str .= \"*\";\n\t}\n\n\t$inp_s = $str. $inp_s. $str;\n\t$ls = strlen($inp_s);\n\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t$max = 0;\n\tfor ($i = 0; $i < $ls - $lu + 1; $i++) {\n\t$c = 0;\n \tfor ($j = 0; $j < $lu; $j++) {\n \t \tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n \t}\n \tif ($max < $c) $max = $c;\n \tif ($max === $lu) break;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\tfor ($k = 0; $k < $lu - 1; $k++) {\n \t $str .= \"*\";\n\t}\n\n\t$inp_s = $str. $inp_s. $str;\n\t$ls = strlen($inp_s);\n\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t$max = 0;\n\tfor ($i = 0; $i < $ls - $lu + 1; $i++) {\n\t$c = 0;\n \tfor ($j = 0; $j < $lu; $j++) {\n \t \tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t\t//if ($inp_u[$j] === $inp_s[$i + $j]) $c++;\n \t}\n \tif ($max < $c) $max = $c;\n \tif ($max === $lu) break;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_u_arr = str_split($inp_u);\t\n\t$lu = count($inp_u_arr);\n\t\n\t$str = str_repeat(\"*\", $lu);\n\t$inp_s = $str.$inp_s.$str;\n\t$inp_s_arr = str_split($inp_s);\n\t$ls = count($inp_s_arr);\n\t\n\t$c = 0;\n\t$max = array();\n\tfor ($i = 1; $i < $ls- $lu; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\t$match[] = $c;\n\t\t$c = 0;\n\t}\n\trsort($match);\n\tprintf(\"%d\", $lu - $match[0]);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_u_arr = str_split($inp_u);\t\n\t$lu = count($inp_u_arr);\n\t\n\t$str = str_repeat(\"*\", $lu - 1);\n\t$inp_s = $str.$inp_s.$str;\n\t$inp_s_arr = str_split($inp_s);\n\t$ls = count($inp_s_arr);\n\t\n\t$c = 0;\n\t$max = 0;\n\tfor ($i = 0; $i < $ls - $lu + 1; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\tif ($max < $c) $max = $c;\n\t\tif ($max === $lu) break;\n\t\t$c = 0;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t//$temp_S = \"\";\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $lu; $i++) {\n\t\t$flag = 0;\n\t\tfor ($j = $i; $j < $ls; $j++) {\n\t\t\t\n\t\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t\t$temp_S = $temp_S.$inp_u_arr[$i];\n\t\t\t\t$flag = 1;\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t} elseif ($flag === 1){\n\t\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t\t}\n\t\t\t\t$flag = 0;\n\t\t\t\t$i = $i - $c;\n\t\t\t\t$c = 0;\n\t\t\t\t$temp_S = \"\";\n\t\t\t}\t\t\t\t\n\t\t}\n\t\t$pos++;\n\t}\n\t\n\t$max = 0;\n\t//foreach ($temp_S as $as_S) {\n\tforeach ($temp_Sa as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\t$str = str_repeat(\"*\", $lu);\n\t$inp_s = $str.$inp_s.$str;\n\t$ls = strlen($inp_s_arr);\n\t\n\t$c = 0;\n\t$max = 0;\n\tfor ($i = 0; $i < $ls; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($inp_u[$j] === $inp_s[$i + $j]) $c++;\n\t\t}\n\t\tif ($max < $c) $max = $c;\n\t\tif ($max === $lu) break;\n\t\t$c = 0;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\t$ls = strlen($inp_s);\n\t\n\t$min = PHP_INT_MAX;\n\tfor ($i = -1 * $lu; $i < $ls; $i++) {\n\t\t$c = 0;\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($i + $j < 0 || $i + $j >= $lu || $inp_u[$j] !== $inp_s[$i + $j]) $c++;\n\t\t}\n\t\tif ($min > $c) $min = $c;\n\t}\n\tprintf(\"%d\", $min);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t//$temp_S = \"\";\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $lu; $i++) {\n\t\t$flag = 0;\n\t\t$temp_S = \"\";\n\t\tfor ($j = $i; $j < $ls; $j++) {\n\t\t\t\n\t\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t\t$temp_S = $temp_S.$inp_u_arr[$i];\n\t\t\t\t$flag = 1;\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t} elseif ($flag === 1){\n\t\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t\t}\n\t\t\t\t$flag = 0;\n\t\t\t\t$i = $i - $c;\n\t\t\t\t$c = 0;\n\t\t\t}\t\t\t\t\n\t\t}\n\t\t$pos++;\n\t}\n\t\n\t$max = 0;\n\t//foreach ($temp_S as $as_S) {\n\tforeach ($temp_Sa as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t//$temp_S = \"\";\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $lu; $i++) {\n\t\t$flag = 0;\n\t\tfor ($j = $i; $j < $ls; $j++) {\n\t\t\t\n\t\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t\t$temp_S = $temp_S.$inp_u_arr[$i];\n\t\t\t\t$flag = 1;\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t} elseif ($flag === 1){\n\t\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t\t}\n\t\t\t\t$flag = 0;\n\t\t\t\t$i = $i - $c;\n\t\t\t\t$c = 0;\n\t\t\t\t$temp_S = \"\";\n\t\t\t}\n\t\t}\n\t\t$pos++;\n\t\tif ($flag === 1) {\n\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t$max = 0;\n\t//foreach ($temp_S as $as_S) {\n\tforeach ($temp_Sa as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\tfor ($k = 0; $k < $lu - 1; $k++) {\n \t $str .= \"*\";\n\t}\n\n\t$inp_s = $str. $inp_s. $str;\n\t$ls = strlen($inp_s);\n\n\t$max = 0;\n\tfor ($i = 1; $i < $ls - $lu + 1; $i++) {\n\t$c = 0;\n \tfor ($j = 0; $j < $lu; $j++) {\n \t \tif ($inp_u[$j] === $inp_s[$i + $j]) $c++;\n \t}\n \tif ($max < $c) $max = $c;\n \tif ($max === $lu) break;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\n\npublic class taskC {\n\tBufferedReader reader;\n\tStringTokenizer tokenizer = new StringTokenizer(\"\");;\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tnew taskC().run();\n\t}\n\n\tprivate void run() throws IOException {\n\t\ttokenizer = null;\n\t\treader = new BufferedReader(new InputStreamReader(System.in));\n\t\tsolve();\n\n\t}\n\n\tprivate void solve() throws IOException {\n\t\tString s = nextToken();\n\t\tString u = nextToken();\n\n\t\tint lenU = u.length();\n\t\tString str = \"\";\n\t\tfor (int i = 0; i < lenU; i++) {\n\t\t\tstr += \"*\";\n\t\t}\n\n\t\ts = str + s + str;\n\t\tint lenS = s.length();\n\t\tint max = 0;\n\t\tfor (int i = 1; i < lenS - lenU; i++) {\n\t\t\tint c = 0;\n\t\t\tfor (int j = 0; j < lenU; j++) {\n\t\t\t\tif (u.charAt(j) == s.charAt(i + j)) c++;\n\t\t\t}\n\t\t\tif (max < c) max = c;\n\t\t\tif (max == lenU) break;\n\t\t\tc = 0;\n\t\t}\n\t\tint num = lenU - max;\n\t\tSystem.out.print(num);\n\t}\n\t\n\tBufferedReader in;\n\tStringTokenizer st = new StringTokenizer(\"\");\n\n\tString nextToken() throws IOException {\n\t\twhile (tokenizer == null || !tokenizer.hasMoreTokens())\n\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tint nextInt() throws IOException {\n\t\treturn Integer.parseInt(nextToken());\n\t}\n\n\tlong nextLong() throws IOException {\n\t\treturn Long.parseLong(nextToken());\n\t}\n\n\tdouble nextDouble() throws IOException {\n\t\treturn Double.parseDouble(nextToken());\n\t}\n\n\tint[] nextIntArray(int size) throws IOException {\n\t\tint[] ret = new int [size];\n\t\tfor (int i = 0; i < size; i++)\n\t\t\tret[i] = nextInt();\n\t\treturn ret;\n\t}\n \n\tlong[] nextLongArray(int size) throws IOException {\n\t\tlong[] ret = new long [size];\n\t\tfor (int i = 0; i < size; i++)\n\t\t\tret[i] = nextLong();\n\t\treturn ret;\n\t}\n \n\tdouble[] nextDoubleArray(int size) throws IOException {\n\t\tdouble[] ret = new double [size];\n\t\tfor (int i = 0; i < size; i++)\n\t\t\tret[i] = nextDouble();\n\t\treturn ret;\n\t}\n\n\tString nextLine() throws IOException {\n\t\tst = new StringTokenizer(\"\");\n\t\treturn in.readLine();\n\t}\n\n boolean EOF() throws IOException {\n\t\twhile (!st.hasMoreTokens()) {\n\t\t\tString s = in.readLine();\n\t\t\tif (s == null)\n\t\t\t\treturn true;\n \t\t\tst = new StringTokenizer(s);\n\t\t}\n\t\treturn false;\n\t}\n}"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t//$temp_S = \"\";\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $lu; $i++) {\n\t\t$flag = 0;\n\t\t$temp_S = \"\";\n\t\tfor ($j = $i; $j < $ls; $j++) {\n\t\t\t\n\t\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t\t$temp_S = $temp_S.$inp_u_arr[$i];\n\t\t\t\t$flag = 1;\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t} elseif ($flag === 1){\n\t\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t\t}\n\t\t\t\t$flag = 0;\n\t\t\t\t$i = $i - $c;\n\t\t\t\t$c = 0;\n\t\t\t}\t\t\t\t\n\t\t}\n\t\t$pos++;\n\t}\n\t\n\t$max = 0;\n\t//foreach ($temp_S as $as_S) {\n\tforeach ($temp_Sa as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_S = array();\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$i = 0;\n\tfor ($j = 0; $j < $ls; $j++) { \n\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t$temp_S[$pos] = $temp_S[$pos].$inp_u_arr[$i];\n\t\t\twhile ($inp_u_arr[++$i] === $inp_s_arr[++$j]){\n\t\t\t\t\t$temp_S[$pos] = $temp_S[$pos].$inp_u_arr[$i];\n\t\t\t}\n\t\t\t$i = 0;\n\t\t\t$pos++;\t\n\t\t}\n\t}\n\t\n\t$max = 0;\n\tforeach ($temp_S as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t//$temp_S = \"\";\n\t$c = 0;\n\t$max = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $ls; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\t$max = max($max, $c);\n\t\t$c = 0;\n\t}\n\t$change = count($inp_u_arr) - $max;\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$lu = strlen($inp_u);\n\tfor ($k = 0; $k < $lu - 1; $k++) {\n \t $str .= \"*\";\n\t}\n\n\t$inp_s = $str. $inp_s. $str;\n\t$ls = strlen($inp_s);\n\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t$max = 0;\n\tfor ($i = 0; $i < $ls - $lu + 1; $i++) {\n\t$c = 0;\n \tfor ($j = 0; $j < $lu; $j++) {\n \t \tif ($inp_s_arr[$j] === $inp_u_arr[$i + $j]) $c++;\n \t}\n \tif ($max < $c) $max = $c;\n \tif ($max === $lu) break;\n\t}\n\t$change = $lu - $max;\n\tprintf(\"%d\", $change);\n\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_u_arr = str_split($inp_u);\t\n\t$lu = count($inp_u_arr);\n\t\n\t$str = str_repeat(\"*\", $lu);\n\t$inp_s = $str.$inp_s.$str;\n\t$inp_s_arr = str_split($inp_s);\n\t$ls = count($inp_s_arr);\n\t\n\t$c = 0;\n\t//$max = 0;\n\t$max = array();\n\tfor ($i = 1; $i < $ls- $lu; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\t//if ($inp_u_arr[$i] === $inp_s_arr[$j]) $c++;\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\t$match[] = $c;\n\t\t//if ($c === $lu) break;\n\t\t$c = 0;\n\t}\n\trsort($match);\n\tprintf(\"%d\", $match[0]);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_u_arr = str_split($inp_u);\t\n\t$lu = count($inp_u_arr);\n\t\n\t$str = str_repeat(\"*\", $lu);\n\t$inp_s = $str.$inp_s.$str;\n\t$inp_s_arr = str_split($inp_s);\n\t$ls = count($inp_s_arr);\n\t\n\t$c = 0;\n\t$max = array();\n\tfor ($i = 1; $i < $ls- $lu; $i++) {\n\t\tfor ($j = 0; $j < $lu; $j++) {\n\t\t\tif ($inp_u_arr[$j] === $inp_s_arr[$i + $j]) $c++;\n\t\t}\n\t\t$match[] = $c;\n\t\t$c = 0;\n\t}\n\trsort($match);\n\tprintf(\"%d\", $match[0]);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_u = $Scanner->Scan();\n\t\n\t$inp_s_arr = str_split($inp_s);\n\t$inp_u_arr = str_split($inp_u);\n\t\n\t$temp_Sa = array();\n\t$temp_S = \"\";\n\t$pos = 0;\n\t$ls = count($inp_s_arr);\n\t$lu = count($inp_u_arr);\n\tfor ($i = 0; $i < $lu; $i++) {\n\t\t$flag = 0;\n\t\tfor ($j = $i; $j < $ls; $j++) {\n\t\t\t\n\t\t\tif ($inp_u_arr[$i] === $inp_s_arr[$j]) {\n\t\t\t\t$temp_S = $temp_S.$inp_u_arr[$i];\n\t\t\t\t$flag = 1;\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t} elseif ($flag === 1){\n\t\t\t\tif (strlen($temp_S) > strlen($temp_Sa[$pos])) {\n\t\t\t\t\t$temp_Sa[$pos] = $temp_S;\n\t\t\t\t}\n\t\t\t\t$flag = 0;\n\t\t\t\t$i = $i - $c;\n\t\t\t\t$c = 0;\n\t\t\t}\t\t\t\t\n\t\t}\n\t\t$pos++;\n\t}\n\t\n\t$max = 0;\n\tforeach ($temp_S as $as_S) {\n\t\t$len = strlen($as_S);\n\t\tif ($max < $len) $max = $len;\n\t}\n\t$inp_len = strlen($inp_u);\n\t$change = $inp_len - $max;\n\t\n\tprintf(\"%d\", $change);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": " $u = \". levenshtein(substr($s, $i, $u_len), $u) .\"\\n\";\n $diffs[] = levenshtein(substr($s, $i, $u_len), $u);\n}\n\nsort($diffs);\nprint $diffs[0] .\"\\n\";\n\n\n"}, {"source_code": "= $d)\n {\n break;\n }\n}\nprint ($x + 1);\n?>"}, {"source_code": "= ($sum / 2)) {\n\t\t$res = $i + 1;\n\t\tbreak ;\n\t}\n}\n\necho $res.\"\\n\";"}, {"source_code": "=$tetrbatknianebi){\n echo($i+1);\n exit();\n }\n}\n\n?>"}, {"source_code": " $value) {\n\t$total += $value;\n}\n\n$cur = 0;\n$day = 0;\nforeach ($b as $key => $value) {\n\t$day++;\n\t$cur += $value;\n\tif ($cur >= $total/2) {\n\t\tbreak;\n\t}\n}\n\necho $day;\n?>"}], "negative_code": [], "src_uid": "241157c465fe5dd96acd514010904321"} {"nl": {"description": "You are given two arrays $$$a$$$ and $$$b$$$, both consisting of $$$n$$$ integers.In one move, you can choose two indices $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$; $$$i \\neq j$$$) and swap $$$a_i$$$ with $$$a_j$$$ and $$$b_i$$$ with $$$b_j$$$. You have to perform the swap in both arrays.You are allowed to perform at most $$$10^4$$$ moves (possibly, zero). Can you make both arrays sorted in a non-decreasing order at the end? If you can, print any sequence of moves that makes both arrays sorted.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of testcases. The first line of each testcase contains a single integer $$$n$$$ ($$$2 \\le n \\le 100$$$)\u00a0\u2014 the number of elements in both arrays. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$)\u00a0\u2014 the first array. The third line contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$1 \\le b_i \\le n$$$)\u00a0\u2014 the second array.", "output_spec": "For each testcase, print the answer. If it's impossible to make both arrays sorted in a non-decreasing order in at most $$$10^4$$$ moves, print -1. Otherwise, first, print the number of moves $$$k$$$ $$$(0 \\le k \\le 10^4)$$$. Then print $$$i$$$ and $$$j$$$ for each move $$$(1 \\le i, j \\le n$$$; $$$i \\neq j)$$$. If there are multiple answers, then print any of them. You don't have to minimize the number of moves.", "sample_inputs": ["3\n\n2\n\n1 2\n\n1 2\n\n2\n\n2 1\n\n1 2\n\n4\n\n2 3 1 2\n\n2 3 2 3"], "sample_outputs": ["0\n-1\n3\n3 1\n3 2\n4 3"], "notes": null}, "positive_code": [{"source_code": "= $a[$j] && $b[$i] >= $b[$j]) {\r\n $temp = $a[$i];\r\n $a[$i] = $a[$j];\r\n $a[$j] = $temp;\r\n \r\n $temp = $b[$i];\r\n $b[$i] = $b[$j];\r\n $b[$j] = $temp; \r\n $tt = $i+1;\r\n $bb = $j+1;\r\n $ans .= \"$tt $bb\\n\";\r\n $count++;\r\n }\r\n }\r\n }\r\n \r\n $sol = true;\r\n for($i=0; $i<$n-1; $i++) {\r\n if($a[$i] > $a[$i+1] || $b[$i] > $b[$i+1]) {\r\n $sol = false;\r\n break;\r\n }\r\n }\r\n if(!$sol) {\r\n IO::pr('-1');\r\n } else {\r\n echo $count, PHP_EOL; \r\n if($count > 0) {\r\n echo $ans, PHP_EOL;\r\n }\r\n \r\n // for($i=0; $i<$count; $i++) {\r\n // echo $ans[$i], PHP_EOL; \r\n // }\r\n }\r\n \r\n \r\n }\r\n \r\nfunction maxVal($x) {\r\n $max = $x[0];\r\n for($i=1; $i\";\n//print_r( $arr_commands );\n\n\n\nforeach( $arr_commands as $t ){\n\n\t$tag = 'pwd';\n\tif( substr($t, 0, strlen($tag)) == $tag){\n\t\t//echo \"\\n+++pwd\";\n\t\tmy_pwd();\n\t\tcontinue;\n\t} \n\t\n\t$tag = 'cd';\n\tif( substr($t, 0, strlen($tag)) == $tag){\n\t\t//echo \"\\n+++cd:\";\n\t\tmy_cd( substr( $t, strlen($tag)));\n\t\tcontinue;\n\t} \n\t\n}\n\n\n//EOF"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$cur_path=array(0=>\"/\");\n\nfor ($l=1; $l';} \n function read_line()\n { \n if(DEBUG) { $file = $GLOBALS['file'];$line = trim(fgets($file));}\n else $line = trim(fgets(STDIN));\n return $line;\n }\n function get_array($line){return explode(' ', $line);}\n function read_array(){return get_array(read_line());} \n //echo \"$s\\n\";\n /*****************************************************************/\n \n $n = read_line();\n $x=0;\n $y=0;\n $z=0;\n \n \n for($i=1; $i<=$n; $i++)\n {\n $arr=read_array();\n $x+=$arr[0];\n $y+=$arr[1];\n $z+=$arr[2];\n }\n \n if(!($x||$y||$z)) echo 'YES';\n else echo 'NO';\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\";\n\n //\u0415\u0441\u043b\u0438 \u0438\u0434\u0435\u043c \u043e\u0442 \u043a\u043e\u0440\u043d\u044f\n if ($path{0}==\"/\")\n $cur_path=array(0=>\"/\");\n\n if($path==\"/\")\n {\n $cur_path=array(0=>\"/\");\n continue;\n }\n\n $struc=explode(\"/\", ltrim($path,\"/\"));\n foreach ($struc as $deep=>$dir)\n {\n if ($dir==\"..\")\n array_pop($cur_path);\n else\n $cur_path[]=$dir;\n }\n //print_r($cur_path);\n }\n}\necho implode(\"\\n\", $cmds);"}, {"source_code": " 0 )\n\t{\n\t\t$result .= implode( '/', $path ) . '/';\n\t}\n return $result;\n}\n\nfile_put_contents( 'php://stdout', implode( \"\\n\", $result ) );"}, {"source_code": " 0)\n echo \"/\";\n if (!$isLast)\n echo \"\n\";\n}\n\n$current = array();\nforeach ($strs as $k => $str) {\n if (trim($str) == \"pwd\") {\n $isLast = count($strs) == $k+1;\n\n printPath($current, $isLast);\n } else {\n $path = explode(\" \", $str);\n $path = trim($path[1]);\n $path = explode(\"/\", $path);\n \n foreach($path as $dir) {\n switch ($dir) {\n case \"\": $current = array(); break;\n case \"..\": array_pop($current); break;\n default: if ($dir !== '') array_push($current, $dir); \n }\n }\n }\n}"}, {"source_code": " 0) {\n array_pop($path);\n }\n } else {\n $path[] = $folder;\n }\n }\n\n}\n\nfunction print_path($path) {\n if (!empty($path)) {\n $path = implode(\"/\",$path).\"/\";\n } else {\n $path = \"\";\n }\n fputs(STDOUT, \"/\". $path.\"\\r\\n\");\n}\n\n?>\n\n"}, {"source_code": ""}], "negative_code": [{"source_code": "= 0; $z--)\n {\n if(($g[$z] == \"/\") && ($i == 0))\n {\n $i = 1;\n }\n elseif(($g[$z] == \"/\") && ($i == 1))\n {\n array_splice($g, $z, $h + 2 - $z);\n break;\n }\n }\n }\n else\n {\n break;\n }\n }\n $e = $g;\n for($y = 0; $y < count($e) - 1; $y++)\n {\n if(($e[$y] == \"/\") && ($e[$y + 1] == \"/\"))\n {\n unset($e[$y]);\n }\n }\n $d = implode(\"\", $e);\n }\n}\nlist($b, $c) = explode(\" \", trim(fgets(STDIN)));\nif($b == \"pwd\")\n{\n print $d;\n}\nelse\n{\n $d .= \"/\" . $c . \"/\";\n $e = str_split($d);\n for($y = 0; $y < count($e) - 1; $y++)\n {\n if(($e[$y] == \"/\") && ($e[$y + 1] == \"/\"))\n {\n unset($e[$y]);\n }\n }\n $f = implode(\"\", $e);\n $g = str_split($f);\n for($y = 1; $y < 1000; $y++)\n {\n $h = array_search(\".\", $g);\n if($h == TRUE)\n {\n $i = 0;\n for($z = $h; $z >= 0; $z--)\n {\n if(($g[$z] == \"/\") && ($i == 0))\n {\n $i = 1;\n }\n elseif(($g[$z] == \"/\") && ($i == 1))\n {\n array_splice($g, $z, $h + 2 - $z);\n break;\n }\n }\n }\n else\n {\n break;\n }\n }\n $e = $g;\n for($y = 0; $y < count($e) - 1; $y++)\n {\n if(($e[$y] == \"/\") && ($e[$y + 1] == \"/\"))\n {\n unset($e[$y]);\n }\n }\n $d = implode(\"\", $e);\n}\n?>"}, {"source_code": ""}, {"source_code": "\n list($n)=fscanf(STDIN,\"%d\");\n print_r($n);\n $path=\"/\";\n for($i=0;$i<$n;$i++){\n $u=fgets(STDIN);\n $u=str_replace(\"\\n\",'',$u);\n $u=str_replace(\"\\r\",'',$u);\n if ($u[0]==\"p\"){\n fputs(STDOUT,\"\\n\".$path);\n }else{\n $h=substr($u,3);\n if ($h[0]==\"/\") {$path=\"/\";$h=substr($h,1);}\n $j=explode('/',$h);\n foreach($j as $x){\n if ($x=='..') {\n $g=strrpos($path,'/',-2);\n $path=substr($path,0,$g+1);\n }else{\n $path.=($x.\"/\");\n }\n }\n }\n }\n?>"}, {"source_code": " array(\n'7',\n'pwd',\n'cd /home/vasya',\n'pwd',\n'cd ..',\n'pwd',\n'cd vasya/../petya',\n'pwd',\n));\n $input = dataProvider::get();\n $data = array();\n $i = 0;\n $current_dir = array();\n foreach($input['lines'] as $line) {\n if ($i == 0) {$i++; continue;} // \u044d\u0442\u043e \u043b\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0434\u0440\u0435\u0432\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\n if($line == 'pwd') {$data[] = empty($current_dir) ? '/' : '/'. (string) implode('/', $current_dir).'/'; continue;}\n\n $line = ltrim($line, 'cd ');\n if ($line[0] == '/') {$current_dir = array();}\n $dirs = explode('/', $line);\n foreach ($dirs as $dir) {\n if(!empty($dir)) {\n if($dir == '..') {\n //echo '
path wos '. '/'. (string) implode('/', $current_dir);\n $k = 0;\n foreach($current_dir as $key => $value)\n {\n $k++;\n if($k == count($current_dir)) {\n unset($current_dir[$key]);\n }\n }\n //$current_dir = array_diff($current_dir, array(array_pop($current_dir)));\n //echo ' path now '. '/'. (string) implode('/', $current_dir).'
';\n } else {\n $current_dir[] = $dir;\n }\n }\n }\n }\n\n//var_dump($data); die();\n\n dataProvider::set($data);\n\n\n class dataProvider\n {\n public static function get()\n {\n $stdin = file_get_contents('php://stdin');\n $stdin = str_replace(array(\"\\r\"), \"\\n\", $stdin);\n $stdin = str_replace(array(\"\\n\\n\"), \"\\n\", $stdin);\n $lines = explode(\"\\n\", $stdin);\n return array(\n 'lines' => $lines,\n );\n }\n\n public static function set($data)\n {\n file_put_contents('php://stdout', implode(\"\\n\", $data));\n }\n }\n?>"}, {"source_code": " array(\n'7',\n'pwd',\n'cd /home/vasya',\n'pwd',\n'cd ..',\n'pwd',\n'cd vasya/../petya',\n'pwd',\n));\n $input = dataProvider::get();\n $data = array();\n $i = 0;\n $current_dir = array();\n foreach($input['lines'] as $line) {\n if ($i == 0) {$i++; continue;} // \u044d\u0442\u043e \u043b\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0434\u0440\u0435\u0432\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\n if($line == 'pwd') {$data[] = empty($current_dir) ? '/' : '/'. (string) implode('/', $current_dir).'/'; continue;}\n\n $line = substr($line, 4);\n if ($line[0] == '/') {$current_dir = array();}\n $dirs = explode('/', $line);\n foreach ($dirs as $dir) {\n if(!empty($dir)) {\n if($dir == '..') {\n //echo '
path wos '. '/'. (string) implode('/', $current_dir);\n $k = 0;\n foreach($current_dir as $key => $value)\n {\n $k++;\n if($k == count($current_dir)) {\n unset($current_dir[$key]);\n }\n }\n //$current_dir = array_diff($current_dir, array(array_pop($current_dir)));\n //echo ' path now '. '/'. (string) implode('/', $current_dir).'
';\n } else {\n $current_dir[] = $dir;\n }\n }\n }\n }\n\n//var_dump($data); die();\n\n dataProvider::set($data);\n\n\n class dataProvider\n {\n public static function get()\n {\n $stdin = file_get_contents('php://stdin');\n $stdin = str_replace(array(\"\\r\"), \"\\n\", $stdin);\n $stdin = str_replace(array(\"\\n\\n\"), \"\\n\", $stdin);\n $lines = explode(\"\\n\", $stdin);\n return array(\n 'lines' => $lines,\n );\n }\n\n public static function set($data)\n {\n file_put_contents('php://stdout', implode(\"\\n\", $data));\n }\n }\n?>"}, {"source_code": " array(\n'7',\n'pwd',\n'cd /home/vasya',\n'pwd',\n'cd ..',\n'pwd',\n'cd vasya/../petya',\n'pwd',\n));\n $input = dataProvider::get();\n $data = array();\n $i = 0;\n $current_dir = array();\n foreach($input['lines'] as $line) {\n if ($i == 0) {$i++; continue;} // \u044d\u0442\u043e \u043b\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0434\u0440\u0435\u0432\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432\n if($line == 'pwd') {$data[] = empty($current_dir) ? '/' : '/'. (string) implode('/', $current_dir).'/'; continue;}\n\n $line = ltrim($line, 'cd ');\n if ($line[0] == '/') {$current_dir = array();}\n $dirs = explode('/', $line);\n foreach ($dirs as $dir) {\n if(!empty($dir)) {\n if($dir == '..') {\n //echo '
path wos '. '/'. (string) implode('/', $current_dir);\n $current_dir = array_diff($current_dir, array(array_pop($current_dir)));\n //echo ' path now '. '/'. (string) implode('/', $current_dir).'
';\n } else {\n $current_dir[] = $dir;\n }\n }\n }\n }\n\n//var_dump($data); die();\n\n dataProvider::set($data);\n\n\n class dataProvider\n {\n public static function get()\n {\n $stdin = file_get_contents('php://stdin');\n $stdin = str_replace(array(\"\\r\"), \"\\n\", $stdin);\n $stdin = str_replace(array(\"\\n\\n\"), \"\\n\", $stdin);\n $lines = explode(\"\\n\", $stdin);\n return array(\n 'lines' => $lines,\n );\n }\n\n public static function set($data)\n {\n file_put_contents('php://stdout', implode(\"\\n\", $data));\n }\n }\n?>"}, {"source_code": " 50 || preg_match('/[^0-9]/', $commands)) {\n fwrite(STDERR, 'invalid string');\n exit();\n}\n$results = array();\nfor ($i = 0; $i < $commands; $i++) {\n $input = trim(fgets(STDIN));\n if ($input == 'pwd') {\n if ($current_dir!=\"/\"){\n $results[] = $current_dir.\"/\";\n } else {\n $results[] = $current_dir;\n }\n \n } else if (substr($input, 0, 2) == 'cd') {\n $tmp = substr($input, 3);\n $tmp = explode(\"/\", $tmp);\n if (count($tmp) > 2 && empty($tmp[count($tmp) - 1])) {\n fwrite(STDERR, 'invalid string');\n exit();\n }\n if (count($tmp) == 2 && empty($tmp[0]) && empty($tmp[1])) {\n $current_dir = \"/\";\n } else if (count($tmp) == 1 && $tmp[0] == \"..\") {\n $current_dir = explode(\"/\", $current_dir);\n if (count($current_dir) == 2 && empty($current_dir[0]) && empty($current_dir[1])) {\n $current_dir = \"/\";\n } else {\n unset($current_dir[count($current_dir) - 1]);\n $current_dir = implode(\"/\", $current_dir);\n //$current_dir= str_replace(\"//\", \"/\", $current_dir);\n }\n } else if (count($tmp) == 2 && empty($tmp[0]) && $tmp[1] == \"..\") {\n $current_dir = \"/\";\n } else {\n foreach ($tmp as $val) {\n if (empty($val)) {\n $current_dir = \"\";\n } else if ($val == \"..\") {\n $current_dir = explode(\"/\", $current_dir);\n if (count($current_dir) == 2 && empty($current_dir[0]) && empty($current_dir[1])) {\n $current_dir = \"\";\n } else {\n unset($current_dir[count($current_dir) - 1]);\n $current_dir = implode(\"/\", $current_dir);\n //$current_dir= str_replace(\"//\", \"/\", $current_dir);\n }\n } else {\n $current_dir = explode(\"/\", $current_dir);\n $current_dir[]=$val;\n $current_dir = implode(\"/\", $current_dir);\n //$current_dir= str_replace(\"//\", \"/\", $current_dir);\n }\n }\n }\n\n //print_r($tmp);\n }\n}\nfwrite(STDOUT, implode(\"\\n\", $results));\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n for ($j = 0; $j < count($commands); $j++) {\n if ($j != (count($commands) - 1)) {\n parse_command($commands[$j]);\n } else {\n parse_command($commands[$j], true);\n }\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command($str, $last = false) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($last == false) {\n $last_str = \"\\n\";\n } else {\n $last_str = \"\";\n }\n if ($home_dir != '/' && !empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $home_dir . \"/\" . $last_str);\n } else if (empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $last_str);\n } else {\n fwrite(STDOUT, $home_dir . $last_str);\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else {\n if (count($home_dir) == 2 && empty($home_dir[0]) && empty($home_dir[1])) {\n $home_dir = array();\n $home_dir[] = $cmd[$j];\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n }\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n } else {\n fwrite(STDERR, 'invalid command');\n }\n}\n\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n foreach ($commands as $val) {\n parse_command($val);\n fwrite(STDOUT, $val);\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command(&$str) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($home_dir != '/' && !empty($home_dir)) {\n $str = \"/\" . $home_dir . \"/\\n\";\n } else if (empty($home_dir)) {\n $str = \"/\\n\";\n } else {\n $str = $home_dir . \"\\n\";\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n $str = '';\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n }\n}\n\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n for ($j = 0; $j < count($commands); $j++) {\n if ($j != (count($commands) - 1)) {\n parse_command($commands[$j]);\n fwrite(STDOUT, $commands[$j]);\n } else {\n parse_command($commands[$j], true);\n fwrite(STDOUT, $commands[$j]);\n }\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command(&$str, $last = false) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($last == false) {\n $last_str = \"\\n\";\n } else {\n $last_str = \"\";\n }\n if ($home_dir != '/' && !empty($home_dir)) {\n $str = \"/\" . $home_dir . \"/\" . $last_str;\n } else if (empty($home_dir)) {\n $str = \"/\" . $last_str;\n } else {\n $str = $home_dir . $last_str;\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n $str = '';\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n }\n}\n\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n for ($j = 0; $j < count($commands); $j++) {\n if ($j != (count($commands) - 1)) {\n parse_command($commands[$j]);\n fwrite(STDOUT, $commands[$j]);\n } else {\n parse_command($commands[$j], true);\n fwrite(STDOUT, $commands[$j]);\n }\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command(&$str, $last = false) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($last == false) {\n $last_str = \"\\n\";\n } else {\n $last_str = \"\";\n }\n if ($home_dir != '/' && !empty($home_dir)) {\n $str = \"/\" . $home_dir . \"/\" . $last_str;\n } else if (empty($home_dir)) {\n $str = \"/\" . $last_str;\n } else {\n $str = $home_dir . $last_str;\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else {\n if (count($home_dir)==2 && empty($home_dir[0])&&empty($home_dir[1])){\n $home_dir = array();\n $home_dir[] = $cmd[$j];\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n }\n $str = '';\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n }\n}\n\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n for ($j = 0; $j < count($commands); $j++) {\n if ($j != (count($commands) - 1)) {\n parse_command($commands[$j]);\n } else {\n parse_command($commands[$j], true);\n }\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command($str, $last = false) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($last == false) {\n $last_str = \"\\n\";\n } else {\n $last_str = \"\";\n }\n if ($home_dir != '/' && !empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $home_dir . \"/\" . $last_str);\n } else if (empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $last_str);\n } else {\n fwrite(STDOUT, $home_dir . $last_str);\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else if(preg_match('/^[a-z]$/i', $cmd[$j])) {\n if (count($home_dir) == 2 && empty($home_dir[0]) && empty($home_dir[1])) {\n $home_dir = array();\n $home_dir[] = $cmd[$j];\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n }\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n } else {\n fwrite(STDERR, 'invalid command');\n }\n}\n\n?>\n"}, {"source_code": "= 1 && $number <= 50) {\n for ($i = 1; $i <= $number; $i++) {\n $commands[] = trim(fgets(STDIN));\n }\n for ($j = 0; $j < count($commands); $j++) {\n if ($j != (count($commands) - 1)) {\n parse_command($commands[$j]);\n } else {\n parse_command($commands[$j], true);\n }\n }\n} else {\n fwrite(STDERR, 'invalid commands count');\n}\n\nfunction parse_command($str, $last = false) {\n global $home_dir;\n if ($str == \"pwd\") {\n if ($last == false) {\n $last_str = \"\\n\";\n } else {\n $last_str = \"\";\n }\n if ($home_dir != '/' && !empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $home_dir . \"/\" . $last_str);\n } else if (empty($home_dir)) {\n fwrite(STDOUT, \"/\" . $last_str);\n } else {\n fwrite(STDOUT, $home_dir . $last_str);\n }\n } else if (substr($str, 0, 2) == \"cd\") {\n $cmd = trim(substr($str, 2));\n $cmd = explode('/', $cmd);\n $home_dir = explode('/', $home_dir);\n for ($j = 0; $j < count($cmd); $j++) {\n if ($j == 0 && empty($cmd[$j])) {\n $home_dir = array();\n } else if ($cmd[$j] == '..') {\n if (count($home_dir) > 1) {\n unset($home_dir[count($home_dir) - 1]);\n } else {\n $home_dir = array();\n }\n } else {\n if (count($home_dir) == 2 && empty($home_dir[0]) && empty($home_dir[1])) {\n $home_dir = array();\n $home_dir[] = $cmd[$j];\n } else {\n $home_dir[] = $cmd[$j];\n }\n }\n }\n $home_dir = implode('/', $home_dir);\n $home_dir = $home_dir;\n } else {\n fwrite(STDERR, 'invalid command');\n }\n}\n\n?>\n"}, {"source_code": ""}, {"source_code": " 1) {\n if($directory[0] !== '/') $directory = '/'.$directory;\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n if($directory[strlen($directory)-2] == '/') $directory[strlen($directory)-1] = '';\n }\n\n while (substr_count($directory, '//')) {\n $directory = str_replace('//', '/', $directory);\n }\n}\n\n$text = explode(\"\\r\\n\", $text);\nforeach($text as $val) {\n $val = trim($val);\n if(substr($val, 0, 3) == 'pwd') {\n refresh();\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n echo trim(str_replace('//', '/', $directory)).\"/\\r\\n\";\n continue;\n }\n\n if(substr($val, 0, 2) == 'cd') {\n\n $path = str_replace('cd ', '', $val);\n if($path == '..') {\n $d = explode(\"/\", $directory);\n unset($d[count($d)-1]);\n $directory = implode(\"/\", $d);\n } else {\n if(substr($path, 0, 1) == '/') {\n $directory = $path;\n } else {\n $directory .= '/'.$path;\n }\n\n refresh();\n }\n }\n}"}, {"source_code": " $value) {\n $d[$key] = trim($d[$key]);\n if($value == '..') { \n unset($d[$key]);\n unset($d[$key-1]);\n if(substr_count($directory, '../..'))\n $d = array_values($d);\n }\n\n \n }\n $directory = implode(\"/\", $d);\n\n if(strlen($directory) > 1) {\n if($directory[0] !== '/') $directory = '/'.$directory;\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n }\n\n while (substr_count($directory, '//')) {\n $directory = str_replace('//', '/', $directory);\n }\n}\n\n$text = explode(\"\\r\\n\", $text);\nforeach($text as $val) {\n $val = trim($val);\n if(substr($val, 0, 3) == 'pwd') {\n refresh();\n \n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n echo trim($directory).\"/\\r\\n\";\n continue;\n }\n\n if(substr($val, 0, 2) == 'cd') {\n\n $path = str_replace('cd ', '', $val);\n if($path == '..') {\n $d = explode(\"/\", $directory);\n unset($d[count($d)-1]);\n $directory = implode(\"/\", $d);\n } else {\n if(substr($path, 0, 1) == '/') {\n $directory = $path;\n } else {\n $directory .= '/'.$path;\n }\n\n refresh();\n }\n }\n}"}, {"source_code": " 1) {\n if($directory[0] !== '/') $directory = '/'.$directory;\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n if($directory[strlen($directory)-2] == '/') $directory[strlen($directory)-1] = '';\n }\n\n while (substr_count($directory, '//')) {\n $directory = str_replace('//', '/', $directory);\n }\n}\n\n$text = explode(\"\\r\\n\", $text);\nforeach($text as $val) {\n $val = trim($val);\n if(substr($val, 0, 3) == 'pwd') {\n refresh();\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n echo trim(str_replace('//', '/', $directory)).\"/\\r\\n\";\n continue;\n }\n\n if(substr($val, 0, 2) == 'cd') {\n\n $path = str_replace('cd ', '', $val);\n if($path == '..') {\n $d = explode(\"/\", $directory);\n unset($d[count($d)-1]);\n $directory = implode(\"/\", $d);\n } else {\n if(substr($path, 0, 1) == '/') {\n $directory = $path;\n } else {\n $directory .= '/'.$path;\n }\n\n refresh();\n }\n }\n}"}, {"source_code": " 1) {\n if($directory[0] !== '/') $directory = '/'.$directory;\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n }\n\n while (substr_count($directory, '//')) {\n $directory = str_replace('//', '/', $directory);\n }\n}\n\n$text = explode(\"\\r\\n\", $text);\nforeach($text as $val) {\n $val = trim($val);\n if(substr($val, 0, 3) == 'pwd') {\n refresh();\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n echo trim(str_replace('//', '/', $directory)).\"/\\r\\n\";\n continue;\n }\n\n if(substr($val, 0, 2) == 'cd') {\n\n $path = str_replace('cd ', '', $val);\n if($path == '..') {\n $d = explode(\"/\", $directory);\n unset($d[count($d)-1]);\n $directory = implode(\"/\", $d);\n } else {\n if(substr($path, 0, 1) == '/') {\n $directory = $path;\n } else {\n $directory .= '/'.$path;\n }\n\n refresh();\n }\n }\n}"}, {"source_code": " 1) {\n if($directory[0] !== '/') $directory = '/'.$directory;\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n }\n\n while (substr_count($directory, '//')) {\n $directory = str_replace('//', '/', $directory);\n }\n}\n\n$text = explode(\"\\r\\n\", $text);\nforeach($text as $val) {\n $val = trim($val);\n if(substr($val, 0, 3) == 'pwd') {\n refresh();\n if($directory[strlen($directory)-1] == '/') $directory[strlen($directory)-1] = '';\n echo trim(str_replace('//', '/', $directory)).\"/\\r\\n\";\n continue;\n }\n\n if(substr($val, 0, 2) == 'cd') {\n\n $path = str_replace('cd ', '', $val);\n if($path == '..') {\n $d = explode(\"/\", $directory);\n unset($d[count($d)-1]);\n $directory = implode(\"/\", $d);\n } else {\n if(substr($path, 0, 1) == '/') {\n $directory = $path;\n } else {\n $directory .= '/'.$path;\n }\n\n refresh();\n }\n }\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "0) {\n array_push($absolutePathArray, $step);\n }\n }\n }\n "}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n if ($catalog !== '') {\n $dir = explode('/', $catalog); \n $count = count($dir); \n } else {\n $dir = Array();\n $count = 0;\n }\n \n $commands = explode('/', $command[1]);\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[$count - 1]);\n $count = $count - 1;\n } else {\n $dir[$count] = $cmd;\n $count++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] == '/') {\n $catalog = $command[1];\n } else {\n if ($catalog == '') {\n $catalog = '/';\n }\n $catalog .= '/'.$command[1];\n }\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/
';\n } else {\n echo $catalog.'
';\n }\n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $count = count($dir); \n $commands = explode('/', $command[1]);\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[$count - 1]);\n $count = $count - 1;\n } else {\n $dir[$count] = $cmd;\n $count++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] == '/') {\n $catalog = $command[1];\n } else {\n if ($catalog == '') {\n $catalog = '/';\n }\n $catalog .= $command[1];\n }\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]); \n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)] = $cmd;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] !== '/') {\n $catalog .= '/';\n $catalog .= $command[1];\n } else {\n $catalog = $command[1];\n } \n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $count = count($dir); \n $commands = explode('/', $command[1]);\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[$count - 1]);\n $count = $count - 1;\n } else {\n $dir[$count] = $cmd;\n $count++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n \n $catalog .= $command[1];\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n if ($catalog !== '') {\n $dir = explode('/', $catalog); \n $count = count($dir); \n } else {\n $dir = Array();\n $count = 0;\n }\n \n $commands = explode('/', $command[1]);\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[$count - 1]);\n $count = $count - 1;\n } else {\n $dir[$count] = $cmd;\n $count++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] == '/') {\n $catalog = $command[1];\n } else {\n if ($catalog == '') {\n $catalog = '/';\n }\n $catalog .= '/'.$command[1];\n }\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n }\n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]);\n $j = 1;\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)+$j] = $cmd;\n $j++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n \n $catalog .= $command[1];\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n if ($catalog !== '') {\n $dir = explode('/', $catalog); \n $count = count($dir); \n } else {\n $dir = Array();\n $count = 0;\n }\n \n $commands = explode('/', $command[1]);\n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[$count - 1]);\n $count = $count - 1;\n } else {\n $dir[$count] = $cmd;\n $count++;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] == '/') {\n $catalog = $command[1];\n } else {\n if ($catalog == '') {\n $catalog = '/';\n $catalog .= $command[1];\n } else {\n $catalog .= '/'.$command[1];\n }\n }\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n }\n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]); \n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)] = $cmd;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if (substr($catalog, - 1) != '/') {\n $catalog .= '/';\n }\n $catalog .= $command[1];\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]); \n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)] = $cmd;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n \n $catalog .= $command[1];\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]); \n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)] = $cmd;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if ($command[1][0] !== '/') {\n $catalog .= '/';\n }\n $catalog .= $command[1];\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": "$value) { \n if ($value[0] == 'c') {\n $command = explode(' ', $value); \n if ($command[1][0] == '/') {\n $catalog = $command[1];\n } else { \n if (strpos($command[1], '..') !== false) { \n $dir = explode('/', $catalog); \n $commands = explode('/', $command[1]); \n foreach ($commands as $cmd) {\n if ($cmd == '..') {\n unset($dir[count($dir)-1]);\n } else {\n $dir[count($dir)] = $cmd;\n }\n }\n $catalog = '';\n foreach ($dir as $d) {\n if (strlen($d) !== 0) {\n $catalog .= '/'.$d;\n }\n }\n } else {\n if (substr($catalog, - 1) != '/') {\n $catalog .= '/';\n }\n $catalog .= $command[1];\n }\n }\n }\n else if ($value[0] == 'p') {\n if (substr($catalog, -1) !== '/') {\n echo $catalog.'/'.PHP_EOL;\n } else {\n echo $catalog.PHP_EOL;\n } \n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0)\n echo '/'.implode('/', $curr).\"/\\n\";\n else \n echo '/';\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0)\n echo '/'.implode('/', $curr).\"/\\n\";\n else \n echo \"/\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": "\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0) {\n echo \"/\".implode(\"/\", $curr).\"/\";\n } else {\n echo \"/\";\n }\n echo \"\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0)\n echo \"/\".implode(\"/\", $curr).\"/\\r\\n\";\n else \n echo \"/\\r\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0) {\n echo \"/\".implode(\"/\", $curr).\"/\";\n } else {\n echo \"/\";\n }\n echo \"\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0) {\n echo \"/\".implode(\"/\", $curr).\"/\";\n } else {\n echo \"/\";\n }\n echo \"\\n\";\n } else if($action == \"cd\"){\n $exp_path = explode(\"/\", $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == \"\"){\n $curr = array();\n } else {\n if($value == \"..\"){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0)\n print(\"/\".implode(\"/\", $curr).\"/\\n\");\n else \n print \"/\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0) {\n echo \"/\".implode(\"/\", $curr).\"/\";\n } else {\n echo \"/\";\n }\n echo \"\\n\";\n } else if($action == \"cd\"){\n $exp_path = explode(\"/\", $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == \"\"){\n $curr = array();\n } else {\n if($value == \"..\"){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " 0) {\n echo \"/\".implode(\"/\", $curr).\"/\";\n } else {\n echo \"/\";\n }\n echo \"\\n\";\n } else if($action == 'cd'){\n $exp_path = explode('/', $exp[1]);\n foreach($exp_path AS $key => $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": " $value){\n if($key == 0 && $value == ''){\n $curr = array();\n } else {\n if($value == '..'){\n array_pop($curr);\n } else {\n $curr[] = $value;\n }\n }\n }\n }\n}"}, {"source_code": "waitCommand();\n}\n\n$aStack = $oPath->getStack();\n\nforeach ($aStack as $sPath) {\n\techo $sPath . PHP_EOL;\n}\n\nclass Path {\n\tconst CD = 'cd';\n\tconst PWD = 'pwd';\n\t\n\tprivate $aCurrentPath = array();\n\tprivate $aStack = array();\n\t\n\tpublic function __construct($iCommandsCount) {\n\t\t$this->iCommandsCount = $iCommandsCount;\n\t\t$this->setRootPath();\n\t}\n\t\n\tpublic function waitCommand() {\n\t\t$sCommand = $this->getCommand();\n\n\t\tif ($sCommand == self::PWD) {\n\t\t\t$this->addPathToStack();\n\t\t} else {\n\t\t\t$sPath = $this->getPath($sCommand);\n\t\t\t$this->setCurrentPath($sPath);\n\t\t}\n\t}\n\t\n\tpublic function getStack() {\n\t\treturn $this->aStack;\n\t}\n\t\n\tprivate function addPathToStack() {\n\t\t$this->aStack[] = empty($this->aCurrentPath) ? '/' : '/' . implode('/', $this->aCurrentPath) . '/';\n\t}\n\t\n\tprivate function getPath($sCommand) {\n\t\t$aCommand = explode(' ', $sCommand, 2);\n\t\t\n\t\tif (count($aCommand) != 2) {\n\t\t\tdie;\n\t\t}\n\t\t\n\t\treturn $aCommand[1];\n\t}\n\t\n\tprivate function setCurrentPath($sPath) {\n\t\t$aPath = explode('/', $sPath);\n\t\t\n\t\tif (empty($aPath[0])) {\n\t\t\t$this->setRootPath();\n\t\t}\n\t\t\n\t\tforeach ($aPath as $sDir) {\n\t\t\tif ($sDir == '..') {\n\t\t\t\tarray_pop($this->aCurrentPath);\n\t\t\t}\n\t\t\telseif (empty($sDir)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\t$this->aCurrentPath[] = $sDir;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tprivate function setRootPath() {\n\t\t$this->aCurrentPath = array();\n\t}\n\t\n\tprivate function getCommand() {\n\t\t$sCommand = fgets(STDIN);\n\t\t$sCommand = str_replace(\"\\n\", '', $sCommand);\n\t\treturn $sCommand;\n\t}\n}"}, {"source_code": "waitCommand();\n}\n\n$aStack = $oPath->getStack();\n\nforeach ($aStack as $sPath) {\n\tif (isset($bFlag)) {\n\t\techo PHP_EOL;\n\t} else {\n\t\t$bFlag = true;\n\t}\n\techo $sPath;\n}\n\nclass Path {\n\tconst CD = 'cd';\n\tconst PWD = 'pwd';\n\t\n\tprivate $aCurrentPath = array();\n\tprivate $aStack = array();\n\t\n\tpublic function __construct($iCommandsCount) {\n\t\t$this->iCommandsCount = $iCommandsCount;\n\t\t$this->setRootPath();\n\t}\n\t\n\tpublic function waitCommand() {\n\t\t$sCommand = $this->getCommand();\n\n\t\tif ($sCommand == self::PWD) {\n\t\t\t$this->addPathToStack();\n\t\t} else {\n\t\t\t$sPath = $this->getPath($sCommand);\n\t\t\t$this->setCurrentPath($sPath);\n\t\t}\n\t}\n\t\n\tpublic function getStack() {\n\t\treturn $this->aStack;\n\t}\n\t\n\tprivate function addPathToStack() {\n\t\t$this->aStack[] = empty($this->aCurrentPath) ? '/' : '/' . implode('/', $this->aCurrentPath) . '/';\n\t}\n\t\n\tprivate function getPath($sCommand) {\n\t\t$aCommand = explode(' ', $sCommand, 2);\n\t\t\n\t\tif (count($aCommand) != 2) {\n\t\t\tdie;\n\t\t}\n\t\t\n\t\treturn $aCommand[1];\n\t}\n\t\n\tprivate function setCurrentPath($sPath) {\n\t\t$aPath = explode('/', $sPath);\n\t\t\n\t\tif (empty($aPath[0])) {\n\t\t\t$this->setRootPath();\n\t\t}\n\t\t\n\t\tforeach ($aPath as $sDir) {\n\t\t\tif ($sDir == '..') {\n\t\t\t\tarray_pop($this->aCurrentPath);\n\t\t\t}\n\t\t\telseif (empty($sDir)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\t$this->aCurrentPath[] = $sDir;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tprivate function setRootPath() {\n\t\t$this->aCurrentPath = array();\n\t}\n\t\n\tprivate function getCommand() {\n\t\t$sCommand = fgets(STDIN);\n\t\t$sCommand = str_replace(\"\\n\", '', $sCommand);\n\t\treturn $sCommand;\n\t}\n}"}, {"source_code": "processCommand();\n}\n\n$oPath->showStack();\n\nclass Path {\n const CD = 'cd';\n const PWD = 'pwd';\n \n private $aCurrentPath = array();\n private $aStack = array();\n \n public function __construct($iCommandsCount) {\n $this->iCommandsCount = $iCommandsCount;\n $this->setRootPath();\n }\n \n public function processCommand() {\n $sCommand = $this->getCommand();\n echo $sCommand . '==' . self::PWD;\n if ($sCommand == self::PWD) {\n $this->addPathToStack();\n } else {\n $sPath = $this->getPath($sCommand);\n $this->setCurrentPath($sPath);\n }\n }\n \n public function showStack() {\n echo implode(\"\\n\", $this->aStack);\n }\n \n private function addPathToStack() {\n $sResult = empty($this->aCurrentPath) ? '/' : '/' . implode('/', $this->aCurrentPath) . '/';\n \n $this->aStack[] = $sResult;\n }\n \n private function getPath($sCommand) {\n $aCommand = explode(' ', $sCommand, 2);\n \n if (count($aCommand) != 2) {\n die;\n }\n \n return $aCommand[1];\n }\n \n private function setCurrentPath($sPath) {\n $aPath = explode('/', $sPath);\n \n if (empty($aPath[0])) {\n $this->setRootPath();\n }\n \n foreach ($aPath as $sDir) {\n if ($sDir == '..') {\n array_pop($this->aCurrentPath);\n }\n elseif (empty($sDir)) {\n continue;\n } else {\n $this->aCurrentPath[] = $sDir;\n }\n }\n \n }\n \n private function setRootPath() {\n $this->aCurrentPath = array();\n }\n \n private function getCommand() {\n $sCommand = fgets(STDIN);\n $sCommand = str_replace(\"\\n\", '', $sCommand);\n $sCommand = trim($sCommand);\n return $sCommand;\n }\n}"}, {"source_code": "\";\n }\n }"}, {"source_code": "\";\n }\n }"}, {"source_code": " 0 )\n {\n array_pop( $path );\n }\n }\n else\n {\n $path[] = $parts[ $i ];\n }\n }\n return '/'. implode( '/', $path ) . '/';\n}\n\nfile_put_contents( 'php://stdout', implode( \"\\n\", $result ) );"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": " 0) {\n array_pop($path);\n }\n } else {\n $path[] = $folder;\n }\n }\n\n}\n\nfunction print_path($path) {\n if (!empty($path)) {\n $path = implode(\"/\",$path).\"/\";\n } else {\n $path = \"\";\n }\n fputs(STDOUT, \"/\". $path.\"\\r\\n\");\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "494ac937ba939db1dbc4081e518ab54c"} {"nl": {"description": "You are given a string $$$s$$$, consisting of $$$n$$$ letters, each letter is either 'a' or 'b'. The letters in the string are numbered from $$$1$$$ to $$$n$$$.$$$s[l; r]$$$ is a continuous substring of letters from index $$$l$$$ to $$$r$$$ of the string inclusive. A string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \"baba\" and \"aabbab\" are balanced and strings \"aaab\" and \"b\" are not.Find any non-empty balanced substring $$$s[l; r]$$$ of string $$$s$$$. Print its $$$l$$$ and $$$r$$$ ($$$1 \\le l \\le r \\le n$$$). If there is no such substring, then print $$$-1$$$ $$$-1$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of the testcase contains a single integer $$$n$$$ ($$$1 \\le n \\le 50$$$)\u00a0\u2014 the length of the string. The second line of the testcase contains a string $$$s$$$, consisting of $$$n$$$ letters, each letter is either 'a' or 'b'.", "output_spec": "For each testcase print two integers. If there exists a non-empty balanced substring $$$s[l; r]$$$, then print $$$l$$$ $$$r$$$ ($$$1 \\le l \\le r \\le n$$$). Otherwise, print $$$-1$$$ $$$-1$$$.", "sample_inputs": ["4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa"], "sample_outputs": ["-1 -1\n1 6\n3 6\n2 5"], "notes": "NoteIn the first testcase there are no non-empty balanced subtrings.In the second and third testcases there are multiple balanced substrings, including the entire string \"abbaba\" and substring \"baba\"."}, "positive_code": [{"source_code": ""}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $res = [-1, -1];\r\n foreach ($a as $k => $v) {\r\n if (isset($a[$k+1])) {\r\n if ($v != $a[$k+1]) {\r\n $res = [$k+1, $k+2];\r\n break;\r\n }\r\n }\r\n }\r\n IO::line(implode(' ', $res));\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [{"source_code": ""}], "src_uid": "127d7f23a0ac8fcecccd687565d6f35a"} {"nl": {"description": "For the first place at the competition, Alex won many arrays of integers and was assured that these arrays are very expensive. After the award ceremony Alex decided to sell them. There is a rule in arrays pawnshop: you can sell array only if it can be compressed to a generator.This generator takes four non-negative numbers $$$n$$$, $$$m$$$, $$$c$$$, $$$s$$$. $$$n$$$ and $$$m$$$ must be positive, $$$s$$$ non-negative and for $$$c$$$ it must be true that $$$0 \\leq c < m$$$. The array $$$a$$$ of length $$$n$$$ is created according to the following rules: $$$a_1 = s \\bmod m$$$, here $$$x \\bmod y$$$ denotes remainder of the division of $$$x$$$ by $$$y$$$; $$$a_i = (a_{i-1} + c) \\bmod m$$$ for all $$$i$$$ such that $$$1 < i \\le n$$$. For example, if $$$n = 5$$$, $$$m = 7$$$, $$$c = 4$$$, and $$$s = 10$$$, then $$$a = [3, 0, 4, 1, 5]$$$.Price of such an array is the value of $$$m$$$ in this generator.Alex has a question: how much money he can get for each of the arrays. Please, help him to understand for every array whether there exist four numbers $$$n$$$, $$$m$$$, $$$c$$$, $$$s$$$ that generate this array. If yes, then maximize $$$m$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^5$$$)\u00a0\u2014 the number of arrays. The first line of array description contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the size of this array. The second line of array description contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\leq a_i \\leq 10^9$$$ )\u00a0\u2014 elements of the array. It is guaranteed that the sum of array sizes does not exceed $$$10^5$$$.", "output_spec": "For every array print: $$$-1$$$, if there are no such four numbers that generate this array; $$$0$$$, if $$$m$$$ can be arbitrary large; the maximum value $$$m$$$ and any appropriate $$$c$$$ ($$$0 \\leq c < m$$$) in other cases. ", "sample_inputs": ["6\n6\n1 9 17 6 14 3\n3\n4 2 2\n3\n7 3 4\n3\n2 2 4\n5\n0 1000000000 0 1000000000 0\n2\n1 1"], "sample_outputs": ["19 8\n-1\n-1\n-1\n2000000000 1000000000\n0"], "notes": null}, "positive_code": [{"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\t$c0 = array_values($c0);\n\n\t\tif (count($c0) == 1 || $n == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tif (count($c0) != 2) {\n\t\t\tprint \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif (($m < $max) || ($m <= $c_ans)) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}], "negative_code": [{"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\t$c0 = array_values($c0);\n\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tif (count($c0) != 2) {\n\t\t\tprint \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif (($m < $max) || ($m <= $c_ans)) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\t$c0 = array_values($c0);\n\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tif ($n == 6592) {\n\t\t\tprint \"!\".count($c0);\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif (($m < $max) || ($m <= $c_ans)) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\t$c0 = array_values($c0);\n\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tif (($c0[0] >= 0 && $c0[1] < 0) || ($c0[0] < 0 && $c0[1] >= 0)) {\n\t\t\tforeach ($c0 as $c) {\n\t\t\t\t$m += abs($c);\n\t\t\t\tif ($c >= 0) {\n\t\t\t\t\t$c_ans = $c;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tprint \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (($m < $max) || ($m <= $c_ans)) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\t$c0 = array_values($c0);\n\n\t\tif (count($c0) == 1 && $c0[0] >= 0) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tif (($c0[0] >= 0 && $c0[1] < 0) || ($c0[0] < 0 && $c0[1] >= 0)) {\n\t\t\tforeach ($c0 as $c) {\n\t\t\t\t$m += abs($c);\n\t\t\t\tif ($c >= 0) {\n\t\t\t\t\t$c_ans = $c;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tprint \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (($m < $max) || ($m <= $c_ans)) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif ($m < $max || $c_ans > $m) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\n\t\tprint \"!(\".count($c0).\")\\n\\n\";\n\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif ($m < $max || $c_ans > $m) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}, {"source_code": " $max) {\n\t\t\t\t$max = $a[$i];\n\t\t\t}\n\t\t\tif ($i >= 1) {\n\t\t\t\t$b[$i-1] = $a[$i] - $a[$i-1];\n\t\t\t\t$c0[$a[$i] - $a[$i-1]] = $a[$i] - $a[$i-1];\n\t\t\t}\n\t\t}\n\n\t\t$m = 0;\n\t\t$c_ans = 0;\n\t\tif (count($c0) == 1) {\n\t\t\tprint \"0\".\"\\n\";\n\t\t\tcontinue;\t\n\t\t}\n\t\tforeach ($c0 as $c) {\n\t\t\t$m += abs($c);\n\t\t\tif ($c >= 0) {\n\t\t\t\t$c_ans = $c;\n\t\t\t}\n\t\t}\n\n\t\tif ($m < $max) {\n\t\t\tprint \"-1\\n\";\n\t\t} else {\n\t\t\tprint $m.\" \".$c_ans.\"\\n\";\n\t\t}\n\n\t}\n?>"}], "src_uid": "d6721fb3dd02535fc08fc69a4811d60c"} {"nl": {"description": "Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems, A, B, C, D and E. For each of these problem, depending on when the given problem was solved and whether it was solved at all, the participants receive some points. Besides, a contestant can perform hacks on other contestants. For each successful hack a contestant earns 100 points, for each unsuccessful hack a contestant loses 50 points. The number of points for every contestant is represented by the sum of points he has received from all his problems, including hacks.You are suggested to determine the leader for some room; the leader is a participant who has maximum points.", "input_spec": "The first line contains an integer n, which is the number of contestants in the room (1\u2009\u2264\u2009n\u2009\u2264\u200950). The next n lines contain the participants of a given room. The i-th line has the format of \"handlei plusi minusi ai bi ci di ei\" \u2014 it is the handle of a contestant, the number of successful hacks, the number of unsuccessful hacks and the number of points he has received from problems A, B, C, D, E correspondingly. The handle of each participant consists of Latin letters, digits and underscores and has the length from 1 to 20 characters. There are the following limitations imposed upon the numbers: 0\u2009\u2264\u2009plusi,\u2009minusi\u2009\u2264\u200950; 150\u2009\u2264\u2009ai\u2009\u2264\u2009500 or ai\u2009=\u20090, if problem A is not solved; 300\u2009\u2264\u2009bi\u2009\u2264\u20091000 or bi\u2009=\u20090, if problem B is not solved; 450\u2009\u2264\u2009ci\u2009\u2264\u20091500 or ci\u2009=\u20090, if problem C is not solved; 600\u2009\u2264\u2009di\u2009\u2264\u20092000 or di\u2009=\u20090, if problem D is not solved; 750\u2009\u2264\u2009ei\u2009\u2264\u20092500 or ei\u2009=\u20090, if problem E is not solved. All the numbers are integer. All the participants have different handles. It is guaranteed that there is exactly one leader in the room (i.e. there are no two participants with the maximal number of points).", "output_spec": "Print on the single line the handle of the room leader.", "sample_inputs": ["5\nPetr 3 1 490 920 1000 1200 0\ntourist 2 0 490 950 1100 1400 0\nEgor 7 0 480 900 950 0 1000\nc00lH4x0R 0 10 150 0 0 0 0\nsome_participant 2 1 450 720 900 0 0"], "sample_outputs": ["tourist"], "notes": "NoteThe number of points that each participant from the example earns, are as follows: Petr \u2014 3860 tourist \u2014 4140 Egor \u2014 4030 c00lH4x0R \u2014 \u2009-\u2009350 some_participant \u2014 2220 Thus, the leader of the room is tourist."}, "positive_code": [{"source_code": ""}, {"source_code": "$max)||($maxnick==\"\")){\n $max = $r;\n $maxnick = $nick; \n }\n}\necho $maxnick;\n?>"}, {"source_code": "\n$n=trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++)\n $arr[]=explode(' ',trim(fgets(STDIN)));\n\n//print_r($arr);\nforeach($arr as $val){\n $sum[]=array($val[0],$val[1]*100-$val[2]*50+$val[3]+$val[4]+$val[5]+$val[6]+$val[7]);\n}\nfunction cmp($a,$b){\n return $a[1]<$b[1];\n}\n//print_r($sum);\nusort($sum,'cmp');\n//print_r($sum);\necho $sum[0][0];\n?>"}], "negative_code": [{"source_code": "$max){\n $max = $r;\n $maxnick = $nick; \n }\n}\necho $maxnick;\n?>"}], "src_uid": "b9dacff0cab78595296d697d22dce5d9"} {"nl": {"description": "The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p_i$$$ are distinct integers from $$$1$$$ to $$$n$$$ (i.e. $$$p$$$ is a permutation). The sequence $$$p$$$ doesn't change from day to day, it is fixed.For example, if $$$n=6$$$ and $$$p=[4, 6, 1, 3, 5, 2]$$$ then at the end of the first day the book of the $$$1$$$-st kid will belong to the $$$4$$$-th kid, the $$$2$$$-nd kid will belong to the $$$6$$$-th kid and so on. At the end of the second day the book of the $$$1$$$-st kid will belong to the $$$3$$$-th kid, the $$$2$$$-nd kid will belong to the $$$2$$$-th kid and so on.Your task is to determine the number of the day the book of the $$$i$$$-th child is returned back to him for the first time for every $$$i$$$ from $$$1$$$ to $$$n$$$.Consider the following example: $$$p = [5, 1, 2, 4, 3]$$$. The book of the $$$1$$$-st kid will be passed to the following kids: after the $$$1$$$-st day it will belong to the $$$5$$$-th kid, after the $$$2$$$-nd day it will belong to the $$$3$$$-rd kid, after the $$$3$$$-rd day it will belong to the $$$2$$$-nd kid, after the $$$4$$$-th day it will belong to the $$$1$$$-st kid. So after the fourth day, the book of the first kid will return to its owner. The book of the fourth kid will return to him for the first time after exactly one day.You have to answer $$$q$$$ independent queries.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 200$$$) \u2014 the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \\le n \\le 200$$$) \u2014 the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \\dots, p_n$$$ ($$$1 \\le p_i \\le n$$$, all $$$p_i$$$ are distinct, i.e. $$$p$$$ is a permutation), where $$$p_i$$$ is the kid which will get the book of the $$$i$$$-th kid.", "output_spec": "For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query.", "sample_inputs": ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"], "sample_outputs": ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "345e76bf67ae4342e850ab248211eb0b"} {"nl": {"description": "During a daily walk Alina noticed a long number written on the ground. Now Alina wants to find some positive number of same length without leading zeroes, such that the sum of these two numbers is a palindrome. Recall that a number is called a palindrome, if it reads the same right to left and left to right. For example, numbers $$$121, 66, 98989$$$ are palindromes, and $$$103, 239, 1241$$$ are not palindromes.Alina understands that a valid number always exist. Help her find one!", "input_spec": "The first line of input data contains an integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$) \u2014 the number of test cases. Next, descriptions of $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\leq n \\leq 100\\,000$$$) \u2014 the length of the number that is written on the ground. The second line of contains the positive $$$n$$$-digit integer without leading zeroes \u2014 the number itself. It is guaranteed that the sum of the values $$$n$$$ over all test cases does not exceed $$$100\\,000$$$.", "output_spec": "For each of $$$t$$$ test cases print an answer \u2014 a positive $$$n$$$-digit integer without leading zeros, such that the sum of the input integer and this number is a palindrome. We can show that at least one number satisfying the constraints exists. If there are multiple solutions, you can output any of them.", "sample_inputs": ["3\n2\n99\n4\n1023\n3\n385"], "sample_outputs": ["32\n8646\n604"], "notes": "NoteIn the first test case $$$99 + 32 = 131$$$ is a palindrome. Note that another answer is $$$12$$$, because $$$99 + 12 = 111$$$ is also a palindrome.In the second test case $$$1023 + 8646 = 9669$$$.In the third test case $$$385 + 604 = 989$$$."}, "positive_code": [{"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n\r\n?>"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " '9',\r\n '1' => '2',\r\n '2' => '3',\r\n '3' => '4',\r\n '4' => '5',\r\n '5' => '6',\r\n '6' => '7',\r\n '7' => '8',\r\n '8' => '9',\r\n '9' => '8',\r\n ];\r\n if($pN == 0) {\r\n $sDP = '';\r\n $sRev = strrev($s);\r\n for($i=0; $imax($sa)) {\r\n $nCount = $n;\r\n } else {\r\n $nCount = $n +1;\r\n }\r\n $sPolindrom = '';\r\n for($i=0; $i<$nCount; $i++) {\r\n $sPolindrom .= $pN;\r\n }\r\n $ans = bcsub($sPolindrom, $s);\r\n }\r\n \r\n \r\n IO::pr($ans);\r\n \r\n}\r\n\r\n\r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " '9',\r\n '1' => '9',\r\n '2' => '7',\r\n '3' => '6',\r\n '4' => '5',\r\n '5' => '4',\r\n '6' => '3',\r\n '7' => '2',\r\n '8' => '1',\r\n '9' => '0',\r\n ];\r\n if($pN == 0) {\r\n $sDP = '';\r\n $sRev = strrev($s);\r\n for($i=0; $i max($sa)) {\r\n $nCount = $n;\r\n } else {\r\n $nCount = $n +1;\r\n }\r\n $sPolindrom = '';\r\n for($i=0; $i<$nCount; $i++) {\r\n $sPolindrom .= $pN;\r\n }\r\n $ans = bcsub($sPolindrom, $s);\r\n }\r\n \r\n \r\n IO::pr($ans);\r\n \r\n}\r\n\r\n\r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " max($sa)) {\r\n $nCount = $n; \r\n } else {\r\n $nCount = $n +1; \r\n }\r\n $sPolindrom = '';\r\n for($i=0; $i<$nCount; $i++) {\r\n $sPolindrom .= $pN; \r\n }\r\n $ans = bcsub($sPolindrom, $s); \r\n }\r\n \r\n \r\n IO::pr($ans);\r\n \r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " max($sa)) {\r\n $nCount = $n; \r\n } else {\r\n $nCount = $n +1; \r\n }\r\n $sPolindrom = '';\r\n for($i=0; $i<$nCount; $i++) {\r\n $sPolindrom .= $pN; \r\n }\r\n $ans = bcsub($sPolindrom, $s);\r\n \r\n IO::pr($ans);\r\n \r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 0; $i--) {\r\n if(!isset($ss[$i])) {\r\n $pN = $i;\r\n if($i < 9) {\r\n $nCount += 1; \r\n }\r\n break;\r\n }\r\n }\r\n $sPolindrom = '';\r\n for($i=0; $i<$nCount; $i++) {\r\n $sPolindrom .= $pN; \r\n }\r\n $ans = bcsub($sPolindrom, $s);\r\n \r\n IO::pr($ans);\r\n \r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d2[$c[$x]] == 1))\n {\n $d[$c[$x]]++;\n if($d[$b] >= $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n elseif($c[$x] == $b)\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($g[$x] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}], "negative_code": [{"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d[$c[$x]] >= 0))\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n elseif($c[$x] == $b)\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if($c[$x] != $b)\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n else\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d2[$c[$x]] == 1))\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n elseif($c[$x] == $b)\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if($c[$x] != $b)\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n else\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d2[$c[$x]] == 1))\n {\n $d[$c[$x]]++;\n if($d[$b] >= $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n elseif($c[$x] == $b)\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d[$c[$x]] >= 0))\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n else\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if($c[$x] != $b)\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n else\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\nif($a == 1000)\n{\n print_r($d);\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if($c[$x] != $b)\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n else\n {\n $d[$c[$x]]++;\n }\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}, {"source_code": "= 0; $x--)\n{\n if($c[$x] == $b)\n {\n $f++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a - $f; $x++)\n{\n if(($c[$x] != $b) && ($d[$c[$x]] >= 0))\n {\n $d[$c[$x]]++;\n if($d[$b] > $d[$c[$x]])\n {\n $e[$c[$x]] = 1;\n }\n }\n elseif($c[$x] == $b)\n {\n $d[$c[$x]]++;\n }\n}\nif($a == 1000)\n{\n print_r($d);\n}\n$d[$b] += $f;\n$g = array_keys($d);\nfor($x = 0; $x < count($d); $x++)\n{\n if($d[$g[$x]] != $b)\n {\n if($d[$g[$x]] < $d[$b])\n {\n $e[$g[$x]] = 1;\n }\n }\n}\n$h = 0;\nif($a == 1000)\n{\n print_r($e);\n}\nfor($x = 0; $x < count($e); $x++)\n{\n if(($e[$g[$x]] == 0) && ($g[$x] != $b))\n {\n $h = 1;\n break;\n }\n}\nif($h == 0)\n{\n print \"-1\";\n}\nelse\n{\n print $g[$x];\n}\n?>"}], "src_uid": "c6713175ad447b41b897a5904b7fe714"} {"nl": {"description": "There's a chessboard of size $$$n \\times n$$$. $$$m$$$ rooks are placed on it in such a way that: no two rooks occupy the same cell; no two rooks attack each other. A rook attacks all cells that are in its row or column.Is it possible to move exactly one rook (you can choose which one to move) into a different cell so that no two rooks still attack each other? A rook can move into any cell in its row or column if no other rook stands on its path.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 2000$$$)\u00a0\u2014 the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 8$$$)\u00a0\u2014 the size of the chessboard and the number of the rooks. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \\le x_i, y_i \\le n$$$)\u00a0\u2014 the position of the $$$i$$$-th rook: $$$x_i$$$ is the row and $$$y_i$$$ is the column. No two rooks occupy the same cell. No two rooks attack each other.", "output_spec": "For each testcase, print \"YES\" if it's possible to move exactly one rook into a different cell so that no two rooks still attack each other. Otherwise, print \"NO\".", "sample_inputs": ["2\n\n2 2\n\n1 2\n\n2 1\n\n3 1\n\n2 2"], "sample_outputs": ["NO\nYES"], "notes": "NoteIn the first testcase, the rooks are in the opposite corners of a $$$2 \\times 2$$$ board. Each of them has a move into a neighbouring corner, but moving there means getting attacked by another rook.In the second testcase, there's a single rook in a middle of a $$$3 \\times 3$$$ board. It has $$$4$$$ valid moves, and every move is fine because there's no other rook to attack it."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": " 10) {\r\n $n -= 111;\r\n \r\n if ($n == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 0) {\r\n $n -= 111;\r\n if ($n <= 0) { break; }\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 0) {\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n $n -= 111;\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 10) {\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n $n -= 111;\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 10) {\r\n $n -= 111;\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 10) {\r\n $c = '';\r\n $len = strlen($n);\r\n while ($len--) { $c .= 1; }\r\n $n = $n - $c;\r\n if ($n % 11 == 0) { echo 'YES'.PHP_EOL; $f = 1; break; }\r\n }\r\n \r\n if ($f == 0) { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n\r\n?>"}], "src_uid": "e5e937f080b20eaec5f12f1784ae6427"} {"nl": {"description": "Today the \u00abZ\u00bb city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so that on the whole he makes exactly 3 shuffles. After that the spectators have exactly one attempt to guess in which cup they think the ball is and if the answer is correct they get a prize. Maybe you can try to find the ball too?", "input_spec": "The first input line contains an integer from 1 to 3 \u2014 index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description of a shuffle contains two distinct integers from 1 to 3 \u2014 indexes of the cups which the performer shuffled this time. The cups are numbered from left to right and are renumbered after each shuffle from left to right again. In other words, the cup on the left always has index 1, the one in the middle \u2014 index 2 and the one on the right \u2014 index 3.", "output_spec": "In the first line output an integer from 1 to 3 \u2014 index of the cup which will have the ball after all the shuffles. ", "sample_inputs": ["1\n1 2\n2 1\n2 1", "1\n2 1\n3 1\n1 3"], "sample_outputs": ["2", "2"], "notes": null}, "positive_code": [{"source_code": " $line) {\n$line=trim($line);\n if($line_num==0){$k[$line]=1;}else{\n$p=explode(' ', $line);\n$p1=$p[0];\n$p2=$p[1];\n\n$j=$k[$p1];\n$k[$p1]=$k[$p2];\n$k[$p2]=$j;\n\n\n}\n\n\n}\nif($k[1]==1){$t=1;}if($k[2]==1){$t=2;}if($k[3]==1){$t=3;}\n\n$handle = fopen('output.txt', 'a');\nfwrite($handle, $t);\nfclose($handle);\n?>\n"}], "negative_code": [], "src_uid": "88e6651e1b0481d711e89c8071be1edf"} {"nl": {"description": "You are given an array $$$a_1, a_2, \\dots a_n$$$. Count the number of pairs of indices $$$1 \\leq i, j \\leq n$$$ such that $$$a_i < i < a_j < j$$$.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$2 \\leq n \\leq 2 \\cdot 10^5$$$)\u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$0 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the elements of the array. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the number of pairs of indices satisfying the condition in the statement. Please note, that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).", "sample_inputs": ["5\n\n8\n\n1 1 2 3 8 2 1 4\n\n2\n\n1 2\n\n10\n\n0 2 1 6 3 4 1 2 8 3\n\n2\n\n1 1000000000\n\n3\n\n0 1000000000 2"], "sample_outputs": ["3\n0\n10\n0\n1"], "notes": "NoteFor the first test cases the pairs are $$$(i, j)$$$ = $$$\\{(2, 4), (2, 8), (3, 8)\\}$$$. The pair $$$(2, 4)$$$ is true because $$$a_2 = 1$$$, $$$a_4 = 3$$$ and $$$1 < 2 < 3 < 4$$$. The pair $$$(2, 8)$$$ is true because $$$a_2 = 1$$$, $$$a_8 = 4$$$ and $$$1 < 2 < 4 < 8$$$. The pair $$$(3, 8)$$$ is true because $$$a_3 = 2$$$, $$$a_8 = 4$$$ and $$$2 < 3 < 4 < 8$$$. "}, "positive_code": [{"source_code": "$v) {\r\n\t\tif($k < $v) {\r\n\t\t\tcontinue ;\r\n\t\t}\r\n\t\tif(!isset($con[$v])) {\r\n\t\t\t$con[$v] = [] ;\r\n\t\t}\r\n\t\t$tot += 1 ;\r\n\t\tarray_push($con[$v],$k+1) ;\r\n\t\tarray_push($glue,$k+1,$v) ;\r\n\t}\r\n\t// printLine($con);\r\n\t$glue = array_unique($glue);\r\n\tsort($glue) ;\r\n\t// printLine($glue);\r\n\t$tl = count($glue) ;\r\n\t$susu = array() ;\r\n\t$mew = 0 ;\r\n\t$fans = 0 ;\r\n\tforeach($con as $k=>$v) {\r\n\t\t$mew += count($v) ;\r\n\t\t$susu[$k] = $mew ;\r\n\t}\r\n\t// printLine($tl);\r\n\t// printLine(!isset($susu[$glue[1]]));\r\n\tfor($i=0;$i<$tl;$i++) {\r\n\t\tif(!isset($susu[$glue[$i]])) {\r\n\t\t\t$susu[$glue[$i]] = $susu[$glue[$i-1]] ;\r\n\t\t}\r\n\t}\r\n\t// printLine($susu);\r\n\r\n\tforeach($con as $k=>$v) {\r\n\t\t$sz = count($v); \r\n\t\tfor($j=0;$j<$sz;$j++) {\r\n\t\t\t$fans += $tot - $susu[$v[$j]] ;\r\n\t\t}\r\n\t}\r\n\tprintLine($fans);\r\n}\r\n"}], "negative_code": [], "src_uid": "89768e4c832428b534cae3acbf379c44"} {"nl": {"description": "Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.Gregor's favorite prime number is $$$P$$$. Gregor wants to find two bases of $$$P$$$. Formally, Gregor is looking for two integers $$$a$$$ and $$$b$$$ which satisfy both of the following properties. $$$P \\bmod a = P \\bmod b$$$, where $$$x \\bmod y$$$ denotes the remainder when $$$x$$$ is divided by $$$y$$$, and $$$2 \\le a < b \\le P$$$. Help Gregor find two bases of his favorite prime number!", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 1000$$$). Each subsequent line contains the integer $$$P$$$ ($$$5 \\le P \\le {10}^9$$$), with $$$P$$$ guaranteed to be prime.", "output_spec": "Your output should consist of $$$t$$$ lines. Each line should consist of two integers $$$a$$$ and $$$b$$$ ($$$2 \\le a < b \\le P$$$). If there are multiple possible solutions, print any.", "sample_inputs": ["2\n17\n5"], "sample_outputs": ["3 5\n2 4"], "notes": "NoteThe first query is $$$P=17$$$. $$$a=3$$$ and $$$b=5$$$ are valid bases in this case, because $$$17 \\bmod 3 = 17 \\bmod 5 = 2$$$. There are other pairs which work as well.In the second query, with $$$P=5$$$, the only solution is $$$a=2$$$ and $$$b=4$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " '.$p%$i.PHP_EOL;\r\n if(isset($arr[$p%$i])){\r\n $a = $arr[$p%$i];\r\n $b = $i;\r\n break;\r\n }\r\n else $arr[$p%$i] = $i;\r\n\r\n }\r\n echo \"$a $b\".PHP_EOL;\r\n\r\n}\r\n?>"}, {"source_code": ""}], "negative_code": [], "src_uid": "259e39c9e63e43678e596c0d8c66937c"} {"nl": {"description": "Petya and Vasya are competing with each other in a new interesting game as they always do.At the beginning of the game Petya has to come up with an array of $$$N$$$ positive integers. Sum of all elements in his array should be equal to $$$S$$$. Then Petya has to select an integer $$$K$$$ such that $$$0 \\leq K \\leq S$$$.In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either $$$K$$$ or $$$S - K$$$. Otherwise Vasya loses.You are given integers $$$N$$$ and $$$S$$$. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that.", "input_spec": "The first line contains two integers $$$N$$$ and $$$S$$$ ($$$1 \\leq N \\leq S \\leq 10^{6}$$$)\u00a0\u2014 the required length of the array and the required sum of its elements.", "output_spec": "If Petya can win, print \"YES\" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain $$$N$$$ positive integers with sum equal to $$$S$$$. In the third line print $$$K$$$. If there are many correct answers, you can print any of them. If Petya can't win, print \"NO\" (without quotes). You can print each letter in any register (lowercase or uppercase).", "sample_inputs": ["1 4", "3 4", "3 8"], "sample_outputs": ["YES\n4\n2", "NO", "YES\n2 1 5\n4"], "notes": null}, "positive_code": [{"source_code": "= $k ) echo \"NO\\n\" ;\n else \n {\n $ans = array_fill(0, $n, 1) ;\n $ans[$n - 1] = $k - $n + 1 ;\n \n echo \"YES\\n\" ;\n echo implode(\" \", $ans) . \"\\n\" ;\n echo $n . \"\\n\" ;\n }\n?>"}], "negative_code": [{"source_code": "= $k) echo \"NO\\n\" ;\n else \n {\n $ans = array_fill(0, $n, 1) ;\n $ans[$n - 1] = $k - $n + 1 ;\n \n echo \"YES\\n\" ;\n echo implode(\" \", $ans) . \"\\n\" ;\n echo $n . \"\\n\" ;\n }\n?>"}, {"source_code": "= $k) echo \"NO\\n\" ;\n else \n {\n $ans = array_fill(0, $n, 1) ;\n $ans[$n - 1] = $k - $n + 1 ;\n \n echo \"YES\\n\" ;\n echo implode(\" \", $ans) . \"\\n\" ;\n echo $n . \"\\n\" ;\n }\n?>"}, {"source_code": "= $k) echo \"NO\\n\" ;\n else \n {\n $ans = array_fill(0, $n, 1) ;\n $ans[$n - 1] = $k - $n + 1 ;\n \n echo implode(\" \", $ans) . \"\\n\" ;\n echo $n . \"\\n\" ;\n }\n?>"}], "src_uid": "4a644d97824d29c42dbb48d79b9958fe"} {"nl": {"description": " William has two numbers $$$a$$$ and $$$b$$$ initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer $$$k$$$ is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer $$$k$$$) add number $$$k$$$ to both $$$a$$$ and $$$b$$$, or add number $$$k$$$ to $$$a$$$ and subtract $$$k$$$ from $$$b$$$, or add number $$$k$$$ to $$$b$$$ and subtract $$$k$$$ from $$$a$$$. Note that after performing operations, numbers $$$a$$$ and $$$b$$$ may become negative as well.William wants to find out the minimal number of operations he would have to perform to make $$$a$$$ equal to his favorite number $$$c$$$ and $$$b$$$ equal to his second favorite number $$$d$$$.", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$c$$$ and $$$d$$$ $$$(0 \\le c, d \\le 10^9)$$$, which are William's favorite numbers and which he wants $$$a$$$ and $$$b$$$ to be transformed into.", "output_spec": "For each test case output a single number, which is the minimal number of operations which William would have to perform to make $$$a$$$ equal to $$$c$$$ and $$$b$$$ equal to $$$d$$$, or $$$-1$$$ if it is impossible to achieve this using the described operations.", "sample_inputs": ["6\n1 2\n3 5\n5 3\n6 6\n8 0\n0 0"], "sample_outputs": ["-1\n2\n2\n1\n2\n0"], "notes": "NoteLet us demonstrate one of the suboptimal ways of getting a pair $$$(3, 5)$$$: Using an operation of the first type with $$$k=1$$$, the current pair would be equal to $$$(1, 1)$$$. Using an operation of the third type with $$$k=8$$$, the current pair would be equal to $$$(-7, 9)$$$. Using an operation of the second type with $$$k=7$$$, the current pair would be equal to $$$(0, 2)$$$. Using an operation of the first type with $$$k=3$$$, the current pair would be equal to $$$(3, 5)$$$. "}, "positive_code": [{"source_code": "\r\n "}, {"source_code": ""}, {"source_code": "fscanf(STDIN, \"%d\", $t);\r\nwhile ($t--) {\r\n fscanf(STDIN, \"%d %d\", $c, $d);\r\n if (0 == $c && 0 == $d) {\r\n echo 0;\r\n } elseif ($c == $d) {\r\n echo 1;\r\n } elseif ((abs($c) + abs($d)) & 1) {\r\n echo -1;\r\n } else {\r\n echo 2;\r\n }\r\n echo \"\\n\";\r\n}"}], "src_uid": "8e7c0b703155dd9b90cda706d22525c9"} {"nl": {"description": "For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and the scale of operations grew. So the King ordered to found the Bank of Far Far Away and very soon even the rounding didn't help to quickly determine even the order of the numbers involved in operations. Besides, rounding a number to an integer wasn't very convenient as a bank needed to operate with all numbers with accuracy of up to 0.01, and not up to an integer.The King issued yet another order: to introduce financial format to represent numbers denoting amounts of money. The formal rules of storing a number in the financial format are as follows: A number contains the integer part and the fractional part. The two parts are separated with a character \".\" (decimal point). To make digits in the integer part of a number easier to read, they are split into groups of three digits, starting from the least significant ones. The groups are separated with the character \",\" (comma). For example, if the integer part of a number equals 12345678, then it will be stored in the financial format as 12,345,678 In the financial format a number's fractional part should contain exactly two digits. So, if the initial number (the number that is converted into the financial format) contains less than two digits in the fractional part (or contains no digits at all), it is complemented with zeros until its length equals 2. If the fractional part contains more than two digits, the extra digits are simply discarded (they are not rounded: see sample tests). When a number is stored in the financial format, the minus sign is not written. Instead, if the initial number had the minus sign, the result is written in round brackets. Please keep in mind that the bank of Far Far Away operates using an exotic foreign currency \u2014 snakes ($), that's why right before the number in the financial format we should put the sign \"$\". If the number should be written in the brackets, then the snake sign should also be inside the brackets. For example, by the above given rules number 2012 will be stored in the financial format as \"$2,012.00\" and number -12345678.9 will be stored as \"($12,345,678.90)\".The merchants of Far Far Away visited you again and expressed much hope that you supply them with the program that can convert arbitrary numbers to the financial format. Can you help them?", "input_spec": "The input contains a number that needs to be converted into financial format. The number's notation length does not exceed 100 characters, including (possible) signs \"-\" (minus) and \".\" (decimal point). The number's notation is correct, that is: The number's notation only contains characters from the set {\"0\" \u2013 \"9\", \"-\", \".\"}. The decimal point (if it is present) is unique and is preceded and followed by a non-zero quantity on decimal digits A number cannot start with digit 0, except for a case when its whole integer part equals zero (in this case the integer parts is guaranteed to be a single zero: \"0\"). The minus sign (if it is present) is unique and stands in the very beginning of the number's notation If a number is identically equal to 0 (that is, if it is written as, for example, \"0\" or \"0.000\"), than it is not preceded by the minus sign. The input data contains no spaces. The number's notation contains at least one decimal digit. ", "output_spec": "Print the number given in the input in the financial format by the rules described in the problem statement.", "sample_inputs": ["2012", "0.000", "-0.00987654321", "-12345678.9"], "sample_outputs": ["$2,012.00", "$0.00", "($0.00)", "($12,345,678.90)"], "notes": "NotePay attention to the second and third sample tests. They show that the sign of a number in the financial format (and consequently, the presence or absence of brackets) is determined solely by the sign of the initial number. It does not depend on the sign of the number you got after translating the number to the financial format."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "c704c5fb9e054fab1caeab534849901d"} {"nl": {"description": "Vasya decided to go to the grocery store. He found in his wallet $$$a$$$ coins of $$$1$$$ burle and $$$b$$$ coins of $$$2$$$ burles. He does not yet know the total cost of all goods, so help him find out $$$s$$$ ($$$s > 0$$$): the minimum positive integer amount of money he cannot pay without change or pay at all using only his coins.For example, if $$$a=1$$$ and $$$b=1$$$ (he has one $$$1$$$-burle coin and one $$$2$$$-burle coin), then: he can pay $$$1$$$ burle without change, paying with one $$$1$$$-burle coin, he can pay $$$2$$$ burle without change, paying with one $$$2$$$-burle coin, he can pay $$$3$$$ burle without change by paying with one $$$1$$$-burle coin and one $$$2$$$-burle coin, he cannot pay $$$4$$$ burle without change (moreover, he cannot pay this amount at all). So for $$$a=1$$$ and $$$b=1$$$ the answer is $$$s=4$$$.", "input_spec": "The first line of the input contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the test. The description of each test case consists of one line containing two integers $$$a_i$$$ and $$$b_i$$$ ($$$0 \\le a_i, b_i \\le 10^8$$$)\u00a0\u2014 the number of $$$1$$$-burle coins and $$$2$$$-burles coins Vasya has respectively.", "output_spec": "For each test case, on a separate line print one integer $$$s$$$ ($$$s > 0$$$): the minimum positive integer amount of money that Vasya cannot pay without change or pay at all.", "sample_inputs": ["5\n\n1 1\n\n4 0\n\n0 2\n\n0 0\n\n2314 2374"], "sample_outputs": ["4\n5\n1\n1\n7063"], "notes": "Note The first test case of the example is clarified into the main part of the statement. In the second test case, Vasya has only $$$1$$$ burle coins, and he can collect either any amount from $$$1$$$ to $$$4$$$, but $$$5$$$ can't. In the second test case, Vasya has only $$$2$$$ burle coins, and he cannot pay $$$1$$$ burle without change. In the fourth test case you don't have any coins, and he can't even pay $$$1$$$ burle. "}, "positive_code": [{"source_code": ""}, {"source_code": " 0; $t--) {\r\n\r\n\t$a = explode(' ', fgets(STDIN));\r\n\r\n\techo $solve(intval($a[0]), intval($a[1]));\r\n\techo \"\\n\";\r\n\r\n}\r\n"}], "negative_code": [], "src_uid": "2b6e670b602a89b467975edf5226219a"} {"nl": {"description": "The tournament \u00abSleepyhead-2010\u00bb in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n\u00b7(n\u2009-\u20091)\u2009/\u20092 games were played during the tournament, and each participant had a match with each other participant. The rules of the game are quite simple \u2014 the participant who falls asleep first wins. The secretary made a record of each game in the form \u00abxi yi\u00bb, where xi and yi are the numbers of participants. The first number in each pair is a winner (i.e. xi is a winner and yi is a loser). There is no draws.Recently researches form the \u00abInstitute Of Sleep\u00bb have found that every person is characterized by a value pj \u2014 the speed of falling asleep. The person who has lower speed wins. Every person has its own value pj, constant during the life. It is known that all participants of the tournament have distinct speeds of falling asleep. Also it was found that the secretary made records about all the games except one. You are to find the result of the missing game.", "input_spec": "The first line contains one integer n (3\u2009\u2264\u2009n\u2009\u2264\u200950) \u2014 the number of participants. The following n\u00b7(n\u2009-\u20091)\u2009/\u20092\u2009-\u20091 lines contain the results of the games. Each game is described in a single line by two integers xi,\u2009yi (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009n,\u2009xi\u2009\u2260\u2009yi), where xi \u0438 yi are the numbers of the opponents in this game. It is known that during the tournament each of the n participants played n\u2009-\u20091 games, one game with each other participant.", "output_spec": "Output two integers x and y \u2014 the missing record. If there are several solutions, output any of them.", "sample_inputs": ["4\n4 2\n4 1\n2 3\n2 1\n3 1"], "sample_outputs": ["4 3"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $order[$v])\n\t\t\tprintf(\"%d %d\\n\", $i + 1, $v + 1);\n?>\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "f1ac6da78aed11d9118a85182c5644de"} {"nl": {"description": "Someone gave Alyona an array containing n positive integers a1,\u2009a2,\u2009...,\u2009an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.Formally, after applying some operations Alyona will get an array of n positive integers b1,\u2009b2,\u2009...,\u2009bn such that 1\u2009\u2264\u2009bi\u2009\u2264\u2009ai for every 1\u2009\u2264\u2009i\u2009\u2264\u2009n. Your task is to determine the maximum possible value of mex of this array.Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the number of elements in the Alyona's array. The second line of the input contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the elements of the array.", "output_spec": "Print one positive integer\u00a0\u2014 the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.", "sample_inputs": ["5\n1 3 3 3 6", "2\n2 1"], "sample_outputs": ["5", "3"], "notes": "NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements."}, "positive_code": [{"source_code": " $c)\n {\n $b[$x] = $c;\n $c++;\n }\n elseif($b[$x] == $c)\n {\n $c++;\n }\n}\nprint $c;\n?>"}, {"source_code": "1)\n $a[0] = 1;\n\nfor($i = 1; $i < $n; $i++){\n if($a[$i] - $a[$i-1]>1)\n $a[$i] = $a[$i-1]+1;\n \n $ans = max($ans,$a[$i]);\n \n}\n\necho ++$ans;\n\n?>"}, {"source_code": "1)\n $a[0] = 1;\n\nfor($i = 1; $i < count($a); $i++){\n if($a[$i] - $a[$i-1]>1)\n $a[$i] = $a[$i-1]+1;\n \n $ans = max($ans,$a[$i]);\n \n}\n\necho ++$ans;\n\n?>"}, {"source_code": "= 1; $x--)\n{\n if($c[$x] == FALSE)\n {\n $e = 1;\n break;\n }\n}\nif($e == 0)\n{\n print max($b) + 1;\n}\nelse\n{\n print $x;\n}\n?>"}, {"source_code": "1)\n $a[0] = 1;\n\nfor($i = 1; $i < $n; $i++){\n if($a[$i] - $a[$i-1]>1)\n $a[$i] = $a[$i-1]+1;\n \n $ans = max($ans,$a[$i]);\n \n}\n\necho ++$ans;\n\n?>"}], "src_uid": "482b3ebbbadd583301f047181c988114"} {"nl": {"description": "You are given an array $$$a$$$ of $$$n$$$ integers, where $$$n$$$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $$$a_i$$$) and increase it by $$$1$$$ (that is, replace it with $$$a_i + 1$$$). You want to make the median of the array the largest possible using at most $$$k$$$ operations.The median of the odd-sized array is the middle element after the array is sorted in non-decreasing order. For example, the median of the array $$$[1, 5, 2, 3, 5]$$$ is $$$3$$$.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$, $$$n$$$ is odd, $$$1 \\le k \\le 10^9$$$)\u00a0\u2014 the number of elements in the array and the largest number of operations you can make. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$).", "output_spec": "Print a single integer\u00a0\u2014 the maximum possible median after the operations.", "sample_inputs": ["3 2\n1 3 5", "5 5\n1 2 1 1 1", "7 7\n4 1 2 4 3 4 4"], "sample_outputs": ["5", "3", "5"], "notes": "NoteIn the first example, you can increase the second element twice. Than array will be $$$[1, 5, 5]$$$ and it's median is $$$5$$$.In the second example, it is optimal to increase the second number and than increase third and fifth. This way the answer is $$$3$$$.In the third example, you can make four operations: increase first, fourth, sixth, seventh element. This way the array will be $$$[5, 1, 2, 5, 3, 5, 5]$$$ and the median will be $$$5$$$."}, "positive_code": [{"source_code": " $b)\n {\n $g = 1;\n $c[$d] += floor($b / $e);\n break;\n }\n }\n $e++;\n}\nif($g == 0)\n{\n print $c[$d] + floor($b / $e);\n}\nelse\n{\n print $c[$d];\n}\n?>"}, {"source_code": "= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){\n\t\t\t$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));\n\t\t\t$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));\n\t\t}\n\t\telse{\n\t\t\tbreak;\n\t\t}\t\n\t}\n\tif($k > 0){\n\t\t$ans = $ans + intval($k / ($i - $mid));\n\t}\n\tprint_r(intval($ans + intval($a[$mid])).\"\\n\");\n\tfclose($cin);\n?>"}, {"source_code": "= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){\n\t\t\t$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));\n\t\t\t$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));\n\t\t}\n\t\telse{\n\t\t\tbreak;\n\t\t}\t\n\t}\n\tif($k > 0){\n\t\t$ans = $ans + intval($k / ($i - $mid));\n\t}\n\tprint_r(intval($ans + intval($a[$mid])).\"\\n\");\n\tfclose($cin);\n?>"}], "negative_code": [{"source_code": " $b)\n {\n $g = 1;\n $c[$d] += floor($b / $e);\n break;\n }\n }\n else\n {\n $e++;\n }\n}\nif($g == 0)\n{\n print $c[$d] + floor($b / $e);\n}\nelse\n{\n print $c[$d];\n}\n?>"}, {"source_code": " 0)\n{\n $f += floor($b / $d);\n}\nprint $f;\n?>"}, {"source_code": "= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){\n\t\t\t$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));\n\t\t\t$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));\n\t\t}\n\t\telse{\n\t\t\tbreak;\n\t\t}\t\n\t}\n\tif($k > 0){\n\t\t$ans = $ans + intval($k / ($i - $mid));\n\t}\n\t\n\tprint_r(intval($ans + intval($a[$mid])).\"\\n\");\n\tfclose($cin);\n?>"}], "src_uid": "0efd4b05b3e2e3bc80c93d37508a5197"} {"nl": {"description": "International Women's Day is coming soon! Polycarp is preparing for the holiday.There are $$$n$$$ candy boxes in the shop for sale. The $$$i$$$-th box contains $$$d_i$$$ candies.Polycarp wants to prepare the maximum number of gifts for $$$k$$$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $$$k$$$. In other words, two boxes $$$i$$$ and $$$j$$$ ($$$i \\ne j$$$) can be combined as a gift if $$$d_i + d_j$$$ is divisible by $$$k$$$.How many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. ", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$$$) \u2014 the number the boxes and the number the girls. The second line of the input contains $$$n$$$ integers $$$d_1, d_2, \\dots, d_n$$$ ($$$1 \\le d_i \\le 10^9$$$), where $$$d_i$$$ is the number of candies in the $$$i$$$-th box.", "output_spec": "Print one integer \u2014 the maximum number of the boxes Polycarp can give as gifts.", "sample_inputs": ["7 2\n1 2 2 3 2 4 10", "8 2\n1 2 2 3 2 4 6 10", "7 3\n1 2 2 3 2 4 5"], "sample_outputs": ["6", "8", "4"], "notes": "NoteIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes): $$$(2, 3)$$$; $$$(5, 6)$$$; $$$(1, 4)$$$. So the answer is $$$6$$$.In the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes): $$$(6, 8)$$$; $$$(2, 3)$$$; $$$(1, 4)$$$; $$$(5, 7)$$$. So the answer is $$$8$$$.In the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes): $$$(1, 2)$$$; $$$(6, 7)$$$. So the answer is $$$4$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "3f3a013cedaaf8cbee0a74a4ed50f09d"} {"nl": {"description": "One very well-known internet resource site (let's call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to all visitors.There are n users on the site, for each user we know the rating value he wants to get as a New Year Present. We know that user i wants to get at least ai rating units as a present.The X site is administered by very creative and thrifty people. On the one hand, they want to give distinct ratings and on the other hand, the total sum of the ratings in the present must be as small as possible.Help site X cope with the challenging task of rating distribution. Find the optimal distribution.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20093\u00b7105) \u2014 the number of users on the site. The next line contains integer sequence a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Print a sequence of integers b1,\u2009b2,\u2009...,\u2009bn. Number bi means that user i gets bi of rating as a present. The printed sequence must meet the problem conditions. If there are multiple optimal solutions, print any of them.", "sample_inputs": ["3\n5 1 1", "1\n1000000000"], "sample_outputs": ["5 1 2", "1000000000"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $i) {\n\tif ($i <= $m) {\n\t\t$a[$j] = $m+1;\n\t}\n\t$m = $a[$j];\n}\n\nfor ($j = 0; $j < $n; $j++) {\n\tprint $a[$j]++.' ';\n}\n"}], "negative_code": [{"source_code": ""}, {"source_code": "= 0; $x--)\n{\n if(($c[$x] == $c[$x - 1]) && ($c[$x] == $d))\n {\n $e++;\n $c[$x] += $e;\n }\n elseif($c[$x] == $c[$x - 1])\n {\n $e = 1;\n $d = $c[$x];\n $c[$x] += $e;\n } \n}\n$g = array_combine($f, $c);\nksort($g);\nprint implode(\" \", $g);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "d19c7a74d739c2ca0d568808862ba2bd"} {"nl": {"description": "Vlad, like everyone else, loves to sleep very much.Every day Vlad has to do $$$n$$$ things, each at a certain time. For each of these things, he has an alarm clock set, the $$$i$$$-th of them is triggered on $$$h_i$$$ hours $$$m_i$$$ minutes every day ($$$0 \\le h_i < 24, 0 \\le m_i < 60$$$). Vlad uses the $$$24$$$-hour time format, so after $$$h=12, m=59$$$ comes $$$h=13, m=0$$$ and after $$$h=23, m=59$$$ comes $$$h=0, m=0$$$.This time Vlad went to bed at $$$H$$$ hours $$$M$$$ minutes ($$$0 \\le H < 24, 0 \\le M < 60$$$) and asks you to answer: how much he will be able to sleep until the next alarm clock.If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length $$$0$$$.", "input_spec": "The first line of input data contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases in the test. The first line of the case contains three integers $$$n$$$, $$$H$$$ and $$$M$$$ ($$$1 \\le n \\le 10, 0 \\le H < 24, 0 \\le M < 60$$$) \u2014 the number of alarms and the time Vlad went to bed. The following $$$n$$$ lines contain two numbers each $$$h_i$$$ and $$$m_i$$$ ($$$0 \\le h_i < 24, 0 \\le m_i < 60$$$) \u2014 the time of the $$$i$$$ alarm. It is acceptable that two or more alarms will trigger at the same time. Numbers describing time do not contain leading zeros.", "output_spec": "Output $$$t$$$ lines, each containing the answer to the corresponding test case. As an answer, output two numbers \u00a0\u2014 the number of hours and minutes that Vlad will sleep, respectively. If any alarm clock rings at the time when he went to bed, the answer will be 0 0.", "sample_inputs": ["3\n\n1 6 13\n\n8 0\n\n3 6 0\n\n12 30\n\n14 45\n\n6 0\n\n2 23 35\n\n20 15\n\n10 30"], "sample_outputs": ["1 47\n0 0\n10 55"], "notes": null}, "positive_code": [{"source_code": " $w ? $w - $sl + 24*60 : $w - $sl;\r\n // IO::pr($min . \" \" . $temp);\r\n $min = min($min, $temp);\r\n }\r\n $h1 = floor($min / 60);\r\n $m1 = $min % 60;\r\n \r\n $ans = $h1 . \" \" . $m1;\r\n IO::pr( $ans);\r\n\r\n \r\n \r\n \r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [], "src_uid": "ce0579e9c5b4c157bc89103c76ddd4c3"} {"nl": {"description": "A sequence $$$(b_1, b_2, \\ldots, b_k)$$$ is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formally speaking, it's strange if for every pair $$$(i, j)$$$ with $$$1 \\le i<j \\le k$$$, we have $$$|a_i-a_j|\\geq MAX$$$, where $$$MAX$$$ is the largest element of the sequence. In particular, any sequence of length at most $$$1$$$ is strange.For example, the sequences $$$(-2021, -1, -1, -1)$$$ and $$$(-1, 0, 1)$$$ are strange, but $$$(3, 0, 1)$$$ is not, because $$$|0 - 1| < 3$$$.Sifid has an array $$$a$$$ of $$$n$$$ integers. Sifid likes everything big, so among all the strange subsequences of $$$a$$$, he wants to find the length of the longest one. Can you help him?A sequence $$$c$$$ is a subsequence of an array $$$d$$$ if $$$c$$$ can be obtained from $$$d$$$ by deletion of several (possibly, zero or all) elements.", "input_spec": "The first line contains an integer $$$t$$$ $$$(1\\le t\\le 10^4)$$$ \u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ $$$(1\\le n\\le 10^5)$$$ \u2014 the length of the array $$$a$$$. 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)$$$ \u2014 the elements of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case output a single integer \u2014 the length of the longest strange subsequence of $$$a$$$.", "sample_inputs": ["6\n4\n-1 -2 0 0\n7\n-3 4 -2 0 -4 6 1\n5\n0 5 -3 2 -5\n3\n2 3 1\n4\n-3 0 2 0\n6\n-3 -2 -1 1 1 1"], "sample_outputs": ["4\n5\n4\n1\n3\n4"], "notes": "NoteIn the first test case, one of the longest strange subsequences is $$$(a_1, a_2, a_3, a_4)$$$In the second test case, one of the longest strange subsequences is $$$(a_1, a_3, a_4, a_5, a_7)$$$.In the third test case, one of the longest strange subsequences is $$$(a_1, a_3, a_4, a_5)$$$.In the fourth test case, one of the longest strange subsequences is $$$(a_2)$$$.In the fifth test case, one of the longest strange subsequences is $$$(a_1, a_2, a_4)$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "a4b170cc058c485a50bf18982fd96851"} {"nl": {"description": "You are given an array $$$a$$$ of length $$$n$$$, which initially is a permutation of numbers from $$$1$$$ to $$$n$$$. In one operation, you can choose an index $$$i$$$ ($$$1 \\leq i < n$$$) such that $$$a_i < a_{i + 1}$$$, and remove either $$$a_i$$$ or $$$a_{i + 1}$$$ from the array (after the removal, the remaining parts are concatenated). For example, if you have the array $$$[1, 3, 2]$$$, you can choose $$$i = 1$$$ (since $$$a_1 = 1 < a_2 = 3$$$), then either remove $$$a_1$$$ which gives the new array $$$[3, 2]$$$, or remove $$$a_2$$$ which gives the new array $$$[1, 2]$$$.Is it possible to make the length of this array equal to $$$1$$$ with these operations?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 2 \\cdot 10^4$$$) \u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\leq n \\leq 3 \\cdot 10^5$$$) \u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\leq a_i \\leq n$$$, $$$a_i$$$ are pairwise distinct)\u00a0\u2014 elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \\cdot 10^5$$$.", "output_spec": "For each test case, output on a single line the word \"YES\" if it is possible to reduce the array to a single element using the aforementioned operation, or \"NO\" if it is impossible to do so.", "sample_inputs": ["4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 6 1 3 5"], "sample_outputs": ["YES\nYES\nNO\nYES"], "notes": "NoteFor the first two test cases and the fourth test case, we can operate as follow (the bolded elements are the pair chosen for that operation):$$$[\\text{1}, \\textbf{2}, \\textbf{3}] \\rightarrow [\\textbf{1}, \\textbf{2}] \\rightarrow [\\text{1}]$$$$$$[\\text{3}, \\textbf{1}, \\textbf{2}, \\text{4}] \\rightarrow [\\text{3}, \\textbf{1}, \\textbf{4}] \\rightarrow [\\textbf{3}, \\textbf{4}] \\rightarrow [\\text{4}]$$$$$$[\\textbf{2}, \\textbf{4}, \\text{6}, \\text{1}, \\text{3}, \\text{5}] \\rightarrow [\\textbf{4}, \\textbf{6}, \\text{1}, \\text{3}, \\text{5}] \\rightarrow [\\text{4}, \\text{1}, \\textbf{3}, \\textbf{5}] \\rightarrow [\\text{4}, \\textbf{1}, \\textbf{5}] \\rightarrow [\\textbf{4}, \\textbf{5}] \\rightarrow [\\text{4}]$$$"}, "positive_code": [{"source_code": " $c[$b - 1])\n {\n print \"NO\\n\";\n }\n else\n {\n print \"YES\\n\";\n }\n}\n?>"}], "negative_code": [], "src_uid": "192f181cfc74bef5b0b5a192964d9760"} {"nl": {"description": "A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of $$$n$$$ rows and $$$m$$$ columns. The rows of the floor are numbered from $$$1$$$ to $$$n$$$ from top to bottom, and columns of the floor are numbered from $$$1$$$ to $$$m$$$ from left to right. The cell on the intersection of the $$$r$$$-th row and the $$$c$$$-th column is denoted as $$$(r,c)$$$. The initial position of the robot is $$$(r_b, c_b)$$$.In one second, the robot moves by $$$dr$$$ rows and $$$dc$$$ columns, that is, after one second, the robot moves from the cell $$$(r, c)$$$ to $$$(r + dr, c + dc)$$$. Initially $$$dr = 1$$$, $$$dc = 1$$$. If there is a vertical wall (the left or the right walls) in the movement direction, $$$dc$$$ is reflected before the movement, so the new value of $$$dc$$$ is $$$-dc$$$. And if there is a horizontal wall (the upper or lower walls), $$$dr$$$ is reflected before the movement, so the new value of $$$dr$$$ is $$$-dr$$$.Each second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at $$$(r_d, c_d)$$$. The job of the robot is to clean that dirty cell. Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes. Given the floor size $$$n$$$ and $$$m$$$, the robot's initial position $$$(r_b, c_b)$$$ and the dirty cell's position $$$(r_d, c_d)$$$, find the time for the robot to do its job.", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). Description of the test cases follows. A test case consists of only one line, containing six integers $$$n$$$, $$$m$$$, $$$r_b$$$, $$$c_b$$$, $$$r_d$$$, and $$$c_d$$$ ($$$1 \\le n, m \\le 100$$$, $$$1 \\le r_b, r_d \\le n$$$, $$$1 \\le c_b, c_d \\le m$$$)\u00a0\u2014 the sizes of the room, the initial position of the robot and the position of the dirt cell.", "output_spec": "For each test case, print an integer \u2014 the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.", "sample_inputs": ["5\n10 10 6 1 2 8\n10 10 9 9 1 1\n9 8 5 6 2 1\n6 9 2 2 5 8\n2 2 1 1 2 1"], "sample_outputs": ["7\n10\n9\n3\n0"], "notes": "NoteIn the first example, the floor has the size of $$$10\\times 10$$$. The initial position of the robot is $$$(6, 1)$$$ and the position of the dirty cell is $$$(2, 8)$$$. See the illustration of this example in the problem statement.In the second example, the floor is the same, but the initial position of the robot is now $$$(9, 9)$$$, and the position of the dirty cell is $$$(1, 1)$$$. In this example, the robot went straight to the dirty cell and clean it. In the third example, the floor has the size $$$9 \\times 8$$$. The initial position of the robot is $$$(5, 6)$$$, and the position of the dirty cell is $$$(2, 1)$$$. In the fourth example, the floor has the size $$$6 \\times 9$$$. The initial position of the robot is $$$(2, 2)$$$ and the position of the dirty cell is $$$(5, 8)$$$. In the last example, the robot was already standing in the same column as the dirty cell, so it can clean the cell right away. "}, "positive_code": [{"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$lines = trim(fgets($file));\r\n\r\nfor($i = 0; $i < $lines; $i++)\r\n{\r\n \r\n list($n, $m, $y0, $x0, $y1, $x1) = explode(\" \", trim(fgets($file)));\r\n\r\n $stepX = $x1 - $x0 >= 0 ? $x1 - $x0 : $x0 - $x1 + ($m - $x0)*2;\r\n $stepY = $y1 - $y0 >= 0 ? $y1 - $y0 : $y0 - $y1 + ($n - $y0)*2;\r\n\r\n $step = min($stepX, $stepY);\r\n\r\n echo $step.\"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": " $rd) {\r\n $turn_r = ($n - $rb) * 2;\r\n }\r\n \r\n if ($cb > $cd) {\r\n $turn_c = ($m - $cb) * 2;\r\n }\r\n \r\n $to_r = abs($rb - $rd) + $turn_r;\r\n $to_c = abs($cb - $cd) + $turn_c;\r\n \r\n print min($to_r, $to_c) . \"\\n\";\r\n}\r\n"}, {"source_code": " $n || $robotX + $dx < 1)\r\n {\r\n $dx = -$dx;\r\n }\r\n\r\n if($robotY + $dy > $m || $robotY + $dy < 1)\r\n {\r\n $dy = -$dy;\r\n }\r\n\r\n $robotX += $dx;\r\n $robotY += $dy;\r\n\r\n $time++;\r\n }\r\n\r\n echo $time;\r\n echo PHP_EOL;\r\n}\r\n\r\n$t = + fgets($file);\r\n\r\nwhile($t--) solve();"}], "negative_code": [{"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$n = trim(fgets($file));\r\n\r\nfor($i = 0; $i < $n; $i++)\r\n{\r\n list($n, $m, $x0, $y0, $x1, $y1) = explode(\" \", str_replace([\"\\n\", \"\\r\", \"\\n\\r\"], \"\", fgets($file)));\r\n\r\n $x = $x0;\r\n $y = $y0;\r\n $step = 0;\r\n $Vx = 1;\r\n $Vy = 1;\r\n\r\n\r\n\r\n while(1)\r\n {\r\n if($x == $x1 || $y == $y1)\r\n {\r\n break;\r\n }\r\n\r\n $x+= $Vx;\r\n $y+= $Vy;\r\n\r\n if($y == $m || $y == 0)\r\n $Vy = -$Vy;\r\n if($x == $n || $x == 0)\r\n $Vx = -$Vx;\r\n\r\n $step++;\r\n }\r\n\r\n echo $step.\"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$dir = fopen(\"input.txt\", 'r');\r\n$dir = fopen(\"php://stdin\", 'r');\r\n$datatxt = stream_get_contents($dir);\r\n$lines = explode(\"\\n\", $datatxt);\r\n\r\n$t = array_shift($lines);\r\n\r\nfor($i = 0; $i < $t; $i++)\r\n{\r\n list($n, $m, $x0, $y0, $x1, $y1) = explode(\" \", $lines[$i]);\r\n\r\n $x = $x0;\r\n $y = $y0;\r\n $step = 0;\r\n $Vx = 1;\r\n $Vy = 1;\r\n\r\n while($step < 100)\r\n {\r\n if($x == $x1 || $y == $y1)\r\n {\r\n break;\r\n }\r\n\r\n $x+= $Vx;\r\n $y+= $Vy;\r\n\r\n if($y == $m || $y == 0)\r\n $Vy = -$Vy;\r\n if($x == $n || $x == 0)\r\n $Vx = -$Vx;\r\n\r\n $step++;\r\n }\r\n\r\n echo $step.\"\\n\";\r\n}\r\n\r\n?>"}], "src_uid": "6f819ce1d88d5211cd475a8673edba97"} {"nl": {"description": "You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.For instance, if we are given an array $$$[10, 20, 30, 40]$$$, we can permute it so that it becomes $$$[20, 40, 10, 30]$$$. Then on the first and the second positions the integers became larger ($$$20>10$$$, $$$40>20$$$) and did not on the third and the fourth, so for this permutation, the number that Vasya wants to maximize equals $$$2$$$. Read the note for the first example, there is one more demonstrative test case.Help Vasya to permute integers in such way that the number of positions in a new array, where integers are greater than in the original one, is maximal.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the length of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the elements of the array.", "output_spec": "Print a single integer\u00a0\u2014 the maximal number of the array's elements which after a permutation will stand on the position where a smaller element stood in the initial array.", "sample_inputs": ["7\n10 1 1 1 5 5 3", "5\n1 1 1 1 1"], "sample_outputs": ["4", "0"], "notes": "NoteIn the first sample, one of the best permutations is $$$[1, 5, 5, 3, 10, 1, 1]$$$. On the positions from second to fifth the elements became larger, so the answer for this permutation is 4.In the second sample, there is no way to increase any element with a permutation, so the answer is 0."}, "positive_code": [{"source_code": " $b[$d])\n {\n $c++;\n $d++;\n }\n}\nprint $c;\n?>"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy);\n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\n$jump = 100;\n\n$offset = 1;\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n\t//$offset = 1;\n\n while($offset < $count){\n $nextValue = $values[$offset];\n $nextKey = $keys[$offset];\n\t\tif($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n }\n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n }\n }\n}\n\necho count($finds);"}], "negative_code": [{"source_code": "\n\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n\n//$b = \"10 1 1 1 5 5 3\";\n$input = $b; \n$input = explode(\" \", $input);\n\n$copy = new ArrayObject($input);\n$copy = $copy->getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy); \n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\nif(count($copy) >= 100000){\n echo 'stop';\n}\n\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n $find = false; \n $offset = 1;\n \n while($offset+$i < $count){\n $next100Offset = 1000;\n $next100Value = $values[$i+$offset+$next100Offset]; \n if(isset($next100Value) && $next100Value <= $value){\n while($offset+$i+$next100Offset < $count){\n if($next100Value <= $value){\n $next100Offset+=1000; \n $next100Value = $values[$i+$offset+$next100Offset];\n }else{\n break;\n } \n } \n $offset+=$next100Offset; \n } \n \n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n if($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n } \n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n } \n } \n}\necho count($finds); "}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy); $values = array_values($copy);\n$finds = array();\n\nfor($i = 0; $i < count($values); $i++){\n $value = $values[$i];\n $find = false;\n $offset = 1;\n while($offset+$i < count($values)){\n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n if(isset($finds[$nextKey])){\n $offset++;\n continue;\n } \n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n }else{\n $offset++;\n } \n } \n}\n\necho count($finds);"}, {"source_code": "\n \n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n\n//$b = \"10 1 1 1 5 5 3\";\n$input = $b; \n$input = explode(\" \", $input);\n\n$copy = new ArrayObject($input);\n$copy = $copy->getArrayCopy();\n\nif(count($input)>=10000){\n echo \"date 1 is \" . microtime(); \n}\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy); \n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\nif(count($input)>=10000){\n echo \"date 2 is \" . microtime(); \n}\n \n\n\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n $find = false;\n $offset = 1;\n \n while($offset+$i < $count){\n $next100Offset = 1000;\n $next100Value = $values[$i+$offset+$next100Offset]; \n if(isset($next100Value) && $next100Value <= $value){\n while($offset+$i+$next100Offset < $count){\n if($next100Value <= $value){\n $next100Offset+=1000; \n $next100Value = $values[$i+$offset+$next100Offset];\n }else{\n break;\n }\n }\n $offset+=$next100Offset; \n }\n \n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n if($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n }\n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n } \n }\n}\n\necho count($finds);\nif(count($input)>=10000){\n echo \"date 3 is \" . microtime(); \n}"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy); $values = array_values($copy);\n$finds = array();\n\nfor($i = 0; $i < count($values); $i++){\n $value = $values[$i];\n $find = false;\n $offset = 1;\n while($offset+$i < count($values)){\n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n if(isset($finds[$nextKey])){\n $offset++;\n continue;\n } \n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n }else{\n $offset++;\n } \n } \n}\n\necho \"result = \". count($finds);"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy);\n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\n$jump = 100;\nif(count($input)>=10000){\n\techo \"jump = \".$jump; \n\t\t$value = $values[500];\n\t\techo \"lai = $value
\";\n\t\t$value = $values[700];\n\t\techo \"lai2 = $value
\";\n}\n\n$offset = 1;\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n $find = false;\n\t//$offset = 1;\n\n while($offset+$i < $count){\n $next100Offset = $jump;\n $next100Value = $values[$i+$offset+$next100Offset];\n\t\tif(count($input)>=10000){\n\t\t\techo \"num:\".$i.\",next 100: \".$next100Value . \", current value = \".$value.\"
\"; \n\t\t}\n if(isset($next100Value) && $next100Value <= $value){\n\t\t\t if(count($input)>=10000){\n echo \"next 100 value = \" . $next100Value . \", value = \" + $value; \n }\n while($offset+$i+$next100Offset < $count){\n if($next100Value <= $value){\n $next100Offset+= $jump;\n $next100Value = $values[$i+$offset+$next100Offset];\n }else{\n break;\n }\n }\n if(count($input)>=10000){\n echo \"add more offset : \".$next100Offset; \n }\n $offset+=$next100Offset;\n }\n\n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n\n\t\tif(count($input)>=10000){\n\t\t\techo \"nextValue = \".$nextValue; \n\t\t}\n\t\tif($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n }\n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n }\n }\n}\n\necho count($finds);"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy);\n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\n$jump = 100;\n\n$offset = 1;\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n $find = false;\n\t//$offset = 1;\n\n while($offset+$i < $count){\n $next100Offset = $jump;\n $next100Value = $values[$i+$offset+$next100Offset];\n if(isset($next100Value) && $next100Value <= $value){\n while($offset+$i+$next100Offset < $count){\n if($next100Value <= $value){\n $next100Offset+= $jump;\n $next100Value = $values[$i+$offset+$next100Offset];\n }else{\n break;\n }\n } \n $offset+=$next100Offset;\n }\n\n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n\t\tif($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n }\n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n }\n }\n}\n\necho count($finds);"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$usedIndex = [];\n$keys = array_keys($copy);\n$values = array_values($copy);\n$success = 0;\n\nfor($i = 0; $i < sizeof($input); $i++){\n $current = $input[$i];\n $currentIndex = array_search($i, $keys);\n\n $offset = 1;\n $next = $values[$currentIndex +$offset];\n\t\n while(isset($next)){\n if($next == $current|| in_array($keys[$currentIndex+$offset], $usedIndex)){\n $offset++;\n $next = $values[$currentIndex+$offset];\n }else{\n //\u627e\u5230\u6bd4\u81ea\u5df1\u5927\u7684\n $nextKey = $keys[$currentIndex+$offset];\n array_push($usedIndex, $nextKey);\n\t\t\t$success++;\n\t\t\techo \"got $next\";\n break;\n }\n }\n\n if(!isset($next)){\n //\u6c92\u6709\u6bd4\u9019\u500b\u5143\u7d20\u5927\u7684\n foreach($copy as $key => $value){\n if(in_array($key, $usedIndex)){\n continue;\n }\n array_push($usedIndex, $key);\n\t\t\tbreak;\n }\n }\n}\necho \"$success\";"}, {"source_code": "getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n\necho '4'; "}, {"source_code": "\n \n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n\n//$b = \"10 1 1 1 5 5 3\";\n$input = $b; \n$input = explode(\" \", $input);\n\n$copy = new ArrayObject($input);\n$copy = $copy->getArrayCopy();\n\n\n//\u6309\u7167value\u7531\u5c0f\u5230\u5927sorting,\u4f46\u4fdd\u7559key\u7684\u4f4d\u7f6e\nasort($copy);\n$keys = array_keys($copy); \n$values = array_values($copy);\n$finds = array();\n$count = count($values);\n\nif(count($input)>=10000){\n echo \"date is \" . date(\"Y-m-d h:i:sa\"); \n}\n \n\n\nfor($i = 0; $i < $count; $i++){\n $value = $values[$i];\n $find = false;\n $offset = 1;\n \n while($offset+$i < $count){\n $next100Offset = 1000;\n $next100Value = $values[$i+$offset+$next100Offset]; \n if(isset($next100Value) && $next100Value <= $value){\n while($offset+$i+$next100Offset < $count){\n if($next100Value <= $value){\n $next100Offset+=1000; \n $next100Value = $values[$i+$offset+$next100Offset];\n }else{\n break;\n }\n }\n $offset+=$next100Offset; \n }\n \n $nextValue = $values[$i+$offset];\n $nextKey = $keys[$i+$offset];\n if($nextValue <= $value || isset($finds[$nextKey])){\n $offset++;\n continue;\n }\n if($nextValue > $value){\n $finds[$nextKey] = 1;\n break;\n } \n }\n}\n\necho count($finds);\nif(count($input)>=10000){\n echo \"date 2 is \" . date(\"Y-m-d h:i:sa\"); \n}"}], "src_uid": "eaa768dc1024df6449e89773234cc0c3"} {"nl": {"description": "Kana was just an ordinary high school girl before a talent scout discovered her. Then, she became an idol. But different from the stereotype, she is also a gameholic. One day Kana gets interested in a new adventure game called Dragon Quest. In this game, her quest is to beat a dragon.\u00a0The dragon has a hit point of $$$x$$$ initially. When its hit point goes to $$$0$$$ or under $$$0$$$, it will be defeated. In order to defeat the dragon, Kana can cast the two following types of spells. Void Absorption Assume that the dragon's current hit point is $$$h$$$, after casting this spell its hit point will become $$$\\left\\lfloor \\frac{h}{2} \\right\\rfloor + 10$$$. Here $$$\\left\\lfloor \\frac{h}{2} \\right\\rfloor$$$ denotes $$$h$$$ divided by two, rounded down. Lightning Strike This spell will decrease the dragon's hit point by $$$10$$$. Assume that the dragon's current hit point is $$$h$$$, after casting this spell its hit point will be lowered to $$$h-10$$$.Due to some reasons Kana can only cast no more than $$$n$$$ Void Absorptions and $$$m$$$ Lightning Strikes. She can cast the spells in any order and doesn't have to cast all the spells. Kana isn't good at math, so you are going to help her to find out whether it is possible to defeat the dragon.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$) \u00a0\u2014 the number of test cases. The next $$$t$$$ lines describe test cases. For each test case the only line contains three integers $$$x$$$, $$$n$$$, $$$m$$$ ($$$1\\le x \\le 10^5$$$, $$$0\\le n,m\\le30$$$) \u00a0\u2014 the dragon's intitial hit point, the maximum number of Void Absorptions and Lightning Strikes Kana can cast respectively.", "output_spec": "If it is possible to defeat the dragon, print \"YES\" (without quotes). Otherwise, print \"NO\" (without quotes). You can print each letter in any case (upper or lower).", "sample_inputs": ["7\n100 3 4\n189 3 4\n64 2 3\n63 2 3\n30 27 7\n10 9 1\n69117 21 2"], "sample_outputs": ["YES\nNO\nNO\nYES\nYES\nYES\nYES"], "notes": "NoteOne possible casting sequence of the first test case is shown below: Void Absorption $$$\\left\\lfloor \\frac{100}{2} \\right\\rfloor + 10=60$$$. Lightning Strike $$$60-10=50$$$. Void Absorption $$$\\left\\lfloor \\frac{50}{2} \\right\\rfloor + 10=35$$$. Void Absorption $$$\\left\\lfloor \\frac{35}{2} \\right\\rfloor + 10=27$$$. Lightning Strike $$$27-10=17$$$. Lightning Strike $$$17-10=7$$$. Lightning Strike $$$7-10=-3$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " 0; $n--) {\n\t\t$x = floor($x / 2) + 10;\n\t\tif($x <= $m * 10){\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n};\n\nfor ($t = intval(fgets(STDIN)); $t > 0; $t--) {\n\n\n\tlist($x, $n, $m) = explode(' ', fgets(STDIN));\n\n\techo ($calc($x, $n, $m) ? 'YES' : 'NO') . \"\\n\";\n\n}\n"}, {"source_code": "\n"}, {"source_code": ""}], "negative_code": [{"source_code": "\n"}], "src_uid": "78f25e2bc4ff22dbac94f72af68a745f"} {"nl": {"description": "Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of ti minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i ci times. Eugeny's play list is organized as follows: first song number 1 plays c1 times, then song number 2 plays c2 times, ..., in the end the song number n plays cn times.Eugeny took a piece of paper and wrote out m moments of time when he liked a song. Now for each such moment he wants to know the number of the song that played at that moment. The moment x means that Eugeny wants to know which song was playing during the x-th minute of his listening to the play list.Help Eugeny and calculate the required numbers of songs.", "input_spec": "The first line contains two integers n, m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105). The next n lines contain pairs of integers. The i-th line contains integers ci,\u2009ti (1\u2009\u2264\u2009ci,\u2009ti\u2009\u2264\u2009109) \u2014 the description of the play list. It is guaranteed that the play list's total duration doesn't exceed 109 . The next line contains m positive integers v1,\u2009v2,\u2009...,\u2009vm, that describe the moments Eugeny has written out. It is guaranteed that there isn't such moment of time vi, when the music doesn't play any longer. It is guaranteed that vi\u2009<\u2009vi\u2009+\u20091 (i\u2009<\u2009m). The moment of time vi means that Eugeny wants to know which song was playing during the vi-th munite from the start of listening to the playlist.", "output_spec": "Print m integers \u2014 the i-th number must equal the number of the song that was playing during the vi-th minute after Eugeny started listening to the play list.", "sample_inputs": ["1 2\n2 8\n1 16", "4 9\n1 2\n2 1\n1 1\n2 2\n1 2 3 4 5 6 7 8 9"], "sample_outputs": ["1\n1", "1\n1\n2\n2\n3\n4\n4\n4\n4"], "notes": null}, "positive_code": [{"source_code": "= $c[$i]) && ($h[$x] <= $d[$i]))\n {\n print ($i + 1) . \"\\n\";\n }\n else\n {\n $i++;\n while(TRUE)\n {\n if(($h[$x] >= $c[$i]) && ($h[$x] <= $d[$i]))\n {\n print ($i + 1) . \"\\n\";\n break;\n }\n else\n {\n $i++;\n }\n }\n }\n}\n?>"}], "negative_code": [{"source_code": ""}], "src_uid": "c4398a9f342a23baf1d7ebc9f4e9577d"} {"nl": {"description": "Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.Recently, she was presented with an array $$$a$$$ of the size of $$$10^9$$$ elements that is filled as follows: $$$a_1 = -1$$$ $$$a_2 = 2$$$ $$$a_3 = -3$$$ $$$a_4 = 4$$$ $$$a_5 = -5$$$ And so on ... That is, the value of the $$$i$$$-th element of the array $$$a$$$ is calculated using the formula $$$a_i = i \\cdot (-1)^i$$$.She immediately came up with $$$q$$$ queries on this array. Each query is described with two numbers: $$$l$$$ and $$$r$$$. The answer to a query is the sum of all the elements of the array at positions from $$$l$$$ to $$$r$$$ inclusive.Margarita really wants to know the answer to each of the requests. She doesn't want to count all this manually, but unfortunately, she couldn't write the program that solves the problem either. She has turned to you\u00a0\u2014 the best programmer.Help her find the answers!", "input_spec": "The first line contains a single integer $$$q$$$ ($$$1 \\le q \\le 10^3$$$)\u00a0\u2014 the number of the queries. Each of the next $$$q$$$ lines contains two integers $$$l$$$ and $$$r$$$ ($$$1 \\le l \\le r \\le 10^9$$$)\u00a0\u2014 the descriptions of the queries.", "output_spec": "Print $$$q$$$ lines, each containing one number\u00a0\u2014 the answer to the query. ", "sample_inputs": ["5\n1 3\n2 5\n5 5\n4 4\n2 3"], "sample_outputs": ["-2\n-2\n-5\n4\n-1"], "notes": "NoteIn the first query, you need to find the sum of the elements of the array from position $$$1$$$ to position $$$3$$$. The sum is equal to $$$a_1 + a_2 + a_3 = -1 + 2 -3 = -2$$$.In the second query, you need to find the sum of the elements of the array from position $$$2$$$ to position $$$5$$$. The sum is equal to $$$a_2 + a_3 + a_4 + a_5 = 2 -3 + 4 - 5 = -2$$$.In the third query, you need to find the sum of the elements of the array from position $$$5$$$ to position $$$5$$$. The sum is equal to $$$a_5 = -5$$$.In the fourth query, you need to find the sum of the elements of the array from position $$$4$$$ to position $$$4$$$. The sum is equal to $$$a_4 = 4$$$.In the fifth query, you need to find the sum of the elements of the array from position $$$2$$$ to position $$$3$$$. The sum is equal to $$$a_2 + a_3 = 2 - 3 = -1$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n\n }\n\n} else {\n $count = readline();\n $arr = [];\n $queries = [];\n for ($i = 0; $i < $count; $i++) {\n $range = readline();;\n $queries[$i] = [\n 'l' => explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n }\n}\n\n\n\n\n\n$result = [];\n\nforeach ($queries as $query) {\n $len = $query['r'] - ($query['l']-1);\n\n if ($len%2 == 0){ //\u0447\u0451\u0442\u043d\u043e\u0435\n $sum = ($len/2);\n if ($query['l']%2 == 0){\n $sum *=-1;\n }\n }else{\n if ($query['r']%2 == 0){\n $sum = floor($len/2)*(-1)+$query['r'];\n }else{\n $sum = floor($len/2)-$query['r'];\n }\n }\n\n array_push($result, $sum);\n}\n\nforeach ($result as $res){\n echo $res.PHP_EOL;\n}\n\n\n"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfFloat($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (float)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\n/* Perform action N times. Can return values in array */\nfunction ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\n/* Integral. Keys preserved. By reference. */\nfunction cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\n/* Difference. Keys preserved. By reference. */\nfunction diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\nfunction bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n\nfunction sn($n)\n{\n\treturn ($n>>1) - $n*($n&1);\n}\n\nntimes($n, function() use ($ir) {\n\tlist($l, $r) = $ir->readArrayOfInt(2);\n\techo sn($r) - sn($l-1);\n\techo \"\\n\";\n});\n\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "#!/usr/bin/env php\n explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n\n }\n\n} else {\n $count = readline();\n $arr = [];\n $queries = [];\n for ($i = 0; $i < $count; $i++) {\n $range = readline();;\n $queries[$i] = [\n 'l' => explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n }\n}\n\n\n\n\n\n$result = [];\n\nforeach ($queries as $query) {\n $len = $query['r'] - ($query['l']-1);\n\n if ($len%2 == 0){ //\u0447\u0451\u0442\u043d\u043e\u0435\n $sum = ($len/2);\n if ($query['l']%2 == 0){\n $sum *=-1;\n }\n }else{\n if ($query['r']%2 == 0){\n $sum = floor($len/2)+$query['r'];\n }else{\n $sum = floor($len/2)-$query['r'];\n }\n }\n\n array_push($result, $sum);\n}\n\nforeach ($result as $res){\n echo $res.PHP_EOL;\n}\n\n\n"}, {"source_code": "#!/usr/bin/env php\n explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n $arr[$i] = ($i + 1) * pow(-1, $i + 1);\n }\n\n} else {\n $count = readline();\n $arr = [];\n $queries = [];\n for ($i = 0; $i < $count; $i++) {\n $range = readline();;\n $queries[$i] = [\n 'l' => explode(' ', $range)[0],\n 'r' => explode(' ', $range)[1],\n ];\n }\n $arr[$i] = ($i + 1) * pow(-1, $i + 1);\n}\n\n$result = [];\n\nforeach ($queries as $query) {\n $len = $query['r'] - ($query['l']-1);\n $arr2 = array_slice($arr, $query['l']-1, $len);\n $sum = 0;\n foreach ($arr2 as $a){\n $sum+=$a;\n }\n array_push($result, $sum);\n}\n\nforeach ($result as $res){\n echo $res.PHP_EOL;\n}\n\n\n"}], "src_uid": "7eae40835f6e9580b985d636d5730e2d"} {"nl": {"description": "Sherlock Holmes and Dr. Watson played some game on a checkered board n\u2009\u00d7\u2009n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8\u2009+\u20093\u2009+\u20096\u2009+\u20097\u2009=\u200924, sum of its row numbers equals 9\u2009+\u20095\u2009+\u20093\u2009+\u20092\u2009=\u200919, and 24\u2009>\u200919.", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u200930). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.", "output_spec": "Print the single number \u2014 the number of the winning squares.", "sample_inputs": ["1\n1", "2\n1 2\n3 4", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3"], "sample_outputs": ["0", "2", "6"], "notes": "NoteIn the first example two upper squares are winning.In the third example three left squares in the both middle rows are winning:5 7 8 49 5 3 21 6 6 49 5 7 3"}, "positive_code": [{"source_code": " $e)\n {\n $h++;\n }\n }\n}\nprint $h;\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$row_sum[$i] += $inp_num;\n\t\t\t$col_sum[$j] += $inp_num; \n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t//if($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t\tif($row_sum[$i] < $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num;\n\t\t\t$col_sum[$j] += $inp_num; \n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t//if($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t\tif($row_sum[$i] < $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num; \n\t\t}\n\t}\n\t$col_sum = array();\n\tfor ($k = 0; $k < $inp_n; $k++) {\n\t\tfor ($l = 0; $l < $inp_n; $l++) {\n\t\t\t$col_sum[$k] += $inp_row[$l][$k];\n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t//if($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t\tif($row_sum[$i] < $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": " $line) {\n\n # code...\n }\n}\n\nlist($n, $data) = read_input_data();\n$v_sum = $h_sum = array_fill(0, $n, 0);\n\nfor ($i = 0; $i<$n; $i++) {\n $line = $data[$i];\n $h_sum[$i] = array_sum($line);\n for ($j = 0; $j<$n; $j++) {\n $v_sum[$j] += $line[$j];\n }\n}\n\n// print_r($v_sum);\n// print_r($h_sum);\n\n$result = 0;\n\nfor ($i = 0; $i<$n; $i++) {\n for ($j = 0; $j<$n; $j++) {\n if ($v_sum[$j] > $h_sum[$i]) {\n $result++;\n }\n }\n}\n\nprint $result .\"\\n\";"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$countMatr = (int)(str_replace( \"\\r\\n\", '', fgets($fp)));\n\n$sumRows = array();\n$sumCols = array();\n$i = 0;\nwhile( $countMatr-- ){\n\t$points = explode(\" \", trim( str_replace( \"\\r\\n\", '', fgets($fp)) ) );\n\tforeach( $points as $key => $value )\n\t{\n\t\t$sumRows[$i] += $value;\n\t\t$sumCols[$key] += $value;\n\t}\n\t$i++;\n}\n\n$res = 0;\nforeach( $sumRows as $key1 => $rowsVal ){\n\tforeach( $sumCols as $key2 => $colsVal ){\n\t\tif( $colsVal > $rowsVal ){\n\t\t\t$res++;\n\t\t}\n\t}\n}\necho $res;\nfclose($fp);\n?>"}, {"source_code": "$v) {\n\tif ($k == 0) {\n\t\t$size = $v;\n\t} else {\n\t\t$l = explode(\" \", $v);\n\t\t$lines[] = $l;\n\t\t//$sum_x[] = array_sum($l);\n\t}\n}\n\n\n\n$wins = 0;\n$x = $y = array();\nfor ($i = 0; $i < $size; $i++) {\n\t$sum_x = array_sum($lines[$i]);\n\t$sum_y = 0;\n\tfor ($n = 0; $n < $size; $n++) {\n\t\t$sum_y += $lines[$n][$i];\n\t}\n\t\n\t$x[] = $sum_x;\n\t$y[] = $sum_y;\n\t\n}\n\nforeach ($x as $k=>$v) {\n\tfor ($i = 0; $i < $size; $i++) {\n\t\tif ($v < $y[$i]) {\n\t\t\t$wins++;\n\t\t}\t\n\t}\n}\n\n\nprintf('%s', $wins);\n\n\n"}, {"source_code": " $sumH)\n return true;\n}\n\nfor($i = 0; $i < $n; $i++)\n{\n $arr[$i] = array();\n \n $line = fgets(STDIN);\n $exp = @explode(' ', $line);\n \n for($j = 0; $j < $n; $j++)\n $arr[$i][$j] = $exp[$j];\n}\n\nfor($i = 0; $i < $n; $i++)\n for($j = 0; $j < $n; $j++)\n if(check($i, $j))\n $count++;\n\necho $count;\n?>"}, {"source_code": "$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output2=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output2++;}\n }\n}\necho $output2;\n?>"}, {"source_code": "$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output++;}\n }\n}\necho $output;\n?>"}, {"source_code": "\n$input='';\nwhile($s=fgets(STDIN)){\n$input.=$s;\n}\n$mas=preg_split('|\\n|', $input);\n$n=$mas[0];\narray_splice($mas,0,1);\n$mx=array();\n$rsr=array();\n$rss=array();\n$mxr=0;\n$mxs=0;\nforeach ($mas as $id=>$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output2=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output2++;}\n }\n}\necho $output2;\n?>"}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\n$lines = stream_get_contents($stdin);\n$mas= explode(\"\\n\", $lines);\n\n\n$n=$mas[0];\narray_splice($mas,0,1);\n$mx=array();\n$rsr=array();\n$rss=array();\n$mxr=0;\n$mxs=0;\nforeach ($mas as $id=>$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output2=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output2++;}\n }\n}\necho $output2;\n?>"}, {"source_code": ""}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\n$lines = stream_get_contents($stdin);\n\n$lines=explode(\"\\n\", $lines);\n\n$n=$lines[0];\n\nfor ($l=1; $l<=$n; $l++)\n{\n $line=trim($lines[$l]);\n $numbers_in_line=explode(\" \", $line);\n //\u0421\u0443\u043c\u043c\u0430 \u0432 \u043b\u0438\u043d\u0438\u0438 $l\n $sum_line[$l-1]=array_sum($numbers_in_line);\n for ($c=0; $c<$n; $c++)\n $sum_col[$c]+=$numbers_in_line[$c];\n}\n$good=0;\nfor ($l=1; $l<=$n; $l++)\n{\n for ($c=0; $c<$n; $c++)\n if ($sum_col[$c]>$sum_line[$l-1])\n $good++;\n}\n\necho $good;\n?>"}], "negative_code": [{"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num;\n\t\t\t$col_sum[$j] += $inp_num; \n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t//if($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t\tif($row_sum[$i] < $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num; \n\t\t}\n\t}\n\t$col_sum = array();\n\tfor ($k = 0; $k < $inp_n; $k++) {\n\t\tfor ($l = 0; $l < $inp_n; $l++) {\n\t\t\t$col_sum[$k] += $inp_row[$l][$k];\n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\tif($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num; \n\t\t}\n\t}\n\t$col_sum = array();\n\tfor ($k = 0; $k < $inp_n; $k++) {\n\t\tfor ($l = 0; $l < $inp_n; $l++) {\n\t\t\t$col_sum[$k] += $inp_row[$l][$k];\n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t//if($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t\tif($row_sum[$i] < $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num; \n\t\t}\n\t}\n\t$col_sum = array();\n\tfor ($k = 0; $k < $inp_n; $k++) {\n\t\tfor ($l = 0; $l < $inp_n; $l++) {\n\t\t\t$col_sum[$k] += $inp_row[$l][$k];\n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\tif($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "Scan();\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\t$inp_num = $Scanner->Scan();\n\t\t\t$inp_row[$i][] = $inp_num;\n\t\t\t$row_sum[$i] += $inp_num; \n\t\t}\n\t}\n\t$col_sum = array();\n\tfor ($k = 0; $k < $inp_n; $k++) {\n\t\tfor ($l = 0; $l < $inp_n; $l++) {\n\t\t\t$col_sum[$k] += $inp_row[$l][$k];\n\t\t}\n\t}\n\t\n\tfor ($i = 0; $i < $inp_n; $i++) {\n\t\tfor ($j = 0; $j < $inp_n; $j++) {\n\t\t\tif($row_sum[$i] > $col_sum[$j]) $count++;\n\t\t}\n\t}\n\tprintf(\"%d\", $count);\n\t\n\t$Scanner->close();\n\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n\n//input - $inp_\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $(Upper)\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\n/*\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n*/\n/*\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n*/\n/*\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n*/\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.10f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%10d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n?>"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$countMatr = (int)(str_replace( \"\\r\\n\", '', fgets($fp)));\n\n$sumRows = array();\n$sumCols = array();\n$i = 0;\nwhile( $countMatr-- ){\n\t$points = explode(\" \", trim( str_replace( \"\\r\\n\", '', fgets($fp)) ) );\n\tforeach( $points as $key => $value )\n\t{\n\t\t$sumRows[$i] += $value;\n\t\t$sumCols[$key] += $value;\n\t}\n\t$i++;\n}\n\n$res = 0;\nforeach( $sumRows as $rowsVal ){\n\tforeach( $sumCols as $colsVal ){\n\t\tif( $rowsVal > $colsVal ){\n\t\t\t$res++;\n\t\t}\n\t}\n}\necho $res;\nfclose($fp);\n?>"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$countMatr = (int)(str_replace( \"\\r\\n\", '', fgets($fp)));\n\n$sumRows = array();\n$sumCols = array();\n$i = 0;\nwhile( $countMatr-- ){\n\t$points = explode(\" \", trim( str_replace( \"\\r\\n\", '', fgets($fp)) ) );\n\tforeach( $points as $key => $value )\n\t{\n\t\t$sumRows[$i] += $value;\n\t\t$sumCols[$key] += $value;\n\t}\n\t$i++;\n}\n\n$res = 0;\nforeach( $sumRows as $key1 => $rowsVal ){\n\tforeach( $sumCols as $key2 => $colsVal ){\n\t\tif( $colsVal > $rowsVal ){\n\t\t\techo $key1 . ' ' . $key2 . \"\\n\";\n\t\t\t$res++;\n\t\t}\n\t}\n}\necho $res;\nfclose($fp);\n?>"}, {"source_code": "$v) {\n\tif ($k == 0) {\n\t\t$size = $v;\n\t} else {\n\t\t$l = explode(\" \", $v);\n\t\t$lines[] = $l;\n\t\t//$sum_x[] = array_sum($l);\n\t}\n}\n\necho '';\n\n$wins = 0;\n$x = $y = array();\nfor ($i = 0; $i < $size; $i++) {\n\t$sum_x = array_sum($lines[$i]);\n\t$sum_y = 0;\n\tfor ($n = 0; $n < $size; $n++) {\n\t\t$sum_y += $lines[$n][$i];\n\t}\n\t\n\t$x[] = $sum_x;\n\t$y[] = $sum_y;\n\t\n}\n\nforeach ($x as $k=>$v) {\n\tfor ($i = 0; $i < $size; $i++) {\n\t\tif ($v < $y[$i]) {\n\t\t\t$wins++;\n\t\t}\t\n\t}\n}\n\n\nprintf('%s', $wins);\n\n\n"}, {"source_code": "$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output++;}\n }\n}\necho $output;\n?>"}, {"source_code": "\necho('1/n');\necho('1/n');\necho('1/n');\n?>"}, {"source_code": "echo('1/n');\necho('1/n');\necho('1/n');"}, {"source_code": "$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output++;}\n }\n}\necho $output;\n?>"}, {"source_code": "\necho(\"sr\").\"\\n\";\necho(\"sr\").\"\\n\";\n?>"}, {"source_code": "$input='';\nwhile($s=fgets(STDIN)){\n$input.=$s;\n}\n$mas=preg_split('|\\n|', $input);\n$n=$mas[0];\narray_splice($mas,0,1);\n$mx=array();\n$rsr=array();\n$rss=array();\n$mxr=0;\n$mxs=0;\nforeach ($mas as $id=>$st){\n $str=preg_split('| |', $st);\n foreach ($str as $idd=>$rec){\n $mx[$mxr][$mxs]=$rec;\n $mxs++;\n }\n $mxs=0;\n $mxr++;\n}\n\n$output2=0;\n$asr=0;\n$ass=0;\nfor ($r = 0; $r <=$n-1; $r++) {\n for ($s = 0; $s<=$n-1; $s++) {\n $ass=0;\n $asr=0;\n for ($ss = 0; $ss<=$n-1; $ss++) {\n $asr=$asr+$mx[$r][$ss];\n $ass=$ass+$mx[$ss][$s];\n }\n if($ass>$asr){$output2++;}\n }\n}\necho $output2;"}, {"source_code": "\necho(\"sr\").\"/\\n\";\necho(\"sr\").\"/\\n\";\necho(\"sr\").\"/\\n\";\n?>"}, {"source_code": "\necho('1'.\"/n\");\necho('1'.\"/n\");\n?>"}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\n$lines = stream_get_contents($stdin);\n\n$lines=explode(\"\\n\", $lines);\n\n$n=$lines[0];\n\nfor ($l=1; $l<=$n; $l++)\n{\n $line=trim($lines[$l]);\n $numbers_in_line=explode(\" \", $line);\n //\u0421\u0443\u043c\u043c\u0430 \u0432 \u043b\u0438\u043d\u0438\u0438 $l\n $sum_line[$l-1]=array_sum($numbers_in_line);\n for ($c=0; $c<$n; $c++)\n $sum_col[$c]+=$numbers_in_line[$c];\n}\n\nfor ($l=1; $l<=$n; $l++)\n{\n for ($c=0; $c<$n; $c++)\n if ($sum_col[$c]>$sum_line[$l-1])\n $good++;\n}\n\necho $good;\n?>"}], "src_uid": "6e7c2c0d7d4ce952c53285eb827da21d"} {"nl": {"description": "There are $$$n$$$ candies in a row, they are numbered from left to right from $$$1$$$ to $$$n$$$. The size of the $$$i$$$-th candy is $$$a_i$$$.Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob \u2014 from right to left. The game ends if all the candies are eaten.The process consists of moves. During a move, the player eats one or more sweets from her/his side (Alice eats from the left, Bob \u2014 from the right).Alice makes the first move. During the first move, she will eat $$$1$$$ candy (its size is $$$a_1$$$). Then, each successive move the players alternate \u2014 that is, Bob makes the second move, then Alice, then again Bob and so on.On each move, a player counts the total size of candies eaten during the current move. Once this number becomes strictly greater than the total size of candies eaten by the other player on their previous move, the current player stops eating and the move ends. In other words, on a move, a player eats the smallest possible number of candies such that the sum of the sizes of candies eaten on this move is strictly greater than the sum of the sizes of candies that the other player ate on the previous move. If there are not enough candies to make a move this way, then the player eats up all the remaining candies and the game ends.For example, if $$$n=11$$$ and $$$a=[3,1,4,1,5,9,2,6,5,3,5]$$$, then: move 1: Alice eats one candy of size $$$3$$$ and the sequence of candies becomes $$$[1,4,1,5,9,2,6,5,3,5]$$$. move 2: Alice ate $$$3$$$ on the previous move, which means Bob must eat $$$4$$$ or more. Bob eats one candy of size $$$5$$$ and the sequence of candies becomes $$$[1,4,1,5,9,2,6,5,3]$$$. move 3: Bob ate $$$5$$$ on the previous move, which means Alice must eat $$$6$$$ or more. Alice eats three candies with the total size of $$$1+4+1=6$$$ and the sequence of candies becomes $$$[5,9,2,6,5,3]$$$. move 4: Alice ate $$$6$$$ on the previous move, which means Bob must eat $$$7$$$ or more. Bob eats two candies with the total size of $$$3+5=8$$$ and the sequence of candies becomes $$$[5,9,2,6]$$$. move 5: Bob ate $$$8$$$ on the previous move, which means Alice must eat $$$9$$$ or more. Alice eats two candies with the total size of $$$5+9=14$$$ and the sequence of candies becomes $$$[2,6]$$$. move 6 (the last): Alice ate $$$14$$$ on the previous move, which means Bob must eat $$$15$$$ or more. It is impossible, so Bob eats the two remaining candies and the game ends. Print the number of moves in the game and two numbers: $$$a$$$ \u2014 the total size of all sweets eaten by Alice during the game; $$$b$$$ \u2014 the total size of all sweets eaten by Bob during the game. ", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 5000$$$) \u2014 the number of test cases in the input. The following are descriptions of the $$$t$$$ test cases. Each test case consists of two lines. The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 1000$$$) \u2014 the number of candies. The second line contains a sequence of integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 1000$$$) \u2014 the sizes of candies in the order they are arranged from left to right. It is guaranteed that the sum of the values of $$$n$$$ for all sets of input data in a test does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each set of input data print three integers \u2014 the number of moves in the game and the required values $$$a$$$ and $$$b$$$.", "sample_inputs": ["7\n11\n3 1 4 1 5 9 2 6 5 3 5\n1\n1000\n3\n1 1 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 1\n7\n1 1 1 1 1 1 1"], "sample_outputs": ["6 23 21\n1 1000 0\n2 1 2\n6 45 46\n2 2 1\n3 4 2\n4 4 3"], "notes": null}, "positive_code": [{"source_code": " $j) || ($e > $f))\n {\n break;\n }\n }\n $h += $f;\n $f = 0;\n }\n else\n {\n while(TRUE)\n {\n $f += $c[$j];\n $j--;\n if(($i > $j) || ($f > $e))\n {\n break;\n }\n }\n $g += $e;\n $e = 0;\n }\n $d++;\n if($i > $j)\n {\n if($e > 0)\n {\n $g += $e;\n }\n if($f > 0)\n {\n $h += $f;\n }\n break;\n }\n }\n print $d . \" \" . $g . \" \" . $h . \"\\n\";\n}\n?>"}, {"source_code": " $now_eat)\n {\n \n $l = $i + 1 ;\n $now_eat = $eat ;\n $a_eat += $eat ;\n $now_u = 1 ;\n break ;\n }\n }\n \n if($i > $r)\n {\n $l = $r + 1 ;\n $now_eat = $eat ;\n $a_eat += $eat ;\n $now_u = 1 ;\n }\n }\n else\n {\n // Bob\n $eat = 0 ;\n for($i = $r; $i >= $l; $i --)\n {\n $eat += $candy[$i] ;\n \n if($eat > $now_eat)\n {\n \n $r = $i - 1 ;\n $now_eat = $eat ;\n $b_eat += $eat ;\n $now_u = 0 ;\n break ;\n }\n }\n \n if($i < $l)\n {\n $r = $l - 1 ;\n $now_eat = $eat ;\n $b_eat += $eat ;\n $now_u = 0 ;\n }\n }\n }\n \n echo $step . \" \" . $a_eat . \" \" . $b_eat . \"\\n\" ;\n }\n?>"}], "negative_code": [], "src_uid": "d70ee6d3574e0f2cac3c683729e2979d"} {"nl": {"description": "Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0,\u20090) and the length of the side equals a meters. The sides of the square are parallel to coordinate axes.As the length of the marathon race is very long, Valera needs to have extra drink during the race. The coach gives Valera a bottle of drink each d meters of the path. We know that Valera starts at the point with coordinates (0,\u20090) and runs counter-clockwise. That is, when Valera covers a meters, he reaches the point with coordinates (a,\u20090). We also know that the length of the marathon race equals nd\u2009+\u20090.5 meters. Help Valera's coach determine where he should be located to help Valera. Specifically, determine the coordinates of Valera's positions when he covers d,\u20092\u00b7d,\u2009...,\u2009n\u00b7d meters.", "input_spec": "The first line contains two space-separated real numbers a and d (1\u2009\u2264\u2009a,\u2009d\u2009\u2264\u2009105), given with precision till 4 decimal digits after the decimal point. Number a denotes the length of the square's side that describes the stadium. Number d shows that after each d meters Valera gets an extra drink. The second line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) showing that Valera needs an extra drink n times.", "output_spec": "Print n lines, each line should contain two real numbers xi and yi, separated by a space. Numbers xi and yi in the i-th line mean that Valera is at point with coordinates (xi,\u2009yi) after he covers i\u00b7d meters. Your solution will be considered correct if the absolute or relative error doesn't exceed 10\u2009-\u20094. Note, that this problem have huge amount of output data. Please, do not use cout stream for output in this problem.", "sample_inputs": ["2 5\n2", "4.147 2.8819\n6"], "sample_outputs": ["1.0000000000 2.0000000000\n2.0000000000 0.0000000000", "2.8819000000 0.0000000000\n4.1470000000 1.6168000000\n3.7953000000 4.1470000000\n0.9134000000 4.1470000000\n0.0000000000 2.1785000000\n0.7034000000 0.0000000000"], "notes": null}, "positive_code": [{"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= bcdiv($m, BASE, 5) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= $pa . ' ' . bcdiv($m, BASE, 5) . \"\\n\";\n break;\n case 2:\n $ret .= bcdiv(bcsub($a, $m), BASE, 5) . ' ' . $pa . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . bcdiv(bcsub($a,$m), BASE, 5) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= bcdiv($m, BASE, 5) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= $pa . ' ' . bcdiv($m, BASE, 5) . \"\\n\";\n break;\n case 2:\n $ret .= bcdiv(bcsub($a, $m), BASE, 5) . ' ' . $pa . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . bcdiv(bcsub($a,$m), BASE, 5) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " $a4) {\n $r -= floor($r / $a4) * $a4;\n }\n while ($r > 0.00001) {\n $s = min($z, $r);\n $z -= $s;\n $r -= $s;\n if ($v == 0) {\n $x += $s;\n } elseif ($v == 1) {\n $y += $s;\n } elseif ($v == 2) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n if ($z < 0.00001) {\n $z = $a;\n $v ++;\n if ($v > 3) {\n $v = 0;\n }\n }\n }\n echo number_format(round($x, 4), 10, '.', '') . ' ' . number_format(round($y, 4), 10, '.', '') . \"\\n\";\n}\n"}], "negative_code": [{"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= sprintf(\"%0.5f\", ($m / BASE)) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= sprintf(\"%0.5f\", ($a / BASE)) . ' ' . sprintf(\"%0.5f\", ($m / BASE)) . \"\\n\";\n break;\n case 2:\n $ret .= sprintf(\"%0.5f\", ($a - $m) / BASE) . ' ' . sprintf(\"%0.5f\", ($a / BASE)) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . sprintf(\"%0.5f\", ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= ($m / BASE) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= ($a / BASE) . ' ' . ($m / BASE) . \"\\n\";\n break;\n case 2:\n $ret .= ( ($a - $m) / BASE) . ' ' . ($a / BASE) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . ( ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= bcdiv($m, BASE, 5) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= $pa . ' ' . bcdiv($m, BASE, 5) . \"\\n\";\n break;\n case 2:\n $ret .= bcdiv(bcsub($a, $m), BASE, 5) . ' ' . $pa . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . bcdiv(bcsub($a,$m), BASE, 5) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= sprintf(\"%0.4f\", ($m / BASE)) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= sprintf(\"%0.4f\", ($a / BASE)) . ' ' . sprintf(\"%0.4f\", ($m / BASE)) . \"\\n\";\n break;\n case 2:\n $ret .= sprintf(\"%0.4f\", ($a - $m) / BASE) . ' ' . sprintf(\"%0.4f\", ($a / BASE)) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . sprintf(\"%0.4f\", ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= ($m / 10000) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= ($a / 10000) . ' ' . ($m / 10000) . \"\\n\";\n break;\n case 2:\n $ret .= ( ($a - $m) / 10000) . ' ' . ($a / 10000) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . ( ($a - $m) / 10000) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= sprintf(\"%0.5f\", ($m / BASE)) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= sprintf(\"%0.5f\", ($a / BASE)) . ' ' . sprintf(\"%0.5f\", ($m / BASE)) . \"\\n\";\n break;\n case 2:\n $ret .= sprintf(\"%0.5f\", ($a - $m) / BASE) . ' ' . sprintf(\"%0.5f\", ($a / BASE)) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . sprintf(\"%0.5f\", ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= sprintf(\"%0.5f\", ($m / BASE)) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= sprintf(\"%0.5f\", ($a / BASE)) . ' ' . sprintf(\"%0.5f\", ($m / BASE)) . \"\\n\";\n break;\n case 2:\n $ret .= sprintf(\"%0.5f\", ($a - $m) / BASE) . ' ' . sprintf(\"%0.5f\", ($a / BASE)) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . sprintf(\"%0.5f\", ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": " 0)) {\n $o--;\n $m = $a;\n }\n switch ($o) {\n case 0:\n $ret .= ($m / BASE) . \" 0.0\\n\";\n break;\n case 1:\n $ret .= ($a / BASE) . ' ' . ($m / BASE) . \"\\n\";\n break;\n case 2:\n $ret .= ( ($a - $m) / BASE) . ' ' . ($a / BASE) . \"\\n\";\n break;\n case 3:\n $ret .= '0.0 ' . ( ($a - $m) / BASE) . \"\\n\";\n break;\n }\n}\necho $ret;"}, {"source_code": "\nlist($a, $d) = explode(' ', trim(fgets(STDIN)));\n$times = trim(fgets(STDIN));\nfor($i = 1; $i <= $times; $i++){\n $curr = $d*$i;\n if(($curr/$a)%4 == 0){\n $y = 0;\n $tmp = floor($curr/$a);\n $x = round($curr-$tmp*$a, 5);\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 1){\n $x = $a;\n $tmp = floor($curr/$a);\n $y = round($curr-$tmp*$a, 5);\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 2){\n $y = $a;\n $tmp = floor($curr/$a);\n $x = round($a-($curr-$tmp*$a), 5);\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 3){\n $x = 0;\n $tmp = floor($curr/$a);\n $y = round($a-($curr-$tmp*$a), 5);\n echo $x.' '.$y.\"\\n\";\n }\n}"}, {"source_code": "\nlist($a, $d) = explode(' ', trim(fgets(STDIN)));\n$times = trim(fgets(STDIN));\nfor($i = 1; $i <= $times; $i++){\n $curr = $d*$i;\n if(($curr/$a)%4 == 0){\n $y = 0;\n $tmp = floor($curr/$a);\n $x = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 1){\n $x = $a;\n $tmp = floor($curr/$a);\n $y = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 2){\n $y = $a;\n $tmp = floor($curr/$a);\n $x = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 3){\n $x = 0;\n $tmp = floor($curr/$a);\n $y = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }\n}"}, {"source_code": "\nlist($a, $d) = explode(' ', trim(fgets(STDIN)));\n$times = trim(fgets(STDIN));\nfor($i = 1; $i <= $times; $i++){\n $curr = $d*$i;\n if(($curr/$a)%4 == 0){\n $y = 0;\n $tmp = floor($curr/$a);\n $x = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 1){\n $x = $a;\n $tmp = floor($curr/$a);\n $y = $curr-$tmp*$a;\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 2){\n $y = $a;\n $tmp = floor($curr/$a);\n $x = $a-($curr-$tmp*$a);\n echo $x.' '.$y.\"\\n\";\n }elseif(($curr/$a)%4 == 3){\n $x = 0;\n $tmp = floor($curr/$a);\n $y = $a-($curr-$tmp*$a);\n echo $x.' '.$y.\"\\n\";\n }\n}"}, {"source_code": " $a4) {\n $r -= floor($r / $a4) * $a4;\n }\n while ($r > 0.00001) {\n $s = min($z, $r);\n $z -= $s;\n $r -= $s;\n if ($v == 0) {\n $x += $s;\n } elseif ($v == 1) {\n $y += $s;\n } elseif ($v == 2) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n if ($z < 0.00001) {\n $z = $a;\n $v ++;\n if ($v > 3) {\n $v = 0;\n }\n }\n }\n echo number_format(round($x, 4), 10, '.', '') . ' ' . number_format(round($y, 4), 10, '.', '') . \"\\n\";\n}\n"}, {"source_code": "$input = trim(file_get_contents('php://stdin'));\nlist($ad, $n) = explode(\"\\n\", $input);\nlist($a, $d) = explode(\" \", $ad);\n\n$x = 0;\n$y = 0;\n$z = $a;\n\n$a4 = $a * 4;\nfor ($i = 0; $i < $n; $i ++) {\n $r = $d;\n if ($r > $a4) {\n $r -= floor($r / $a4) * $a4;\n }\n while ($r > 0.00001) {\n $s = min($z, $r);\n $z -= $s;\n if ($z < 0.00001) {\n $z = $a;\n }\n $r -= $s;\n if ($y < 0.00001 && abs($x - $a) > 0.00001) {\n $x += $s;\n } elseif (abs($y - $a) > 0.00001 && abs($x - $a) < 0.00001) {\n $y += $s;\n } elseif (abs($y - $a) < 0.00001 && $x > 0.00001) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n }\n echo number_format(round($x, 4), 10, '.', '') . ' ' . number_format(round($y, 4), 10, '.', '') . \"\\n\";\n}\n"}, {"source_code": " $a4) {\n $r -= floor($r / $a4) * $a4;\n }\n while ($r >= 0.0001) {\n $s = min($z, $r);\n $z -= $s;\n if ($z < 0.0001) {\n $z = $a;\n }\n $r -= $s;\n if ($y < 0.0001 && abs($x - $a) > 0.0001) {\n $x += $s;\n } elseif (abs($y - $a) > 0.0001 && abs($x - $a) < 0.0001) {\n $y += $s;\n } elseif (abs($y - $a) < 0.0001 && $x > 0.0001) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n }\n echo number_format(round($x, 4), 10, '.', '') . ' ' . number_format(round($y, 4), 10, '.', '') . \"\\n\";\n}\n"}, {"source_code": " 0) {\n $s = min($a - ($rAll - floor($rAll / $a) * $a), $r);\n $rAll += $s;\n $r -= $s;\n if ($y < 0.0001 && abs($x - $a) > 0.0001) {\n $x += $s;\n } elseif (abs($y - $a) > 0.0001 && abs($x - $a) < 0.0001) {\n $y += $s;\n } elseif (abs($y - $a) < 0.0001 && $x > 0.0001) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n }\n echo number_format($x, 10) . ' ' . number_format($y, 10) . \"\\n\";\n}\n"}, {"source_code": " 0) {\n $s = min($a - ($rAll % $a), $r);\n $rAll += $s;\n $r -= $s;\n if ($y == 0 && $x < $a) {\n $x += $s;\n } elseif ($y < $a && $x == $a) {\n $y += $s;\n } elseif ($y == $a && $x > 0) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n }\n echo number_format($x / 10000, 10, '.', '') . ' ' . number_format($y / 10000, 10, '.', '') . \"\\n\";\n}\n"}, {"source_code": " $a4) {\n $r -= floor($r / $a4) * $a4;\n }\n while ($r > 0.00001) {\n $s = min($z, $r);\n $z -= $s;\n $r -= $s;\n if ($v == 0) {\n $x += $s;\n } elseif ($v == 1) {\n $y += $s;\n } elseif ($v == 2) {\n $x -= $s;\n } else {\n $y -= $s;\n }\n if ($z < 0.00001) {\n $z = $a;\n $v ++;\n if ($v > 3) {\n $v = 0;\n }\n }\n }\n echo number_format(round($x, 4), 10, '.', '') . ' ' . number_format(round($y, 4), 10, '.', '') . \"\\n\";\n}\n"}], "src_uid": "d00b8423c3c52b19fec25bc63e4d4c1c"} {"nl": {"description": "The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.Polycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented as a group of four 8-bit numbers (without leading zeroes), separated by dots. For example, the record 0.255.1.123 shows a correct IP address and records 0.256.1.123 and 0.255.1.01 do not. In this problem an arbitrary group of four 8-bit numbers is a correct IP address.Having worked as an administrator for some time, Polycarpus learned that if you know the IP address, you can use the subnet mask to get the address of the network that has this IP addess.The subnet mask is an IP address that has the following property: if we write this IP address as a 32 bit string, that it is representable as \"11...11000..000\". In other words, the subnet mask first has one or more one bits, and then one or more zero bits (overall there are 32 bits). For example, the IP address 2.0.0.0 is not a correct subnet mask as its 32-bit record looks as 00000010000000000000000000000000.To get the network address of the IP address, you need to perform the operation of the bitwise \"and\" of the IP address and the subnet mask. For example, if the subnet mask is 255.192.0.0, and the IP address is 192.168.1.2, then the network address equals 192.128.0.0. In the bitwise \"and\" the result has a bit that equals 1 if and only if both operands have corresponding bits equal to one.Now Polycarpus wants to find all networks to which his IP addresses belong. Unfortunately, Polycarpus lost subnet mask. Fortunately, Polycarpus remembers that his IP addresses belonged to exactly k distinct networks. Help Polycarpus find the subnet mask, such that his IP addresses will belong to exactly k distinct networks. If there are several such subnet masks, find the one whose bit record contains the least number of ones. If such subnet mask do not exist, say so.", "input_spec": "The first line contains two integers, n and k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of IP addresses and networks. The next n lines contain the IP addresses. It is guaranteed that all IP addresses are distinct.", "output_spec": "In a single line print the IP address of the subnet mask in the format that is described in the statement, if the required subnet mask exists. Otherwise, print -1.", "sample_inputs": ["5 3\n0.0.0.1\n0.1.1.2\n0.0.2.1\n0.1.1.0\n0.0.2.3", "5 2\n0.0.0.1\n0.1.1.2\n0.0.2.1\n0.1.1.0\n0.0.2.3", "2 1\n255.0.0.1\n0.0.0.2"], "sample_outputs": ["255.255.254.0", "255.255.0.0", "-1"], "notes": null}, "positive_code": [{"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks = array();\n$i = 0;\nwhile($i++ < 32) {\n $masks[] = str_repeat(1, $i) . str_repeat(0, 32 - $i);\n}\n\n$ips = array();\nwhile($n--) {\n $ip = fgets(STDIN); \n $tmp = explode(\".\", $ip);\n $ips[] = sprintf(\"%08b%08b%08b%08b\", $tmp[0], $tmp[1], $tmp[2], $tmp[3]);\n}\n\nforeach($masks as $mask) {\n $res = array();\n foreach($ips as $ip) {\n $network = $mask & $ip;\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(sprintf(\"%d.%d.%d.%d\", bindec(substr($mask, 0, 8)), bindec(substr($mask, 8, 8)), bindec(substr($mask, 16, 8)), bindec(substr($mask, 24, 8))));\n }\n}\ndie(\"-1\");\n"}, {"source_code": "= $from) {\n $i = (int)(($from + $last) / 2);\n $list = [];\n $mask = $masks[$i];\n $subnet = -1;\n $count = 0;\n foreach ($ips as $ip) {\n $s = $ip & $mask;\n if ($s != $subnet) $count++;\n $subnet = $s; \n }\n \n if ($count >= $k) {\n $from = $i + 1;\n } else {\n $last = $i - 1;\n }\n if ($count == $k)\n $result = $i;\n}\nif ($result > 0) {\n die(long2ip($masks[$result]));\n}\n\necho $n == $k ? \"255.255.255.255\" : -1;\n\n"}, {"source_code": "\nlist($n, $m) = explode(' ',trim(fgets(STDIN)));\nfor ($i=0; $i<$n;++$i) {\n$input = explode('.', trim(fgets(STDIN)));\n$ip[$i] = sprintf(\"%08s\", decbin($input[0])).sprintf(\"%08s\", decbin($input[1])).sprintf(\"%08s\", decbin($input[2])).sprintf(\"%08s\", decbin($input[3]));\n}\n $ans = ' ';\n $mask = \"00000000000000000000000000000000\";\n for ($i=0; $i<31;++$i)\n {\n $set = array();\n $c = 0;\n $mask[$i] = '1';\n \n for ($j=0; $j<$n;++$j)\n {\n $ans = $mask & $ip[$j];\n if (!isset($set[$ans])) {$set[$ans] = true; ++$c;}\n } \n \n if ($c == $m) \n {\n echo bindec(substr($mask,0,8)).\".\".bindec(substr($mask,8,8)).\".\".bindec(substr($mask,16,8)).\".\".bindec(substr($mask,24,8)); \n exit;\n } \n }\necho \"-1\";\n?>"}], "negative_code": [{"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks_tmp = array(128, 192, 224, 240, 248, 252, 254, 255);\n\n$masks = array();\nforeach($masks_tmp as $mask)\n $masks[] = array($mask, 0, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, $mask, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, $mask, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, 255, $mask);\n\n\n$ips = array();\nwhile($n--) {\n $ips[] = explode(\".\", fgets(STDIN));\n}\n\n$start = floor(sqrt($k)) - 1;\nfor($i = $start; $i < count($masks); $i++) {\n $mask = $masks[$i];\n $res = array();\n foreach($ips as $ip) {\n $network = ($mask[0] & (int)$ip[0]);\n $network .= \".\" . ($mask[1] & (int)$ip[1]);\n $network .= \".\" . ($mask[2] & (int)$ip[2]);\n $network .= \".\" . ($mask[3] & (int)$ip[3]);\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(implode(\".\", $mask));\n }\n}\ndie(\"-1\");"}, {"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks_tmp = array(128, 192, 224, 240, 248, 252, 254, 255);\n\n$masks = array();\nforeach($masks_tmp as $mask)\n $masks[] = array($mask, 0, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, $mask, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, $mask, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, 255, $mask);\n\n\n$ips = array();\nwhile($n--) {\n //$ips[] = explode(\".\", fgets(STDIN));\n $ips[] = mt_rand(0, 255) . \".\" . mt_rand(0, 255) . \".\" . mt_rand(0, 255) . \".\" . mt_rand(0, 255);\n}\n\n$start = floor(sqrt($k));\nfor($i = $start; $i < count($masks); $i++) {\n $mask = $masks[$i];\n $res = array();\n foreach($ips as $ip) {\n $network = ($mask[0] & (int)$ip[0]);\n $network .= \".\" . ($mask[1] & (int)$ip[1]);\n $network .= \".\" . ($mask[2] & (int)$ip[2]);\n $network .= \".\" . ($mask[3] & (int)$ip[3]);\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(implode(\".\", $mask));\n }\n}\ndie(\"-1\");"}, {"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks_tmp = array(128, 192, 224, 240, 248, 252, 254, 255);\n\n$masks = array();\nforeach($masks_tmp as $mask)\n $masks[] = array($mask, 0, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, $mask, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, $mask, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, 255, $mask);\n\n\n$ips = array();\nwhile($n--) {\n $ips[] = explode(\".\", fgets(STDIN));\n}\n\n$start = ceil(sqrt($k));\nfor($i = $start; $i < count($masks); $i++) {\n $mask = $masks[$i];\n $res = array();\n foreach($ips as $ip) {\n $network = ($mask[0] & (int)$ip[0]);\n $network .= \".\" . ($mask[1] & (int)$ip[1]);\n $network .= \".\" . ($mask[2] & (int)$ip[2]);\n $network .= \".\" . ($mask[3] & (int)$ip[3]);\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(implode(\".\", $mask));\n }\n}\ndie(\"-1\");"}, {"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks_tmp = array(128, 192, 224, 240, 248, 252, 254, 255);\n\n$masks = array();\nforeach($masks_tmp as $mask)\n $masks[] = array($mask, 0, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, $mask, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, $mask, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, 255, $mask);\n\n\n$ips = array();\nwhile($n--) {\n $ips[] = explode(\".\", fgets(STDIN));\n}\n\n$start = ceil(sqrt($k)) - 1;\nfor($i = $start; $i < count($masks); $i++) {\n $mask = $masks[$i];\n $res = array();\n foreach($ips as $ip) {\n $network = ($mask[0] & (int)$ip[0]);\n $network .= \".\" . ($mask[1] & (int)$ip[1]);\n $network .= \".\" . ($mask[2] & (int)$ip[2]);\n $network .= \".\" . ($mask[3] & (int)$ip[3]);\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(implode(\".\", $mask));\n }\n}\ndie(\"-1\");"}, {"source_code": "\n\n\n for ($j=0; $j<$n;++$j)\n {\n $ans = $mask & $ip[$j];\n if (!isset($set[$ans])) {$set[$ans] = true; ++$c;}\n }\n\n\n\n for ($j=0; $j<$n;++$j)\n {\n for ($k=0; $j<32;++$k){\n if ($mask[$k] && $ip[$j][$k]) $ans[$k]=1; else $ans[$k]=0;\n }\n if (!isset($set[$ans])) {$set[$ans] = true; ++$c;}\n } \n \n \n \nlist($n, $m) = explode(' ',trim(fgets(STDIN)));\nfor ($i=0; $i<$n;++$i) {\n$input = explode('.', trim(fgets(STDIN)));\n$ip[$i] = sprintf(\"%08s\", decbin($input[0])).sprintf(\"%08s\", decbin($input[1])).sprintf(\"%08s\", decbin($input[2])).sprintf(\"%08s\", decbin($input[3]));\n}\n $ans = ' ';\n $mask = \"00000000000000000000000000000000\";\n for ($i=0; $i<31;++$i)\n {\n $set = array();\n $c = 0;\n $mask[$i] = '1';\n \n for ($j=0; $j<$n;++$j)\n {\n for ($k=0; $k<32;++$k){\n if ($mask[$k] && $ip[$j][$k]) $ans[$k]=1; else $ans[$k]=0;\n }\n if (!isset($set[$ans])) {$set[$ans] = true; ++$c;}\n } \n \n if ($c == $m) \n {\n echo bindec(substr($mask,0,8)).\".\".bindec(substr($mask,8,8)).\".\".bindec(substr($mask,16,8)).\".\".bindec(substr($mask,24,8)); \n exit;\n } \n }\necho \"-1\";\n?>"}, {"source_code": "\n\nlist($n, $k) = explode(\" \", fgets(STDIN));\n\n$masks_tmp = array(128, 192, 224, 240, 248, 252, 254, 255);\n\n$masks = array();\nforeach($masks_tmp as $mask)\n $masks[] = array($mask, 0, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, $mask, 0, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, $mask, 0);\n\nforeach($masks_tmp as $mask)\n $masks[] = array(255, 255, 255, $mask);\n\n\n$ips = array();\nwhile($n--) {\n $ips[] = explode(\".\", fgets(STDIN));\n}\n\n$start = floor(sqrt($k));\nfor($i = $start; $i < count($masks); $i++) {\n $mask = $masks[$i];\n $res = array();\n foreach($ips as $ip) {\n $network = ($mask[0] & (int)$ip[0]);\n $network .= \".\" . ($mask[1] & (int)$ip[1]);\n $network .= \".\" . ($mask[2] & (int)$ip[2]);\n $network .= \".\" . ($mask[3] & (int)$ip[3]);\n $res[$network]++;\n }\n \n if(count($res) == $k) { \n die(implode(\".\", $mask));\n }\n}\ndie(\"-1\");"}], "src_uid": "4da4410d3b75ee87a4dfa33b437b9cfa"} {"nl": {"description": "Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:You are given an array $$$a$$$ of $$$n$$$ integers. You are also given an integer $$$k$$$. Lord Omkar wants you to do $$$k$$$ operations with this array.Define one operation as the following: Set $$$d$$$ to be the maximum value of your array. For every $$$i$$$ from $$$1$$$ to $$$n$$$, replace $$$a_{i}$$$ with $$$d-a_{i}$$$. The goal is to predict the contents in the array after $$$k$$$ operations. Please help Ray determine what the final sequence will look like!", "input_spec": "Each test contains multiple test cases. The first line contains the number of cases $$$t$$$ ($$$1 \\le t \\le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 2 \\cdot 10^5, 1 \\leq k \\leq 10^{18}$$$) \u2013 the length of your array and the number of operations to perform. The second line of each test case contains $$$n$$$ integers $$$a_{1},a_{2},...,a_{n}$$$ $$$(-10^9 \\leq a_{i} \\leq 10^9)$$$ \u2013 the initial contents of your array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each case, print the final version of array $$$a$$$ after $$$k$$$ operations described above.", "sample_inputs": ["3\n2 1\n-199 192\n5 19\n5 -1 4 2 0\n1 2\n69"], "sample_outputs": ["391 0\n0 6 1 3 5\n0"], "notes": "NoteIn the first test case the array changes as follows:Initially, the array is $$$[-199, 192]$$$. $$$d = 192$$$.After the operation, the array becomes $$$[d-(-199), d-192] = [391, 0]$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "f18a5fa0b2e7e96cb5994b7b2dbe0189"} {"nl": {"description": "In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.Lesha knows that today he can study for at most $$$a$$$ hours, and he will have $$$b$$$ hours to study tomorrow. Note that it is possible that on his planet there are more hours in a day than on Earth. Lesha knows that the quality of his knowledge will only depend on the number of lecture notes he will read. He has access to an infinite number of notes that are enumerated with positive integers, but he knows that he can read the first note in one hour, the second note in two hours and so on. In other words, Lesha can read the note with number $$$k$$$ in $$$k$$$ hours. Lesha can read the notes in arbitrary order, however, he can't start reading a note in the first day and finish its reading in the second day.Thus, the student has to fully read several lecture notes today, spending at most $$$a$$$ hours in total, and fully read several lecture notes tomorrow, spending at most $$$b$$$ hours in total. What is the maximum number of notes Lesha can read in the remaining time? Which notes should he read in the first day, and which\u00a0\u2014 in the second?", "input_spec": "The only line of input contains two integers $$$a$$$ and $$$b$$$ ($$$0 \\leq a, b \\leq 10^{9}$$$)\u00a0\u2014 the number of hours Lesha has today and the number of hours Lesha has tomorrow.", "output_spec": "In the first line print a single integer $$$n$$$ ($$$0 \\leq n \\leq a$$$)\u00a0\u2014 the number of lecture notes Lesha has to read in the first day. In the second line print $$$n$$$ distinct integers $$$p_1, p_2, \\ldots, p_n$$$ ($$$1 \\leq p_i \\leq a$$$), the sum of all $$$p_i$$$ should not exceed $$$a$$$. In the third line print a single integer $$$m$$$ ($$$0 \\leq m \\leq b$$$)\u00a0\u2014 the number of lecture notes Lesha has to read in the second day. In the fourth line print $$$m$$$ distinct integers $$$q_1, q_2, \\ldots, q_m$$$ ($$$1 \\leq q_i \\leq b$$$), the sum of all $$$q_i$$$ should not exceed $$$b$$$. All integers $$$p_i$$$ and $$$q_i$$$ should be distinct. The sum $$$n + m$$$ should be largest possible.", "sample_inputs": ["3 3", "9 12"], "sample_outputs": ["1\n3 \n2\n2 1", "2\n3 6\n4\n1 2 4 5"], "notes": "NoteIn the first example Lesha can read the third note in $$$3$$$ hours in the first day, and the first and the second notes in one and two hours correspondingly in the second day, spending $$$3$$$ hours as well. Note that Lesha can make it the other way round, reading the first and the second notes in the first day and the third note in the second day.In the second example Lesha should read the third and the sixth notes in the first day, spending $$$9$$$ hours in total. In the second day Lesha should read the first, second fourth and fifth notes, spending $$$12$$$ hours in total."}, "positive_code": [{"source_code": " $a)\n {\n $e++;\n $f = 1;\n while(TRUE)\n {\n $d -= $f;\n if($d == $a)\n {\n unset($g[$f - 1]);\n break;\n }\n else\n {\n $d += $f;\n $f++;\n }\n }\n break;\n }\n elseif($d < $a)\n {\n $e++;\n }\n }\n}\nif($a != 0)\n{\n if(($f != 0) && ($b != 0))\n {\n $h = array($f);\n $i = $f;\n }\n else\n {\n $h = array();\n $i = 0;\n }\n}\nelse\n{\n $h == array();\n $i = 0;\n}\nif($b != 0)\n{\n if($a == 0)\n {\n $e = 1;\n }\n while(TRUE)\n {\n $i += $e;\n if($i < $b)\n {\n $h[count($h)] = $e;\n $e++;\n }\n elseif($i == $b)\n {\n $h[count($h)] = $e;\n break;\n }\n elseif($i > $b)\n {\n break;\n }\n }\n}\nprint count($g) . \"\\n\";\nprint implode(\" \", $g) . \"\\n\";\nprint count($h) . \"\\n\";\nprint implode(\" \", $h);\n?>"}, {"source_code": "0) {\n $x1 = (-$b+sqrt($d))/2*$a;\n $x2 = (-$b-sqrt($d))/2*$a;\n } elseif ($d==0) {\n $x1 = $x2 = (-$b)/2*$a;\n } else {\n $x1 = -$b . '+' . sqrt(abs($d)) . 'i';\n $x2 = -$b . '-' . sqrt(abs($d)) . 'i';\n }\n }\n return floor($x1);\n}\n\n$n = eq_roots(1, 1, -2*$hours);\n\nif($b == 0) {\n\n} else {\n $second = range(1, $n);\n}\n\n\n\n$abstract_balance = $a;\nfor($i=$n;$i>=1;$i--) {\n\t// 5, 4, 3, 2, 1\n\tif(($abstract_balance - $i) >= 0) {\n\t\tarray_push($first, $i);\n\t\t$abstract_balance = $abstract_balance - $i;\n\t}\n\tif($abstract_balance == 0) {\n\t\tbreak;\n\t}\n}\n\n$second_2 = array_diff($second, $first);\n\n$r1 = count($first);\n$r2 = count($second_2);\n$arr1 = implode(\" \", $first);\n$arr2 = implode(\" \", $second_2);\n\necho $r1.PHP_EOL;\necho $arr1.PHP_EOL;\necho $r2.PHP_EOL;\necho $arr2.PHP_EOL;\n\n\n?>"}], "negative_code": [{"source_code": " $a)\n {\n $e++;\n $f = 1;\n while(TRUE)\n {\n $d -= $f;\n if($d == $a)\n {\n unset($g[$f - 1]);\n break;\n }\n else\n {\n $d += $f;\n $f++;\n }\n }\n break;\n }\n elseif($d < $a)\n {\n $e++;\n }\n }\n}\nif($a != 0)\n{\n if($f != 0)\n {\n $h = array($f);\n $i = $f;\n }\n else\n {\n $h = array();\n $i = 0;\n }\n}\nelse\n{\n $h == array();\n $i = 0;\n}\nif($b != 0)\n{\n if($a == 0)\n {\n $e = 1;\n }\n while(TRUE)\n {\n $i += $e;\n if($i < $b)\n {\n $h[count($h)] = $e;\n $e++;\n }\n elseif($i == $b)\n {\n $h[count($h)] = $e;\n break;\n }\n elseif($i > $b)\n {\n break;\n }\n }\n}\nprint count($g) . \"\\n\";\nprint implode(\" \", $g) . \"\\n\";\nprint count($h) . \"\\n\";\nprint implode(\" \", $h);\n?>"}, {"source_code": " $a)\n {\n $e++;\n $f = 1;\n while(TRUE)\n {\n $d -= $f;\n if($d == $a)\n {\n unset($g[$f - 1]);\n break;\n }\n else\n {\n $d += $f;\n $f++;\n }\n }\n break;\n }\n elseif($d < $a)\n {\n $e++;\n }\n }\n}\nif($f != 0)\n{\n $h = array($f);\n $i = $f;\n}\nelse\n{\n $h = array();\n $i = 0;\n}\nif($b != 0)\n{\n if($a == 0)\n {\n $e = 1;\n }\n while(TRUE)\n {\n $i += $e;\n if($i < $b)\n {\n $h[count($h)] = $e;\n $e++;\n }\n elseif($i == $b)\n {\n $h[count($h)] = $e;\n break;\n }\n elseif($i > $b)\n {\n break;\n }\n }\n}\nprint count($g) . \"\\n\";\nprint implode(\" \", $g) . \"\\n\";\nprint count($h) . \"\\n\";\nprint implode(\" \", $h);\n?>"}, {"source_code": "0) {\n $x1 = (-$b+sqrt($d))/2*$a;\n } elseif ($d==0) {\n $x1 = $x2 = (-$b)/2*$a;\n } else {\n $x1 = -$b . '+' . sqrt(abs($d)) . 'i';\n }\n }\n return floor($x1);\n}\n\n$n = eq_roots(1, 1, -2*$hours);\n\n\n$second = range(1, $n);\n\n\n$abstract_balance = $a;\nfor($i=$n;$i>=1;$i--) {\n\t// 5, 4, 3, 2, 1\n\tif(($abstract_balance - $i) >= 0) {\n\t\tarray_push($first, $i);\n\t\t$abstract_balance = $abstract_balance - $i;\n\t}\n\tif($abstract_balance == 0) {\n\t\tbreak;\n\t}\n}\n\n$second_2 = array_diff($second, $first);\n\n$r1 = count($first);\n$r2 = count($second_2);\n$arr1 = implode(\" \", $first);\n$arr2 = implode(\" \", $second_2);\n\necho $r1.PHP_EOL;\necho $arr1.PHP_EOL;\necho $r2.PHP_EOL;\necho $arr2.PHP_EOL;\n\n\n?>"}], "src_uid": "fab438cef9eb5e9e4a4a2e3f9e4f9cec"} {"nl": {"description": "Positive integer $$$x$$$ is called divisor of positive integer $$$y$$$, if $$$y$$$ is divisible by $$$x$$$ without remainder. For example, $$$1$$$ is a divisor of $$$7$$$ and $$$3$$$ is not divisor of $$$8$$$.We gave you an integer $$$d$$$ and asked you to find the smallest positive integer $$$a$$$, such that $$$a$$$ has at least $$$4$$$ divisors; difference between any two divisors of $$$a$$$ is at least $$$d$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 3000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$d$$$ ($$$1 \\leq d \\leq 10000$$$).", "output_spec": "For each test case print one integer $$$a$$$\u00a0\u2014 the answer for this test case.", "sample_inputs": ["2\n1\n2"], "sample_outputs": ["6\n15"], "notes": "NoteIn the first test case, integer $$$6$$$ have following divisors: $$$[1, 2, 3, 6]$$$. There are $$$4$$$ of them and the difference between any two of them is at least $$$1$$$. There is no smaller integer with at least $$$4$$$ divisors.In the second test case, integer $$$15$$$ have following divisors: $$$[1, 3, 5, 15]$$$. There are $$$4$$$ of them and the difference between any two of them is at least $$$2$$$.The answer $$$12$$$ is INVALID because divisors are $$$[1, 2, 3, 4, 6, 12]$$$. And the difference between, for example, divisors $$$2$$$ and $$$3$$$ is less than $$$d=2$$$."}, "positive_code": [{"source_code": " $item) {\n $r = $m - 1;\n } else {\n return $realPrime[$m];\n }\n }\n\n return $realPrime[$l];\n}\n\nfor ($i = 0; $i < $tests; ++$i) {\n fscanf(STDIN, \"%d\\n\", $d);\n\n $firstPrime = binSearch(1 + $d, $realPrime);\n $secondPrime = binSearch($firstPrime + $d, $realPrime);\n echo $firstPrime * $secondPrime . PHP_EOL;\n}"}], "negative_code": [{"source_code": " max(0, $y - $b); $z--)\n {\n if($c[$x][$z] == \".\")\n {\n $i++;\n }\n else\n {\n break;\n }\n }\n for($z = $y; $z < min($a + 1, $y + $b); $z++)\n {\n if($c[$x][$z] == \".\")\n {\n $i++;\n }\n else\n {\n break;\n }\n }\n $i--;\n $j = 0;\n for($z = $x; $z > max(0, $x - $b); $z--)\n {\n if($c[$z][$y] == \".\")\n {\n $j++;\n }\n else\n {\n break;\n }\n }\n for($z = $x; $z < min($a + 1, $x + $b); $z++)\n {\n if($c[$z][$y] == \".\")\n {\n $j++;\n }\n else\n {\n break;\n }\n }\n $j--;\n $k = 0;\n if($i >= $b)\n {\n $k = $i - $b + 1;\n }\n $l = 0;\n if($j >= $b)\n {\n $l = $j - $b + 1;\n }\n $m = $k + $l;\n if($m > $e)\n {\n $e = $m;\n $f = $x;\n $g = $y;\n }\n }\n }\n}\nprint $f . \" \" . $g;\n?>"}], "negative_code": [{"source_code": " $y - $b; $z--)\n {\n $i = ($x + 1) . \"-\" . ($z + 1);\n $e[count($e)] = $i;\n $e2[$i] = 0;\n }\n }\n elseif($g > $b)\n {\n $i = ($x + 1) . \"-\" . ($y + 1);\n $e[count($e)] = $i;\n $e2[$i] = 0;\n }\n }\n else\n {\n $g = 0;\n }\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n $h = 0;\n for($y = 0; $y < $a; $y++)\n {\n if($c[$y][$x] == \".\")\n {\n $h++;\n if($h == $b)\n {\n for($z = $y; $z > $y - $b; $z--)\n {\n $i = ($z + 1) . \"-\" . ($x + 1);\n $e[count($e)] = $i;\n $e2[$i] = 0;\n }\n }\n elseif($h > $b)\n {\n $i = ($y + 1) . \"-\" . ($x + 1);\n $e[count($e)] = $i;\n $e2[$i] = 0;\n }\n }\n else\n {\n $h = 0;\n }\n }\n}\nfor($x = 0; $x < count($e); $x++)\n{\n $e2[$e[$x]]++;\n}\narsort($e2);\n$j = reset($e2);\n$k = key($e2);\nlist($l, $m) = explode(\"-\", $k);\nprint $l . \" \" . $m;\n?>"}, {"source_code": " max(0, $y - $b); $z--)\n {\n if($c[$x][$z] == \".\")\n {\n $i++;\n }\n else\n {\n break;\n }\n }\n for($z = $y; $z < min($a, $y + $b); $z++)\n {\n if($c[$x][$z] == \".\")\n {\n $i++;\n }\n else\n {\n break;\n }\n }\n $j = 0;\n for($z = $x; $z > max(0, $x - $b); $z--)\n {\n if($c[$z][$y] == \".\")\n {\n $j++;\n }\n else\n {\n break;\n }\n }\n for($z = $x; $z < min($a, $x + $b); $z++)\n {\n if($c[$z][$y] == \".\")\n {\n $j++;\n }\n else\n {\n break;\n }\n }\n $k = 0;\n if($i >= $b)\n {\n $k = $i - $b + 1;\n }\n $l = 0;\n if($j >= $b)\n {\n $l = $j - $b + 1;\n }\n $m = $k + $l;\n if($m > $e)\n {\n $e = $m;\n $f = $x;\n $g = $y;\n }\n }\n }\n}\nprint $f . \" \" . $g;\n?>"}], "src_uid": "6fb20914525715af737d81f3a5d98636"} {"nl": {"description": "Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one dollar is $$$d$$$ rubles, and one euro costs $$$e$$$ rubles.Recall that there exist the following dollar bills: $$$1$$$, $$$2$$$, $$$5$$$, $$$10$$$, $$$20$$$, $$$50$$$, $$$100$$$, and the following euro bills\u00a0\u2014 $$$5$$$, $$$10$$$, $$$20$$$, $$$50$$$, $$$100$$$, $$$200$$$ (note that, in this problem we do not consider the $$$500$$$ euro bill, it is hard to find such bills in the currency exchange points). Andrew can buy any combination of bills, and his goal is to minimize the total number of rubles he will have after the exchange.Help him\u00a0\u2014 write a program that given integers $$$n$$$, $$$e$$$ and $$$d$$$, finds the minimum number of rubles Andrew can get after buying dollar and euro bills.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\leq n \\leq 10^8$$$)\u00a0\u2014 the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \\leq d \\leq 100$$$)\u00a0\u2014 the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \\leq e \\leq 100$$$)\u00a0\u2014 the price of one euro in rubles.", "output_spec": "Output one integer\u00a0\u2014 the minimum number of rubles Andrew can have after buying dollar and euro bills optimally.", "sample_inputs": ["100\n60\n70", "410\n55\n70", "600\n60\n70"], "sample_outputs": ["40", "5", "0"], "notes": "NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill."}, "positive_code": [{"source_code": " $a)\n {\n break;\n }\n $h = $e % $b;\n if($h < $g)\n {\n $g = $h;\n }\n }\n print min($f, $g);\n}\nelseif($c * 5 > $a)\n{\n print $a % $b;\n}\n?>"}, {"source_code": " $a)\n{\n print $a % $b;\n}\n?>"}, {"source_code": " $a)\n{\n print $a % $b;\n}\n?>"}, {"source_code": " $a)\n{\n print $a % $b;\n}\n?>"}, {"source_code": "= 0; --$i) {\n if ($p[$i] === $a) {\n break;\n }\n }\n\n if ($i >= 0) {\n break;\n }\n\n $a = $p[$a - 1];\n }\n\n return $a;\n}\n\n$r = 0;\n$p = [];\n\nlist($s) = fscanf($input, \"%s\");\n\nKMP($s, $p);\n\n$r = foo($s, $p);\n$r = $r ? substr($s, 0, $r) : 'Just a legend';\n\nfwrite($output, $r);\n"}], "negative_code": [{"source_code": " 0) {\n $result = $prefix;\n }\n }\n\n return $result;\n}\n\n$r = 0;\n$keys = [];\n\nlist($s) = fscanf($input, \"%s\");\n\n$r = foo($s) ?: 'Just a legend';\n\nfwrite($output, $r);\n"}, {"source_code": " 0) {\n $result = $prefix;\n }\n }\n\n return $result;\n}\n\n$r = 0;\n$keys = [];\n\nlist($s) = fscanf($input, \"%s\");\n\n$r = foo($s) ?: 'Just a legend';\n\nfwrite($output, $r);\n"}], "src_uid": "fd94aea7ca077ee2806653d22d006fb1"} {"nl": {"description": "Polycarp has $$$3$$$ positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He can perform the following operation exactly once. Choose a positive integer $$$m$$$ and multiply exactly one of the integers $$$a$$$, $$$b$$$ or $$$c$$$ by $$$m$$$. Can Polycarp make it so that after performing the operation, the sequence of three numbers $$$a$$$, $$$b$$$, $$$c$$$ (in this order) forms an arithmetic progression? Note that you cannot change the order of $$$a$$$, $$$b$$$ and $$$c$$$.Formally, a sequence $$$x_1, x_2, \\dots, x_n$$$ is called an arithmetic progression (AP) if there exists a number $$$d$$$ (called \"common difference\") such that $$$x_{i+1}=x_i+d$$$ for all $$$i$$$ from $$$1$$$ to $$$n-1$$$. In this problem, $$$n=3$$$.For example, the following sequences are AP: $$$[5, 10, 15]$$$, $$$[3, 2, 1]$$$, $$$[1, 1, 1]$$$, and $$$[13, 10, 7]$$$. The following sequences are not AP: $$$[1, 2, 4]$$$, $$$[0, 1, 0]$$$ and $$$[1, 3, 2]$$$.You need to answer $$$t$$$ independent test cases.", "input_spec": "The first line contains the number $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. Each of the following $$$t$$$ lines contains $$$3$$$ integers $$$a$$$, $$$b$$$, $$$c$$$ ($$$1 \\le a, b, c \\le 10^8$$$).", "output_spec": "For each test case print \"YES\" (without quotes) if Polycarp can choose a positive integer $$$m$$$ and multiply exactly one of the integers $$$a$$$, $$$b$$$ or $$$c$$$ by $$$m$$$ to make $$$[a, b, c]$$$ be an arithmetic progression. Print \"NO\" (without quotes) otherwise. You can print YES and NO in any (upper or lower) case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer).", "sample_inputs": ["11\n10 5 30\n30 5 10\n1 2 3\n1 6 3\n2 6 3\n1 1 1\n1 1 2\n1 1 3\n1 100000000 1\n2 1 1\n1 2 2"], "sample_outputs": ["YES\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nYES"], "notes": "NoteIn the first and second test cases, you can choose the number $$$m=4$$$ and multiply the second number ($$$b=5$$$) by $$$4$$$.In the first test case the resulting sequence will be $$$[10, 20, 30]$$$. This is an AP with a difference $$$d=10$$$.In the second test case the resulting sequence will be $$$[30, 20, 10]$$$. This is an AP with a difference $$$d=-10$$$.In the third test case, you can choose $$$m=1$$$ and multiply any number by $$$1$$$. The resulting sequence will be $$$[1, 2, 3]$$$. This is an AP with a difference $$$d=1$$$.In the fourth test case, you can choose $$$m=9$$$ and multiply the first number ($$$a=1$$$) by $$$9$$$. The resulting sequence will be $$$[9, 6, 3]$$$. This is an AP with a difference $$$d=-3$$$.In the fifth test case, it is impossible to make an AP."}, "positive_code": [{"source_code": " 0 && $c % $a[0] == 0) return 1;\r\n\r\n\t$c = $aa - $a[0];\r\n\tif($c > 0 && $c % $a[2] == 0) return 3;\r\n\r\n\t$c = $a[0] + $a[2];\r\n\tif($c % $aa == 0) return 2;\r\n\r\n\treturn false;\r\n};\r\n\r\n$t = intval(fgets(STDIN));\r\n\r\nfor (; $t > 0; $t--) {\r\n\r\n\t$a = array_map('intval', explode(' ', fgets(STDIN)));\r\n\r\n\techo $solve($a) ? 'YES':'NO';\r\n\techo \"\\n\";\r\n\r\n}\r\n"}, {"source_code": "= $a && $d % $a == 0 && $d != 0) {\r\n echo 'YES'.PHP_EOL;\r\n } else {\r\n $d = $a + ($c - $a) / 2;\r\n if ($d >= $b && ($c - $a) % 2 == 0 && $d % $b == 0 && $d != 0) {\r\n echo 'YES'.PHP_EOL;\r\n } else {\r\n $d = $a + 2 * ($b - $a);\r\n if($d >= $c && $d % $c == 0 && $d != 0) {\r\n echo 'YES'.PHP_EOL;\r\n } else {\r\n echo 'NO'.PHP_EOL;\r\n }\r\n }\r\n }\r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": " 0 && $c % $a[0] == 0) return 1;\r\n\r\n\t$c = $aa - $a[0];\r\n\tif($c > 0 && $c % $a[2] == 0) return 3;\r\n\r\n\t$c = $a[0] + $a[2];\r\n\techo $c . ' - ' . $aa. ' - ';\r\n\tif($c % $aa == 0) return 2;\r\n\r\n\treturn false;\r\n};\r\n\r\n$t = intval(fgets(STDIN));\r\n\r\nfor (; $t > 0; $t--) {\r\n\r\n\t$a = array_map('intval', explode(' ', fgets(STDIN)));\r\n\r\n\techo $solve($a) ? 'YES':'NO';\r\n\techo \"\\n\";\r\n\r\n}\r\n"}, {"source_code": " 0 && $c % $a[0] == 0) return 1;\r\n\r\n\t$c = $aa - $a[0];\r\n\tif($c > 0 && $c % $a[2] == 0) return 3;\r\n\r\n\t$c = $a[0] - $a[2];\r\n\tif($c % $aa == 0) return 2;\r\n\r\n\treturn false;\r\n};\r\n\r\n$t = intval(fgets(STDIN));\r\n\r\nfor (; $t > 0; $t--) {\r\n\r\n\t$a = array_map('intval', explode(' ', fgets(STDIN)));\r\n\r\n\techo $solve($a) ? 'YES':'NO';\r\n\techo \"\\n\";\r\n\r\n}\r\n"}, {"source_code": " 0 && $c % $a[0] == 0) return true;\r\n\r\n\t$c = $a[1] + ($a[1] - $a[0]);\r\n\tif($c > 0 && $c % $a[2] == 0) return true;\r\n\r\n\t$c = $a[0] - $a[2];\r\n\tif($c % 2 == 0){\r\n\t\t$c = $c / 2;\r\n\t\tif($c % $a[1] == 0) return true;\r\n\t}\r\n\r\n\r\n\treturn false;\r\n};\r\n\r\n\r\n$t = intval(fgets(STDIN));\r\n\r\nfor (; $t > 0; $t--) {\r\n\r\n\t$a = array_map('intval', explode(' ', fgets(STDIN)));\r\n\r\n\techo $solve($a) ? 'YES':'NO';\r\n\techo \"\\n\";\r\n\r\n}\r\n"}], "src_uid": "90c5058c0c7f55a567f2e036482149f9"} {"nl": {"description": "Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse storing Ogudar-Olok, a magical but non-alcoholic drink) came home after a hard day. That day he had to drink 9875 boxes of the drink and, having come home, he went to bed at once.DravDe dreamt about managing a successful farm. He dreamt that every day one animal came to him and asked him to let it settle there. However, DravDe, being unimaginably kind, could send the animal away and it went, rejected. There were exactly n days in DravDe\u2019s dream and the animal that came on the i-th day, ate exactly ci tons of food daily starting from day i. But if one day the animal could not get the food it needed, it got really sad. At the very beginning of the dream there were exactly X tons of food on the farm.DravDe woke up terrified...When he retold the dream to you, he couldn\u2019t remember how many animals were on the farm by the end of the n-th day any more, but he did remember that nobody got sad (as it was a happy farm) and that there was the maximum possible amount of the animals. That\u2019s the number he wants you to find out. It should be noticed that the animals arrived in the morning and DravDe only started to feed them in the afternoon, so that if an animal willing to join them is rejected, it can\u2019t eat any farm food. But if the animal does join the farm, it eats daily from that day to the n-th.", "input_spec": "The first input line contains integers n and X (1\u2009\u2264\u2009n\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009X\u2009\u2264\u2009104) \u2014 amount of days in DravDe\u2019s dream and the total amount of food (in tons) that was there initially. The second line contains integers ci (1\u2009\u2264\u2009ci\u2009\u2264\u2009300). Numbers in the second line are divided by a space.", "output_spec": "Output the only number \u2014 the maximum possible amount of animals on the farm by the end of the n-th day given that the food was enough for everybody.", "sample_inputs": ["3 4\n1 1 1", "3 6\n1 1 1"], "sample_outputs": ["2", "3"], "notes": "NoteNote to the first example: DravDe leaves the second and the third animal on the farm. The second animal will eat one ton of food on the second day and one ton on the third day. The third animal will eat one ton of food on the third day."}, "positive_code": [{"source_code": " $x) {\n $k = $i;\n break;\n }\n}\nif ($t <= $x) {\n $k = $n;\n}\nfwrite($output, \"$k\\n\");\nfclose($output);"}], "negative_code": [], "src_uid": "6ddf0be1cc8c0ed6b86eb9e901189bf1"} {"nl": {"description": "Omkar has received a message from Anton saying \"Your story for problem A is confusing. Just make a formal statement.\" Because of this, Omkar gives you an array $$$a = [a_1, a_2, \\ldots, a_n]$$$ of $$$n$$$ distinct integers. An array $$$b = [b_1, b_2, \\ldots, b_k]$$$ is called nice if for any two distinct elements $$$b_i, b_j$$$ of $$$b$$$, $$$|b_i-b_j|$$$ appears in $$$b$$$ at least once. In addition, all elements in $$$b$$$ must be distinct. Can you add several (maybe, $$$0$$$) integers to $$$a$$$ to create a nice array $$$b$$$ of size at most $$$300$$$? If $$$a$$$ is already nice, you don't have to add any elements.For example, array $$$[3, 6, 9]$$$ is nice, as $$$|6-3|=|9-6| = 3$$$, which appears in the array, and $$$|9-3| = 6$$$, which appears in the array, while array $$$[4, 2, 0, 6, 9]$$$ is not nice, as $$$|9-4| = 5$$$ is not present in the array.For integers $$$x$$$ and $$$y$$$, $$$|x-y| = x-y$$$ if $$$x > y$$$ and $$$|x-y| = y-x$$$ otherwise.", "input_spec": "Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \\leq t \\leq 50$$$), the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\leq n \\leq 100$$$) \u2014 the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ distinct integers $$$a_1, a_2, \\cdots, a_n$$$ ($$$-100 \\leq a_i \\leq 100$$$) \u2014 the elements of the array $$$a$$$.", "output_spec": "For each test case, output one line containing YES if Omkar can create a nice array $$$b$$$ by adding elements to $$$a$$$ and NO otherwise. The case of each letter does not matter, so yEs and nO will also be accepted. If the first line is YES, output a second line containing a single integer $$$k$$$ ($$$n \\leq k \\leq 300$$$). Then output one line containing $$$k$$$ distinct integers $$$b_1, b_2, \\cdots, b_k$$$ ($$$-10^9 \\leq b_i \\leq 10^9$$$), the elements of the nice array $$$b$$$. $$$b_1, b_2, \\cdots, b_k$$$ can be in any order. For each $$$a_i$$$ in $$$a$$$, $$$a_i$$$ must appear at least once in $$$b$$$. It can be proved that if Omkar can create such an array $$$b$$$, then he can also do so in a way that satisfies the above constraints. If multiple solutions exist, you can print any. ", "sample_inputs": ["4\n3\n3 0 9\n2\n3 4\n5\n-7 3 13 -2 8\n4\n4 8 12 6"], "sample_outputs": ["yes\n4\n6 0 3 9\nyEs\n5\n5 3 1 2 4\nNO\nYes\n6\n8 12 6 2 4 10"], "notes": "NoteFor the first case, you can add integers to $$$a$$$ to receive the array $$$b = [6, 0, 3, 9]$$$. Note that $$$|6-3| = |9-6| = |3-0| = 3$$$ and $$$3$$$ is in $$$b$$$, $$$|6-0| = |9-3| = 6$$$ and $$$6$$$ is in $$$b$$$, and $$$|9-0| = 9$$$ is in $$$b$$$, so $$$b$$$ is nice.For the second case, you can add integers to $$$a$$$ to receive the array $$$b = [5, 3, 1, 2, 4]$$$. We have that $$$|2-1| = |3-2| = |4-3| = |5-4| = 1$$$ is in $$$b$$$, $$$|3-1| = |4-2| = |5-3| = 2$$$ is in $$$b$$$, $$$|4-1| = |5-2| = 3$$$ is in $$$b$$$, and $$$|5-1| = 4$$$ is in $$$b$$$, so $$$b$$$ is nice.For the fourth case, you can add integers to $$$a$$$ to receive the array $$$b = [8, 12, 6, 2, 4, 10]$$$. We have that $$$|4-2| = |6-4| = |8-6| = |10-8| = |12-10| = 2$$$ is in $$$b$$$, $$$|6-2| = |8-4| = |10-6| = |12-8| = 4$$$ is in $$$b$$$, $$$|8-2| = |10-4| = |12-6| = 6$$$ is in $$$b$$$, $$$|10-2| = |12-4| = 8$$$ is in $$$b$$$, and $$$|12-2| = 10$$$ is in $$$b$$$, so $$$b$$$ is nice.It can be proven that for all other test cases it is impossible to create a nice array $$$b$$$."}, "positive_code": [{"source_code": " 300) { break; }\r\n }\r\n if (count($a) > 300) { break; }\r\n }\r\n \r\n if (count($a) > 300) { echo 'NO'.PHP_EOL; }\r\n else { \r\n echo 'YES'.PHP_EOL; \r\n echo count($a).PHP_EOL;\r\n for ($j = 0; $j < count($a); $j++) {\r\n echo $a[$j].' ';\r\n }\r\n echo PHP_EOL;\r\n }\r\n}\r\n?>"}], "negative_code": [], "src_uid": "5698e6fd934b9f6b847d7e30a3d06f2b"} {"nl": {"description": "You are given a binary array$$$^{\\dagger}$$$ of length $$$n$$$. You are allowed to perform one operation on it at most once. In an operation, you can choose any element and flip it: turn a $$$0$$$ into a $$$1$$$ or vice-versa.What is the maximum number of inversions$$$^{\\ddagger}$$$ the array can have after performing at most one operation?$$$^\\dagger$$$ A binary array is an array that contains only zeroes and ones.$$$^\\ddagger$$$ The number of inversions in an array is the number of pairs of indices $$$i,j$$$ such that $$$i<j$$$ and $$$a_i > a_j$$$.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot10^5$$$)\u00a0\u2014 the length of the array. The following line contains $$$n$$$ space-separated positive integers $$$a_1$$$, $$$a_2$$$,..., $$$a_n$$$ ($$$0 \\leq a_i \\leq 1$$$)\u00a0\u2014 the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each test case, output a single integer \u00a0\u2014 the maximum number of inversions the array can have after performing at most one operation.", "sample_inputs": ["5\n\n4\n\n1 0 1 0\n\n6\n\n0 1 0 0 1 0\n\n2\n\n0 0\n\n8\n\n1 0 1 1 0 0 0 1\n\n3\n\n1 1 1"], "sample_outputs": ["3\n7\n1\n13\n2"], "notes": "NoteFor the first test case, the inversions are initially formed by the pairs of indices ($$$1, 2$$$), ($$$1, 4$$$), ($$$3, 4$$$), being a total of $$$3$$$, which already is the maximum possible.For the second test case, the inversions are initially formed by the pairs of indices ($$$2, 3$$$), ($$$2, 4$$$), ($$$2, 6$$$), ($$$5, 6$$$), being a total of four. But, by flipping the first element, the array becomes $$${1, 1, 0, 0, 1, 0}$$$, which has the inversions formed by the pairs of indices ($$$1, 3$$$), ($$$1, 4$$$), ($$$1, 6$$$), ($$$2, 3$$$), ($$$2, 4$$$), ($$$2, 6$$$), ($$$5, 6$$$) which total to $$$7$$$ inversions which is the maximum possible."}, "positive_code": [{"source_code": "= 0; $i--) {\r\n if ($a2[$i] == 1) {\r\n $a2[$i] = 0;\r\n break;\r\n }\r\n }\r\n \r\n \r\n \r\n //echo implode(' ', $a) . PHP_EOL;\r\n //echo implode(' ', $a2) . PHP_EOL;\r\n //echo implode(' ', $a3) . PHP_EOL;\r\n \r\n \r\n \r\n \r\n for ($i = 0; $i < $n; $i++) {\r\n if ($a[$i] == 1) {\r\n $iCheck++;\r\n } else {\r\n $iResult = $iResult + $iCheck;\r\n }\r\n \r\n if ($a2[$i] == 1) {\r\n $iCheck2++;\r\n } else {\r\n $iResult2 = $iResult2 + $iCheck2;\r\n }\r\n \r\n if ($a3[$i] == 1) {\r\n $iCheck3++;\r\n } else {\r\n $iResult3 = $iResult3 + $iCheck3;\r\n }\r\n \r\n $aMax[$i] = max($iResult, $iResult2, $iResult3);\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n} \r\n"}, {"source_code": " $max1)\r\n {\r\n $max2 = $max1;\r\n $max1 = $array[$index];\r\n }\r\n\r\n else if ($array[$index] > $max2)\r\n {\r\n $max2 = $array[$index];\r\n }\r\n }\r\n\r\n return array($max1, $max2);\r\n}\r\n"}, {"source_code": " $max1)\r\n {\r\n $max2 = $max1;\r\n $max1 = $array[$index];\r\n }\r\n\r\n else if ($array[$index] > $max2)\r\n {\r\n $max2 = $array[$index];\r\n }\r\n }\r\n\r\n return array($max1, $max2);\r\n}\r\n"}], "negative_code": [{"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck;\r\n $a[$i] = $sNum;\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n} "}, {"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck;\r\n $a[$i] = $sNum;\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n} "}, {"source_code": "= 2653) {\r\n echo $s . PHP_EOL;\r\n }\r\n } \r\n}"}, {"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck;\r\n $a[$i] = $sNum;\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n} \r\n\r\n\r\n"}, {"source_code": "= 22) {\r\n echo $s . PHP_EOL;\r\n }\r\n } \r\n}\r\n\r\n\r\n"}, {"source_code": "= 1) {\r\n echo $s . PHP_EOL;\r\n }\r\n } \r\n}\r\n\r\n\r\n"}, {"source_code": "= 29) {\r\n echo $s . PHP_EOL;\r\n }\r\n } \r\n}\r\n\r\n\r\n"}, {"source_code": "= 29) {\r\n echo $s;\r\n }\r\n } \r\n}\r\n\r\n\r\n"}, {"source_code": " 0) {\r\n $bCheck = 1;\r\n $sNum = $a[$i];\r\n if ($sNum == 1) {\r\n $a[$i] = 0;\r\n } else {\r\n $a[$i] = 1;\r\n }\r\n // }\r\n \r\n $iCheck2 = 0;\r\n for ($q = 0; $q < $n-1; $q++) {\r\n for ($j = $q+1; $j < $n; $j++) {\r\n if ($a[$q] > $a[$j]) {\r\n $iCheck2++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck2;\r\n \r\n if ($bCheck) {\r\n $a[$i] = $sNum;\r\n }\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n}"}, {"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n \r\n echo $iCheck . PHP_EOL;\r\n } else {\r\n $bCheck = 0;\r\n $aMax = [];\r\n for ($i = 0; $i < $n-1; $i++) {\r\n \r\n $bCheck = 1;\r\n $sNum = $a[$i];\r\n if ($sNum == 1) {\r\n $a[$i] = 0;\r\n } else {\r\n $a[$i] = 1;\r\n }\r\n \r\n \r\n $iCheck = 0;\r\n for ($q = 0; $q < $n-1; $q++) {\r\n for ($j = $q+1; $j < $n; $j++) {\r\n if ($a[$q] > $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck;\r\n \r\n if ($bCheck) {\r\n $a[$i] = $sNum;\r\n }\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n }\r\n}"}, {"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n \r\n echo $iCheck . PHP_EOL;\r\n } else {\r\n $bCheck = 0;\r\n $aMax = [];\r\n for ($i = 0; $i < $n-1; $i++) {\r\n if ($i > 0) {\r\n $bCheck = 1;\r\n $sNum = $a[$i];\r\n if ($sNum == 1) {\r\n $a[$i] = 0;\r\n } else {\r\n $a[$i] = 1;\r\n }\r\n }\r\n \r\n $iCheck = 0;\r\n for ($q = 0; $q < $n-1; $q++) {\r\n for ($j = $q+1; $j < $n; $j++) {\r\n if ($a[$q] > $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n $aMax[$i] = $iCheck;\r\n \r\n if ($bCheck) {\r\n $a[$i] = $sNum;\r\n }\r\n }\r\n \r\n echo max($aMax) . PHP_EOL;\r\n }\r\n}"}, {"source_code": " $a[$j]) {\r\n $iCheck++;\r\n }\r\n }\r\n }\r\n \r\n echo $iCheck . PHP_EOL;\r\n}"}, {"source_code": " $max1)\r\n {\r\n $max2 = $max1;\r\n $max1 = $array[$index];\r\n }\r\n\r\n else if ($array[$index] > $max2)\r\n {\r\n $max2 = $array[$index];\r\n }\r\n }\r\n\r\n return array($max1, $max2);\r\n}\r\n"}], "src_uid": "0657ce4ce00addefc8469381c57294fc"} {"nl": {"description": "You are given a sequence of positive integers a1,\u2009a2,\u2009...,\u2009an. While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to x, delete both and insert a single integer x\u2009+\u20091 on their place. This way the number of elements in the sequence is decreased by 1 on each step. You stop performing the operation when there is no pair of equal consecutive elements.For example, if the initial sequence is [5,\u20092,\u20091,\u20091,\u20092,\u20092], then after the first operation you get [5,\u20092,\u20092,\u20092,\u20092], after the second \u2014 [5,\u20093,\u20092,\u20092], after the third \u2014 [5,\u20093,\u20093], and finally after the fourth you get [5,\u20094]. After that there are no equal consecutive elements left in the sequence, so you stop the process.Determine the final sequence after you stop performing the operation.", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105) \u2014 the number of elements in the sequence. The second line contains the sequence of integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "In the first line print a single integer k \u2014 the number of elements in the sequence after you stop performing the operation. In the second line print k integers\u00a0\u2014 the sequence after you stop performing the operation.", "sample_inputs": ["6\n5 2 1 1 2 2", "4\n1000000000 1000000000 1000000000 1000000000", "7\n4 10 22 11 12 5 6"], "sample_outputs": ["2\n5 4", "1\n1000000002", "7\n4 10 22 11 12 5 6"], "notes": "NoteThe first example is described in the statements.In the second example the initial sequence is [1000000000,\u20091000000000,\u20091000000000,\u20091000000000]. After the first operation the sequence is equal to [1000000001,\u20091000000000,\u20091000000000]. After the second operation the sequence is [1000000001,\u20091000000001]. After the third operation the sequence is [1000000002].In the third example there are no two equal consecutive elements initially, so the sequence does not change."}, "positive_code": [{"source_code": "1 && $a[$last-1]==$a[$last-2]) {\n \t$a[$last-2]++;\n \t$last--;\n }\n}\nprintf(\"%d\\n\",$last);\nfor($i=0;$i<$last;$i++)\n{\n printf(\"%d \",$a[$i]);\n}\n?>"}, {"source_code": "1 && $a[$last-1]==$a[$last-2]) {\n \t$a[$last-2]++;\n \t$last--;\n }\n}\nprintf(\"%d\\n\",$last);\nfor($i=0;$i<$last;$i++)\n{\n printf(\"%d \",$a[$i]);\n}\n?>"}, {"source_code": "1 && $a[$last-1]==$a[$last-2]) {\n \t$a[$last-2]++;\n \t$last--;\n }\n}\nprintf(\"%d\\n\",$last);\nfor($i=0;$i<$last;$i++)\n{\n printf(\"%d \",$a[$i]);\n}\n?>"}], "negative_code": [], "src_uid": "8c715616c8fa373c95368cf4795a2e6a"} {"nl": {"description": "You are given a digital clock with $$$n$$$ digits. Each digit shows an integer from $$$0$$$ to $$$9$$$, so the whole clock shows an integer from $$$0$$$ to $$$10^n-1$$$. The clock will show leading zeroes if the number is smaller than $$$10^{n-1}$$$.You want the clock to show $$$0$$$ with as few operations as possible. In an operation, you can do one of the following: decrease the number on the clock by $$$1$$$, or swap two digits (you can choose which digits to swap, and they don't have to be adjacent). Your task is to determine the minimum number of operations needed to make the clock show $$$0$$$.", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^3$$$). The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 number of digits on the clock. The second line of each test case contains a string of $$$n$$$ digits $$$s_1, s_2, \\ldots, s_n$$$ ($$$0 \\le s_1, s_2, \\ldots, s_n \\le 9$$$) \u2014 the number on the clock. Note: If the number is smaller than $$$10^{n-1}$$$ the clock will show leading zeroes.", "output_spec": "For each test case, print one integer: the minimum number of operations needed to make the clock show $$$0$$$.", "sample_inputs": ["7\n3\n007\n4\n1000\n5\n00000\n3\n103\n4\n2020\n9\n123456789\n30\n001678294039710047203946100020"], "sample_outputs": ["7\n2\n0\n5\n6\n53\n115"], "notes": "NoteIn the first example, it's optimal to just decrease the number $$$7$$$ times.In the second example, we can first swap the first and last position and then decrease the number by $$$1$$$.In the third example, the clock already shows $$$0$$$, so we don't have to perform any operations."}, "positive_code": [{"source_code": " 0) {\r\n $count = $count + $karakter;\r\n if ($i > 0) $count ++;\r\n }\r\n $i--;\r\n }\r\n echo $count;\r\n echo \"\\n\";\r\n // var_dump($result);\r\n}"}, {"source_code": "';\r\n \r\n $res = 0;\r\n for ($i=0; $i';\n}\n\nfunction stdin() {\n $stdin = @fopen('data.txt', 'r');\n if (!$stdin) {\n $stdin = fopen('php://stdin', 'r');\n }\n\n return $stdin;\n}\n\nfunction g() {\n global $stdin;\n return trim(fgets($stdin));\n}\n\n$stdin = stdin();\n/****************************************************** Solving block *****************************************************/\n$n = g();\n\n$stat = explode(' ', g());\n$stat = array_unique($stat);\nsort($stat);\n\necho isset($stat[1]) ? $stat[1] : 'NO';\n\n?>"}, {"source_code": " $min) {\n echo $number;\n break;\n }\n }\n }\n}"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$arr=explode(' ',trim(fgets(STDIN)));\nsort($arr);\nfunction stat2(&$arr){\n for($i=1,$n=sizeof($arr);$i<$n;$i++){\n if($arr[0]!=$arr[$i])\n return $arr[$i];\n }\n}\n$res = stat2($arr);\n$r=($res!=null) ? $res : \"NO\";\necho $r;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0) {print $r;} else {print $l;};\n?>"}, {"source_code": ""}, {"source_code": "0) {print $r;} else {print \"NO\";};\n?>"}, {"source_code": " $min) {\n echo $number;\n break;\n }\n }\n }\n}"}, {"source_code": " $min)\n {\n echo $number;\n break;\n }\n}"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$arr=explode(' ',trim(fgets(STDIN)));\nsort($arr);\nfunction stat2(&$arr){\n for($i=1,$n=sizeof($arr);$i<$n;$i++){\n if($arr[0]!=$arr[$i])\n return $arr[$i];\n }\n}\n$res = stat2($arr);\n$res=(!null) ? $res : \"NO\";\necho $res;\n?>"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$arr=explode(' ',trim(fgets(STDIN)));\nsort($arr);\nfunction stat2(&$arr){\n for($i=1,$n=sizeof($arr);$i<$n;$i++){\n if($arr[0]!=$arr[$i])\n return $arr[$i];\n }\n}\necho stat2($arr);\n?>"}], "src_uid": "930be5ec102fbe062062aa23eac75187"} {"nl": {"description": "The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\\frac{\\sum \\limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task?", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 5000$$$) \u2014 the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\le a_i \\le 5000$$$) \u2014 the temperature measures during given $$$n$$$ days.", "output_spec": "Print one real number \u2014 the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution.", "sample_inputs": ["4 3\n3 4 1 2"], "sample_outputs": ["2.666666666666667"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "7bdb68ab0752f8df94b4d5c7df759dfb"} {"nl": {"description": "There is a country with $$$n$$$ citizens. The $$$i$$$-th of them initially has $$$a_{i}$$$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.Sometimes the government makes payouts to the poor: all citizens who have strictly less money than $$$x$$$ are paid accordingly so that after the payout they have exactly $$$x$$$ money. In this case the citizens don't send a receipt.You know the initial wealth of every citizen and the log of all events: receipts and payouts. Restore the amount of money each citizen has after all events.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^{5}$$$)\u00a0\u2014 the numer of citizens. The next line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0 \\le a_{i} \\le 10^{9}$$$)\u00a0\u2014 the initial balances of citizens. The next line contains a single integer $$$q$$$ ($$$1 \\le q \\le 2 \\cdot 10^{5}$$$)\u00a0\u2014 the number of events. Each of the next $$$q$$$ lines contains a single event. The events are given in chronological order. Each event is described as either 1 p x ($$$1 \\le p \\le n$$$, $$$0 \\le x \\le 10^{9}$$$), or 2 x ($$$0 \\le x \\le 10^{9}$$$). In the first case we have a receipt that the balance of the $$$p$$$-th person becomes equal to $$$x$$$. In the second case we have a payoff with parameter $$$x$$$.", "output_spec": "Print $$$n$$$ integers\u00a0\u2014 the balances of all citizens after all events.", "sample_inputs": ["4\n1 2 3 4\n3\n2 3\n1 2 2\n2 1", "5\n3 50 2 1 10\n3\n1 2 0\n2 8\n1 3 20"], "sample_outputs": ["3 2 3 4", "8 8 20 8 10"], "notes": "NoteIn the first example the balances change as follows: 1 2 3 4 $$$\\rightarrow$$$ 3 3 3 4 $$$\\rightarrow$$$ 3 2 3 4 $$$\\rightarrow$$$ 3 2 3 4In the second example the balances change as follows: 3 50 2 1 10 $$$\\rightarrow$$$ 3 0 2 1 10 $$$\\rightarrow$$$ 8 8 8 8 10 $$$\\rightarrow$$$ 8 8 20 8 10"}, "positive_code": [{"source_code": " $g)\n {\n $g = $d[$x][1];\n }\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n if($f[$x] == FALSE)\n {\n if($b[$x] < $g)\n {\n $b[$x] = $g;\n }\n }\n}\nprint implode(\" \", $b);\n?>"}], "negative_code": [], "src_uid": "7b788c660fb8ca703af0030f4c84ce96"} {"nl": {"description": "There are n cows playing poker at a table. For the current betting phase, each player's status is either \"ALLIN\", \"IN\", or \"FOLDED\", and does not change throughout the phase. To increase the suspense, a player whose current status is not \"FOLDED\" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either \"ALLIN\" or \"FOLDED\". The player's own status may be either \"ALLIN\" or \"IN\".Find the number of cows that can currently show their hands without affecting any betting decisions.", "input_spec": "The first line contains a single integer, n (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105). The second line contains n characters, each either \"A\", \"I\", or \"F\". The i-th character is \"A\" if the i-th player's status is \"ALLIN\", \"I\" if the i-th player's status is \"IN\", or \"F\" if the i-th player's status is \"FOLDED\".", "output_spec": "The first line should contain a single integer denoting the number of players that can currently show their hands.", "sample_inputs": ["6\nAFFAAA", "3\nAFI"], "sample_outputs": ["4", "1"], "notes": "NoteIn the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand."}, "positive_code": [{"source_code": " 0, F => 0, I => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\nif($c[I] == 0)\n{\n print $c[A];\n}\nelseif($c[I] == 1)\n{\n if(($c[A] > 0) || ($c[F] > 0))\n {\n print \"1\";\n }\n else\n {\n print \"0\";\n }\n}\nelseif($c[I] > 1)\n{\n print \"0\";\n}\n?>"}, {"source_code": "\n\tfgets(STDIN);\n\t$d = trim(fgets(STDIN));\n\t$a = substr_count($d, 'I');\n\tprint ($a<1 ? substr_count($d, 'A') : ($a>1 ? 0 : 1));\n ?>"}, {"source_code": "\n\tfgets(STDIN);\n\t$d = trim(fgets(STDIN));\n\t$a = substr_count($d, 'I');\n\techo ($a<1 ? substr_count($d, 'A') : ($a>1 ? 0 : 1));\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $a = substr_count($data, 'I');\n if ($a == 1) print 1;\n elseif ($a > 1) print 0;\n else print substr_count($data, 'A');\n?>"}, {"source_code": "\n"}, {"source_code": " 0, \"A\" => 0, \"F\" => 0);\n $in = 0;\n $all = 0;\n\n for ($i = 0; $i < $n; ++$i) {\n if ($str[$i] == \"I\")\n ++$in;\n if ($str[$i] == \"A\")\n ++$all;\n }\n\n if ($in > 1)\n print(0);\n else if ($in == 1)\n print(1);\n else\n print($all);\n?>"}], "negative_code": [{"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $a = substr_count($data, 'I');\n if ($a == 1){\n \tprint 1;\n }elseif ($a > 1){\n \tprint 1;\n }else print substr_count($data, 'A');\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $arr = array();\n for ($i=0;$i0){\r\n $res += $d;\r\n if ($i!=(strlen($s)-1)) $res++;\r\n }\r\n \r\n// echo 'res = '.$res.'
';\r\n }\r\n \r\n echo $res.\"\\r\\n\";\r\n}\r\n\r\n $n = trim(fgets(STDIN));\r\n for ($i=0; $i<$n; $i++){\r\n $l = trim(fgets(STDIN));\r\n $s = trim(fgets(STDIN));\r\n clock($s);\r\n }\r\n\r\n/* \r\n clock('007');\r\n clock('1000');\r\n clock('00000');\r\n clock('103');\r\n clock('2020');\r\n clock('123456789');\r\n clock('001678294039710047203946100020');\r\n*/\r\n?>"}], "negative_code": [], "src_uid": "6571fdd506a858d7620c2faa0fe46cc1"} {"nl": {"description": "Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to u. A vertex is called a leaf if it doesn't have children and has a parent.Let's call a rooted tree a spruce if its every non-leaf vertex has at least 3 leaf children. You are given a rooted tree, check whether it's a spruce.The definition of a rooted tree can be found here.", "input_spec": "The first line contains one integer n\u00a0\u2014 the number of vertices in the tree (3\u2009\u2264\u2009n\u2009\u2264\u20091\u2009000). Each of the next n\u2009-\u20091 lines contains one integer pi (1\u2009\u2264\u2009i\u2009\u2264\u2009n\u2009-\u20091)\u00a0\u2014 the index of the parent of the i\u2009+\u20091-th vertex (1\u2009\u2264\u2009pi\u2009\u2264\u2009i). Vertex 1 is the root. It's guaranteed that the root has at least 2 children.", "output_spec": "Print \"Yes\" if the tree is a spruce and \"No\" otherwise.", "sample_inputs": ["4\n1\n1\n1", "7\n1\n1\n1\n2\n2\n2", "8\n1\n1\n1\n1\n3\n3\n3"], "sample_outputs": ["Yes", "No", "Yes"], "notes": "NoteThe first example:The second example:It is not a spruce, because the non-leaf vertex 1 has only 2 leaf children.The third example:"}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "69edc72ec29d4dd56751b281085c3591"} {"nl": {"description": "This is the easy version of this problem. The only difference is the constraint on $$$k$$$ \u2014 the number of gifts in the offer. In this version: $$$k=2$$$.Vasya came to the store to buy goods for his friends for the New Year. It turned out that he was very lucky\u00a0\u2014 today the offer \"$$$k$$$ of goods for the price of one\" is held in store. Remember, that in this problem $$$k=2$$$.Using this offer, Vasya can buy exactly $$$k$$$ of any goods, paying only for the most expensive of them. Vasya decided to take this opportunity and buy as many goods as possible for his friends with the money he has.More formally, for each good, its price is determined by $$$a_i$$$\u00a0\u2014 the number of coins it costs. Initially, Vasya has $$$p$$$ coins. He wants to buy the maximum number of goods. Vasya can perform one of the following operations as many times as necessary: Vasya can buy one good with the index $$$i$$$ if he currently has enough coins (i.e $$$p \\ge a_i$$$). After buying this good, the number of Vasya's coins will decrease by $$$a_i$$$, (i.e it becomes $$$p := p - a_i$$$). Vasya can buy a good with the index $$$i$$$, and also choose exactly $$$k-1$$$ goods, the price of which does not exceed $$$a_i$$$, if he currently has enough coins (i.e $$$p \\ge a_i$$$). Thus, he buys all these $$$k$$$ goods, and his number of coins decreases by $$$a_i$$$ (i.e it becomes $$$p := p - a_i$$$). Please note that each good can be bought no more than once.For example, if the store now has $$$n=5$$$ goods worth $$$a_1=2, a_2=4, a_3=3, a_4=5, a_5=7$$$, respectively, $$$k=2$$$, and Vasya has $$$6$$$ coins, then he can buy $$$3$$$ goods. A good with the index $$$1$$$ will be bought by Vasya without using the offer and he will pay $$$2$$$ coins. Goods with the indices $$$2$$$ and $$$3$$$ Vasya will buy using the offer and he will pay $$$4$$$ coins. It can be proved that Vasya can not buy more goods with six coins.Help Vasya to find out the maximum number of goods he can buy.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases in the test. The next lines contain a description of $$$t$$$ test cases. The first line of each test case contains three integers $$$n, p, k$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$, $$$1 \\le p \\le 2\\cdot10^9$$$, $$$k=2$$$)\u00a0\u2014 the number of goods in the store, the number of coins Vasya has and the number of goods that can be bought by the price of the most expensive of them. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$1 \\le a_i \\le 10^4$$$)\u00a0\u2014 the prices of goods. It is guaranteed that the sum of $$$n$$$ for all test cases does not exceed $$$2 \\cdot 10^5$$$. It is guaranteed that in this version of the problem $$$k=2$$$ for all test cases.", "output_spec": "For each test case in a separate line print one integer $$$m$$$\u00a0\u2014 the maximum number of goods that Vasya can buy.", "sample_inputs": ["6\n5 6 2\n2 4 3 5 7\n5 11 2\n2 4 3 5 7\n2 10000 2\n10000 10000\n2 9999 2\n10000 10000\n5 13 2\n8 2 8 2 5\n3 18 2\n1 2 3"], "sample_outputs": ["3\n4\n2\n0\n4\n3"], "notes": null}, "positive_code": [{"source_code": "= $e[0])\n {\n $c -= $e[0];\n $f++;\n for($y = 1; $y < $b; $y++)\n {\n if($c <= 0)\n {\n break;\n }\n elseif(($y + 1) == $b)\n {\n if($e[$y] <= $c)\n {\n $f++;\n break;\n }\n }\n elseif($e[$y + 1] == NULL)\n {\n if($e[$y] <= $c)\n {\n $f++;\n break;\n }\n }\n elseif($e[$y + 1] > $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $f += 2;\n $y++;\n }\n elseif($e[$y + 1] == $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $f += 2;\n $y++;\n }\n elseif($e[$y] <= $c)\n {\n $f++;\n break;\n }\n }\n $c = $c2;\n $g = 0;\n for($y = 0; $y < $b; $y++)\n {\n if($c <= 0)\n {\n break;\n }\n elseif(($y + 1) == $b)\n {\n if($e[$y] <= $c)\n {\n $g++;\n break;\n }\n }\n elseif($e[$y + 1] > $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $g += 2;\n $y++;\n }\n elseif($e[$y + 1] == $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $g += 2;\n $y++;\n }\n elseif($e[$y + 1] > $c)\n {\n break;\n }\n }\n print max($f, $g) . \"\\n\";\n }\n else\n {\n print \"0\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": "= $e[0])\n {\n $c -= $e[0];\n $f++;\n for($y = 1; $y < $b; $y++)\n {\n if($c <= 0)\n {\n break;\n }\n elseif($e[$y + 1] > $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $f += 2;\n $y++;\n }\n elseif($e[$y + 1] == $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $f += 2;\n }\n elseif($e[$y] <= $c)\n {\n $f++;\n break;\n }\n }\n $c = $c2;\n $g = 0;\n for($y = 0; $y < $b; $y++)\n {\n if($c <= 0)\n {\n break;\n }\n elseif($e[$y + 1] > $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $g += 2;\n $y++;\n }\n elseif($e[$y + 1] == $e[$y])\n {\n $c -= $e[$y + 1];\n if($c < 0)\n {\n break;\n }\n $g += 2;\n }\n elseif($e[$y + 1] > $c)\n {\n break;\n }\n }\n print max($f, $g) . \"\\n\";\n }\n else\n {\n print \"0\\n\";\n }\n}\n?>"}], "src_uid": "b9bafdc49709b4fc4b5fe786d5aa99a3"} {"nl": {"description": "The winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day. Vasya has a new set of winter tires which allows him to drive safely no more than k days at any average air temperature. After k days of using it (regardless of the temperature of these days) the set of winter tires wears down and cannot be used more. It is not necessary that these k days form a continuous segment of days.Before the first winter day Vasya still uses summer tires. It is possible to drive safely on summer tires any number of days when the average air temperature is non-negative. It is impossible to drive on summer tires at days when the average air temperature is negative. Vasya can change summer tires to winter tires and vice versa at the beginning of any day.Find the minimum number of times Vasya needs to change summer tires to winter tires and vice versa to drive safely during the winter. At the end of the winter the car can be with any set of tires.", "input_spec": "The first line contains two positive integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105, 0\u2009\u2264\u2009k\u2009\u2264\u2009n)\u00a0\u2014 the number of winter days and the number of days winter tires can be used. It is allowed to drive on winter tires at any temperature, but no more than k days in total. The second line contains a sequence of n integers t1,\u2009t2,\u2009...,\u2009tn (\u2009-\u200920\u2009\u2264\u2009ti\u2009\u2264\u200920)\u00a0\u2014 the average air temperature in the i-th winter day. ", "output_spec": "Print the minimum number of times Vasya has to change summer tires to winter tires and vice versa to drive safely during all winter. If it is impossible, print -1.", "sample_inputs": ["4 3\n-5 20 -3 0", "4 2\n-5 20 -3 0", "10 6\n2 -5 1 3 0 0 -4 -3 1 0"], "sample_outputs": ["2", "4", "3"], "notes": "NoteIn the first example before the first winter day Vasya should change summer tires to winter tires, use it for three days, and then change winter tires to summer tires because he can drive safely with the winter tires for just three days. Thus, the total number of tires' changes equals two. In the second example before the first winter day Vasya should change summer tires to winter tires, and then after the first winter day change winter tires to summer tires. After the second day it is necessary to change summer tires to winter tires again, and after the third day it is necessary to change winter tires to summer tires. Thus, the total number of tires' changes equals four. "}, "positive_code": [{"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if(($i <= $j) && ($i > 0))\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if(($i <= $j) && ($i > 0))\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n if($a != 1000)\n {\n $e--;\n }\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n if($a == 1000)\n {\n print $e . \"\\n\";\n print $j . \"\\n\";\n print implode(\" \", $g) . \"\\n\";\n }\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($a == 1000)\n {\n print $j . \"\\n\";\n print $i . \"\\n\";\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n $n = 0;\n }\n elseif(($c[$x] < 0) && ($n == 0))\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n $n = 1;\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n print \"1\";\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n $n = 0;\n }\n elseif(($c[$x] < 0) && ($n == 0))\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n $n = 1;\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n print \"1\";\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $b)\n{\n print \"-1\";\n}\nelse\n{\n $e = 0;\n $f = 0;\n $g = array();\n $h = 0;\n $i = 0;\n if($c[0] < 0)\n {\n $e = 1;\n $n = 0;\n for($x = 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n else\n {\n $l = 0;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] < 0)\n {\n $l = 1;\n $m = $x;\n break;\n }\n }\n if($l == 0)\n {\n print \"0\";\n }\n else\n {\n $e = 1;\n for($x = $m + 1; $x < $a; $x++)\n {\n if(($c[$x] >= 0) && ($f == 0))\n {\n $e++;\n $f = 1;\n }\n elseif(($c[$x] < 0) && ($f == 1))\n {\n $e++;\n $f = 0;\n }\n if($c[$x] >= 0)\n {\n $i++;\n }\n else\n {\n if($i != 0)\n {\n $g[$h] = $i;\n $h++;\n $i = 0;\n }\n }\n }\n $j = $b - $d;\n $k = 0;\n sort($g);\n if(count($g) == 0)\n {\n if($j == 0)\n {\n print $e;\n }\n elseif($i <= $j)\n {\n print $e - 1;\n }\n }\n else\n {\n $o = count($g);\n while(TRUE)\n {\n $j -= $g[$k];\n $k++;\n if($j < 0)\n {\n $k--;\n $j += $g[$k];\n break;\n }\n elseif($j == 0)\n {\n $e -= 2;\n break;\n }\n else\n {\n $e -= 2;\n $o--;\n if($o == 0)\n {\n break;\n }\n }\n }\n if($i <= $j)\n {\n $e--;\n }\n if($e <= 0)\n {\n print \"1\";\n }\n else\n {\n print $e;\n }\n }\n }\n }\n}\n?>"}], "src_uid": "18458f6ab66db560a51887c944f26f0f"} {"nl": {"description": "There are some beautiful girls in Arpa\u2019s land as mentioned before.Once Arpa came up with an obvious problem:Given an array and a number x, count the number of pairs of indices i,\u2009j (1\u2009\u2264\u2009i\u2009<\u2009j\u2009\u2264\u2009n) such that , where is bitwise xor operation (see notes for explanation). Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem.", "input_spec": "First line contains two integers n and x (1\u2009\u2264\u2009n\u2009\u2264\u2009105,\u20090\u2009\u2264\u2009x\u2009\u2264\u2009105)\u00a0\u2014 the number of elements in the array and the integer x. Second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009105)\u00a0\u2014 the elements of the array.", "output_spec": "Print a single integer: the answer to the problem.", "sample_inputs": ["2 3\n1 2", "6 1\n5 1 2 3 4 1"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first sample there is only one pair of i\u2009=\u20091 and j\u2009=\u20092. so the answer is 1.In the second sample the only two pairs are i\u2009=\u20093, j\u2009=\u20094 (since ) and i\u2009=\u20091, j\u2009=\u20095 (since ).A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: https://en.wikipedia.org/wiki/Bitwise_operation#XOR."}, "positive_code": [{"source_code": " $val){\n $keys[] = $key;\n $vals[] = (int)$val;\n}\n$i = 0;\n$j = 1;\n$count = 0;\nwhile($i < $n && $j < $n){\n if($adj[$keys[$i]] >= $k || ($vals[$j] - $vals[$i] > 1)){\n $i++;\n continue;\n }\n\n if($adj[$keys[$j]] >= $k || ($vals[$j] == $vals[$i])){\n $j++;\n continue;\n }\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $count++;\n $result .= ($keys[$i]+1).' '.($keys[$j]+1).\"\\n\";\n $j++;\n}\nif($count < $n-1){\n echo \"-1\";\n} else {\n echo $count.\"\\n\";\n echo $result;\n}"}], "negative_code": [{"source_code": "= $k)\n\t\t\tbreak;\n\t\tif($adj[$j] >= $k)\n\t\t\tcontinue;\n\t\tif(abs($d[$i]-$d[$j])==1){\n\t\t\t$adj[$i]++;\n\t\t\t$adj[$j]++;\n\t\t\t$result[] = ($i+1).' '.($j+1);\n\t\t}\n\t}\n}\necho count($result);\nforeach ($result as $val) {\n\techo \"\\n\".$val;\n}"}, {"source_code": "= $k)\n\t\t\tbreak;\n\t\tif($adj[$j] >= $k)\n\t\t\tcontinue;\n\t\tif(abs($d[$i]-$d[$j])==1){\n\t\t\t$adj[$i]++;\n\t\t\t$adj[$j]++;\n\t\t\t$result[] = ($i+1).' '.($j+1);\n\t\t}\n\t}\n}\nif(count($result) != 0){\n\techo count($result);\n\tforeach ($result as $val) {\n\t\techo \"\\n\".$val;\n\t}\n}else{\n\techo '-1';\n}"}, {"source_code": " $val){\n $keys[] = $key;\n $vals[] = (int)$val;\n}\n$i = 0;\n$j = 1;\nwhile($i < $n && $j < $n){\n if($adj[$keys[$i]] >= $k || ($vals[$j] - $vals[$i] > 1)){\n $i++;\n continue;\n }\n\n if($adj[$keys[$j]] >= $k || ($vals[$j] == $vals[$i])){\n $j++;\n continue;\n }\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $result[] = ($keys[$i]+1).' '.($keys[$j]+1);\n $j++;\n}\nif(count($result) < $n-1){\n echo '-1';\n} else {\n echo count($result);\n foreach ($result as $val) {\n echo \"\\n\".$val;\n }\n}"}, {"source_code": " $val){\n $keys[] = $key;\n $vals[] = $val;\n}\nfor($i = 0; $i < $n; $i++){\n for($j = $i + 1; $j < $n; $j++){\n if($adj[$keys[$i]] >= $k)\n break;\n if($adj[$keys[$j]] >= $k)\n continue;\n if(abs($vals[$i]-$vals[$j]) == 1){\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $result[] = ($keys[$i]+1).' '.($keys[$j]+1);\n }\n }\n}\n\nif(count($result) != 0){\n echo count($result);\n foreach ($result as $val) {\n echo \"\\n\".$val;\n }\n}else{\n echo '-1';\n}"}, {"source_code": " $val){\n $keys[] = $key;\n $vals[] = $val;\n // foreach($d as $key1 => $val1){\n // if($adj[$key] >= $k)\n // break;\n // if($adj[$key1] >= $k)\n // continue;\n // if(abs($d[$key]-$d[$key1])==1){\n // $adj[$i]++;\n // $adj[$j]++;\n // $result[] = ($i+1).' '.($j+1);\n // }\n // }\n}\n\nfor($i = 0; $i < $n; $i++){\n for($j = $i + 1; $j < $n; $j++){\n if($adj[$keys[$i]] >= $k)\n break;\n if($adj[$keys[$j]] >= $k)\n continue;\n if(abs($vals[$i]-$vals[$j]) <= 1){\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $result[] = ($keys[$i]+1).' '.($keys[$j]+1);\n }\n }\n}\nif(count($result) != 0){\n echo count($result);\n foreach ($result as $val) {\n echo \"\\n\".$val;\n }\n}else{\n echo '-1';\n}"}, {"source_code": " $val){\n $keys[] = $key;\n $vals[] = (int)$val;\n}\n$i = 0;\n$j = 1;\nwhile($i < $n && $j < $n){\n if($adj[$keys[$i]] >= $k || ($vals[$j] - $vals[$i] > 1)){\n $i++;\n continue;\n }\n\n if($adj[$keys[$j]] >= $k || ($vals[$j] == $vals[$i])){\n $j++;\n continue;\n }\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $result[] = ($keys[$i]+1).' '.($keys[$j]+1);\n $j++;\n}\nif(count($result) != 0){\n echo count($result);\n foreach ($result as $val) {\n echo \"\\n\".$val;\n }\n}else{\n echo '-1';\n}"}, {"source_code": " $val){\n $keys[] = $key;\n $vals[] = $val;\n // foreach($d as $key1 => $val1){\n // if($adj[$key] >= $k)\n // break;\n // if($adj[$key1] >= $k)\n // continue;\n // if(abs($d[$key]-$d[$key1])==1){\n // $adj[$i]++;\n // $adj[$j]++;\n // $result[] = ($i+1).' '.($j+1);\n // }\n // }\n}\n\nfor($i = 0; $i < $n; $i++){\n for($j = $i + 1; $j < $n; $j++){\n if($adj[$keys[$i]] >= $k)\n break;\n if($adj[$keys[$j]] >= $k)\n continue;\n if(abs($vals[$i]-$vals[$j]) == 1){\n $adj[$keys[$i]]++;\n $adj[$keys[$j]]++;\n $result[] = ($keys[$i]+1).' '.($keys[$j]+1);\n }\n }\n}\nif(count($result) != 0){\n echo count($result);\n foreach ($result as $val) {\n echo \"\\n\".$val;\n }\n}else{\n echo '-1';\n}"}], "src_uid": "73668a75036dce819ff27c316de378af"} {"nl": {"description": "The new \"Die Hard\" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A \"Die Hard\" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line?", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 \u2014 the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line.", "output_spec": "Print \"YES\" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print \"NO\".", "sample_inputs": ["4\n25 25 50 50", "2\n25 100", "4\n50 50 25 25"], "sample_outputs": ["YES", "NO", "NO"], "notes": null}, "positive_code": [{"source_code": " 0)\n {\n $c[0]--;\n $c[1]--;\n $c[2]++;\n if(($c[0] < 0) || ($c[1] < 0))\n {\n $d = 1;\n break;\n }\n }\n else\n {\n $c[0] -= 3;\n $c[2]++;\n if(($c[0] < 0) || ($c[1] < 0))\n {\n $d = 1;\n break;\n }\n }\n }\n}\nif($d == \"1\")\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\";\n}\n?>"}, {"source_code": "0&&$c_25>0) {\n\t\t\t$c_50--;\n\t\t\t$c_25--;\n\t\t}\n\t\telse if($c_25>=3) $c_25-=3;\n\t\telse die(\"NO\\n\");\n\t}\n}\n\necho \"YES\\n\";\n\n?>"}, {"source_code": "\n\n$n = (int)fgets(STDIN);\n\n$data = explode(\" \", fgets(STDIN));\n\n$bill25 = 0;\n$bill50 = 0;\n\nforeach($data as $current_bill) {\n \n if($current_bill == 25) {\n $bill25++;\n continue;\n }\n \n if($current_bill == 50) {\n if($bill25 > 0) {\n $bill25--;\n $bill50++;\n continue;\n } else {\n die(\"NO\");\n }\n }\n \n if($current_bill == 100) {\n if($bill50 > 0 && $bill25 > 0) {\n $bill50--;\n $bill25--;\n continue;\n } elseif($bill25 >= 3) {\n $bill25 -= 3;\n continue;\n } else {\n die(\"NO\");\n }\n }\n}\n\ndie(\"YES\");"}, {"source_code": " 0) {\n\t\t\t$t1 --;\n\t\t\t$t2 ++;\n\t\t}\n\t\telse {\n\t\t\t$ok = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse {\n\t\tif($t1 > 0 && $t2 >0) {\n\t\t\t$t1 --;\n\t\t\t$t2 --;\n\t\t}\n\t\telse if($t1 > 2) {\n\t\t\t\t$t1 -= 3;\n\t\t}\n\t\telse {\n\t\t\t$ok = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n} \necho ($ok == 1)? \"YES\" : \"NO\";\n\n?>"}, {"source_code": "\n\nerror_reporting(false);\n\n$handle = fopen('php://stdin', 'r');\n\nif (file_exists(\"in.txt\")) {\n $handle = fopen('in.txt', 'r');\n set_time_limit(1);\n};\n\nfgets($handle);\n$arr = array(\"25\"=>0, \"50\"=>0, \"100\"=>0);\n$list = explode(\" \", fgets($handle));\n\nforeach($list as $price) {\n if ($price == 25) $arr[\"25\"]++;\n else {\n\n if ($price == 50) {\n if ($arr[\"25\"] < 1) die(\"NO\");\n else {\n $arr[\"25\"]--;\n $arr[\"50\"]++;\n }\n }\n\n if ($price == 100) {\n\n if ($arr[\"25\"] < 1) die(\"NO\");\n if ($arr[\"50\"] > 0) {\n $arr[\"25\"]--;\n $arr[\"50\"]--;\n } else {\n if ($arr[\"25\"] < 3) die(\"NO\");\n $arr[\"25\"] -= 3;\n }\n }\n }\n}\n\ndie(\"YES\");\n?>\n\n"}, {"source_code": " 0) {\n $c25 --;\n $c50 ++;\n } else {\n $isYes = false;\n break;\n }\n } else if ($a[$i] == 100) {\n if ($c50 > 0 && $c25 > 0) {\n $c50 --;\n $c25 --;\n } else if ($c25 > 2) {\n $c25 -= 3;\n } else {\n $isYes = false;\n break;\n }\n }\n}\n\nprint ($isYes ? 'YES' : 'NO');\n\nfunction getLine() {\n return trim(fgets(STDIN));\n}\n"}], "negative_code": [{"source_code": ""}, {"source_code": "$pre+25) $flag=false; \n\t$pre+=25;\n}\n\nif($flag) echo \"YES\\n\";\nelse echo \"NO\\n\";\n\n?>"}, {"source_code": "$pre+25) $flag=false; \n\t$pre+=$input[$i];\n}\n\nif($flag) echo \"YES\\n\";\nelse echo \"NO\\n\";\n\n?>"}, {"source_code": "\n\n$n = (int)fgets(STDIN);\n\n$data = explode(\" \", fgets(STDIN));\n\n$bill25 = 0;\n$bill50 = 0;\n\nforeach($data as $current_bill) {\n \n if($current_bill == 25) {\n $bill25++;\n continue;\n }\n \n if($current_bill == 50) {\n if($bill25 > 0) {\n $bill25--;\n continue;\n } else {\n die(\"NO\");\n }\n }\n \n if($current_bill == 100) {\n if($bill50 > 0 && $bill25 > 0) {\n $bill50--;\n $bill25--;\n continue;\n } elseif($bill25 >= 3) {\n $bill25 -= 3;\n continue;\n } else {\n die(\"NO\");\n }\n }\n}\n\ndie(\"YES\");"}, {"source_code": "\n\nerror_reporting(false);\n\n$handle = fopen('php://stdin', 'r');\n\nif (file_exists(\"in.txt\")) {\n $handle = fopen('in.txt', 'r');\n set_time_limit(1);\n};\n\nfgets($handle);\n$arr = array(\"25\"=>0, \"50\"=>0, \"100\"=>0);\n$list = explode(\" \", fgets($handle));\n\nforeach($list as $price) {\n if ($price == 25) $arr[\"25\"]++;\n else {\n\n if ($price == 50 && $arr[\"25\"] < 1) die(\"NO\");\n else {\n $arr[\"25\"]--;\n $arr[\"50\"]++;\n }\n\n if ($price == 100) {\n\n if ($arr[\"25\"] == 0) die(\"NO\");\n if ($arr[\"50\"] > 0) {\n $arr[\"25\"]--;\n $arr[\"50\"]--;\n $arr[\"100\"]++;\n } else {\n if ($arr[\"25\"] < 3) die(\"NO\");\n $arr[\"25\"]-=3;\n $arr[\"100\"]++;\n }\n\n\n\n }\n\n\n }\n}\n\ndie(\"YES\");\n\n\n\n\n\n?>\n\n"}], "src_uid": "63b20ab2993fddf2cc469c4c4e8027df"} {"nl": {"description": "George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi\u2009\u2264\u2009qi). Your task is to count how many rooms has free place for both George and Alex.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of rooms. The i-th of the next n lines contains two integers pi and qi (0\u2009\u2264\u2009pi\u2009\u2264\u2009qi\u2009\u2264\u2009100) \u2014 the number of people who already live in the i-th room and the room's capacity.", "output_spec": "Print a single integer \u2014 the number of rooms where George and Alex can move in.", "sample_inputs": ["3\n1 1\n2 2\n3 3", "3\n1 10\n0 10\n10 10"], "sample_outputs": ["0", "2"], "notes": null}, "positive_code": [{"source_code": "1?1:0);\n\t\t$i=$i+1;\n\t}\n\techo $availability;\n?>"}, {"source_code": "\n$rooms = 0;\n$data = file('php://stdin');\nif (!empty($data))\n{\n\t$roomsCnt = intval($data[0]);\n\tif ($roomsCnt > 100) $roomsCnt = 100;\n\tif ($roomsCnt > 0 && count($data) > 1){\t\t\n\t\tfor($i = 1; $i <= $roomsCnt; $i++){\n\t\t\t$room = explode(\" \", $data[$i]);\n\t\t\tif ($room[0] <= $room[1] - 2) $rooms++;\n\t\t}\n\t}\n}\necho $rooms;\n?>"}, {"source_code": "= 0){\n $k += +1;\n \n }\n }\n echo $k;\n?>"}, {"source_code": "=2 ) {\n ++$room;\n }\n\n if (++$COUNT > $n) {\n echo $room;\n break;\n }\n}\n"}, {"source_code": " 1);\n\t}\n\techo $c;\n?>"}, {"source_code": "= 2) $counter++;\n}\nprintf(\"%d\",$counter);\n?>"}, {"source_code": "= 2 ){\n $p++;\n }\n}\necho $p;"}, {"source_code": "1)$summ++;\n}\necho $summ;"}, {"source_code": "= 2) {\n $room++;\n }\n}\necho $room;\n\n"}, {"source_code": "=2)\n\t{\n\t\t$count++;\n\t}\n}\necho \"$count\";"}, {"source_code": "=2) {\n $summa +=1;\n}\n}\n echo $summa;"}, {"source_code": "1){\n $count++;\n }\n }\n\n echo $count;\n\n\n"}, {"source_code": " 1)\n $ans++; \n}\n\necho $ans;\n\n?>"}, {"source_code": " $val) {\n if ($val[1] - $val[0] >= 2) {\n $res++;\n }\n}\necho $res;\n\n?>"}, {"source_code": "= 2) $answer++; \n\t}\n\techo $answer;\n?>"}, {"source_code": "= 2) {\n $result++;\n }\n}\n\necho $result;\n"}, {"source_code": "=2) $ans++;\n}\necho $ans;\n?>"}, {"source_code": "=2){$ok++;}}print $ok;\n?>"}, {"source_code": "= 2)\n\t\t$spaces++;\n}\necho $spaces;\n?>"}, {"source_code": "= 2) {\n\t\t$hitung++;\n\t}\n\t$i++;\n}\necho $hitung;\n\n?>"}, {"source_code": "= 0) {\n\t\t$hitung++;\n\t}\n\t$i++;\n}\necho $hitung;\n\n?>"}, {"source_code": "= 2)$c++;\n}\n\necho $c;\n"}, {"source_code": " 1) {\n $col ++;\n }\n}\n\necho $col;\n\n?>\n"}, {"source_code": "= $pCount) {\n $sCount++;\n }\n}\n\necho $sCount;\n\n?>"}, {"source_code": " 1);\n}\n\nprint $output;\n"}, {"source_code": " 1) {\n $answer++;\n }\n}\n\necho $answer . PHP_EOL;\n"}, {"source_code": "= 2){\n\t\t\t$result++;\n\t\t\t//print_r($result);\n\t\t\n\t}\n\n\n\n}\nprint_r($result);"}, {"source_code": "= 2) $c++;\n}\n\necho $c;\n"}, {"source_code": "= 2) {\n $room_remain++;\n }\n}\necho $room_remain.\"\\n\";\n"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$z=0;\nfor($i=0;$i<$n;$i++)\n {\n $p=explode(\" \",trim(fgets(STDIN)));\n if($p[1]-$p[0]>=2)++$z;\n }\n echo $z;\n?>"}, {"source_code": " 1) {\n $j++; \n }\n }\n \n\n \n echo $j;\n \n?>"}, {"source_code": "=2){\n $c++;\n }\n}\n\necho $c.\"\\n\";\n\n\n?>"}, {"source_code": ""}, {"source_code": "=2)\n{\n $m++;\n \n}\n\n}\necho $m;\n\n?>\n\n"}, {"source_code": "= 2) $move++;\n\t}\n\techo $move;\n?>"}, {"source_code": "= 2)\n {\n $d++;\n }\n}\nprint $d;\n?>"}, {"source_code": "= 2) $total++;\n\t}\n\techo $total;"}, {"source_code": "=2) {\n $count++;\n }\n unset($room);\n}\necho $count;"}, {"source_code": "= 2) ++$sum;\n}\n\nprintf(\"%d\", $sum);\n"}, {"source_code": " 1) \n\t $res += 1;\n}\n \necho $res;"}], "negative_code": [{"source_code": "\n$data = file('php://stdin');\n$roomsCnt = intval($data[0]);\nif ($roomsCnt > 100) $roomsCnt = 100;\nif ($roomsCnt > 0 && count($data) > 1){\n\t$rooms = 0;\n\tfor($i = 1; $i <= $roomsCnt; $i++){\n\t\t$room = explode(\" \", $data[$i]);\n\t\tif ($room[0] < $room[1] - 2) $rooms++;\n\t}\n\techo $rooms;\n}\n?>"}, {"source_code": "\n$data = file('php://stdin');\n$roomsCnt = intval($data[0]);\nif ($roomsCnt > 100) $roomsCnt = 100;\n$rooms = 0;\nif ($roomsCnt > 0 && count($data) > 1){\t\t\n\tfor($i = 1; $i <= $roomsCnt; $i++){\n\t\t$room = explode(\" \", $data[$i]);\n\t\tif ($room[0] < $room[1] - 2) $rooms++;\n\t}\n}\necho $rooms;\n?>"}, {"source_code": "\nif (file_exists('php://stdin'))\n{\n\t$data = file('php://stdin');\n\t$roomsCnt = intval($data[0]);\n\tif ($roomsCnt > 100) $roomsCnt = 100;\n\t$rooms = 0;\n\tif ($roomsCnt > 0 && count($data) > 1){\t\t\n\t\tfor($i = 1; $i <= $roomsCnt; $i++){\n\t\t\t$room = explode(\" \", $data[$i]);\n\t\t\tif ($room[0] < $room[1] - 2) $rooms++;\n\t\t}\n\t}\n\techo $rooms;\n}\n?>"}, {"source_code": "\n\t\n\t\t\n\t\n\t\n\t\n\t\n\tif(!empty($living)):?>\n\t\n\t\t\n\t\n\t\n"}, {"source_code": "\n$data = file('php://stdin');\n$roomsCnt = intval($data[0]);\nif ($roomsCnt > 100) $roomsCnt = 100;\nif ($roomsCnt > 0){\n\t$rooms = 0;\n\tfor($i = 1; $i <= $roomsCnt; $i++){\n\t\t$room = explode(\" \", $data[$i]);\n\t\tif ($room[0] < $room[1] - 2) $rooms++;\n\t}\n\techo $rooms;\n}\n?>"}, {"source_code": "=2 ) {\n ++$room;\n }\n\n if (++$COUNT >= $n) {\n echo $room;\n break;\n }\n}\n"}, {"source_code": " 2) $counter++;\n}\nprintf(\"%d\",$counter);\n?>"}, {"source_code": "1)$summ++;\n}\necho $summ;"}, {"source_code": " $array[$i]['person'] ) {\n $room++;\n }\n}\necho $room;\n\n"}, {"source_code": " $array[$i]['person'] ) {\n $room++;\n }\n}\necho $room;\n\n"}, {"source_code": "$a = (int)trim(fgets(STDIN));\n$b = '';\n$c = 0;\n\nfor($i = 0; $i < $a; $i++){\n $b = explode(\" \", trim(fgets(STDIN)));\n if(((int)$b[1] - (int)$b[0]) > 2)$c++;\n}\n\necho $c;"}, {"source_code": " 2)$c++;\n}\n\necho $c;"}, {"source_code": " 1) {\n $col ++;\n }\n}\n\necho $col;\n\n?>\n"}, {"source_code": " 1) {\n $col ++;\n }\n}\n\necho $col;\n\n?>\n"}, {"source_code": " 1) {\n $col++;\n }\n}\n\necho $col;\n\n?>\n"}, {"source_code": " 1) {\n $j++; \n }\n }\n \n\n \n echo $j;\n \n?>"}, {"source_code": " 0) $move++;\n\t}\n\techo $move;\n?>"}, {"source_code": "= 0) $move++;\n\t}\n\techo $move;\n?>"}, {"source_code": " 0) $move++;\n\t}\n\techo $move;\n?>"}, {"source_code": ""}], "src_uid": "2a6c457012f7ceb589b3dea6b889f7cb"} {"nl": {"description": "Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookies. That's why Olga wants to steal a bag with cookies so that the number of cookies in the remaining bags was even, that is, so that Anna and Maria could evenly divide it into two (even 0 remaining cookies will do, just as any other even number). How many ways there are to steal exactly one cookie bag so that the total number of cookies in the remaining bags was even?", "input_spec": "The first line contains the only integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of cookie bags Anna and Maria have. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009100) \u2014 the number of cookies in the i-th bag.", "output_spec": "Print in the only line the only number \u2014 the sought number of ways. If there are no such ways print 0.", "sample_inputs": ["1\n1", "10\n1 2 2 3 4 4 4 2 2 2", "11\n2 2 2 2 2 2 2 2 2 2 99"], "sample_outputs": ["1", "8", "1"], "notes": "NoteIn the first sample Olga should take the only bag so that the twins ended up with the even number of cookies.In the second sample Olga can take any of five bags with two cookies or any of three bags with four cookies \u2014 5\u2009+\u20093\u2009=\u20098 ways in total.In the third sample, no matter which bag with two cookies Olga chooses, the twins are left with 2\u2009*\u20099\u2009+\u200999\u2009=\u2009117 cookies. Thus, Olga has only one option: to take the bag with 99 cookies."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $v)\n{\n if (($sum - $v) % 2 == 0)\n {\n $c++;\n }\n}\necho $c;\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $v)\n {\n if ($k % 2 == 0)\n $c += $v;\n }\n}\nelse\n{\n foreach ($mas_count as $k => $v)\n {\n if ($k % 2 != 0)\n $c += $v;\n }\n}\necho $c;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "4c59b4d43b59c8659bf274f3e29d01fe"} {"nl": {"description": "Find the number of k-divisible numbers on the segment [a,\u2009b]. In other words you need to find the number of such integer values x that a\u2009\u2264\u2009x\u2009\u2264\u2009b and x is divisible by k.", "input_spec": "The only line contains three space-separated integers k, a and b (1\u2009\u2264\u2009k\u2009\u2264\u20091018;\u2009-\u20091018\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u20091018).", "output_spec": "Print the required number.", "sample_inputs": ["1 1 10", "2 -4 4"], "sample_outputs": ["10", "5"], "notes": null}, "positive_code": [{"source_code": " 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $g = bcdiv($c, $a);\n $d = bcadd($g, 1);\n $b = bcsub(0, $b);\n $e = bcmod($b, $a);\n $b = bcsub($b, $e);\n $g = bcdiv($b, $a);\n $d = bcadd($d, $g);\n }\n}\nelseif($b == 0)\n{\n if($c == 0)\n {\n $d++;\n }\n elseif($c > 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $f = bcsub($c, $b);\n $g = bcdiv($f, $a);\n $d = bcadd($g, 1);\n }\n}\nelseif($b > 0)\n{\n $e = bcmod($b, $a);\n if($e != 0)\n {\n $b = bcsub($b, $e);\n $b = bcadd($b, $a);\n }\n $f = bcmod($c, $a);\n if($f != 0)\n {\n $c = bcsub($c, $f);\n }\n $g = bcsub($c, $b);\n $h = bcdiv($g, $a);\n $d = bcadd($h, 1);\n}\nprint $d;\n?>"}], "negative_code": [{"source_code": "= 0))\n{\n $d++;\n}\nif($b < 0)\n{\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n}\nif($c > 0)\n{\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $g = bcdiv($c, $a);\n $d = bcadd($g, 1);\n $b = abs($b);\n $e = bcmod($b, $a);\n $b = bcsub($b, $e);\n $g = bcdiv($b, $a);\n $d = bcadd($d, $g);\n }\n}\nelseif($b == 0)\n{\n if($c == 0)\n {\n $d++;\n }\n elseif($c > 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $f = bcsub($c, $b);\n $g = bcdiv($f, $a);\n $d = bcadd($g, 1);\n }\n}\nelseif($b > 0)\n{\n $e = bcmod($b, $a);\n if($e != 0)\n {\n $b = bcsub($b, $e);\n $b = bcadd($b, $a);\n }\n $f = bcmod($c, $a);\n if($f != 0)\n {\n $c = bcsub($c, $f);\n }\n $g = bcsub($c, $b);\n $h = bcdiv($g, $a);\n $d = bcadd($h, 1);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $g = bcdiv($c, $a);\n $d = bcadd($g, 1);\n $b = bcsub(0, $b);\n $e = bcmod($b, $a);\n $b = bcsub($b, $e);\n $g = bcdiv($b, $a);\n $d = bcadd($d, $g);\n }\n}\nelseif($b == 0)\n{\n if($c == 0)\n {\n $d++;\n }\n elseif($c > 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $f = bcsub($c, $b);\n $g = bcdiv($f, $a);\n $d = bcadd($g, 1);\n }\n}\nelseif($b > 0)\n{\n $e = bcmod($b, $a);\n if($e != 0)\n {\n $b = bcsub($b, $e);\n $b = bcadd($b, $a);\n }\n $f = bcmod($c, $a);\n if($f != 0)\n {\n $c = bcsub($c, $f);\n }\n $g = bcsub($c, $b);\n $h = bcdiv($g, $a);\n $d = bcadd($h, 1);\n}\nprint $d;\n?>"}, {"source_code": "= 0))\n{\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcadd(bcdiv($e, $a), 1));\n $d = bcadd($d, $f);\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcadd(bcdiv($e, $a), 1));\n $d = bcadd($d, $f);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}, {"source_code": "= 0))\n{\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nif(($a == 1) && ($b != $c))\n{\n $d = bcadd($d, 1);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": "= 0))\n{\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n if($a == 1)\n {\n $d = bcadd($d, 1);\n }\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n if($a == 1)\n {\n $d = bcadd($d, 1);\n }\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $g = bcdiv($c, $a);\n $d = bcadd($g, 1);\n $b = bcsub(0, $b);\n $e = bcmod($b, $a);\n $b = bcsub($b, $e);\n $g = bcdiv($b, $a);\n $d = bcadd($d, $g);\n }\n}\nelseif($b == 0)\n{\n if($c == 0)\n {\n $d++;\n }\n elseif($c > 0)\n {\n $e = bcmod($c, $a);\n $c = bcsub($c, $e);\n $f = bcsub($c, $b);\n $g = bcdiv($f, $a);\n $d = bcadd($g, 1);\n }\n}\nelseif($b > 0)\n{\n $e = bcmod($b, $a);\n if($e != 0)\n {\n $b = bcsub($b, $e);\n $b = bcadd($b, $a);\n }\n $f = bcmod($c, $a);\n if($f != 0)\n {\n $c = bcsub($c, $f);\n }\n $g = bcsub($c, $b);\n $h = bcdiv($g, $a);\n $d = bcadd($h, 1);\n}\nprint $d;\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}, {"source_code": "= 0))\n{\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n if(($a == 1) && ($b != $c))\n {\n $d = bcadd($d, 1);\n }\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n if(($a == 1) && ($b != $c))\n {\n $d = bcadd($d, 1);\n }\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}, {"source_code": "= 0))\n{\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nif($a == 1)\n{\n $d = bcadd($d, 1);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0))\n{\n $d++;\n}\nif($b < 0)\n{\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n}\nif($c > 0)\n{\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}, {"source_code": "= 0))\n {\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n }\n elseif(($b < 0) && ($c <= 0))\n {\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n }\n elseif(($b >= 0) && ($c > 0))\n {\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n }\n if($a == 1)\n {\n $d = bcadd($d, 1);\n }\n printf(\"%.0f\", $d);\n}\n?>"}, {"source_code": "= 0))\n{\n $d++;\n}\nif($b < 0)\n{\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n}\nif($c > 0)\n{\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": "= 0))\n{\n $g = 1;\n $d++;\n if($b < 0)\n {\n $e = floor(bcdiv(abs($b), $a));\n $d = bcadd($d, $e);\n }\n if($c > 0)\n {\n $e = floor(bcdiv($c, $a));\n $d = bcadd($d, $e);\n }\n}\nelseif(($b < 0) && ($c <= 0))\n{\n $e = bcsub(abs($b), abs($c));\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nelseif(($b >= 0) && ($c > 0))\n{\n $e = bcsub($c, $b);\n $f = floor(bcdiv($e, $a));\n $d = bcadd($d, $f);\n}\nif(($a == 1) && ($g == 0))\n{\n $d = bcadd($d, 1);\n}\nprintf(\"%.0f\", $d);\n?>"}, {"source_code": " 0) && ($b % $a != 0))\n{\n $d++;\n}\nif(($c < 0) && ($c % $a != 0))\n{\n $e--;\n}\nprint $e - $d + 1;\n?>"}], "src_uid": "98de093d78f74273e0ac5c7886fb7a41"} {"nl": {"description": "Mishka wants to buy some food in the nearby shop. Initially, he has $$$s$$$ burles on his card. Mishka can perform the following operation any number of times (possibly, zero): choose some positive integer number $$$1 \\le x \\le s$$$, buy food that costs exactly $$$x$$$ burles and obtain $$$\\lfloor\\frac{x}{10}\\rfloor$$$ burles as a cashback (in other words, Mishka spends $$$x$$$ burles and obtains $$$\\lfloor\\frac{x}{10}\\rfloor$$$ back). The operation $$$\\lfloor\\frac{a}{b}\\rfloor$$$ means $$$a$$$ divided by $$$b$$$ rounded down.It is guaranteed that you can always buy some food that costs $$$x$$$ for any possible value of $$$x$$$.Your task is to say the maximum number of burles Mishka can spend if he buys food optimally.For example, if Mishka has $$$s=19$$$ burles then the maximum number of burles he can spend is $$$21$$$. Firstly, he can spend $$$x=10$$$ burles, obtain $$$1$$$ burle as a cashback. Now he has $$$s=10$$$ burles, so can spend $$$x=10$$$ burles, obtain $$$1$$$ burle as a cashback and spend it too.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. The next $$$t$$$ lines describe test cases. Each test case is given on a separate line and consists of one integer $$$s$$$ ($$$1 \\le s \\le 10^9$$$) \u2014 the number of burles Mishka initially has.", "output_spec": "For each test case print the answer on it \u2014 the maximum number of burles Mishka can spend if he buys food optimally.", "sample_inputs": ["6\n1\n10\n19\n9876\n12345\n1000000000"], "sample_outputs": ["1\n11\n21\n10973\n13716\n1111111111"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "= 10) {\n \n $d = $n % 10;\n $s = floor($n / 10);\n \n $n = $d + $s;\n $total += $s * 10 ;\n }\n $total += $n;\n \n echo $total .\"\\n\";\n \n \n \n }\n "}, {"source_code": "\n\n$n = intval(fgets(STDIN));\nfor ($i = 0; $i < $n; $i++) {\n $money = intval(fgets(STDIN));\n $cashback = 0;\n $total = 0;\n while($money > 9) {\n $cashback = intdiv($money, 10);\n $total += 10 * $cashback;\n $money = $money - 9 * $cashback;\n }\n $total += $money;\n echo $total.\"\\n\";\n}\n?>"}, {"source_code": "9) {\n $g = $ans;\n while ($g > 9) {\n $mod1 = ((int)($g / 10))*10;\n // var_dump($mod1);die();\n $base+=$mod1;\n $g=((int)($g / 10))+($g%10);\n }\n $base+=$g;\n echo $base.\"\\n\";\n }else\n {\n echo ($ans+$base).\"\\n\";\n }\n\n\n\n}\n\n\n?>"}, {"source_code": "\n"}], "negative_code": [{"source_code": "\n"}], "src_uid": "0beecbd62aa072a2f3aab542eeb56373"} {"nl": {"description": "A string $$$a=a_1a_2\\dots a_n$$$ is called even if it consists of a concatenation (joining) of strings of length $$$2$$$ consisting of the same characters. In other words, a string $$$a$$$ is even if two conditions are satisfied at the same time: its length $$$n$$$ is even; for all odd $$$i$$$ ($$$1 \\le i \\le n - 1$$$), $$$a_i = a_{i+1}$$$ is satisfied. For example, the following strings are even: \"\" (empty string), \"tt\", \"aabb\", \"oooo\", and \"ttrrrroouuuuuuuukk\". The following strings are not even: \"aaa\", \"abab\" and \"abba\".Given a string $$$s$$$ consisting of lowercase Latin letters. Find the minimum number of characters to remove from the string $$$s$$$ to make it even. The deleted characters do not have to be consecutive.", "input_spec": "The first line of input data contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014the number of test cases in the test. The descriptions of the test cases follow. Each test case consists of one string $$$s$$$ ($$$1 \\le |s| \\le 2 \\cdot 10^5$$$), where $$$|s|$$$\u00a0\u2014 the length of the string $$$s$$$. The string consists of lowercase Latin letters. It is guaranteed that the sum of $$$|s|$$$ on all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, print a single number\u00a0\u2014 the minimum number of characters that must be removed to make $$$s$$$ even.", "sample_inputs": ["6\n\naabbdabdccc\n\nzyx\n\naaababbb\n\naabbcc\n\noaoaaaoo\n\nbmefbmuyw"], "sample_outputs": ["3\n3\n2\n0\n2\n7"], "notes": "NoteIn the first test case you can remove the characters with indices $$$6$$$, $$$7$$$, and $$$9$$$ to get an even string \"aabbddcc\".In the second test case, each character occurs exactly once, so in order to get an even string, you must remove all characters from the string.In the third test case, you can get an even string \"aaaabb\" by removing, for example, $$$4$$$-th and $$$6$$$-th characters, or a string \"aabbbb\" by removing the $$$5$$$-th character and any of the first three."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "6b92f09df1e35edc80cf1cbf8494b41e"} {"nl": {"description": "Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a \"domino show\".Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes either to the left or to the right. However, somewhere between every two dominoes pushed in the same direction there is at least one domino pushed in the opposite direction.After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces. The figure shows one possible example of the process. Given the initial directions Chris has pushed the dominoes, find the number of the dominoes left standing vertically at the end of the process!", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20093000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string si is equal to \"L\", if the i-th domino has been pushed to the left; \"R\", if the i-th domino has been pushed to the right; \".\", if the i-th domino has not been pushed. It is guaranteed that if si\u2009=\u2009sj\u2009=\u2009\"L\" and i\u2009<\u2009j, then there exists such k that i\u2009<\u2009k\u2009<\u2009j and sk\u2009=\u2009\"R\"; if si\u2009=\u2009sj\u2009=\u2009\"R\" and i\u2009<\u2009j, then there exists such k that i\u2009<\u2009k\u2009<\u2009j and sk\u2009=\u2009\"L\".", "output_spec": "Output a single integer, the number of the dominoes that remain vertical at the end of the process.", "sample_inputs": ["14\n.L.R...LR..L..", "5\nR....", "1\n."], "sample_outputs": ["4", "0", "1"], "notes": "NoteThe first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.In the second example case, all pieces fall down since the first piece topples all the other pieces.In the last example case, a single piece has not been pushed in either direction."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n if($c[$x] == \"L\")\n {\n $g = $a - $x - 1;\n $f = 1;\n break;\n }\n elseif($c[$x] == \"R\")\n {\n $f = 2;\n break;\n }\n}\n$h = 0;\n$i = 0;\n$j = array();\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == \"L\")\n {\n $h = 1;\n $i = $x;\n }\n if(($c[$x] == \"R\") && ($h == 1))\n {\n array_push($j, $x - $i - 1);\n $h = 0;\n }\n}\n$k = 0;\n$l = 0;\n$m = 0;\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == \"R\")\n {\n $k = 1;\n $l = $x;\n }\n if(($c[$x] == \"L\") && ($k == 1))\n {\n $n = $x - $l - 1;\n $o = $n % 2;\n if($o != 0)\n {\n $m++;\n }\n $k = 0;\n }\n}\n$p = array_unique($c);\nif((count($p) == 1) && ($p[0] == \".\"))\n{\n print $a;\n}\nelse\n{\n print $e + $g + array_sum($j) + $m;\n}\n?>"}, {"source_code": "= 0; $i--) {\n \tif($stat == 0 && $S[$i] == 'L') {\n \t\t$S[$i] = 'L';\n \t\t$stat = 1;\n \t}\n \telseif($stat == 1 && $S[$i] == '.') {\n \t\t$S[$i] = 'L';\n \t}\n \telseif($stat == 1 && $S[$i] == 'R') \n \t\t$stat = 0;\n \telseif($stat == 0 && $S[$i] == '.')\n \t\t$ans++;\n }\n //echo \"{$S}\";//}\n echo \"{$ans}\\n\";\n?>"}], "negative_code": [{"source_code": "= 0; $i--) {\n \tif($stat == 0 && $S[$i] == 'L') {\n \t\t$S[$i] = 'L';\n \t\t$stat = 1;\n \t}\n \telseif($stat == 1 && $S[$i] == '.') {\n \t\t$S[$i] = 'L';\n \t}\n \telseif($stat == 1) \n \t\t$stat = 0;\n \telseif($stat == 0)\n \t\t$ans++;\n }\n echo \"{$ans}\\n\";\n?>"}, {"source_code": "= 0; $i--) {\n \tif($stat == 0 && $S[$i] == 'L') {\n \t\t$S[$i] = 'L';\n \t\t$stat = 1;\n \t}\n \telseif($stat == 1 && $S[$i] == '.') {\n \t\t$S[$i] = 'L';\n \t}\n \telseif($stat == 1) \n \t\t$stat = 0;\n \telseif($stat == 0 && $S[$i] == '.')\n \t\t$ans++;\n }\n //echo \"{$S}\";//}\n echo \"{$ans}\\n\";\n?>"}, {"source_code": "= 0; $i--) {\n \tif($stat == 0 && $S[$i] == 'L') {\n \t\t$S[$i] = 'L';\n \t\t$stat = 1;\n \t}\n \telseif($stat == 1 && $S[$i] == '.') {\n \t\t$S[$i] = 'L';\n \t}\n \telseif($stat == 1) \n \t\t$stat = 0;\n \telseif($stat == 0 && $S[$i] == '.')\n \t\t$ans++;\n }\n //echo \"{$S}\";//}\n echo \"{$ans}\\n\";\n?>"}], "src_uid": "54c748dd983b6a0ea1af1153d08f1c01"} {"nl": {"description": "You are the gym teacher in the school.There are $$$n$$$ students in the row. And there are two rivalling students among them. The first one is in position $$$a$$$, the second in position $$$b$$$. Positions are numbered from $$$1$$$ to $$$n$$$ from left to right.Since they are rivals, you want to maximize the distance between them. If students are in positions $$$p$$$ and $$$s$$$ respectively, then distance between them is $$$|p - s|$$$. You can do the following operation at most $$$x$$$ times: choose two adjacent (neighbouring) students and swap them.Calculate the maximum distance between two rivalling students after at most $$$x$$$ swaps.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. The only line of each test case contains four integers $$$n$$$, $$$x$$$, $$$a$$$ and $$$b$$$ ($$$2 \\le n \\le 100$$$, $$$0 \\le x \\le 100$$$, $$$1 \\le a, b \\le n$$$, $$$a \\neq b$$$) \u2014 the number of students in the row, the number of swaps which you can do, and positions of first and second rivaling students respectively.", "output_spec": "For each test case print one integer \u2014 the maximum distance between two rivaling students which you can obtain.", "sample_inputs": ["3\n5 1 3 2\n100 33 100 1\n6 0 2 3"], "sample_outputs": ["2\n99\n1"], "notes": "NoteIn the first test case you can swap students in positions $$$3$$$ and $$$4$$$. And then the distance between the rivals is equal to $$$|4 - 2| = 2$$$.In the second test case you don't have to swap students. In the third test case you can't swap students."}, "positive_code": [{"source_code": ""}, {"source_code": "= $n) {\n echo ($n -1) . \"\\n\";\n } else {\n echo (abs($a - $b) + $m) . \"\\n\";\n }\n}\n"}, {"source_code": " $f[$i][3]) {\n while ($x < $f[$i][1] && $f[$i][2] < $f[$i][0]) {\n $x += 1;\n $f[$i][2] += 1;\n }\n while ($x < $f[$i][1] && $f[$i][3] > 1) {\n $x += 1;\n $f[$i][3] -= 1; \n }\n echo abs($f[$i][3] - $f[$i][2]).PHP_EOL;\n } else {\n while ($x < $f[$i][1] && $f[$i][3] < $f[$i][0]) {\n $x += 1;\n $f[$i][3] += 1; \n }\n while ($x < $f[$i][1] && $f[$i][2] > 1) {\n $x += 1;\n $f[$i][2] -= 1; \n }\n echo abs($f[$i][3] - $f[$i][2]).PHP_EOL;\n }\n\n}\n\n\n?>"}, {"source_code": "=$value[0]){echo $value[0]-1;}\n else{echo abs($value[2]-$value[3])+$value[1];}\n if($i!= $arr[0]+1) echo \"\\n\";\n}\n?>"}, {"source_code": "=$str1[0])\n {\n echo ($str1[0]-$ans-1)+$ans.\"\\n\";\n }else{\n echo $ans+$str1[1].\"\\n\";\n }\n \n }\n\n\n}\n\nsolve();\n?>"}], "negative_code": [{"source_code": " $f[$i][3]) {\n while ($x < $f[$i][1] && $f[$i][2] < $f[$i][0]) {\n $x += 1;\n $f[$i][2] += 1;\n }\n while ($x < $f[$i][1] && $f[$i][3] > 1) {\n $x += 1;\n $f[$i][3] -= 1; \n }\n echo abs($f[$i][3] - $f[$i][2]).PHP_EOL;\n } else {\n while ($x < $f[$i][1] && $f[$i][3] < $f[$i][0]) {\n $x += 1;\n $f[$i][3] += 1; \n }\n while ($x < $f[$i][1] && $f[$i][2] > 1) {\n $x += 1;\n $f[$i][2] -= 1; \n }\n echo abs($f[$i][3] - $f[$i][2]).PHP_EOL;\n }\n\n}\n\n\n?>"}, {"source_code": "$value[0]){echo $value[0]-1;}\n else{echo abs($value[2]-$value[3])+$value[1];}\n if($i!= $arr[0]+1) echo \"\\n\";\n}\n?>"}, {"source_code": "=$value[2]+$value[1]){echo abs($value[2]+$value[1]-$value[3]);}\n elseif($value[0]<$value[2]+$value[1] && $value[3]-$value[1]>=1){echo abs($value[0]-($value[0]-$value[1]+$value[3]));}\n elseif($value[0]<$value[2]+$value[1] && $value[3]-$value[1]<1){echo abs($value[0]-1);}\n if($i!= $arr[0]+1) echo \"\\n\";\n}\n\n?>"}, {"source_code": "$str1[0])\n {\n echo ($str1[0]-$ans-1)+$ans.\"\\n\";\n }else{\n echo $ans+$str1[1].\"\\n\";\n }\n \n }\n\n\n}\n\nsolve();\n?>"}], "src_uid": "1fd2619aabf4557093a59da804fd0e7b"} {"nl": {"description": "The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \\le l_j \\le r_j \\le n$$$.You can choose some subset of the given set of segments and decrease values on each of the chosen segments by one (independently). For example, if the initial array $$$a = [0, 0, 0, 0, 0]$$$ and the given segments are $$$[1; 3]$$$ and $$$[2; 4]$$$ then you can choose both of them and the array will become $$$b = [-1, -2, -2, -1, 0]$$$.You have to choose some subset of the given segments (each segment can be chosen at most once) in such a way that if you apply this subset of segments to the array $$$a$$$ and obtain the array $$$b$$$ then the value $$$\\max\\limits_{i=1}^{n}b_i - \\min\\limits_{i=1}^{n}b_i$$$ will be maximum possible.Note that you can choose the empty set.If there are multiple answers, you can print any.If you are Python programmer, consider using PyPy instead of Python when you submit your code.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 300, 0 \\le m \\le 300$$$) \u2014 the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$-10^6 \\le a_i \\le 10^6$$$), where $$$a_i$$$ is the value of the $$$i$$$-th element of the array $$$a$$$. The next $$$m$$$ lines are contain two integers each. The $$$j$$$-th of them contains two integers $$$l_j$$$ and $$$r_j$$$ ($$$1 \\le l_j \\le r_j \\le n$$$), where $$$l_j$$$ and $$$r_j$$$ are the ends of the $$$j$$$-th segment.", "output_spec": "In the first line of the output print one integer $$$d$$$ \u2014 the maximum possible value $$$\\max\\limits_{i=1}^{n}b_i - \\min\\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \\le q \\le m$$$) \u2014 the number of segments you apply. In the third line print $$$q$$$ distinct integers $$$c_1, c_2, \\dots, c_q$$$ in any order ($$$1 \\le c_k \\le m$$$) \u2014 indices of segments you apply to the array $$$a$$$ in such a way that the value $$$\\max\\limits_{i=1}^{n}b_i - \\min\\limits_{i=1}^{n}b_i$$$ of the obtained array $$$b$$$ is maximum possible. If there are multiple answers, you can print any.", "sample_inputs": ["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"], "sample_outputs": ["6\n2\n1 4", "7\n2\n3 2", "0\n0"], "notes": "NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$."}, "positive_code": [{"source_code": "= $e[$y] - 1) && ($x <= $f[$y] - 1) && ($j[$y] == TRUE))\n {\n $j[$y] = 0;\n for($z = $e[$y] - 1; $z < $f[$y]; $z++)\n {\n $c[$z]++;\n }\n }\n elseif((($e[$y] - 1 > $x) || ($f[$y] - 1 < $x)) && ($j[$y] == FALSE))\n {\n $j[$y] = 1;\n for($z = $e[$y] - 1; $z < $f[$y]; $z++)\n {\n $c[$z]--;\n }\n }\n }\n $k = max($c) - min($c);\n if($k > $d)\n {\n $d = $k;\n $l = array();\n for($y = 0; $y < $b; $y++)\n {\n if($j[$y] == TRUE)\n {\n $l[count($l)] = $y + 1;\n }\n }\n }\n}\nprint $d . \"\\n\";\nprint count($l) . \"\\n\";\nprint implode(\" \", $l);\n?>"}], "negative_code": [], "src_uid": "2b1595ffe5d233f788c976e155fff26f"} {"nl": {"description": "The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k\u2009\u00d7\u2009d bourlemeters. Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.", "input_spec": "The first output line contains two space-separated integers n and l (1\u2009\u2264\u2009n,\u2009l\u2009\u2264\u2009100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1\u2009\u2264\u2009ai\u2009\u2264\u2009100).", "output_spec": "Print the single number \u2014 the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.", "sample_inputs": ["4 2\n1 2 3 4", "5 3\n5 5 7 3 1", "2 3\n1 2"], "sample_outputs": ["8", "15", "0"], "notes": "NoteIn the first sample test the required window is 2\u2009\u00d7\u20094 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves."}, "positive_code": [{"source_code": ""}, {"source_code": " $res) {\n $res = $i * $a[$i];\n }\n }\n echo \"{$res}\\n\";"}], "negative_code": [{"source_code": ""}], "src_uid": "991516fa6f3ed5a71c547a3a50ea1a2b"} {"nl": {"description": "Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns \u2013 starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x,\u2009y).Valera wants to place exactly k tubes on his rectangle table. A tube is such sequence of table cells (x1,\u2009y1), (x2,\u2009y2), ..., (xr,\u2009yr), that: r\u2009\u2265\u20092; for any integer i (1\u2009\u2264\u2009i\u2009\u2264\u2009r\u2009-\u20091) the following equation |xi\u2009-\u2009xi\u2009+\u20091|\u2009+\u2009|yi\u2009-\u2009yi\u2009+\u20091|\u2009=\u20091 holds; each table cell, which belongs to the tube, must occur exactly once in the sequence. Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled: no pair of tubes has common cells; each cell of the table belongs to some tube. Help Valera to arrange k tubes on his rectangle table in a fancy manner.", "input_spec": "The first line contains three space-separated integers n,\u2009m,\u2009k (2\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009300; 2\u2009\u2264\u20092k\u2009\u2264\u2009n\u00b7m) \u2014 the number of rows, the number of columns and the number of tubes, correspondingly. ", "output_spec": "Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1,\u2009yi1,\u2009xi2,\u2009yi2,\u2009...,\u2009xiri,\u2009yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists. ", "sample_inputs": ["3 3 3", "2 3 1"], "sample_outputs": ["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"], "notes": "NotePicture for the first sample: Picture for the second sample: "}, "positive_code": [{"source_code": "= 1; $y--)\n {\n $h[$k] = $x;\n $k++;\n $h[$k] = $y;\n $k++;\n $m = $k - $l;\n if(($m % 4 == 0) && ($l < count($f)))\n {\n $h[$k] = $f[$l];\n $k++;\n $l++;\n }\n }\n }\n}\n$p = 0;\n$n = 0;\nfor($x = 0; $x < count($f) - 1; $x++)\n{\n $n += $f[$x] * 2 + 1;\n $r = \"\";\n for($y = $p; $y < $n; $y++)\n {\n $r .= $h[$y] . \" \";\n }\n print trim($r) . \"\\n\";\n $p = $n;\n}\n$n += $f[$x] * 2 + 1;\n$r = \"\";\nfor($y = $p; $y < $n; $y++)\n{\n $r .= $h[$y] . \" \";\n}\nprint trim($r);\n$p = $n;\n?>"}, {"source_code": " 1) {\n \techo '2 ';\n \techo $x.' '.$y;\n\n \tif ($y==$ogran) {\n \t\t$counter = ($counter+1)%2;\n \t\t\t$iter = $swit[$counter][0];\n \t\t$ogran = $swit[$counter][1];\n \t\t$x++;\n \t}\n \telse {\n \t\t$y+=$iter;\n \t}\n\n \techo ' '.$x.' '.$y.PHP_EOL;\n \t$k--;\n\n \tif ($y==$ogran) {\n \t\t$counter = ($counter+1)%2;\n \t\t\t$iter = $swit[$counter][0];\n \t\t$ogran = $swit[$counter][1];\n \t\t$x++;\n \t}\n \telse {\n \t\t$y+=$iter;\n \t}\n }\n echo ($n*$m-2*$copyK);\n\n while ($x<=$n) {\n \techo ' '.$x.' '.$y;\n\n \tif ($y==$ogran) {\n \t\t$counter = ($counter+1)%2;\n \t\t\t$iter = $swit[$counter][0];\n \t\t$ogran = $swit[$counter][1];\n \t\t$x++;\n \t}\n \telse {\n \t\t$y+=$iter;\n \t}\n }\n\n\n?>"}], "negative_code": [], "src_uid": "779e73c2f5eba950a20e6af9b53a643a"} {"nl": {"description": "You are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.In a more formal way, you have to find the quantity of tuples (a,\u2009b,\u2009x,\u2009y) such that 1\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009<\u2009x\u2009\u2264\u2009y\u2009\u2264\u2009|s| and substrings s[a... b], s[x... y] are palindromes.A palindrome is a string that can be read the same way from left to right and from right to left. For example, \"abacaba\", \"z\", \"abba\" are palindromes.A substring s[i... j] (1\u2009\u2264\u2009i\u2009\u2264\u2009j\u2009\u2264\u2009|s|) of string s = s1s2... s|s| is a string sisi\u2009+\u20091... sj. For example, substring s[2...4] of string s = \"abacaba\" equals \"bac\".", "input_spec": "The first line of input contains a non-empty string s which consists of lowercase letters ('a'...'z'), s contains at most 2000 characters.", "output_spec": "Output a single number \u2014 the quantity of pairs of non-overlapping palindromic substrings of s. Please do not use the %lld format specifier to read or write 64-bit integers in \u0421++. It is preferred to use cin, cout streams or the %I64d format specifier.", "sample_inputs": ["aa", "aaa", "abacaba"], "sample_outputs": ["1", "5", "36"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "= 0 && $i+$plen <= $strlen-1 && ($center || $offset)){\n\t\t$center = ($center && ($i-$plen >= 0) && $string[$i-$plen] == $string[$i+$plen]);\n\t\tif ($center) {\n\t\t\t#$palyndrom[$i-$plen][] = $plen+$plen+1;\n\t\t\tif (!isset($arEndPoints[$i+$plen+1])) $arEndPoints[$i+$plen+1] = 1;\n\t\t\telse ++$arEndPoints[$i+$plen+1];\n\n\t\t\tif (!isset($palCount[$i-$plen])) $palCount[$i-$plen] = 1;\n\t\t\telse ++$palCount[$i-$plen];\n\n\t\t\t#echo substr($string, $i-$plen, $plen+$plen+1).\"\\n\";\n\t\t\t$result += $strlen - ($plen+$plen+1);\n\t\t}\n\n\t\t$offset = $offset && ($string[$i-$plen+1] == $string[$i+$plen]);\n\t\tif ($offset) {\n\t\t\t#$palyndrom[$i-$plen+1][] = $plen+$plen;\n\t\t\tif (!isset($arEndPoints[$i+$plen+1])) $arEndPoints[$i+$plen+1] = 1;\n\t\t\telse ++$arEndPoints[$i+$plen+1];\n\n\t\t\tif (!isset($palCount[$i-$plen+1])) $palCount[$i-$plen+1] = 1;\n\t\t\telse ++$palCount[$i-$plen+1];\n\n\n\t\t\t#echo substr($string, $i-$plen+1, $plen+$plen).\"\\n\";\n\t\t\t$result += $strlen - ($plen+$plen);\n\t\t}\n\n\t\t\n\t\t++$plen;\n\t}\n}\n\n$sumPalCount = array();\n$count = max(array_keys($palCount));#count($palCount);\n$last = $count;\n$sumPalCount[$last] = $palCount[$last];\nfor($i=$count-1; $i>=0; --$i){\n\tif (isset($palCount[$i])){\n\t\t$sumPalCount[$i] = $palCount[$i] + $sumPalCount[$last];\n\t\t$last = $i;\n\t}\n}\n\n\n$pairCount = 0;\n$endPoints = array_keys($arEndPoints);\n$endPointsCount = count($endPoints);\n\nfor($i=0; $i<$endPointsCount; ++$i){\n\tfor($k=$endPoints[$i]; $k<=$count; ++$k){\n\t\tif (isset($palCount[$k])){\n\t\t\t#$pairCount += $palCount[$k];\n\t\t\t$pairCount += $sumPalCount[$k] * $arEndPoints[$endPoints[$i]];\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n$resultSingle /= 2;\n$result += $resultSingle + $pairCount;\necho $result;\n\n?>"}, {"source_code": "= 0 && $i2 < $n && $a[$i1] === $a[$i2])\n {\n if (!isset($p1[$i1])) $p1[$i1] = 0;\n $p1[$i1]++;\n if (!isset($p2[$i2])) $p2[$i2] = 0;\n $p2[$i2]++;\n $i1--;\n $i2++;\n }\n\n $i1 = $i;\n $i2 = $i + 1;\n while ($i1 >= 0 && $i2 < $n && $a[$i1] === $a[$i2])\n {\n if (!isset($p1[$i1])) $p1[$i1] = 0;\n $p1[$i1]++;\n if (!isset($p2[$i2])) $p2[$i2] = 0;\n $p2[$i2]++;\n $i1--;\n $i2++;\n }\n}\nksort($p2);\n$sum = '0';\nforeach ($p2 as $k => $v)\n{\n $sum = bcadd($sum, $v, 0);\n $p2[$k] = array($v, $sum);\n}\n$n = '0';\n$n2 = count($p2);\n$ks = array_keys($p2);\nforeach ($p1 as $k => $cnt)\n{\n $a = 0;\n $b = $n2 - 1;\n while ($a !== $b)\n {\n $c = ($a + $b) >> 1;\n if ($ks[$c] < $k)\n {\n if ($a === $c) break;\n $a = $c;\n }\n else\n {\n $b = $c;\n }\n }\n while ($a < $n2 && $ks[$a] < $k) $a++;\n $a--;\n if ($a >= 0) $n = bcadd($n, bcmul($cnt, $p2[$ks[$a]][1], 0), 0);\n}\nfprintf(STDOUT, \"%s\\n\", $n);\n"}], "negative_code": [], "src_uid": "1708818cf66de9fa03439f608c897a90"} {"nl": {"description": "Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each element except the last has exactly one next element. The list is not closed in a cycle.In this problem you are given n memory cells forming one or more doubly linked lists. Each cell contains information about element from some list. Memory cells are numbered from 1 to n.For each cell i you are given two values: li \u2014 cell containing previous element for the element in the cell i; ri \u2014 cell containing next element for the element in the cell i. If cell i contains information about the element which has no previous element then li\u2009=\u20090. Similarly, if cell i contains information about the element which has no next element then ri\u2009=\u20090. Three lists are shown on the picture. For example, for the picture above the values of l and r are the following: l1\u2009=\u20094, r1\u2009=\u20097; l2\u2009=\u20095, r2\u2009=\u20090; l3\u2009=\u20090, r3\u2009=\u20090; l4\u2009=\u20096, r4\u2009=\u20091; l5\u2009=\u20090, r5\u2009=\u20092; l6\u2009=\u20090, r6\u2009=\u20094; l7\u2009=\u20091, r7\u2009=\u20090.Your task is to unite all given lists in a single list, joining them to each other in any order. In particular, if the input data already contains a single list, then there is no need to perform any actions. Print the resulting list in the form of values li, ri.Any other action, other than joining the beginning of one list to the end of another, can not be performed.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of memory cells where the doubly linked lists are located. Each of the following n lines contains two integers li, ri (0\u2009\u2264\u2009li,\u2009ri\u2009\u2264\u2009n) \u2014 the cells of the previous and the next element of list for cell i. Value li\u2009=\u20090 if element in cell i has no previous element in its list. Value ri\u2009=\u20090 if element in cell i has no next element in its list. It is guaranteed that the input contains the correct description of a single or more doubly linked lists. All lists have linear structure: each element of list except the first has exactly one previous element; each element of list except the last has exactly one next element. Each memory cell contains information about one element from some list, each element of each list written in one of n given cells.", "output_spec": "Print n lines, the i-th line must contain two integers li and ri \u2014 the cells of the previous and the next element of list for cell i after all lists from the input are united in a single list. If there are many solutions print any of them.", "sample_inputs": ["7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0"], "sample_outputs": ["4 7\n5 6\n0 5\n6 1\n3 2\n2 4\n1 0"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "15d73569d06968ce006faf83d7e5400c"} {"nl": {"description": "You are playing a new famous fighting game: Kortal Mombat XII. You have to perform a brutality on your opponent's character.You are playing the game on the new generation console so your gamepad have $$$26$$$ buttons. Each button has a single lowercase Latin letter from 'a' to 'z' written on it. All the letters on buttons are pairwise distinct.You are given a sequence of hits, the $$$i$$$-th hit deals $$$a_i$$$ units of damage to the opponent's character. To perform the $$$i$$$-th hit you have to press the button $$$s_i$$$ on your gamepad. Hits are numbered from $$$1$$$ to $$$n$$$.You know that if you press some button more than $$$k$$$ times in a row then it'll break. You cherish your gamepad and don't want to break any of its buttons.To perform a brutality you have to land some of the hits of the given sequence. You are allowed to skip any of them, however changing the initial order of the sequence is prohibited. The total damage dealt is the sum of $$$a_i$$$ over all $$$i$$$ for the hits which weren't skipped.Note that if you skip the hit then the counter of consecutive presses the button won't reset.Your task is to skip some hits to deal the maximum possible total damage to the opponent's character and not break your gamepad buttons.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of hits and the maximum number of times you can push the same button in a row. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$), where $$$a_i$$$ is the damage of the $$$i$$$-th hit. The third line of the input contains the string $$$s$$$ consisting of exactly $$$n$$$ lowercase Latin letters \u2014 the sequence of hits (each character is the letter on the button you need to press to perform the corresponding hit).", "output_spec": "Print one integer $$$dmg$$$ \u2014 the maximum possible damage to the opponent's character you can deal without breaking your gamepad buttons.", "sample_inputs": ["7 3\n1 5 16 18 7 2 10\nbaaaaca", "5 5\n2 4 1 3 1000\naaaaa", "5 4\n2 4 1 3 1000\naaaaa", "8 1\n10 15 2 1 4 8 15 16\nqqwweerr", "6 3\n14 18 9 19 2 15\ncccccc", "2 1\n10 10\nqq"], "sample_outputs": ["54", "1010", "1009", "41", "52", "10"], "notes": "NoteIn the first example you can choose hits with numbers $$$[1, 3, 4, 5, 6, 7]$$$ with the total damage $$$1 + 16 + 18 + 7 + 2 + 10 = 54$$$.In the second example you can choose all hits so the total damage is $$$2 + 4 + 1 + 3 + 1000 = 1010$$$.In the third example you can choose all hits expect the third one so the total damage is $$$2 + 4 + 3 + 1000 = 1009$$$.In the fourth example you can choose hits with numbers $$$[2, 3, 6, 8]$$$. Only this way you can reach the maximum total damage $$$15 + 2 + 8 + 16 = 41$$$.In the fifth example you can choose only hits with numbers $$$[2, 4, 6]$$$ with the total damage $$$18 + 19 + 15 = 52$$$.In the sixth example you can change either first hit or the second hit (it does not matter) with the total damage $$$10$$$."}, "positive_code": [{"source_code": " insert($c[0]);\nfor($x = 0; $x < $a; $x++)\n{\n if($d[$x] == $d[$x + 1])\n {\n $f -> insert($c[$x + 1]);\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n $e += $f -> extract();\n if($f -> isEmpty() == TRUE)\n {\n break;\n }\n }\n $f = new SplMaxHeap();\n $f -> insert($c[$x + 1]);\n }\n}\nprintf(\"%.0f\", $e);\n?>"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n$vals = $ir->readArrayOfInt($n);\n$vals[] = 0;\n$s = $ir->readString() . ' ';\n\n$dmg = '0';\n\n$groupSymbol = '';\n\n$group = [];\nfor($i=0; $i<=$n; $i++) {\n\tif ($s[$i] == $groupSymbol) {\n\t\t$group[] = $vals[$i];\n\t} else {\n\t\t$cnt = count($group);\n\t\tforeach ($group as $gg) {\n\t\t\t$dmg = bcadd($dmg, $gg);\n\t\t}\n\t\t$j = $cnt - $k;\n\t\tif ($j>0) {\n\t\t\tsort($group);\n\t\t\twhile ($j--) {\n\t\t\t\t$dmg = bcsub($dmg, $group[$j]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t$groupSymbol = $s[$i];\n\t\t$group = [$vals[$i]];\n\t}\n}\n\necho $dmg;\n"}], "negative_code": [{"source_code": " insert($c[0]);\nfor($x = 0; $x < $a; $x++)\n{\n if($d[$x] == $d[$x + 1])\n {\n $f -> insert($c[$x + 1]);\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n $e += $f -> extract();\n if($f -> isEmpty() == TRUE)\n {\n break;\n }\n }\n $f = new SplMaxHeap();\n $f -> insert($c[$x + 1]);\n }\n}\nprint $e;\n?>"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n$vals = $ir->readArrayOfInt($n);\n$vals[] = 0;\n$s = $ir->readString() . ' ';\n\n$dmg = 0;\n\n$groupSymbol = '';\n\n$group = [];\nfor($i=0; $i<=$n; $i++) {\n\tif ($s[$i] == $groupSymbol) {\n\t\t$group[] = $vals[$i];\n\t} else {\n\t\t//var_dump($group);\n\t\t$cnt = count($group);\n\t\t$dmg += array_sum($group);\n\t\t$j = $cnt - $k;\n\t\tif ($j>0) {\n\t\t\tsort($group);\n\t\t\twhile ($j--) {\n\t\t\t\t$dmg -= $group[$j];\n\t\t\t}\n\t\t}\n\t\t\n\t\t$groupSymbol = $s[$i];\n\t\t$group = [$vals[$i]];\n\t}\n}\n\necho $dmg;\n"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n$vals = $ir->readArrayOfInt($n);\n$vals[] = 0;\n$s = $ir->readString() . ' ';\n\n$dmg = '0';\n\n$groupSymbol = '';\n\n$group = [];\nfor($i=0; $i<=$n; $i++) {\n\tif ($s[$i] == $groupSymbol) {\n\t\t$group[] = $vals[$i];\n\t} else {\n\t\t//var_dump($group);\n\t\t$cnt = count($group);\n\t\t$dmg = bcadd($dmg, array_sum($group));\n\t\t$j = $cnt - $k;\n\t\tif ($j>0) {\n\t\t\tsort($group);\n\t\t\twhile ($j--) {\n\t\t\t\t$dmg = bcsub($dmg, $group[$j]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t$groupSymbol = $s[$i];\n\t\t$group = [$vals[$i]];\n\t}\n}\n\necho $dmg;\n"}], "src_uid": "aa3b5895046ed34e89d5fcc3264b3944"} {"nl": {"description": "You are given the string s of length n and the numbers p,\u2009q. Split the string s to pieces of length p and q.For example, the string \"Hello\" for p\u2009=\u20092, q\u2009=\u20093 can be split to the two strings \"Hel\" and \"lo\" or to the two strings \"He\" and \"llo\".Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test).", "input_spec": "The first line contains three positive integers n,\u2009p,\u2009q (1\u2009\u2264\u2009p,\u2009q\u2009\u2264\u2009n\u2009\u2264\u2009100). The second line contains the string s consists of lowercase and uppercase latin letters and digits.", "output_spec": "If it's impossible to split the string s to the strings of length p and q print the only number \"-1\". Otherwise in the first line print integer k \u2014 the number of strings in partition of s. Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s \u2014 from left to right. If there are several solutions print any of them.", "sample_inputs": ["5 2 3\nHello", "10 9 5\nCodeforces", "6 4 5\nPrivet", "8 1 1\nabacabac"], "sample_outputs": ["2\nHe\nllo", "2\nCodef\norces", "-1", "8\na\nb\na\nc\na\nb\na\nc"], "notes": null}, "positive_code": [{"source_code": " $a)\n {\n break;\n }\n }\n while(TRUE)\n {\n if(($i < 0) || ($j < 0) || ($k < 0))\n { \n break;\n }\n if($i < $a)\n {\n $i += $g;\n $k++;\n }\n elseif($i == $a)\n {\n $l = 1;\n break;\n }\n elseif($i > $a)\n {\n $i -= $h;\n $j--;\n }\n }\n if($l == 0)\n {\n $g = max($b, $c);\n $h = min($b, $c);\n $i = 0;\n $j = 0;\n $k = 0;\n $l = 0;\n while(TRUE)\n {\n $i += $h;\n $j++;\n if($i > $a)\n {\n break;\n }\n }\n while(TRUE)\n {\n if(($i < 0) || ($j < 0) || ($k < 0))\n {\n break;\n }\n if($i < $a)\n {\n $i += $g;\n $k++;\n }\n elseif($i == $a)\n {\n $l = 1;\n break;\n }\n elseif($i > $a)\n {\n $i -= $h;\n $j--;\n }\n }\n if($l == 0)\n {\n print \"-1\";\n }\n else\n {\n $m = array();\n $n = 0;\n for($x = 1; $x <= $j; $x++)\n {\n $o = substr($d, $n, $h);\n $n += $h;\n array_push($m, $o);\n }\n for($x = 1; $x <= $k; $x++)\n {\n $o = substr($d, $n, $g);\n $n += $g;\n array_push($m, $o);\n }\n print count($m) . \"\\n\";\n for($x = 0; $x < count($m) - 1; $x++)\n {\n print $m[$x] . \"\\n\";\n }\n print $m[$x];\n }\n }\n else\n {\n $m = array();\n $n = 0;\n for($x = 1; $x <= $j; $x++)\n {\n $o = substr($d, $n, $h);\n $n += $h;\n array_push($m, $o);\n }\n for($x = 1; $x <= $k; $x++)\n {\n $o = substr($d, $n, $g);\n $n += $g;\n array_push($m, $o);\n }\n print count($m) . \"\\n\";\n for($x = 0; $x < count($m) - 1; $x++)\n {\n print $m[$x] . \"\\n\";\n }\n print $m[$x];\n }\n }\n}\n?>"}, {"source_code": " $a)\n {\n break;\n }\n }\n while(TRUE)\n {\n if(($i < 0) || ($j < 0) || ($k < 0))\n { \n break;\n }\n if($i < $a)\n {\n $i += $g;\n $k++;\n }\n elseif($i == $a)\n {\n $l = 1;\n break;\n }\n elseif($i > $a)\n {\n $i -= $h;\n $j--;\n }\n }\n if($l == 0)\n {\n $g = max($b, $c);\n $h = min($b, $c);\n $i = 0;\n $j = 0;\n $k = 0;\n $l = 0;\n while(TRUE)\n {\n $i += $h;\n $j++;\n if($i > $a)\n {\n break;\n }\n }\n while(TRUE)\n {\n if(($i < 0) || ($j < 0) || ($k < 0))\n {\n break;\n }\n if($i < $a)\n {\n $i += $g;\n $k++;\n }\n elseif($i == $a)\n {\n $l = 1;\n break;\n }\n elseif($i > $a)\n {\n $i -= $h;\n $j--;\n }\n }\n if($l == 0)\n {\n print \"-1\";\n }\n else\n {\n $m = array();\n $n = 0;\n for($x = 1; $x <= $j; $x++)\n {\n $o = substr($d, $n, $h);\n $n += $h;\n array_push($m, $o);\n }\n for($x = 1; $x <= $k; $x++)\n {\n $o = substr($d, $n, $g);\n $n += $g;\n array_push($m, $o);\n }\n print count($m) . \"\\n\";\n for($x = 0; $x < count($m) - 1; $x++)\n {\n print $m[$x] . \"\\n\";\n }\n print $m[$x];\n }\n }\n else\n {\n $m = array();\n $n = 0;\n for($x = 1; $x <= $j; $x++)\n {\n $o = substr($d, $n, $h);\n $n += $h;\n array_push($m, $o);\n }\n for($x = 1; $x <= $k; $x++)\n {\n $o = substr($d, $n, $g);\n $n += $g;\n array_push($m, $o);\n }\n print count($m) . \"\\n\";\n for($x = 0; $x < count($m) - 1; $x++)\n {\n print $m[$x] . \"\\n\";\n }\n print $m[$x];\n }\n }\n}\n?>"}], "negative_code": [{"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\\n\";\n echo substr($s,0,$p).\"\\n\";\n echo substr($s,$p).\"\\n\";\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1.\"\\n\";\nfor($j=1;$j<=$ans1;$j++)\n{\n echo substr($s,$c,$ans2).\"\\n\";\n $c=$c+$ans2;\n}\nif($k==0) \n echo \"-1\";\n\n\n\n?>"}, {"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\";\n echo substr($s,0,$p);\n echo substr($s,$p);\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1;\nfor($j=1;$j<=$ans1;$j++)\n{\n $c=$c+ans1;\n echo substr($s,$c,$ans2);\n}\nif($k==0) \n echo \"-1\";\n\n\n?>"}, {"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\\n\";\n echo substr($s,0,$p).\"\\n\";\n echo substr($s,$p).\"\\n\";\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1.\"\\n\";\nfor($j=1;$j<=$ans1;$j++)\n{\n echo substr($s,$c,$ans2).\"\\n\";\n $c=$c+$ans2;\n}\nif($k==0) \n echo \"-1\";\n\n\n\n?>"}, {"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\\n\";\n echo substr($s,0,$p).\"\\n\";\n echo substr($s,$p).\"\\n\";\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1.\"\\n\";\nfor($j=1;$j<=$ans1;$j++)\n{\n echo substr($s,$c,$ans2).\"\\n\";\n $c=$c+$ans2;\n}\nif($k==0) \n echo \"-1\";\n\n\n\n?>"}, {"source_code": "=1;$i--)\n{\n\tif($i*$p==$n)\n\t{\n\t\t$ans1=$i;\n\t\t$ans2=$p;\n\t\t$k=1;\n\t\t$i=0;\n\t}\n\telse if($i*$q==$n)\n\t{\n\t\t$ans1=$i;\n\t\t$ans2=$q;\n\t\t$k=1;\n\t\t$i=0;\n\t}\n\telse if($p+$q==$n)\n\t{\n\t\techo \"2\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:
\n\t\t\n\t\t$rooms = 0;\n\t\tfor($i = 0; $i < $roomsCnt; $i++){\n\t\t\tif ($living[$i] < $maxLiving[$i] - 1) $rooms++;\n\t\t}\n\t\techo $rooms;\n\t\t?>\n\t
\";\n\t\techo substr($s,0,$p).\"
\";\n\t\techo substr($s,$p).\"
\";\n\t\t$k=1;\n\t\t$i=0;\t\t\n\t}\n}\n$c=0;\necho $ans1.\"
\";\nfor($j=1;$j<=$ans1;$j++)\n{\n\t$c=$c+ans1;\n\techo substr($s,$c,$ans2).\"
\";\n}\nif($k==0)\t\n\techo \"-1\";\n\n\n?>"}, {"source_code": ""}, {"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\\n\";\n echo substr($s,0,$p).\"\\n\";\n echo substr($s,$p).\"\\n\";\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1.\"\\n\";\nfor($j=1;$j<=$ans1;$j++)\n{\n echo substr($s,($ans2*($j-1)),($ans2*$j)).\"\\n\";\n}\nif($k==0) \n echo \"-1\";\n\n\n?>"}, {"source_code": "=1;$i--)\n{\n if($i*$p==$n)\n {\n $ans1=$i;\n $ans2=$p;\n $k=1;\n $i=0;\n }\n else if($i*$q==$n)\n {\n $ans1=$i;\n $ans2=$q;\n $k=1;\n $i=0;\n }\n else if($p+$q==$n)\n {\n echo \"2\\n\";\n echo substr($s,0,$p).\"\\n\";\n echo substr($s,$p).\"\\n\";\n $k=1;\n $i=0; \n }\n}\n$c=0;\necho $ans1.\"\\n\";\nfor($j=1;$j<=$ans1;$j++)\n{\n echo substr($s,$c,$ans2).\"\\n\";\n $c=$c+$ans2;\n}\nif($k==0) \n echo \"-1\";\n\n\n\n?>"}], "src_uid": "c4da69789d875853beb4f92147825ebf"} {"nl": {"description": "Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.Help Luba to determine the minimum number of day when she finishes reading.It is guaranteed that the answer doesn't exceed n.Remember that there are 86400 seconds in a day.", "input_spec": "The first line contains two integers n and t (1\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009t\u2009\u2264\u2009106) \u2014 the number of days and the time required to read the book. The second line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u200986400) \u2014 the time Luba has to spend on her work during i-th day.", "output_spec": "Print the minimum day Luba can finish reading the book. It is guaranteed that answer doesn't exceed n.", "sample_inputs": ["2 2\n86400 86398", "2 86400\n0 86400"], "sample_outputs": ["2", "1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $time) {\n $freeTime = 86400 - $time;\n\n $timeRequired -= $freeTime;\n\n if($timeRequired <= 0) {\n echo $day + 1;\n break;\n }\n}\n"}, {"source_code": "\n"}, {"source_code": "=$requiredTime){echo$minRequiredTime;break;}\n}"}, {"source_code": "=$requiredTime){\n echo$minRequiredDay;\n break;\n }\n}"}, {"source_code": "= $requiredTime) {\n echo $minRequiredDay;\n break;\n }\n}"}, {"source_code": "=$b){echo$e;break;}}"}, {"source_code": "=$a){echo$d;break;}}"}, {"source_code": "=$b){echo$e;break;}}"}, {"source_code": ""}], "negative_code": [{"source_code": "^/XfK_'\"Fe\\~G(Kg9D!^!=b&PBR66_4WS_hc6_td>sMD/{Wx/vYy_\".gZ8Dc"}], "src_uid": "8e423e4bec2d113612a4dc445c4b86a9"} {"nl": {"description": "The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.There are $$$a$$$ programmers and $$$b$$$ mathematicians at Berland State University. How many maximum teams can be made if: each team must consist of exactly $$$4$$$ students, teams of $$$4$$$ mathematicians or $$$4$$$ programmers are unlikely to perform well, so the decision was made not to compose such teams. Thus, each team must have at least one programmer and at least one mathematician.Print the required maximum number of teams. Each person can be a member of no more than one team.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014the number of test cases. This is followed by descriptions of $$$t$$$ sets, one per line. Each set is given by two integers $$$a$$$ and $$$b$$$ ($$$0 \\le a,b \\le 10^9$$$).", "output_spec": "Print $$$t$$$ lines. Each line must contain the answer to the corresponding set of input data\u00a0\u2014 the required maximum number of teams.", "sample_inputs": ["6\n5 5\n10 1\n2 3\n0 0\n17 2\n1000000000 1000000000"], "sample_outputs": ["2\n1\n1\n0\n2\n500000000"], "notes": "NoteIn the first test case of the example, two teams can be composed. One way to compose two teams is to compose two teams of $$$2$$$ programmers and $$$2$$$ mathematicians.In the second test case of the example, only one team can be composed: $$$3$$$ programmers and $$$1$$$ mathematician in the team."}, "positive_code": [{"source_code": "= 2) {\n $m=(int)($n/2);\n if ($m >= $b) {\n $result[]=$b;\n continue;\n }\n $i+=$m;\n $b-=$m;\n $a-=$m*3;\n }\n $i += (int)(min($a,$b) / 2);\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "= 2) {\n $m=(int)($n/2);\n if ($m >= $b) {\n $result[]=$b;\n continue;\n }\n $i+=$m;\n $b-=$m;\n $a-=$m*3;\n }\n $i += (int)(min($a,$b) / 2);\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n\n\t\t \t\t\t\t \t \t \t\t\t\t \t \t\t\t \t\t"}, {"source_code": ""}, {"source_code": " 2) {\n $m=(int)($n/2);\n if ($m >= $b) {\n $result[]=$b;\n continue;\n }\n $i+=$m;\n $b-=$m;\n }\n $i += (int)($b / 2);\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": " 2) {\n $m=(int)(($n-2)/2);\n if ($m >= $b) {\n $result[]=$b;\n continue;\n }\n $i+=$m;\n $b-=$m;\n }\n $i += (int)($b / 2);\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": " 2) {\n $m=(int)(($n-2)/2);\n if ($m >= $b) {\n $result[]=$b;\n continue;\n }\n $i+=$m;\n $a-=3*$m;\n }\n $i += (int)($a / 2);\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "= 4 && min($a, $b) > 0) {\n $k=false;\n while ($a % $n === 0 && $b % $n === 0) {\n $n *= 10;\n $k=true;\n }\n if($k){\n $n = max($n / 100, 1);\n $a /= $n;\n $b /= $n;\n }\n if ($a > $b) {\n $a -= 3;\n --$b;\n } elseif ($b > $a) {\n $b -= 3;\n --$a;\n } else {\n $b -= 2;\n $a -= 2;\n }\n if (max($a, $b) < 0) {\n break;\n }\n $i+=$n;\n }\n $result[] = $i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "100000 && $b>100000) {\n $a-=100000;\n $b-=100000;\n $i+=50000;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n if ($i === 250000500) {\n $i=375000000;\n }\n if ($i === 166666833) {\n $i=333333333;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "1000 && $b>1000) {\n $a-=1000;\n $b-=1000;\n $i+=500;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n if ($i === 250000500) {\n $i=375000000;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "1000 && $b>1000) {\n $a-=1000;\n $b-=1000;\n $i+=500;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "1000 && $b>1000) {\n $a-=1000;\n $b-=1000;\n $i+=500;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);\n"}, {"source_code": "1000 && $b>1000) {\n $a-=1000;\n $b-=1000;\n $i+=500;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);"}, {"source_code": "1000 && $b>1000) {\n $a-=1000;\n $b-=1000;\n $i+=500;\n }\n while ($a + $b >= 4 && min($a,$b)>0) {\n if ($a > $b) {\n $a-=3;\n --$b;\n }elseif ($b > $a) {\n $b-=3;\n --$a;\n } else {\n $b-=2;\n $a-=2;\n }\n if (max($a,$b)<0) {\n break;\n }\n ++$i;\n }\n $result[]=$i;\n}\necho implode(\"\\n\", $result);\n"}], "src_uid": "8a1ceac1440f7cb406f12d9fc2ca0e20"} {"nl": {"description": "Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sort execution, edges appear as described in the following algorithm (pseudocode). procedure bubbleSortGraph() build a graph G with n vertices and 0 edges repeat swapped = false for i = 1 to n - 1 inclusive do: if a[i] > a[i + 1] then add an undirected edge in G between a[i] and a[i + 1] swap( a[i], a[i + 1] ) swapped = true end if end for until not swapped /* repeat the algorithm as long as swapped value is true. */ end procedureFor a graph, an independent set is a set of vertices in a graph, no two of which are adjacent (so there are no edges between vertices of an independent set). A maximum independent set is an independent set which has maximum cardinality. Given the permutation, find the size of the maximum independent set of graph G, if we use such permutation as the premutation a in procedure bubbleSortGraph.", "input_spec": "The first line of the input contains an integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009105). The next line contains n distinct integers a1, a2, ..., an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n).", "output_spec": "Output a single integer \u2014 the answer to the problem. ", "sample_inputs": ["3\n3 1 2"], "sample_outputs": ["2"], "notes": "NoteConsider the first example. Bubble sort swaps elements 3 and 1. We add edge (1, 3). Permutation is now [1, 3, 2]. Then bubble sort swaps elements 3 and 2. We add edge (2, 3). Permutation is now sorted. We have a graph with 3 vertices and 2 edges (1, 3) and (2, 3). Its maximal independent set is [1, 2]."}, "positive_code": [{"source_code": " n = $n + 10;\n $this -> count = array_fill(1, $this -> n , 0);\n }\n\n public function update($i, $val) {\n for (; $i <= $this -> n; $i += $i & -$i) $this -> count[$i] = max($this -> count[$i], $val);\n }\n \n public function get($i) {\n $max = 0;\n for (; $i > 0; $i -= $i & -$i) $max = max($max, $this -> count[$i]);\n return $max;\n }\n }\n \n $n = fgets(STDIN);\n $a = explode(\" \", trim(fgets(STDIN)));\n $fw = new Fenwick($n);\n $ans = 0;\n for ($i = 0; $i < $n; $i++) {\n $cur = $fw -> get($a[$i]) + 1;\n $fw -> update($a[$i], $cur);\n $ans = max($ans, $cur);\n }\n\n echo $ans;\n \n \n"}, {"source_code": "> 1;\n if ($dp[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n $n = fgets(STDIN);\n $a = explode(\" \", trim(fgets(STDIN)));\n $dp = array_fill(0, $n, 0);\n $dp[0] = $a[0];\n $ans = 1;\n for ($i = 1; $i < $n; $i++) {\n if ($a[$i] > $dp[$ans - 1]) $dp[$ans++] = $a[$i];\n elseif ($a[$i] < $dp[0]) $dp[0] = $a[$i];\n else $dp[lowerBound($dp, 0, $ans, $a[$i])] = $a[$i];\n }\n\n echo $ans;\n \n \n"}], "negative_code": [{"source_code": " n = $n + 10;\n $this -> count = array_fill(1, $GLOBALS['n'] , 0);\n }\n\n public function update($i, $val) {\n for (; $i <= $GLOBALS['n']; $i += $i & -$i) $GLOBALS['count'][$i] = max($GLOBALS['count'][$i], $val);\n }\n \n public function get($i) {\n $max = 0;\n for (; $i > 0; $i -= $i & -$i) $max = max($max, $GLOBALS['count'][$i]);\n return $max;\n }\n }\n \n $n = fgets(STDIN);\n $a = explode(\" \", trim(fgets(STDIN)));\n $fw = new Fenwick($n);\n $ans = 0;\n for ($i = 0; $i < $n; $i++) {\n $cur = $fw -> get($a[$i]) + 1;\n $fw -> update($a[$i], $cur);\n $ans = max($ans, $cur);\n }\n\n echo $ans;\n \n \n"}, {"source_code": " n = $n;\n $this -> count = array_fill(1, $n, 0);\n }\n\n public function update($i, $val) {\n for (; $i <= $this -> n; $i += $i & -$i) $this -> count[$i] = max($this -> count[$i], $val);\n }\n \n public function get($i) {\n $max = 0;\n for (; $i > 0; $i -= $i & -$i) $max = max($max, $this -> count[$i]);\n return $max;\n }\n }\n \n $n = fgets(STDIN);\n $a = explode(\" \", trim(fgets(STDIN)));\n $fw = new Fenwick($n);\n $ans = 0;\n for ($i = 0; $i < $n; $i++) {\n $cur = $fw -> get($a[$i]) + 1;\n $fw -> update($a[$i], $cur);\n $ans = max($ans, $cur);\n }\n\n echo $ans;\n \n \n"}, {"source_code": "> 1;\n if ($dp[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n $n = fgets(STDIN);\n $a = array_reverse(explode(\" \", trim(fgets(STDIN))));\n $dp = array_fill(0, $n, 0);\n $dp[0] = $a[0];\n $ans = 1;\n for ($i = 1; $i < $n; $i++) {\n if ($a[$i] > $dp[$ans - 1]) $dp[$ans++] = $a[$i];\n elseif ($a[$i] < $dp[0]) $dp[0] = $a[$i];\n else $dp[lowerBound($dp, 0, $ans, $a[$i])] = $a[$i];\n }\n\n echo $ans;\n \n \n"}], "src_uid": "e132767dd89801a237b998a410b22a44"} {"nl": {"description": "The elections in which three candidates participated have recently ended. The first candidate received $$$a$$$ votes, the second one received $$$b$$$ votes, the third one received $$$c$$$ votes. For each candidate, solve the following problem: how many votes should be added to this candidate so that he wins the election (i.e. the number of votes for this candidate was strictly greater than the number of votes for any other candidate)?Please note that for each candidate it is necessary to solve this problem independently, i.e. the added votes for any candidate do not affect the calculations when getting the answer for the other two candidates.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line containing three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$0 \\le a,b,c \\le 10^9$$$).", "output_spec": "For each test case, output in a separate line three integers $$$A$$$, $$$B$$$, and $$$C$$$ ($$$A, B, C \\ge 0$$$) separated by spaces \u2014 the answers to the problem for the first, second, and third candidate, respectively.", "sample_inputs": ["5\n0 0 0\n10 75 15\n13 13 17\n1000 0 0\n0 1000000000 0"], "sample_outputs": ["1 1 1\n66 0 61\n5 5 0\n0 1001 1001\n1000000001 0 1000000001"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($a,$b,$c) = IO::arr();\r\n $votes = array();\r\n if ($a == $b && $a == $c) {\r\n $votes[] = 1;\r\n $votes[] = 1;\r\n $votes[] = 1;\r\n $res[] = $votes;\r\n continue;\r\n }\r\n\r\n $max = max($a, $b);\r\n $max = max($c, $max);\r\n\r\n $fa = false;\r\n $fb = false;\r\n $fc = false;\r\n if ($a == $b || $a == $c) {\r\n $fa = true;\r\n }\r\n\r\n if ($b == $a || $b == $c) {\r\n $fb = true;\r\n }\r\n\r\n if ($c == $a || $c == $b) {\r\n $fc = true;\r\n }\r\n $win = $max + 1;\r\n\r\n if ($a == $max) {\r\n if ($fa) {\r\n $a = 1;\r\n } else {\r\n $a = 0;\r\n }\r\n } else {\r\n $a = $win - $a;\r\n }\r\n\r\n if ($b == $max) {\r\n if ($fb) {\r\n $b = 1;\r\n } else {\r\n $b = 0;\r\n }\r\n } else {\r\n $b = $win - $b;\r\n }\r\n\r\n if ($c == $max) {\r\n if ($fc) {\r\n $c = 1;\r\n } else {\r\n $c = 0;\r\n }\r\n } else {\r\n $c = $win - $c;\r\n }\r\n\r\n $votes = [$a, $b, $c];\r\n\r\n $res[] = $votes;\r\n}\r\n\r\nfunction setValue($a, $b, $c, $max) {\r\n if ($max == 0);\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $f) {\r\n echo $f . ' ';\r\n }\r\n echo PHP_EOL;\r\n}"}, {"source_code": " $sV) {\r\n if ($k == $sV) {\r\n $iCount++;\r\n }\r\n }\r\n foreach ($aArray as $sK => $sV) {\r\n if ($k == $sV) {\r\n if ($k == 0) {\r\n $aAnswer[] = 1;\r\n } else {\r\n if ($iCount > 1) {\r\n $aAnswer[] = 1;\r\n } else {\r\n $aAnswer[] = 0;\r\n }\r\n }\r\n } else {\r\n $aAnswer[] = ($k - $sV) + 1;\r\n }\r\n }\r\n echo implode(\" \", $aAnswer). \"\\n\";\r\n}"}, {"source_code": "$c) {\r\n //Each test case\r\n $result_1=[];\r\n for ($j = 0; $j < 3; $j++) {\r\n $ct=$c;unset($ct[$j]);shuffle($ct);\r\n// die(json_encode($c));\r\n $c1=$ct[0];$c2=$ct[1];$c0=$c[$j];\r\n //Retrieved $c1,$c2 and $c0 as now value\r\n $diff1=($c0>$c1)?0:($c1-$c0+1);\r\n $diff2=($c0>$c2)?0:($c2-$c0+1);\r\n $result_1[]=max($diff1,$diff2);\r\n }\r\n $results[]=$result_1;\r\n}\r\n//print_r($results);\r\nforeach ($results as $caseNo =>$r) {\r\n printf(\"%d %d %d\",$r[0],$r[1],$r[2]);\r\n if($caseNo !=($caseCount-1)){print(\"\\n\");}\r\n}"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($a,$b,$c) = IO::arr();\r\n $votes = array();\r\n if ($a == $b && $a == $c) {\r\n $votes[] = $a+1;\r\n $votes[] = $a+1;\r\n $votes[] = $a+1;\r\n $res[] = $votes;\r\n continue;\r\n }\r\n\r\n $max = max($a, $b);\r\n $max = max($c, $max);\r\n\r\n $fa = false;\r\n $fb = false;\r\n $fc = false;\r\n if ($a == $b || $a == $c) {\r\n $fa = true;\r\n }\r\n\r\n if ($b == $a || $b == $c) {\r\n $fb = true;\r\n }\r\n\r\n if ($c == $a || $c == $b) {\r\n $fc = true;\r\n }\r\n $win = $max + 1;\r\n\r\n if ($a == $max) {\r\n if ($fa) {\r\n $a = 1;\r\n } else {\r\n $a = 0;\r\n }\r\n } else {\r\n $a = $win - $a;\r\n }\r\n\r\n if ($b == $max) {\r\n if ($fb) {\r\n $b = 1;\r\n } else {\r\n $b = 0;\r\n }\r\n } else {\r\n $b = $win - $b;\r\n }\r\n\r\n if ($c == $max) {\r\n if ($fc) {\r\n $c = 1;\r\n } else {\r\n $c = 0;\r\n }\r\n } else {\r\n $c = $win - $c;\r\n }\r\n\r\n $votes = [$a, $b, $c];\r\n\r\n $res[] = $votes;\r\n}\r\n\r\nfunction setValue($a, $b, $c, $max) {\r\n if ($max == 0);\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $f) {\r\n echo $f . ' ';\r\n }\r\n echo PHP_EOL;\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($a,$b,$c) = IO::arr();\r\n $votes = array();\r\n if ($a == $b && $a == $c) {\r\n $votes[] = $a+1;\r\n $votes[] = $a+1;\r\n $votes[] = $a+1;\r\n $res[] = $votes;\r\n continue;\r\n }\r\n\r\n $max = max($a, $b);\r\n $max = max($c, $max);\r\n\r\n if ($a - $max == 0) {\r\n $votes[] = 0;\r\n $votes[] = $max - $b + 1;\r\n $votes[] = $max - $c + 1;\r\n } else if ($b - $max == 0) {\r\n $votes[] = $max - $a + 1;\r\n $votes[] = 0;\r\n $votes[] = $max - $c + 1;\r\n } else if ($c - $max == 0) {\r\n $votes[] = $max - $a + 1;\r\n $votes[] = $max - $b + 1;\r\n $votes[] = 0;\r\n }\r\n\r\n $res[] = $votes;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $f) {\r\n echo $f . ' ';\r\n }\r\n echo PHP_EOL;\r\n}"}, {"source_code": " $sV) {\r\n if ($k == $sV) {\r\n if ($k == 0) {\r\n $aAnswer[] = 1;\r\n } else {\r\n $aAnswer[] = 0;\r\n }\r\n } else {\r\n $aAnswer[] = ($k - $sV) + 1;\r\n }\r\n }\r\n echo implode(\" \", $aAnswer). \"\\n\";\r\n}"}, {"source_code": " $sV) {\r\n if ($k == $sV) {\r\n $aAnswer[] = 0;\r\n } else {\r\n $aAnswer[] = $k - $sV + 1;\r\n }\r\n }\r\n echo implode(\" \", $aAnswer). \"\\n\";\r\n }\r\n}"}, {"source_code": "$c) {\r\n //Each test case\r\n $result_1=[];\r\n for ($j = 0; $j < 3; $j++) {\r\n $ct=$c;unset($ct[$j]);shuffle($ct);\r\n// die(json_encode($c));\r\n $c1=$ct[0];$c2=$ct[1];$c0=$c[$j];\r\n //Retrieved $c1,$c2 and $c0 as now value\r\n $diff1=($c0>$c1)?0:($c1-$c0+1);\r\n $diff2=($c0>$c2)?0:($c2-$c0+1);\r\n $result_1[]=max($diff1,$diff2);\r\n }\r\n $results[]=$result_1;\r\n}\r\n//print_r($results);\r\nforeach ($results as $caseNo =>$r) {\r\n printf(\"%d %d %d\",$r[0],$r[1],$r[2]);\r\n if($caseNo !=($caseCount-1)){print(\"\\n\");}\r\n}"}], "src_uid": "f80dea1e07dba355bfbefa4ff65ff45a"} {"nl": {"description": "You are given two $$$n \\times m$$$ matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are strictly increasing. A column is strictly increasing if all numbers from top to bottom are strictly increasing. A matrix is increasing if all rows are strictly increasing and all columns are strictly increasing. For example, the matrix $$$\\begin{bmatrix} 9&10&11\\\\ 11&12&14\\\\ \\end{bmatrix}$$$ is increasing because each individual row and column is strictly increasing. On the other hand, the matrix $$$\\begin{bmatrix} 1&1\\\\ 2&3\\\\ \\end{bmatrix}$$$ is not increasing because the first row is not strictly increasing.Let a position in the $$$i$$$-th row (from top) and $$$j$$$-th column (from left) in a matrix be denoted as $$$(i, j)$$$. In one operation, you can choose any two numbers $$$i$$$ and $$$j$$$ and swap the number located in $$$(i, j)$$$ in the first matrix with the number in $$$(i, j)$$$ in the second matrix. In other words, you can swap two numbers in different matrices if they are located in the corresponding positions.You would like to make both matrices increasing by performing some number of operations (possibly none). Determine if it is possible to do this. If it is, print \"Possible\", otherwise, print \"Impossible\".", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n,m \\leq 50$$$)\u00a0\u2014 the dimensions of each matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i1}, a_{i2}, \\ldots, a_{im}$$$ ($$$1 \\leq a_{ij} \\leq 10^9$$$)\u00a0\u2014 the number located in position $$$(i, j)$$$ in the first matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$b_{i1}, b_{i2}, \\ldots, b_{im}$$$ ($$$1 \\leq b_{ij} \\leq 10^9$$$)\u00a0\u2014 the number located in position $$$(i, j)$$$ in the second matrix.", "output_spec": "Print a string \"Impossible\" or \"Possible\".", "sample_inputs": ["2 2\n2 10\n11 5\n9 4\n3 12", "2 3\n2 4 5\n4 5 6\n3 6 7\n8 10 11", "3 2\n1 3\n2 4\n5 10\n3 1\n3 6\n4 8"], "sample_outputs": ["Possible", "Possible", "Impossible"], "notes": "NoteThe first example, we can do an operation on the top left and bottom right cells of the matrices. The resulting matrices will be $$$\\begin{bmatrix} 9&10\\\\ 11&12\\\\ \\end{bmatrix}$$$ and $$$\\begin{bmatrix} 2&4\\\\ 3&5\\\\ \\end{bmatrix}$$$.In the second example, we don't need to do any operations.In the third example, no matter what we swap, we can't fix the first row to be strictly increasing in both matrices. "}, "positive_code": [{"source_code": "= $c[$x][$y + 1])\n {\n $e = 1;\n break;\n }\n }\n if($e == 1)\n {\n break;\n }\n}\nfor($x = 0; $x < $b; $x++)\n{\n for($y = 0; $y < $a - 1; $y++)\n {\n if($c[$y][$x] >= $c[$y + 1][$x])\n {\n $e = 1;\n break;\n }\n }\n if($e == 1)\n {\n break;\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n for($y = 0; $y < $b - 1; $y++)\n {\n if($d[$x][$y] >= $d[$x][$y + 1])\n {\n $e = 1;\n break;\n }\n }\n if($e == 1)\n {\n break;\n }\n}\nfor($x = 0; $x < $b; $x++)\n{\n for($y = 0; $y < $a - 1; $y++)\n {\n if($d[$y][$x] >= $d[$y + 1][$x])\n {\n $e = 1;\n break;\n }\n }\n if($e == 1)\n {\n break;\n }\n}\nif($e == 0)\n{\n print \"Possible\";\n}\nelse\n{\n print \"Impossible\";\n}\n?>"}, {"source_code": " 0 && ($a[$i][$j] <= $a[$i-1][$j] || $b[$i][$j] <= $b[$i-1][$j]))\n || ($j > 0 && ($a[$i][$j] <= $a[$i][$j-1] || $b[$i][$j] <= $b[$i][$j-1]))\n ) {\n die('Impossible');\n }\n }\n}\necho 'Possible';\n"}], "negative_code": [], "src_uid": "53e061fe3fbe3695d69854c621ab6037"} {"nl": {"description": "You still have partial information about the score during the historic football match. You are given a set of pairs $$$(a_i, b_i)$$$, indicating that at some point during the match the score was \"$$$a_i$$$: $$$b_i$$$\". It is known that if the current score is \u00ab$$$x$$$:$$$y$$$\u00bb, then after the goal it will change to \"$$$x+1$$$:$$$y$$$\" or \"$$$x$$$:$$$y+1$$$\". What is the largest number of times a draw could appear on the scoreboard?The pairs \"$$$a_i$$$:$$$b_i$$$\" are given in chronological order (time increases), but you are given score only for some moments of time. The last pair corresponds to the end of the match.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 10000$$$) \u2014 the number of known moments in the match. Each of the next $$$n$$$ lines contains integers $$$a_i$$$ and $$$b_i$$$ ($$$0 \\le a_i, b_i \\le 10^9$$$), denoting the score of the match at that moment (that is, the number of goals by the first team and the number of goals by the second team). All moments are given in chronological order, that is, sequences $$$x_i$$$ and $$$y_j$$$ are non-decreasing. The last score denotes the final result of the match.", "output_spec": "Print the maximum number of moments of time, during which the score was a draw. The starting moment of the match (with a score 0:0) is also counted.", "sample_inputs": ["3\n2 0\n3 1\n3 4", "3\n0 0\n0 0\n0 0", "1\n5 4"], "sample_outputs": ["2", "1", "5"], "notes": "NoteIn the example one of the possible score sequences leading to the maximum number of draws is as follows: 0:0, 1:0, 2:0, 2:1, 3:1, 3:2, 3:3, 3:4."}, "positive_code": [{"source_code": "= $c))\n {\n $b++;\n }\n elseif(($f == $d) && ($e < $f) && ($c >= $d))\n {\n $b++;\n }\n else\n {\n $g = min($c, $d);\n $h = min($e, $f);\n $i = max($e, $f);\n $j = max($c, $d);\n if(($i < $g) && ($j == $g) && ($h < $i))\n {\n $b += $g - $i + 1;\n }\n elseif(($i < $g) && ($j == $g))\n {\n $b += $g - $i;\n }\n elseif(($i < $g) && ($j > $g) && ($e == $f))\n {\n $b += $g - $i;\n }\n elseif(($i < $g) && ($j > $g))\n {\n $b += $g - $i + 1;\n }\n elseif(($i == $g) && ($h < $i))\n {\n $b++;\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}], "negative_code": [{"source_code": " $c))\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if(($f < $e) && ($d == $e))\n {\n $b++;\n }\n elseif(($f < $e) && ($d > $e))\n {\n $b += min($c, $d) - $f;\n }\n elseif(($f == $e) && ($d > $e))\n {\n $b += min($c, $d) - $e;\n }\n elseif($f > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c)) && ($e != $f))\n {\n if($d != $f)\n {\n $b++;\n }\n }\n }\n elseif($c > $e)\n {\n if($d == max($e, $f))\n {\n $b += $d - min($e, $f);\n }\n elseif($d > max($e, $f))\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": " $f)\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if($d == $e)\n {\n $b += $e - $f;\n }\n elseif($d > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c))\n {\n $b++;\n }\n elseif(($f == $d) && ($e < $f) && ($c >= $d))\n {\n $b++;\n }\n else\n {\n $g = min($c, $d);\n $h = min($e, $f);\n $i = max($e, $f);\n if($i < $g)\n {\n $b += $g - $h;\n }\n elseif(($i == $g) && ($h < $i))\n {\n $b++;\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= max($e, $f))\n {\n $b += max($e, $f) - min($c, $d) + 1;\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c))\n {\n if($d != $f)\n {\n $b++;\n }\n }\n }\n elseif($c > $e)\n {\n if($d == max($e, $f))\n {\n $b += $d - min($e, $f);\n }\n elseif($d > max($e, $f))\n {\n $b += min($c, $d) - max($c, $d);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": " $c))\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if($d == $e)\n {\n $b += $e - $f;\n }\n elseif($d > $e)\n {\n $b += min($c, $d) - max($e, $f) + 1;\n if((max($e, $f) == 0) || ($e == $f))\n {\n $b--;\n }\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": " $c))\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if(($f < $e) && ($d == $e))\n {\n $b++;\n }\n elseif(($f < $e) && ($d > $e))\n {\n $b += min($c, $d) - $e;\n }\n elseif(($f == $e) && ($d > $e))\n {\n $b += min($c, $d) - $e;\n }\n elseif($f > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c))\n {\n if(($c != $e) && ($d != $f))\n {\n $b++;\n }\n }\n }\n elseif($c > $e)\n {\n if($d == max($e, $f))\n {\n $b += $d - min($e, $f);\n }\n elseif($d > max($e, $f))\n {\n $b += min($c, $d) - max($c, $d);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": " $c))\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if($d == $e)\n {\n $b += $e - $f;\n }\n elseif($d > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c)) && ($e != $f))\n {\n if($d != $f)\n {\n $b++;\n }\n }\n }\n elseif($c > $e)\n {\n if($d == max($e, $f))\n {\n $b += $d - min($e, $f);\n }\n elseif($d > max($e, $f))\n {\n if($e == $f)\n {\n $b += min($c, $d) - max($e, $f);\n }\n else\n {\n $b += min($c, $d) - max($e, $f) + 1;\n }\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c))\n {\n $b++;\n }\n }\n elseif($c > $e)\n {\n if(($f < $e) && ($d == $e))\n {\n $b++;\n }\n elseif(($f < $e) && ($d > $e))\n {\n $b += min($c, $d) - $f;\n }\n elseif(($f == $e) && ($d > $e))\n {\n $b += min($c, $d) - $e;\n }\n elseif(($f > $e) && ($f == $d) && ($c >= $d))\n {\n $b++;\n }\n elseif(($f > $e) && ($d >= $c))\n {\n $b += max(0, min($c, $d) - max($e, $f) + 1);\n }\n elseif($f > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": " $e)\n {\n if($d == $e)\n {\n $b += $e - $f;\n }\n elseif($d > $e)\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= max($e, $f)) && (($c != $e) && ($d != $f)))\n {\n $b += max($e, $f) - min($c, $d) + 1;\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}, {"source_code": "= $c))\n {\n if($d != $f)\n {\n $b++;\n }\n }\n }\n elseif($c > $e)\n {\n if($d == max($e, $f))\n {\n $b += $d - min($e, $f);\n }\n elseif($d > max($e, $f))\n {\n $b += min($c, $d) - min($e, $f);\n }\n }\n }\n $e = $c;\n $f = $d;\n}\nprint $b;\n?>"}], "src_uid": "5b84295330fa07a9b42570766012990b"} {"nl": {"description": "You are given a system of pipes. It consists of two rows, each row consists of $$$n$$$ pipes. The top left pipe has the coordinates $$$(1, 1)$$$ and the bottom right \u2014 $$$(2, n)$$$.There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types: Types of pipes You can turn each of the given pipes $$$90$$$ degrees clockwise or counterclockwise arbitrary (possibly, zero) number of times (so the types $$$1$$$ and $$$2$$$ can become each other and types $$$3, 4, 5, 6$$$ can become each other).You want to turn some pipes in a way that the water flow can start at $$$(1, 0)$$$ (to the left of the top left pipe), move to the pipe at $$$(1, 1)$$$, flow somehow by connected pipes to the pipe at $$$(2, n)$$$ and flow right to $$$(2, n + 1)$$$.Pipes are connected if they are adjacent in the system and their ends are connected. Here are examples of connected pipes: Examples of connected pipes Let's describe the problem using some example: The first example input And its solution is below: The first example answer As you can see, the water flow is the poorly drawn blue line. To obtain the answer, we need to turn the pipe at $$$(1, 2)$$$ $$$90$$$ degrees clockwise, the pipe at $$$(2, 3)$$$ $$$90$$$ degrees, the pipe at $$$(1, 6)$$$ $$$90$$$ degrees, the pipe at $$$(1, 7)$$$ $$$180$$$ degrees and the pipe at $$$(2, 7)$$$ $$$180$$$ degrees. Then the flow of water can reach $$$(2, n + 1)$$$ from $$$(1, 0)$$$.You have to answer $$$q$$$ independent queries.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 10^4$$$) \u2014 the number of queries. Then $$$q$$$ queries follow. Each query consists of exactly three lines. The first line of the query contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of pipes in each row. The next two lines contain a description of the first and the second rows correspondingly. Each row description consists of $$$n$$$ digits from $$$1$$$ to $$$6$$$ without any whitespaces between them, each digit corresponds to the type of pipe in the corresponding cell. See the problem statement to understand which digits correspond to which types of pipes. It is guaranteed that the sum of $$$n$$$ over all queries does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For the $$$i$$$-th query print the answer for it \u2014 \"YES\" (without quotes) if it is possible to turn some pipes in a way that the water flow can reach $$$(2, n + 1)$$$ from $$$(1, 0)$$$, and \"NO\" otherwise.", "sample_inputs": ["6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54"], "sample_outputs": ["YES\nYES\nYES\nNO\nYES\nNO"], "notes": "NoteThe first query from the example is described in the problem statement."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "f34cff4302e047b1e3bfc2c79aa57be3"} {"nl": {"description": "Lunar New Year is approaching, and you bought a matrix with lots of \"crosses\".This matrix $$$M$$$ of size $$$n \\times n$$$ contains only 'X' and '.' (without quotes). The element in the $$$i$$$-th row and the $$$j$$$-th column $$$(i, j)$$$ is defined as $$$M(i, j)$$$, where $$$1 \\leq i, j \\leq n$$$. We define a cross appearing in the $$$i$$$-th row and the $$$j$$$-th column ($$$1 < i, j < n$$$) if and only if $$$M(i, j) = M(i - 1, j - 1) = M(i - 1, j + 1) = M(i + 1, j - 1) = M(i + 1, j + 1) = $$$ 'X'.The following figure illustrates a cross appearing at position $$$(2, 2)$$$ in a $$$3 \\times 3$$$ matrix. X.X.X.X.X Your task is to find out the number of crosses in the given matrix $$$M$$$. Two crosses are different if and only if they appear in different rows or columns.", "input_spec": "The first line contains only one positive integer $$$n$$$ ($$$1 \\leq n \\leq 500$$$), denoting the size of the matrix $$$M$$$. The following $$$n$$$ lines illustrate the matrix $$$M$$$. Each line contains exactly $$$n$$$ characters, each of them is 'X' or '.'. The $$$j$$$-th element in the $$$i$$$-th line represents $$$M(i, j)$$$, where $$$1 \\leq i, j \\leq n$$$.", "output_spec": "Output a single line containing only one integer number $$$k$$$ \u2014 the number of crosses in the given matrix $$$M$$$.", "sample_inputs": ["5\n.....\n.XXX.\n.XXX.\n.XXX.\n.....", "2\nXX\nXX", "6\n......\nX.X.X.\n.X.X.X\nX.X.X.\n.X.X.X\n......"], "sample_outputs": ["1", "0", "4"], "notes": "NoteIn the first sample, a cross appears at $$$(3, 3)$$$, so the answer is $$$1$$$.In the second sample, no crosses appear since $$$n < 3$$$, so the answer is $$$0$$$.In the third sample, crosses appear at $$$(3, 2)$$$, $$$(3, 4)$$$, $$$(4, 3)$$$, $$$(4, 5)$$$, so the answer is $$$4$$$."}, "positive_code": [{"source_code": ""}, {"source_code": "\n\n$n = trim(fgets(STDIN));\n$arr = [];\nfor($i=0;$i<$n;$i++){\n\t$arr[$i]=str_split(trim(fgets(STDIN)));\n}\n$cnt = 0;\n\n\n\nfor($i=0;$i<$n;$i++){\n\tfor($j=0;$j<$n;$j++){\n\t\tif($arr[$i][$j]==\"X\"&&$i!=0&&$j!=0&&$i!=$n-1&&$j!=$n-1){\n\t\t\t\n\t\t\tif($arr[$i-1][$j-1]==\"X\"&&$arr[$i-1][$j+1]==\"X\"&&$arr[$i+1][$j-1]==\"X\"&$arr[$i+1][$j+1]==\"X\"){\n\t\t\t\t$cnt++;\n\t\t\t}\n\t\t}\n\t}\n}\n\necho $cnt;\n"}], "negative_code": [], "src_uid": "3270260030fc56dda3e375af4dad9330"} {"nl": {"description": "\u041d\u0435\u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 \u0432 \u043a\u0443\u043f\u043e\u043b\u0435 \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0433\u043e \u0414\u043e\u043c\u0430 \u0417\u0438\u043d\u0433\u0435\u0440\u0430, \u0433\u0434\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u0448\u0442\u0430\u0431-\u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0446\u0432\u0435\u0442\u043e\u043c \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0447\u0430\u0442 \u00ab\u0417\u0438\u043d\u0433\u0435\u0440 | color\u00bb, \u0430 \u0431\u043e\u0442 \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0438 \u0441\u043c\u0435\u043d\u0438\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u0445 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439 \u0441\u043c\u0435\u043d\u0430 \u0446\u0432\u0435\u0442\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f.\u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0431\u043e\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439: lock: \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d\u043e \u0438 \u0442\u0430\u043a \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f. unlock: \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d\u043e \u0438 \u0442\u0430\u043a \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f. red / orange / yellow / green / blue / indigo / violet: \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439, \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e. \u0412\u0430\u043c \u0434\u0430\u043d\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0431\u043e\u0442\u043e\u043c, \u0432 \u0445\u0440\u043e\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0421\u0447\u0438\u0442\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u043f\u043e\u043b \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u043e\u043b\u0443\u0431\u044b\u043c (blue), \u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u043d\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e.\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u0446\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443 \u043a\u0443\u043f\u043e\u043b\u0430 \u0414\u043e\u043c\u0430 \u0417\u0438\u043d\u0433\u0435\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.", "input_spec": "\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $$$n$$$ ($$$1 \\le n \\le 100$$$)\u00a0\u2014 \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0431\u043e\u0442\u043e\u043c. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 $$$n$$$ \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0431\u043e\u0442\u043e\u043c, \u0432 \u0445\u0440\u043e\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u00a0\u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430: lock, unlock, red, orange, yellow, green, blue, indigo, violet.", "output_spec": "\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0446\u0432\u0435\u0442 \u043a\u0443\u043f\u043e\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0431\u043e\u0442\u043e\u043c.", "sample_inputs": ["7\nred\nviolet\nunlock\nred\norange\nlock\nindigo", "5\nlock\nunlock\nlock\nunlock\nunlock"], "sample_outputs": ["orange", "blue"], "notes": null}, "positive_code": [{"source_code": "\n"}, {"source_code": "handleCommand($command);\r\n}\r\n\r\necho $zingerTower->getColor();\r\n\r\nclass Zinger\r\n{\r\n const LOCK_COMMAND = 'lock';\r\n const UNLOCK_COMMAND = 'unlock';\r\n static $colorCommands = [\r\n 'red',\r\n 'orange',\r\n 'yellow',\r\n 'green',\r\n 'blue',\r\n 'indigo',\r\n 'violet',\r\n ];\r\n\r\n private $isLocked = false;\r\n private $color = 'blue';\r\n\r\n public function handleCommand(string $command): void\r\n {\r\n switch ($command) {\r\n case self::LOCK_COMMAND: $this->lock(); break;\r\n case self::UNLOCK_COMMAND: $this->unlock(); break;\r\n case in_array($command, self::$colorCommands): $this->changeColor($command);break;\r\n default: echo 'command undefined';\r\n }\r\n }\r\n\r\n public function getColor(): string\r\n {\r\n return $this->color;\r\n }\r\n\r\n private function lock(): void\r\n {\r\n if ($this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->isLocked = true;\r\n }\r\n\r\n private function unlock(): void\r\n {\r\n if (!$this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->isLocked = false;\r\n }\r\n\r\n private function changeColor(string $color): void\r\n {\r\n if ($this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->color = $color;\r\n }\r\n}\r\n\r\nfunction readInput()\r\n{\r\n $commandsCount = trim(fgets(STDIN));\r\n if (empty($commandsCount)) {\r\n return [];\r\n }\r\n\r\n $result = [];\r\n\r\n for ($i = 0; $i < $commandsCount; $i++) {\r\n $result[] = trim(fgets(STDIN));\r\n }\r\n\r\n return $result;\r\n}\r\n"}, {"source_code": " 100){\r\n echo $lastColor; \r\n }else{\r\n \r\n foreach ($actions as $i => $action){\r\n \r\n if($i==0) continue;\r\n \r\n\t if($action == 'lock'){\r\n\t $lock = true;\r\n\t }\r\n\t if($action == 'unlock'){\r\n\t $lock = false;\r\n\t }\r\n\t if($action != 'unlock' && $action != 'lock' && !$lock){\r\n\t $lastColor = $action;\r\n\t }\r\n\t \r\n }\r\n \r\n echo $lastColor; \r\n }\r\n?>"}], "negative_code": [{"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "handleCommand($command);\r\n}\r\n\r\necho $zingerTower->getColor();\r\n\r\nclass Zinger\r\n{\r\n const LOCK_COMMAND = 'lock';\r\n const UNLOCK_COMMAND = 'unlock';\r\n static $colorCommands = [\r\n 'red',\r\n 'orange',\r\n 'yellow',\r\n 'green',\r\n 'blue',\r\n 'indigo',\r\n 'violet',\r\n ];\r\n\r\n private $isLocked = false;\r\n private $color = 'blue';\r\n\r\n public function handleCommand(string $command): void\r\n {\r\n switch ($command) {\r\n case self::LOCK_COMMAND: $this->lock(); break;\r\n case self::UNLOCK_COMMAND: $this->unlock(); break;\r\n case in_array($command, self::$colorCommands): $this->changeColor($command);break;\r\n default: echo 'command undefined';\r\n }\r\n }\r\n\r\n public function getColor(): string\r\n {\r\n return $this->color;\r\n }\r\n\r\n private function lock(): void\r\n {\r\n if ($this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->isLocked = true;\r\n }\r\n\r\n private function unlock(): void\r\n {\r\n if (!$this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->isLocked = true;\r\n }\r\n\r\n private function changeColor(string $color): void\r\n {\r\n if ($this->isLocked) {\r\n return;\r\n }\r\n\r\n $this->color = $color;\r\n }\r\n}\r\n\r\nfunction readInput()\r\n{\r\n $commandsCount = trim(fgets(STDIN));\r\n if (empty($commandsCount)) {\r\n return [];\r\n }\r\n\r\n $result = [];\r\n\r\n for ($i = 0; $i < $commandsCount; $i++) {\r\n $result[] = trim(fgets(STDIN));\r\n }\r\n\r\n return $result;\r\n}\r\n"}], "src_uid": "6215233349b0f682a238a476e9153ac4"} {"nl": {"description": "The Squareland national forest is divided into equal $$$1 \\times 1$$$ square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates $$$(x, y)$$$ of its south-west corner.Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land $$$A, B, C$$$ in the forest. Initially, all plots in the forest (including the plots $$$A, B, C$$$) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots $$$A, B, C$$$ from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side. For example, $$$A=(0,0)$$$, $$$B=(1,1)$$$, $$$C=(2,2)$$$. The minimal number of plots to be cleared is $$$5$$$. One of the ways to do it is shown with the gray color. Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.", "input_spec": "The first line contains two integers $$$x_A$$$ and $$$y_A$$$\u00a0\u2014 coordinates of the plot $$$A$$$ ($$$0 \\leq x_A, y_A \\leq 1000$$$). The following two lines describe coordinates $$$(x_B, y_B)$$$ and $$$(x_C, y_C)$$$ of plots $$$B$$$ and $$$C$$$ respectively in the same format ($$$0 \\leq x_B, y_B, x_C, y_C \\leq 1000$$$). It is guaranteed that all three plots are distinct.", "output_spec": "On the first line print a single integer $$$k$$$\u00a0\u2014 the smallest number of plots needed to be cleaned from trees. The following $$$k$$$ lines should contain coordinates of all plots needed to be cleaned. All $$$k$$$ plots should be distinct. You can output the plots in any order. If there are multiple solutions, print any of them.", "sample_inputs": ["0 0\n1 1\n2 2", "0 0\n2 0\n1 1"], "sample_outputs": ["5\n0 0\n1 0\n1 1\n1 2\n2 2", "4\n0 0\n1 0\n1 1\n2 0"], "notes": "NoteThe first example is shown on the picture in the legend.The second example is illustrated with the following image: "}, "positive_code": [{"source_code": ""}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($xa, $ya) = $ir->readArrayOfInt(2);\nlist($xb, $yb) = $ir->readArrayOfInt(2);\nlist($xc, $yc) = $ir->readArrayOfInt(2);\n\n$xs = [$xa, $xb, $xc]; \n$ys = [$ya, $yb, $yc]; \nsort($ys);\nsort($xs);\n\n$ymid = $ys[1];\n\n$trace = [];\nfor ($i=$xs[0]; $i<=$xs[2]; $i++) {\n\t$trace[$i.\" \".$ys[1]] = true;\n}\n\nfor ($i=min([$ya,$ys[1]]); $i<=max([$ya,$ys[1]]); $i++) {\n\t$trace[$xa.\" \".$i] = true;\n}\n\nfor ($i=min([$yb,$ys[1]]); $i<=max([$yb,$ys[1]]); $i++) {\n\t$trace[$xb.\" \".$i] = true;\n}\n\nfor ($i=min([$yc,$ys[1]]); $i<=max([$yc,$ys[1]]); $i++) {\n\t$trace[$xc.\" \".$i] = true;\n}\n\necho count($trace).\"\\n\";\nforeach ($trace as $k=>$v) {\n\techo $k.\"\\n\";\n}\n"}], "negative_code": [{"source_code": ""}], "src_uid": "1a358e492dfd7e226138ea64e432c180"} {"nl": {"description": "The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of $$$n$$$ haybale piles on the farm. The $$$i$$$-th pile contains $$$a_i$$$ haybales. However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move one haybale in any pile to an adjacent pile. Formally, in one day she can choose any two indices $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) such that $$$|i-j|=1$$$ and $$$a_i>0$$$ and apply $$$a_i = a_i - 1$$$, $$$a_j = a_j + 1$$$. She may also decide to not do anything on some days because she is lazy.Bessie wants to maximize the number of haybales in pile $$$1$$$ (i.e. to maximize $$$a_1$$$), and she only has $$$d$$$ days to do so before Farmer John returns. Help her find the maximum number of haybales that may be in pile $$$1$$$ if she acts optimally!", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u00a0\u2014 the number of test cases. Next $$$2t$$$ lines contain a description of test cases \u00a0\u2014 two lines per test case. The first line of each test case contains integers $$$n$$$ and $$$d$$$ ($$$1 \\le n,d \\le 100$$$) \u2014 the number of haybale piles and the number of days, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\le a_i \\le 100$$$) \u00a0\u2014 the number of haybales in each pile.", "output_spec": "For each test case, output one integer: the maximum number of haybales that may be in pile $$$1$$$ after $$$d$$$ days if Bessie acts optimally.", "sample_inputs": ["3\n4 5\n1 0 3 2\n2 2\n100 1\n1 8\n0"], "sample_outputs": ["3\n101\n0"], "notes": "NoteIn the first test case of the sample, this is one possible way Bessie can end up with $$$3$$$ haybales in pile $$$1$$$: On day one, move a haybale from pile $$$3$$$ to pile $$$2$$$ On day two, move a haybale from pile $$$3$$$ to pile $$$2$$$ On day three, move a haybale from pile $$$2$$$ to pile $$$1$$$ On day four, move a haybale from pile $$$2$$$ to pile $$$1$$$ On day five, do nothing In the second test case of the sample, Bessie can do nothing on the first day and move a haybale from pile $$$2$$$ to pile $$$1$$$ on the second day."}, "positive_code": [{"source_code": " 0)\n {\n $e++;\n $c -= $y;\n $d[$y]--;\n if($c < 0)\n {\n $e--;\n break;\n }\n elseif($c == 0)\n {\n break;\n }\n }\n else\n {\n break;\n }\n }\n if($c <= 0)\n {\n break;\n }\n }\n print $e . \"\\n\";\n}\n?>"}, {"source_code": " floor($b/($i))) {\n $iCount = floor($b/($i));\n } else {\n $iCount = $aArray[$i];\n }\n $iAnswer += $iCount;\n $b = $b - $iCount * $i;\n }\n $iAnswer += $aArray[0];\n echo $iAnswer . \"\\n\";\n}"}, {"source_code": " 0) {\n $ar[$t+1] -=1;\n $ar[$t] +=1;\n break;\n } \n } \n echo $ar[0] . \"\\n\";\n }\n \n }\n \n\n "}, {"source_code": "= $i){\n $d -= $i;\n $arr[$i]--;\n $arr[0]++;\n } \n else{\n print($arr[0]);\n echo \"\\n\";\n return;\n } \n\n } \n } \n\n print($arr[0]);\n echo \"\\n\";\n return;\n\n}"}, {"source_code": " $v){\n for($i = 1; $i <= $v && $boo; $i++){\n if($c >= $k){\n $d++;\n $c-= $k;\n } else {\n $boo = false;\n }\n }\n if(!$boo){\n break;\n }\n }\n \n echo $d.\"\\n\";\n}\n "}], "negative_code": [{"source_code": "= $i) {\n $iCount += $i;\n }\n }\n echo $iCount + $aArray[0] . \"\\n\";\n}"}], "src_uid": "7bbb4b9f5eccfe13741445c815a4b1ca"} {"nl": {"description": "Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindrome numbers. Pari loves integers with even length (i.e. the numbers with even number of digits), so she tries to see a lot of big palindrome numbers with even length (like a 2-digit 11 or 6-digit 122221), so maybe she could see something in them.Now Pari asks you to write a program that gets a huge integer n from the input and tells what is the n-th even-length positive palindrome number?", "input_spec": "The only line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u200910100\u2009000).", "output_spec": "Print the n-th even-length palindrome number.", "sample_inputs": ["1", "10"], "sample_outputs": ["11", "1001"], "notes": "NoteThe first 10 even-length palindrome numbers are 11,\u200922,\u200933,\u2009... ,\u200988,\u200999 and 1001."}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "bcf75978c9ef6202293773cf533afadf"} {"nl": {"description": "A ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note that a ticket can have leading zeroes.", "input_spec": "The first line of the input contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^3$$$)\u00a0\u2014 the number of testcases. The description of each test consists of one line containing one string consisting of six digits.", "output_spec": "Output $$$t$$$ lines, each of which contains the answer to the corresponding test case. Output \"YES\" if the given ticket is lucky, and \"NO\" otherwise. You can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).", "sample_inputs": ["5\n213132\n973894\n045207\n000000\n055776"], "sample_outputs": ["YES\nNO\nYES\nYES\nNO"], "notes": "NoteIn the first test case, the sum of the first three digits is $$$2 + 1 + 3 = 6$$$ and the sum of the last three digits is $$$1 + 3 + 2 = 6$$$, they are equal so the answer is \"YES\".In the second test case, the sum of the first three digits is $$$9 + 7 + 3 = 19$$$ and the sum of the last three digits is $$$8 + 9 + 4 = 21$$$, they are not equal so the answer is \"NO\".In the third test case, the sum of the first three digits is $$$0 + 4 + 5 = 9$$$ and the sum of the last three digits is $$$2 + 0 + 7 = 9$$$, they are equal so the answer is \"YES\"."}, "positive_code": [{"source_code": " 1) {\r\n $tamanho = 0;\r\n $soma_esquerda = 0;\r\n $soma_direita = 0;\r\n while ($tamanho < 6) {\r\n if ($tamanho < 3) {\r\n $soma_esquerda += $linha[$tamanho];\r\n } else {\r\n $soma_direita += $linha[$tamanho];\r\n }\r\n $tamanho++;\r\n }\r\n\r\n if ($soma_esquerda == $soma_direita) {\r\n echo \"YES\\n\";\r\n } else {\r\n echo \"NO\\n\";\r\n }\r\n }\r\n $primeira++;\r\n}\r\n"}, {"source_code": ""}, {"source_code": " 0; $i--) {\r\n $str = readline();\r\n if ($str[0] + $str[1] + $str[2] == $str[3] + $str[4] + $str[5]) {\r\n echo 'YES' . \"\\n\";\r\n } else {\r\n echo 'NO' . \"\\n\";\r\n }\r\n\r\n\r\n}\r\n\r\n?>"}, {"source_code": ""}, {"source_code": " $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }"}], "negative_code": [{"source_code": " 1) {\r\n $tamanho = 0;\r\n $soma_esquerda = 0;\r\n $soma_direita = 0;\r\n while ($tamanho < 6) {\r\n if ($tamanho < 3) {\r\n $soma_esquerda += $linha[$tamanho];\r\n } else {\r\n $soma_direita += $linha[$tamanho];\r\n }\r\n $tamanho++;\r\n }\r\n\r\n if ($soma_esquerda == $soma_direita) {\r\n echo \"YES\\n\";\r\n } else {\r\n echo \"NO\\n\";\r\n }\r\n }\r\n $primeira++;\r\n}\r\n"}, {"source_code": " 1) {\r\n $linha = fgets($input);\r\n $tamanho = 0;\r\n $soma_esquerda = 0;\r\n $soma_direita = 0;\r\n while ($tamanho < 6) {\r\n if ($tamanho < 3) {\r\n $soma_esquerda += $linha[$tamanho];\r\n } else {\r\n $soma_direita += $linha[$tamanho];\r\n }\r\n $tamanho++;\r\n }\r\n\r\n if ($soma_esquerda == $soma_direita) {\r\n echo \"YES\\n\";\r\n } else {\r\n echo \"NO\\n\";\r\n }\r\n }\r\n $primeira++;\r\n}\r\n"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "c7a5b4a015e28dd3759569bbdc130e93"} {"nl": {"description": "Dima worked all day and wrote down on a long paper strip his favorite number $$$n$$$ consisting of $$$l$$$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive integer without leading zeros. After that he will compute the sum of the two integers and write it down on a new strip.Dima wants the resulting integer to be as small as possible, because it increases the chances that the sum will fit it in the bookshelf. Help Dima decide what is the minimum sum he can obtain.", "input_spec": "The first line contains a single integer $$$l$$$ ($$$2 \\le l \\le 100\\,000$$$)\u00a0\u2014 the length of the Dima's favorite number. The second line contains the positive integer $$$n$$$ initially written on the strip: the Dima's favorite number. The integer $$$n$$$ consists of exactly $$$l$$$ digits and it does not contain leading zeros. Dima guarantees, that there is at least one valid way to split the strip.", "output_spec": "Print a single integer\u00a0\u2014 the smallest number Dima can obtain.", "sample_inputs": ["7\n1234567", "3\n101"], "sample_outputs": ["1801", "11"], "notes": "NoteIn the first example Dima can split the number $$$1234567$$$ into integers $$$1234$$$ and $$$567$$$. Their sum is $$$1801$$$.In the second example Dima can split the number $$$101$$$ into integers $$$10$$$ and $$$1$$$. Their sum is $$$11$$$. Note that it is impossible to split the strip into \"1\" and \"01\" since the numbers can't start with zeros."}, "positive_code": [{"source_code": " $m) {\n $min = $m;\n }\n }\n $lt .= $d[$i];\n}\necho $min;\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "6d5ecac49fe1320eef1391b6d5cf5f0d"} {"nl": {"description": "The Department of economic development of IT City created a model of city development till year 2100.To prepare report about growth perspectives it is required to get growth estimates from the model.To get the growth estimates it is required to solve a quadratic equation. Since the Department of economic development of IT City creates realistic models only, that quadratic equation has a solution, moreover there are exactly two different real roots.The greater of these roots corresponds to the optimistic scenario, the smaller one corresponds to the pessimistic one. Help to get these estimates, first the optimistic, then the pessimistic one.", "input_spec": "The only line of the input contains three integers a,\u2009b,\u2009c (\u2009-\u20091000\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u20091000) \u2014 the coefficients of ax2\u2009+\u2009bx\u2009+\u2009c\u2009=\u20090 equation.", "output_spec": "In the first line output the greater of the equation roots, in the second line output the smaller one. Absolute or relative error should not be greater than 10\u2009-\u20096.", "sample_inputs": ["1 30 200"], "sample_outputs": ["-10.000000000000000\n-20.000000000000000"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "2d4ad39d42b349765435b351897403da"} {"nl": {"description": "You are given $$$n$$$ chips on a number line. The $$$i$$$-th chip is placed at the integer coordinate $$$x_i$$$. Some chips can have equal coordinates.You can perform each of the two following types of moves any (possibly, zero) number of times on any chip: Move the chip $$$i$$$ by $$$2$$$ to the left or $$$2$$$ to the right for free (i.e. replace the current coordinate $$$x_i$$$ with $$$x_i - 2$$$ or with $$$x_i + 2$$$); move the chip $$$i$$$ by $$$1$$$ to the left or $$$1$$$ to the right and pay one coin for this move (i.e. replace the current coordinate $$$x_i$$$ with $$$x_i - 1$$$ or with $$$x_i + 1$$$). Note that it's allowed to move chips to any integer coordinate, including negative and zero.Your task is to find the minimum total number of coins required to move all $$$n$$$ chips to the same coordinate (i.e. all $$$x_i$$$ should be equal after some sequence of moves).", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the number of chips. The second line of the input contains $$$n$$$ integers $$$x_1, x_2, \\dots, x_n$$$ ($$$1 \\le x_i \\le 10^9$$$), where $$$x_i$$$ is the coordinate of the $$$i$$$-th chip.", "output_spec": "Print one integer \u2014 the minimum total number of coins required to move all $$$n$$$ chips to the same coordinate.", "sample_inputs": ["3\n1 2 3", "5\n2 2 2 3 3"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first example you need to move the first chip by $$$2$$$ to the right and the second chip by $$$1$$$ to the right or move the third chip by $$$2$$$ to the left and the second chip by $$$1$$$ to the left so the answer is $$$1$$$.In the second example you need to move two chips with coordinate $$$3$$$ by $$$1$$$ to the left so the answer is $$$2$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n"}], "negative_code": [{"source_code": ""}, {"source_code": "// I am Varun Das from Jadavpur University\n#include\n#pragma GCC target (\"avx2\")\n#pragma GCC optimization (\"O3\")\n#pragma GCC optimization (\"unroll-loops\")\n#define mod 1000000007\n#define ll long long\n#define dbg(x) cerr << #x << \" = \" << x << endl\n#define INF LLONG_MAX\n#define loop(i,a,b) for(int i=a;i=b;i--)\n#define nax 503405\nusing namespace std;\n\nint main() {\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n//\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\nios_base::sync_with_stdio(false);\ncin.tie(NULL);\n//cout< >n;\nll k,s=0;\nloop(i,0,n) cin>>k,s+=k%2;\ncout< = $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n , $k) = IO::arr();\r\n $a = IO::arr();\r\n $b = [];\r\n $c = [];\r\n $res = [];\r\n $tp = 0;\r\n foreach ($a as $ind => $v) {\r\n if (isset($b[$v])) {\r\n $b[$v] += 1;\r\n $c[$v][] = $ind;\r\n } else {\r\n $b[$v] = 1;\r\n $c[$v] = [$ind];\r\n }\r\n if ($b[$v] == $k) {\r\n $tp += $k;\r\n }\r\n if ($b[$v] > $k) {\r\n $tp++;\r\n }\r\n $res[] = 0;\r\n }\r\n $x = floor(($n - $tp) / $k);\r\n $count = 1;\r\n $cycle = 0;\r\n foreach ($c as $v => $aV) {\r\n if ($b[$v] >= $k) {\r\n for ($i = 1; $i <= $k; $i++) {\r\n $res[$aV[$i - 1]] = $i;\r\n }\r\n } else {\r\n foreach ($aV as $item) {\r\n if ($cycle < $x) {\r\n $res[$item] = $count;\r\n $count++;\r\n }\r\n if ($count > $k) {\r\n $count = 1;\r\n $cycle++;\r\n }\r\n if ($cycle >= $x) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n IO::line(implode(' ', $res));\r\n}\r\n\r\n\r\n?>"}], "negative_code": [], "src_uid": "98aca7d5bf74c7787bf2159770054297"} {"nl": {"description": "Lunar New Year is approaching, and Bob is planning to go for a famous restaurant \u2014 \"Alice's\".The restaurant \"Alice's\" serves $$$n$$$ kinds of food. The cost for the $$$i$$$-th kind is always $$$c_i$$$. Initially, the restaurant has enough ingredients for serving exactly $$$a_i$$$ dishes of the $$$i$$$-th kind. In the New Year's Eve, $$$m$$$ customers will visit Alice's one after another and the $$$j$$$-th customer will order $$$d_j$$$ dishes of the $$$t_j$$$-th kind of food. The $$$(i + 1)$$$-st customer will only come after the $$$i$$$-th customer is completely served.Suppose there are $$$r_i$$$ dishes of the $$$i$$$-th kind remaining (initially $$$r_i = a_i$$$). When a customer orders $$$1$$$ dish of the $$$i$$$-th kind, the following principles will be processed. If $$$r_i > 0$$$, the customer will be served exactly $$$1$$$ dish of the $$$i$$$-th kind. The cost for the dish is $$$c_i$$$. Meanwhile, $$$r_i$$$ will be reduced by $$$1$$$. Otherwise, the customer will be served $$$1$$$ dish of the cheapest available kind of food if there are any. If there are multiple cheapest kinds of food, the one with the smallest index among the cheapest will be served. The cost will be the cost for the dish served and the remain for the corresponding dish will be reduced by $$$1$$$. If there are no more dishes at all, the customer will leave angrily. Therefore, no matter how many dishes are served previously, the cost for the customer is $$$0$$$.If the customer doesn't leave after the $$$d_j$$$ dishes are served, the cost for the customer will be the sum of the cost for these $$$d_j$$$ dishes.Please determine the total cost for each of the $$$m$$$ customers.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n, m \\leq 10^5$$$), representing the number of different kinds of food and the number of customers, respectively. The second line contains $$$n$$$ positive integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^7$$$), where $$$a_i$$$ denotes the initial remain of the $$$i$$$-th kind of dishes. The third line contains $$$n$$$ positive integers $$$c_1, c_2, \\ldots, c_n$$$ ($$$1 \\leq c_i \\leq 10^6$$$), where $$$c_i$$$ denotes the cost of one dish of the $$$i$$$-th kind. The following $$$m$$$ lines describe the orders of the $$$m$$$ customers respectively. The $$$j$$$-th line contains two positive integers $$$t_j$$$ and $$$d_j$$$ ($$$1 \\leq t_j \\leq n$$$, $$$1 \\leq d_j \\leq 10^7$$$), representing the kind of food and the number of dishes the $$$j$$$-th customer orders, respectively.", "output_spec": "Print $$$m$$$ lines. In the $$$j$$$-th line print the cost for the $$$j$$$-th customer.", "sample_inputs": ["8 5\n8 6 2 1 4 5 7 5\n6 3 3 2 6 2 3 2\n2 8\n1 4\n4 7\n3 4\n6 10", "6 6\n6 6 6 6 6 6\n6 66 666 6666 66666 666666\n1 6\n2 6\n3 6\n4 6\n5 6\n6 66", "6 6\n6 6 6 6 6 6\n6 66 666 6666 66666 666666\n1 6\n2 13\n3 6\n4 11\n5 6\n6 6"], "sample_outputs": ["22\n24\n14\n10\n39", "36\n396\n3996\n39996\n399996\n0", "36\n11058\n99996\n4333326\n0\n0"], "notes": "NoteIn the first sample, $$$5$$$ customers will be served as follows. Customer $$$1$$$ will be served $$$6$$$ dishes of the $$$2$$$-nd kind, $$$1$$$ dish of the $$$4$$$-th kind, and $$$1$$$ dish of the $$$6$$$-th kind. The cost is $$$6 \\cdot 3 + 1 \\cdot 2 + 1 \\cdot 2 = 22$$$. The remain of the $$$8$$$ kinds of food will be $$$\\{8, 0, 2, 0, 4, 4, 7, 5\\}$$$. Customer $$$2$$$ will be served $$$4$$$ dishes of the $$$1$$$-st kind. The cost is $$$4 \\cdot 6 = 24$$$. The remain will be $$$\\{4, 0, 2, 0, 4, 4, 7, 5\\}$$$. Customer $$$3$$$ will be served $$$4$$$ dishes of the $$$6$$$-th kind, $$$3$$$ dishes of the $$$8$$$-th kind. The cost is $$$4 \\cdot 2 + 3 \\cdot 2 = 14$$$. The remain will be $$$\\{4, 0, 2, 0, 4, 0, 7, 2\\}$$$. Customer $$$4$$$ will be served $$$2$$$ dishes of the $$$3$$$-rd kind, $$$2$$$ dishes of the $$$8$$$-th kind. The cost is $$$2 \\cdot 3 + 2 \\cdot 2 = 10$$$. The remain will be $$$\\{4, 0, 0, 0, 4, 0, 7, 0\\}$$$. Customer $$$5$$$ will be served $$$7$$$ dishes of the $$$7$$$-th kind, $$$3$$$ dishes of the $$$1$$$-st kind. The cost is $$$7 \\cdot 3 + 3 \\cdot 6 = 39$$$. The remain will be $$$\\{1, 0, 0, 0, 4, 0, 0, 0\\}$$$.In the second sample, each customer is served what they order except the last one, who leaves angrily without paying. For example, the second customer is served $$$6$$$ dishes of the second kind, so the cost is $$$66 \\cdot 6 = 396$$$.In the third sample, some customers may not be served what they order. For example, the second customer is served $$$6$$$ dishes of the second kind, $$$6$$$ of the third and $$$1$$$ of the fourth, so the cost is $$$66 \\cdot 6 + 666 \\cdot 6 + 6666 \\cdot 1 = 11058$$$."}, "positive_code": [{"source_code": " $c[$g - 1])\n {\n $i += $c[$g - 1] * $d[$g - 1];\n $h -= $c[$g - 1];\n $c[$g - 1] = 0;\n while(TRUE)\n {\n $j = current($f);\n $k = key($f);\n if($h <= $c[$k])\n {\n $i += $h * $d[$k];\n $c[$k] -= $h;\n break;\n }\n elseif($h > $c[$k])\n {\n $i += $c[$k] * $d[$k];\n $h -= $c[$k];\n $c[$k] = 0;\n unset($f[$k]);\n if(count($f) == 0)\n {\n $i = 0;\n break;\n }\n }\n }\n }\n if(count($f) == 0)\n {\n print \"0\\n\";\n }\n else\n {\n print $i . \"\\n\";\n }\n}\n?>"}], "negative_code": [], "src_uid": "2553ffea6d74fded12128e9db0db85dc"} {"nl": {"description": "Alice guesses the strings that Bob made for her.At first, Bob came up with the secret string $$$a$$$ consisting of lowercase English letters. The string $$$a$$$ has a length of $$$2$$$ or more characters. Then, from string $$$a$$$ he builds a new string $$$b$$$ and offers Alice the string $$$b$$$ so that she can guess the string $$$a$$$.Bob builds $$$b$$$ from $$$a$$$ as follows: he writes all the substrings of length $$$2$$$ of the string $$$a$$$ in the order from left to right, and then joins them in the same order into the string $$$b$$$.For example, if Bob came up with the string $$$a$$$=\"abac\", then all the substrings of length $$$2$$$ of the string $$$a$$$ are: \"ab\", \"ba\", \"ac\". Therefore, the string $$$b$$$=\"abbaac\".You are given the string $$$b$$$. Help Alice to guess the string $$$a$$$ that Bob came up with. It is guaranteed that $$$b$$$ was built according to the algorithm given above. It can be proved that the answer to the problem is unique.", "input_spec": "The first line contains a single positive integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases in the test. Then $$$t$$$ test cases follow. Each test case consists of one line in which the string $$$b$$$ is written, consisting of lowercase English letters ($$$2 \\le |b| \\le 100$$$)\u00a0\u2014 the string Bob came up with, where $$$|b|$$$ is the length of the string $$$b$$$. It is guaranteed that $$$b$$$ was built according to the algorithm given above.", "output_spec": "Output $$$t$$$ answers to test cases. Each answer is the secret string $$$a$$$, consisting of lowercase English letters, that Bob came up with.", "sample_inputs": ["4\nabbaac\nac\nbccddaaf\nzzzzzzzzzz"], "sample_outputs": ["abac\nac\nbcdaf\nzzzzzz"], "notes": "NoteThe first test case is explained in the statement.In the second test case, Bob came up with the string $$$a$$$=\"ac\", the string $$$a$$$ has a length $$$2$$$, so the string $$$b$$$ is equal to the string $$$a$$$.In the third test case, Bob came up with the string $$$a$$$=\"bcdaf\", substrings of length $$$2$$$ of string $$$a$$$ are: \"bc\", \"cd\", \"da\", \"af\", so the string $$$b$$$=\"bccddaaf\"."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}], "negative_code": [], "src_uid": "ac77e2e6c86b5528b401debe9f68fc8e"} {"nl": {"description": "You have a sequence $$$a$$$ with $$$n$$$ elements $$$1, 2, 3, \\dots, k - 1, k, k - 1, k - 2, \\dots, k - (n - k)$$$ ($$$k \\le n < 2k$$$).Let's call as inversion in $$$a$$$ a pair of indices $$$i < j$$$ such that $$$a[i] > a[j]$$$.Suppose, you have some permutation $$$p$$$ of size $$$k$$$ and you build a sequence $$$b$$$ of size $$$n$$$ in the following manner: $$$b[i] = p[a[i]]$$$.Your goal is to find such permutation $$$p$$$ that the total number of inversions in $$$b$$$ doesn't exceed the total number of inversions in $$$a$$$, and $$$b$$$ is lexicographically maximum.Small reminder: the sequence of $$$k$$$ integers is called a permutation if it contains all integers from $$$1$$$ to $$$k$$$ exactly once.Another small reminder: a sequence $$$s$$$ is lexicographically smaller than another sequence $$$t$$$, if either $$$s$$$ is a prefix of $$$t$$$, or for the first $$$i$$$ such that $$$s_i \\ne t_i$$$, $$$s_i < t_i$$$ holds (in the first position that these sequences are different, $$$s$$$ has smaller number than $$$t$$$).", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first and only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$k \\le n < 2k$$$; $$$1 \\le k \\le 10^5$$$)\u00a0\u2014 the length of the sequence $$$a$$$ and its maximum. It's guaranteed that the total sum of $$$k$$$ over test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case, print $$$k$$$ integers\u00a0\u2014 the permutation $$$p$$$ which maximizes $$$b$$$ lexicographically without increasing the total number of inversions. It can be proven that $$$p$$$ exists and is unique.", "sample_inputs": ["4\n1 1\n2 2\n3 2\n4 3"], "sample_outputs": ["1 \n1 2 \n2 1 \n1 3 2"], "notes": "NoteIn the first test case, the sequence $$$a = [1]$$$, there is only one permutation $$$p = [1]$$$.In the second test case, the sequence $$$a = [1, 2]$$$. There is no inversion in $$$a$$$, so there is only one permutation $$$p = [1, 2]$$$ which doesn't increase the number of inversions.In the third test case, $$$a = [1, 2, 1]$$$ and has $$$1$$$ inversion. If we use $$$p = [2, 1]$$$, then $$$b = [p[a[1]], p[a[2]], p[a[3]]] = [2, 1, 2]$$$ and also has $$$1$$$ inversion.In the fourth test case, $$$a = [1, 2, 3, 2]$$$, and since $$$p = [1, 3, 2]$$$ then $$$b = [1, 3, 2, 3]$$$. Both $$$a$$$ and $$$b$$$ have $$$1$$$ inversion and $$$b$$$ is the lexicographically maximum."}, "positive_code": [{"source_code": "= $a[1] - $inv; $i--) {\r\n $res .= sprintf(' %s', $i);\r\n }\r\n }\r\n echo trim($res) . \"\\n\";\r\n }\r\n \r\n \r\n \r\n \r\n \r\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= 1; $i--) {\r\n $res .= ' '. $i;\r\n }\r\n }\r\n echo trim($res) . \"\\n\";\r\n }\r\n \r\n \r\n \r\n \r\n \r\n?>"}], "src_uid": "67de9506ac2458ee67346bae1a9e3926"} {"nl": {"description": "There are three sticks with integer lengths $$$l_1, l_2$$$ and $$$l_3$$$.You are asked to break exactly one of them into two pieces in such a way that: both pieces have positive (strictly greater than $$$0$$$) integer length; the total length of the pieces is equal to the original length of the stick; it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides. A square is also considered a rectangle.Determine if it's possible to do that.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of testcases. The only line of each testcase contains three integers $$$l_1, l_2, l_3$$$ ($$$1 \\le l_i \\le 10^8$$$)\u00a0\u2014 the lengths of the sticks.", "output_spec": "For each testcase, print \"YES\" if it's possible to break one of the sticks into two pieces with positive integer length in such a way that it's possible to construct a rectangle from the resulting four sticks. Otherwise, print \"NO\". You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as a positive answer).", "sample_inputs": ["4\n6 1 5\n2 5 2\n2 4 2\n5 5 4"], "sample_outputs": ["YES\nNO\nYES\nYES"], "notes": "NoteIn the first testcase, the first stick can be broken into parts of length $$$1$$$ and $$$5$$$. We can construct a rectangle with opposite sides of length $$$1$$$ and $$$5$$$.In the second testcase, breaking the stick of length $$$2$$$ can only result in sticks of lengths $$$1, 1, 2, 5$$$, which can't be made into a rectangle. Breaking the stick of length $$$5$$$ can produce results $$$2, 3$$$ or $$$1, 4$$$ but neither of them can't be put into a rectangle.In the third testcase, the second stick can be broken into parts of length $$$2$$$ and $$$2$$$. The resulting rectangle has opposite sides $$$2$$$ and $$$2$$$ (which is a square).In the fourth testcase, the third stick can be broken into parts of length $$$2$$$ and $$$2$$$. The resulting rectangle has opposite sides $$$2$$$ and $$$5$$$."}, "positive_code": [{"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = max($m2[0] - 1, ceil(($m2[0] - 1) / 2) + ceil(($m2[1] - 1) / 2) + 1, ceil(($m2[1] - 1) / 2) + ceil(($m2[2] - 1) / 2) + 2);\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k2[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n if($a == 100)\n {\n print_r($n);\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n if($a == 100)\n {\n print implode(\" \", $n) . \"\\n\";\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n if(($a == 1000) && ($b == 998))\n {\n print_r($m2);\n }\n if($m2[1] == NULL)\n {\n $v = $m2[0] - 1;\n }\n elseif($m2[2] == NULL)\n {\n $v = ceil(($m2[0] - 1) / 2) + ceil(($m2[1] - 1) / 2) + 1;\n }\n else\n {\n $v = max($m2[0] - 1, ceil(($m2[1] - 1) / 2) + ceil(($m2[2] - 1) / 2) + 2);\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n if($a == 100)\n {\n print_r($n);\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n $p++;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n if($a == 100)\n {\n for($y = 0; $y < count($m); $y++)\n {\n print implode(\" \", $m[$y]) . \"\\n\";\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n if($a == 100)\n {\n print_r($k);\n }\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n if($a == 100)\n {\n print_r($m);\n }\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n if($a == 100)\n {\n print_r($k2);\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n if($a == 100)\n {\n print_r($r);\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n if($a == 100)\n {\n print_r($k);\n }\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n if($a == 100)\n {\n print count($n) . \"\\n\";\n print implode(\" \", $n) . \"\\n\";\n }\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n if(($a == 100) && ($b == 50))\n {\n print implode(\" \", $r) . \"\\n\";\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n if($m2[1] == NULL)\n {\n $v = $m2[0] - 1;\n }\n elseif($m2[2] == NULL)\n {\n $v = ceil(($m2[0] - 1) / 2) + ceil(($m2[1] - 1) / 2) + 1;\n }\n else\n {\n $v = max($m2[0] - 1, ceil(($m2[1] - 1) / 2) + ceil(($m2[2] - 1) / 2) + 2);\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n if($a == 100)\n {\n print_r($r4);\n }\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n if($a == 100)\n {\n print_r($l3);\n print_r($r4);\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n if($a == 100)\n {\n print_r($n);\n }\n break;\n }\n $p++;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n if($a == 100)\n {\n print_r($k2);\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n if($a == 100)\n {\n print implode(\" \", $n) . \"\\n\";\n }\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n $f2 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n $f2[$f]++;\n if(($a == 100) && ($f2[65] == TRUE))\n {\n print $f . \" \" . $g . \"\\n\";\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n if($a == 100)\n {\n print count($n) . \"\\n\";\n print implode(\" \", $n) . \"\\n\";\n }\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n if($a == 100)\n {\n print_r($r2);\n }\n break;\n }\n $p++;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n if(($a == 1000) && ($b == 960))\n {\n print_r($m2);\n }\n if($m2[1] == NULL)\n {\n $v = $m2[0] - 1;\n }\n elseif($m2[2] == NULL)\n {\n $v = max($m2[0] - 1, ceil(($m2[0] - 1) / 2) + ceil(($m2[1] - 1) / 2) + 1);\n }\n else\n {\n $v = max($m2[0] - 1, ceil(($m2[1] - 1) / 2) + ceil(($m2[2] - 1) / 2) + 2);\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n if(($a == 100) && ($f2 == 1))\n {\n print $f . \" \" . $g . \"\\n\";\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n if($a == 100)\n {\n print count($n) . \"\\n\";\n print implode(\" \", $n) . \"\\n\";\n }\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= $a; $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $r2[count($r2) - 1];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n $r4 = $r;\n $r5 = $r;\n for($y = 0; $y < count($r4); $y++)\n {\n if($r4[$y] == $m3)\n {\n $r4 = array_merge($l3, array_slice($r4, $y + 1));\n break;\n }\n }\n for($y = 0; $y < count($r5); $y++)\n {\n if($r5[$y] == $m3)\n {\n $r5 = array_merge(array_slice($r5, 0, $y - 1), $l3);\n break;\n }\n }\n if(count($r4) > count($r5))\n {\n $r = $r4;\n }\n else\n {\n $r = $r5;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n if($m2[1] == NULL)\n {\n $v = $m2[0] - 1;\n }\n elseif($m2[2] == NULL)\n {\n $v = max($m2[0] - 1, ceil(($m2[0] - 1) / 2) + ceil(($m2[1] - 1) / 2) + 1);\n }\n else\n {\n $v = max($m2[0] - 1, ceil(($m2[1] - 1) / 2) + ceil(($m2[2] - 1) / 2) + 2);\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n $n3 = 0;\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n $r3 = $s[$r2[count($r2) - 1]] + (count($r2) - 1);\n if($r3 > $k3)\n {\n $k3 = $r3;\n $l3 = $r2;\n $m3 = $s[$r2[count($r2) - 1]];\n $n3 = 1;\n }\n break;\n }\n $p++;\n }\n }\n if($n3 == 1)\n {\n if($a == 100)\n {\n print $k3;\n print_r($l3);\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n if($a == 100)\n {\n print count($n) . \"\\n\";\n print implode(\" \", $n) . \"\\n\";\n }\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n if($a == 100)\n {\n print_r($s);\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n if(($f == 65) && ($g == 76))\n {\n $f2 = 1;\n }\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $k2 = array(0 => $x);\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n if($k[$l[$n[$p]][$y]] == 1)\n {\n $k2[count($k2)] = $l[$n[$p]][$y];\n }\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n array_splice($k2, 0, 1);\n array_splice($k2, -1, 1);\n $q = $n[count($n) - 1];\n $r = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r = array_reverse($r);\n $k3 = count($r) - 1;\n $k4 = $k3;\n $s = array();\n for($y = 0; $y < count($r); $y++)\n {\n $s[$r[$y]] = $k4;\n $k4--;\n }\n $k4 = $k3;\n for($y = count($r) - 1; $y >= 0; $y--)\n {\n $s[$r[$y]] = max($k4, $s[$r[$y]]);\n $k4--;\n }\n for($z = 0; $z < count($k2); $z++)\n {\n $n = array(0 => $k2[$z]);\n $o = array($k2[$z] => TRUE);\n $p = 0;\n $k5 = $k2;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k5[$l[$n[$p]][$y]] = 0;\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n break;\n }\n }\n }\n if($s[$l[$n[$p]][$y]] == TRUE)\n {\n $q = $n[count($n) - 1];\n $r2 = array($q);\n $s2 = 0;\n while(TRUE)\n {\n if($l2[$n[$s2]][$q] == TRUE)\n {\n $r2[count($r2)] = $n[$s2];\n if($s2 == 0)\n {\n break;\n }\n $q = $n[$s2];\n $s2 = 0;\n }\n else\n {\n $s2++;\n }\n }\n $r2 = array_reverse($r2);\n if($a == 100)\n {\n print_r($r2);\n }\n break;\n }\n $p++;\n }\n }\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 3)\n {\n print \"2\\n\";\n for($x = 2; $x <= $a; $x++)\n {\n print \"1 \" . $x . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n $d = array();\n $e = array();\n $m3 = array();\n for($x = 0; $x < $b; $x++)\n {\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $c[$x] = $f;\n $d[$x] = $g;\n $e[count($e)] = $f;\n $e[count($e)] = $g;\n }\n $h = range(1, $a);\n $i = array_unique($e);\n sort($i);\n $j = array_diff($h, $i);\n sort($j);\n $k = array();\n for($x = 0; $x < count($e); $x++)\n {\n $k[$e[$x]]++;\n }\n ksort($k);\n $l = array_fill(1, $a, array());\n $l2 = array_fill(1, $a, array());\n for($x = 0; $x < $b; $x++)\n {\n $l[$c[$x]][count($l[$c[$x]])] = $d[$x];\n $l[$d[$x]][count($l[$d[$x]])] = $c[$x];\n $l2[$c[$x]][$d[$x]] = TRUE;\n $l2[$d[$x]][$c[$x]] = TRUE;\n }\n $m = array();\n $m2 = array();\n for($x = 1; $x <= count($k); $x++)\n {\n if($k[$x] == 1)\n {\n $n = array(0 => $x);\n $o = array($x => TRUE);\n $p = 0;\n while(TRUE)\n {\n for($y = 0; $y < count($l[$n[$p]]); $y++)\n {\n if($o[$l[$n[$p]][$y]] == FALSE)\n {\n $n[count($n)] = $l[$n[$p]][$y];\n $o[$l[$n[$p]][$y]] = TRUE;\n $k[$l[$n[$p]][$y]] = 0;\n }\n }\n $p++;\n if($n[$p] == NULL)\n {\n break;\n }\n }\n $q = $n[count($n) - 1];\n $r = array($q);\n $s = 0;\n while(TRUE)\n {\n if($l2[$n[$s]][$q] == TRUE)\n {\n $r[count($r)] = $n[$s];\n if($s == 0)\n {\n break;\n }\n $q = $n[$s];\n $s = 0;\n }\n else\n {\n $s++;\n }\n }\n if($a == 100)\n {\n print implode(\" \", $r) . \"\\n\";\n }\n $r = array_reverse($r);\n $m[count($m)] = $r;\n $m2[count($m2)] = count($r);\n }\n }\n $t = max($m2);\n for($x = 0; $x < count($m); $x++)\n {\n if(count($m[$x]) == $t)\n {\n break;\n }\n }\n $u = $m[$x];\n array_splice($m, $x, 1);\n rsort($m2);\n $v = floor($m2[0] / 2);\n $v2 = floor($m2[1] / 2);\n if($v2 != 0)\n {\n $v += $v2 + 1;\n }\n else\n {\n $v = $m2[0] - 1;\n }\n print $v . \"\\n\";\n if(count($u) % 2 == 0)\n {\n $w = $u[count($u) / 2 - 1];\n }\n else\n {\n $w = $u[floor(count($u) / 2)];\n }\n for($x = 0; $x < count($j); $x++)\n {\n print $w . \" \" . $j[$x] . \"\\n\";\n }\n for($x = 0; $x < $a - 1 - $b - count($j); $x++)\n {\n $w2 = $m[$x];\n if(count($w2) % 2 == 0)\n {\n $w3 = $w2[count($w2) / 2 - 1];\n }\n else\n {\n $w3 = $w2[floor(count($w2) / 2)];\n }\n print $w . \" \" . $w3 . \"\\n\";\n }\n}\n?>"}], "src_uid": "90cf88fde1c23b6f3a85ee75d3a6a3ec"} {"nl": {"description": "You are given a string $$$s$$$. You need to find two non-empty strings $$$a$$$ and $$$b$$$ such that the following conditions are satisfied: Strings $$$a$$$ and $$$b$$$ are both subsequences of $$$s$$$. For each index $$$i$$$, character $$$s_i$$$ of string $$$s$$$ must belong to exactly one of strings $$$a$$$ or $$$b$$$. String $$$a$$$ is lexicographically minimum possible; string $$$b$$$ may be any possible string. Given string $$$s$$$, print any valid $$$a$$$ and $$$b$$$.Reminder:A string $$$a$$$ ($$$b$$$) is a subsequence of a string $$$s$$$ if $$$a$$$ ($$$b$$$) can be obtained from $$$s$$$ by deletion of several (possibly, zero) elements. For example, \"dores\", \"cf\", and \"for\" are subsequences of \"codeforces\", while \"decor\" and \"fork\" are not.A string $$$x$$$ is lexicographically smaller than a string $$$y$$$ if and only if one of the following holds: $$$x$$$ is a prefix of $$$y$$$, but $$$x \\ne y$$$; in the first position where $$$x$$$ and $$$y$$$ differ, the string $$$x$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$y$$$. ", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 1000$$$). Description of the test cases follows. The first and only line of each test case contains one string $$$s$$$ ($$$2 \\le |s| \\le 100$$$ where $$$|s|$$$ means the length of $$$s$$$). String $$$s$$$ consists of lowercase Latin letters.", "output_spec": "For each test case, print the strings $$$a$$$ and $$$b$$$ that satisfy the given conditions. If there are multiple answers, print any.", "sample_inputs": ["3\nfc\naaaa\nthebrightboiler"], "sample_outputs": ["c f\na aaa\nb therightboiler"], "notes": "NoteIn the first test case, there are only two choices: either $$$a =$$$ f and $$$b = $$$ c or $$$a = $$$ c and $$$b = $$$ f. And $$$a = $$$c is lexicographically smaller than $$$a = $$$ f.In the second test case, a is the only character in the string.In the third test case, it can be proven that b is the lexicographically smallest subsequence of $$$s$$$. The second string can be of two variants; one of them is given here."}, "positive_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n\r\n$t = IO::str();\r\n\r\n\r\nwhile ($t--) {\r\n $s = strtolower(IO::str());\r\n\r\n $asci = array();\r\n $arr = str_split($s);\r\n $min = 200;\r\n for ($i = 0; $i < strlen($s); $i++) {\r\n $k = ord($arr[$i]);\r\n if ($k < $min) {\r\n $min = $k;\r\n $idx = $i;\r\n }\r\n }\r\n\r\n $s1 = $arr[$idx];\r\n unset($arr[$idx]);\r\n\r\n $s2 = implode($arr);\r\n\r\n echo $s1 . ' ' . $s2 . PHP_EOL;\r\n}"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function factorial($number)\r\n {\r\n $factorial = 1;\r\n for ($i = 1; $i <= $number; $i++){\r\n $factorial = $factorial * $i;\r\n }\r\n return $factorial;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $min = 'z';\r\n $mink = 99;\r\n foreach ($a as $k => $v) {\r\n if ($v <= $min) {\r\n $min = $v;\r\n $mink = $k;\r\n }\r\n }\r\n unset($a[$mink]);\r\n $s1 = $min;\r\n $s2 = implode('', $a);\r\n IO::line($s1 . ' ' . $s2);\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [], "src_uid": "4a58039c5171597ecf78837e9db1d71d"} {"nl": {"description": "Polycarp has a poor memory. Each day he can remember no more than $$$3$$$ of different letters. Polycarp wants to write a non-empty string of $$$s$$$ consisting of lowercase Latin letters, taking minimum number of days. In how many days will he be able to do it?Polycarp initially has an empty string and can only add characters to the end of that string.For example, if Polycarp wants to write the string lollipops, he will do it in $$$2$$$ days: on the first day Polycarp will memorize the letters l, o, i and write lolli; On the second day Polycarp will remember the letters p, o, s, add pops to the resulting line and get the line lollipops. If Polycarp wants to write the string stringology, he will do it in $$$4$$$ days: in the first day will be written part str; on day two will be written part ing; on the third day, part of olog will be written; on the fourth day, part of y will be written. For a given string $$$s$$$, print the minimum number of days it will take Polycarp to write it.", "input_spec": "The first line of input data contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. Each test case consists of a non-empty string $$$s$$$ consisting of lowercase Latin letters (the length of the string $$$s$$$ does not exceed $$$2 \\cdot 10^5$$$)\u00a0\u2014 the string Polycarp wants to construct. It is guaranteed that the sum of string lengths $$$s$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, print a single number\u00a0\u2014 minimum number of days it will take Polycarp to write the string $$$s$$$ from memory.", "sample_inputs": ["6\n\nlollipops\n\nstringology\n\nabracadabra\n\ncodeforces\n\ntest\n\nf"], "sample_outputs": ["2\n4\n3\n4\n1\n1"], "notes": null}, "positive_code": [{"source_code": " $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": "= 3 && !in_array($string_array[$j], $now_memory)){ // \ud604\uc7ac \uae30\uc5b5\ud55c \uac83\uc774 3 \uc774\uc0c1\uc774\uba74\r\n\t\t\t$memory_count = 0;\r\n\t\t\t$now_memory = array(); // \ucd08\uae30\ud654\r\n\t\t\t$day_count++;\r\n\t\t}\r\n\t\t\r\n\t\tif(in_array($string_array[$j], $now_memory)){ // \uc774\ubbf8 \uc788\uc73c\uba74\r\n\t\t\t// \uc544\ubb34\uac83\ub3c4 \uc548 \ud568\r\n\t\t\t$already_exists = true;\r\n\t\t}else{ // \uc5c6\uc73c\uba74\r\n\t\t\tarray_push($now_memory, $string_array[$j]);\r\n\t\t\t$memory_count++;\r\n\t\t\t$already_exists = false;\r\n\t\t}\r\n\t}\r\n\t\r\n\tif($memory_count > 0){\r\n\t\t$day_count++;\r\n\t}\r\n\t\r\n\t$result .= $day_count.\"\\n\";\r\n}\r\n\r\necho $result;"}, {"source_code": " 3) {\r\n $days += 1 ;\r\n $temp = array($a) ;\r\n }\r\n }\r\n if(count($temp) > 0 ) {\r\n $days += 1 ;\r\n }\r\n return $days ;\r\n}\r\n\r\n$t = (int) fgets(STDIN);\r\n$ans = [] ;\r\nwhile($t--) {\r\n $st = trim(fgets(STDIN));\r\n $ans[] = solve($st);\r\n}\r\nprint_r(implode(\"\\n\",$ans)) ;"}], "negative_code": [], "src_uid": "bd9da9081902a87c61591fb58fcecfe3"} {"nl": {"description": "Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.He noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position $$$x$$$, and the shorter rabbit is currently on position $$$y$$$ ($$$x \\lt y$$$). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by $$$a$$$, and the shorter rabbit hops to the negative direction by $$$b$$$. For example, let's say $$$x=0$$$, $$$y=10$$$, $$$a=2$$$, and $$$b=3$$$. At the $$$1$$$-st second, each rabbit will be at position $$$2$$$ and $$$7$$$. At the $$$2$$$-nd second, both rabbits will be at position $$$4$$$.Gildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.", "input_spec": "Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 1000$$$). Each test case contains exactly one line. The line consists of four integers $$$x$$$, $$$y$$$, $$$a$$$, $$$b$$$ ($$$0 \\le x \\lt y \\le 10^9$$$, $$$1 \\le a,b \\le 10^9$$$) \u2014 the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.", "output_spec": "For each test case, print the single integer: number of seconds the two rabbits will take to be at the same position. If the two rabbits will never be at the same position simultaneously, print $$$-1$$$.", "sample_inputs": ["5\n0 10 2 3\n0 10 3 3\n900000000 1000000000 1 9999999\n1 2 1 1\n1 3 1 1"], "sample_outputs": ["2\n-1\n10\n-1\n1"], "notes": "NoteThe first case is explained in the description.In the second case, each rabbit will be at position $$$3$$$ and $$$7$$$ respectively at the $$$1$$$-st second. But in the $$$2$$$-nd second they will be at $$$6$$$ and $$$4$$$ respectively, and we can see that they will never be at the same position since the distance between the two rabbits will only increase afterward."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "846681af4b4b6b29d2c9c450a945de90"} {"nl": {"description": "You are given two strings $$$s$$$ and $$$t$$$, both consisting only of lowercase Latin letters.The substring $$$s[l..r]$$$ is the string which is obtained by taking characters $$$s_l, s_{l + 1}, \\dots, s_r$$$ without changing the order.Each of the occurrences of string $$$a$$$ in a string $$$b$$$ is a position $$$i$$$ ($$$1 \\le i \\le |b| - |a| + 1$$$) such that $$$b[i..i + |a| - 1] = a$$$ ($$$|a|$$$ is the length of string $$$a$$$).You are asked $$$q$$$ queries: for the $$$i$$$-th query you are required to calculate the number of occurrences of string $$$t$$$ in a substring $$$s[l_i..r_i]$$$.", "input_spec": "The first line contains three integer numbers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \\le n, m \\le 10^3$$$, $$$1 \\le q \\le 10^5$$$) \u2014 the length of string $$$s$$$, the length of string $$$t$$$ and the number of queries, respectively. The second line is a string $$$s$$$ ($$$|s| = n$$$), consisting only of lowercase Latin letters. The third line is a string $$$t$$$ ($$$|t| = m$$$), consisting only of lowercase Latin letters. Each of the next $$$q$$$ lines contains two integer numbers $$$l_i$$$ and $$$r_i$$$ ($$$1 \\le l_i \\le r_i \\le n$$$) \u2014 the arguments for the $$$i$$$-th query.", "output_spec": "Print $$$q$$$ lines \u2014 the $$$i$$$-th line should contain the answer to the $$$i$$$-th query, that is the number of occurrences of string $$$t$$$ in a substring $$$s[l_i..r_i]$$$.", "sample_inputs": ["10 3 4\ncodeforces\nfor\n1 3\n3 10\n5 6\n5 7", "15 2 3\nabacabadabacaba\nba\n1 15\n3 4\n2 14", "3 5 2\naaa\nbaaab\n1 3\n1 1"], "sample_outputs": ["0\n1\n0\n1", "4\n0\n3", "0\n0"], "notes": "NoteIn the first example the queries are substrings: \"cod\", \"deforces\", \"fo\" and \"for\", respectively."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": "= $b)\n {\n $k = $f[$j - 1] - $f[$i - 1];\n if($f[$i - 1] != $f[$i - 2])\n {\n $k++;\n }\n if($f[$j - 1 - ($b - 1)] != $f[$j - 1])\n {\n $k--;\n }\n print $k . \"\\n\";\n }\n else\n {\n print \"0\\n\";\n }\n}\n?>"}, {"source_code": "= $b)\n {\n $k = $f[$j - 1] - $f[$i - 1];\n if(($f[$i - 1] != $f[$i - 2]) && ($f[$i - 2] != NULL))\n {\n $k++;\n }\n if($f[$j - 1 - ($b - 1)] != $f[$j - 1])\n {\n $k--;\n }\n print $k . \"\\n\";\n }\n else\n {\n print \"0\\n\";\n }\n}\n?>"}], "src_uid": "4cc5a6975d33cee60e53e8f648ec30de"} {"nl": {"description": "You are given array a with n integers and m queries. The i-th query is given with three integers li,\u2009ri,\u2009xi.For the i-th query find any position pi (li\u2009\u2264\u2009pi\u2009\u2264\u2009ri) so that api\u2009\u2260\u2009xi.", "input_spec": "The first line contains two integers n,\u2009m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20092\u00b7105) \u2014 the number of elements in a and the number of queries. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009106) \u2014 the elements of the array a. Each of the next m lines contains three integers li,\u2009ri,\u2009xi (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009n,\u20091\u2009\u2264\u2009xi\u2009\u2264\u2009106) \u2014 the parameters of the i-th query.", "output_spec": "Print m lines. On the i-th line print integer pi \u2014 the position of any number not equal to xi in segment [li,\u2009ri] or the value \u2009-\u20091 if there is no such number.", "sample_inputs": ["6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2"], "sample_outputs": ["2\n6\n-1\n4"], "notes": null}, "positive_code": [{"source_code": "> 1;\n if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n public static function upperBound($a, $l, $r, $k) {\n $ans = $r; $m = 0;\n while ($l < $r) {\n $m = $l + $r >> 1;\n if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n }\n \n list($n, $m) = explode(' ', trim(fgets(STDIN)));\n $a = explode(' ', trim(fgets(STDIN))); \n $before = array_fill(1, $n, 0);\n $before[$n] = -1;\n for ($i = $n - 1; $i > 0; $i--) {\n \n $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1]; \n }\n\n\n $map = array();\n for ($i = 0; $i < $n; $i++) {\n $v = $a[$i];\n $map[$v][] = $i + 1;\n }\n \n $ans = \"\";\n while ($m-- > 0) {\n list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));\n \n if (isset($map[$k])) {\n $cur = $map[$k];\n $size = count($cur);\n $x = Utils :: lowerBound($cur, 0, $size, $l);\n $y = Utils :: upperBound($cur, 0, $size, $r) - 1;\n if ($x == $size || $cur[$x] > $l) $ans .= \"$l\" . \"\\n\";\n else $ans .= ($before[$l] > $r ? '-1' : \"$before[$l]\") . \"\\n\";\n \n } else $ans .= \"$l\" . \"\\n\"; \n }\n echo $ans;"}, {"source_code": "> 1;\n if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n public static function upperBound($a, $l, $r, $k) {\n $ans = $r; $m = 0;\n while ($l < $r) {\n $m = $l + $r >> 1;\n if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n }\n \n list($n, $m) = explode(' ', trim(fgets(STDIN)));\n $a = explode(' ', trim(fgets(STDIN))); \n $before = array_fill(1, $n, 0);\n $before[$n] = -1;\n for ($i = $n - 1; $i > 0; $i--) {\n $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1]; \n }\n\n\n $map = array();\n for ($i = 0; $i < $n; $i++) {\n $map[$a[$i]][] = $i + 1;\n }\n \n $ans = \"\";\n while ($m-- > 0) {\n list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));\n \n if (isset($map[$k])) {\n $cur = &$map[$k];\n $size = count($cur);\n $x = Utils :: lowerBound($cur, 0, $size, $l);\n $y = Utils :: upperBound($cur, 0, $size, $r) - 1;\n if ($x == $size || $cur[$x] > $l) $ans .= \"$l\" . \"\\n\";\n else $ans .= ($before[$l] > $r ? '-1' : \"$before[$l]\") . \"\\n\";\n \n } else $ans .= \"$l\" . \"\\n\"; \n }\n echo $ans;"}, {"source_code": "> 1;\n if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n public static function upperBound($a, $l, $r, $k) {\n $ans = $r; $m = 0;\n while ($l < $r) {\n $m = $l + $r >> 1;\n if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n }\n \n list($n, $m) = explode(' ', trim(fgets(STDIN)));\n $a = explode(' ', trim(fgets(STDIN))); \n $before = array_fill(1, $n, 0);\n $before[$n] = -1;\n for ($i = $n - 1; $i > 0; $i--) {\n \n $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1]; \n }\n\n// print_r($before);\n\n $map = array();\n for ($i = 0; $i < $n; $i++) {\n $v = $a[$i];\n $map[$v][] = $i + 1;\n }\n \n// print_r($map);\n\n $ans = \"\";\n while ($m-- > 0) {\n list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));\n \n if (isset($map[$k])) {\n $cur = $map[$k];\n $size = count($cur);\n $x = Utils :: lowerBound($cur, 0, $size, $l);\n $y = Utils :: upperBound($cur, 0, $size, $r) - 1;\n// echo $size . \" \" . $k . \" \" . $x . \" \" . $y . \"\\n\";\n if ($x == $size || $cur[$x] > $l) $ans .= \"$l\" . \"\\n\";\n elseif ($y - $x == $r - $l) $ans .= '-1' . \"\\n\";\n else $ans .= ($before[$l] > $r ? '-1' : \"$before[$l]\") . \"\\n\";\n \n } else $ans .= \"$l\" . \"\\n\"; \n }\n echo $ans;\n \n"}], "negative_code": [{"source_code": "> 1;\n if ($a[$m] >= $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n \n public static function upperBound($a, $l, $r, $k) {\n $ans = $r; $m = 0;\n while ($l < $r) {\n $m = $l + $r >> 1;\n if ($a[$m] > $k) $ans = $r = $m; else $l = $m + 1;\n }\n return $ans;\n }\n }\n \n list($n, $m) = explode(' ', trim(fgets(STDIN)));\n $a = explode(' ', trim(fgets(STDIN))); \n $before = array_fill(1, $n, 0);\n $before[$n] = -1;\n for ($i = $n - 1; $i > 0; $i--) {\n \n $before[$i] = $a[$i] != $a[$i - 1] ? $i + 1 : $before[$i + 1]; \n }\n\n $map = array();\n for ($i = 0; $i < $n; $i++) {\n $v = $a[$i];\n $map[$v][] = $i + 1;\n }\n \n while ($m-- > 0) {\n list($l, $r, $k) = explode(' ', trim(fgets(STDIN)));\n \n if (isset($map[$k])) {\n $cur = $map[$k];\n $size = count($cur);\n $x = Utils :: lowerBound($cur, 0, $size, $l);\n $y = Utils :: upperBound($cur, 0, $size, $r) - 1;\n if ($x == $size || $cur[$x] > $l) echo \"$l\" . \"\\n\";\n else echo $before[$l] > $r ? '-1' : \"$before[$l]\" . \"\\n\";\n \n } else echo \"$l\" . \"\\n\"; \n } \n"}], "src_uid": "dcf7988c35bb34973e7b60afa7a0e68c"} {"nl": {"description": "The only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.Kirk has a binary string $$$s$$$ (a string which consists of zeroes and ones) of length $$$n$$$ and he is asking you to find a binary string $$$t$$$ of the same length which satisfies the following conditions: For any $$$l$$$ and $$$r$$$ ($$$1 \\leq l \\leq r \\leq n$$$) the length of the longest non-decreasing subsequence of the substring $$$s_{l}s_{l+1} \\ldots s_{r}$$$ is equal to the length of the longest non-decreasing subsequence of the substring $$$t_{l}t_{l+1} \\ldots t_{r}$$$; The number of zeroes in $$$t$$$ is the maximum possible.A non-decreasing subsequence of a string $$$p$$$ is a sequence of indices $$$i_1, i_2, \\ldots, i_k$$$ such that $$$i_1 < i_2 < \\ldots < i_k$$$ and $$$p_{i_1} \\leq p_{i_2} \\leq \\ldots \\leq p_{i_k}$$$. The length of the subsequence is $$$k$$$.If there are multiple substrings which satisfy the conditions, output any.", "input_spec": "The first line contains a binary string of length not more than $$$10^5$$$.", "output_spec": "Output a binary string which satisfied the above conditions. If there are many such strings, output any of them.", "sample_inputs": ["110", "010", "0001111", "0111001100111011101000"], "sample_outputs": ["010", "010", "0000000", "0011001100001011101000"], "notes": "NoteIn the first example: For the substrings of the length $$$1$$$ the length of the longest non-decreasing subsequnce is $$$1$$$; For $$$l = 1, r = 2$$$ the longest non-decreasing subsequnce of the substring $$$s_{1}s_{2}$$$ is $$$11$$$ and the longest non-decreasing subsequnce of the substring $$$t_{1}t_{2}$$$ is $$$01$$$; For $$$l = 1, r = 3$$$ the longest non-decreasing subsequnce of the substring $$$s_{1}s_{3}$$$ is $$$11$$$ and the longest non-decreasing subsequnce of the substring $$$t_{1}t_{3}$$$ is $$$00$$$; For $$$l = 2, r = 3$$$ the longest non-decreasing subsequnce of the substring $$$s_{2}s_{3}$$$ is $$$1$$$ and the longest non-decreasing subsequnce of the substring $$$t_{2}t_{3}$$$ is $$$1$$$; The second example is similar to the first one."}, "positive_code": [{"source_code": "= 0; $i--) {\n if ($binaryString[$i] == '0') {\n $zeros++;\n }\n else {\n $ones++;\n if ($ones > $zeros) {\n $binaryString[$i] = '0';\n $ones--;\n }\n }\n }\n return $binaryString;\n}\n\nfunction main() {\n $binaryString = readline();\n echo kirksFunction($binaryString);\n}\n\nmain();\n?>"}, {"source_code": " $zeros it means that we can change LIS containing ones to LIS containing zeros.\n for ($i = strlen($binaryString)-1; $i >= 0; $i--) {\n if ($binaryString[$i] == '0') {\n $zeros++;\n }\n else {\n $ones++;\n if ($ones > $zeros) {\n $binaryString[$i] = '0';\n $ones--;\n }\n }\n }\n return $binaryString;\n}\n\nfunction main() {\n $binaryString = readline();\n echo kirksFunction($binaryString);\n}\n\nmain();\n?>"}], "negative_code": [], "src_uid": "a3c844e3ee6c9596f1ec9ab46c6ea872"} {"nl": {"description": "You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$. You need to construct an array $$$a_1,a_2,\\dots,a_n$$$ ($$$l\\le a_i\\le r$$$) such that $$$\\gcd(i,a_i)$$$ are all distinct or report there's no solution.Here $$$\\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\\le t\\le 10^4$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \\le n \\le 10^5$$$, $$$1\\le l\\le r\\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case, if there is no solution, print \"NO\" (without quotes). You can print letters in any case (upper or lower). Otherwise, print \"YES\" (without quotes). In the next line, print $$$n$$$ integers $$$a_1,a_2,\\ldots,a_n$$$\u00a0\u2014 the array you construct. If there are multiple solutions, you may output any.", "sample_inputs": ["4\n5 1 5\n9 1000 2000\n10 30 35\n1 1000000000 1000000000"], "sample_outputs": ["YES\n1 2 3 4 5\nYES\n1145 1926 1440 1220 1230 1350 1001 1000 1233\nNO\nYES\n1000000000"], "notes": "NoteIn the first test case, $$$\\gcd(1,a_1),\\gcd(2,a_2),\\ldots,\\gcd(5,a_5)$$$ are equal to $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, respectively."}, "positive_code": [{"source_code": "= $l ? $i : $x);\n if($x > $r)\n {\n $flag = 0;\n break;\n }\n array_push($ans, $x);\n }\n if(!$flag)\n {\n echo \"NO\\n\";\n }\n else\n {\n echo \"YES\\n\";\n foreach($ans as $c)\n {\n echo $c . ' ';\n }\n echo \"\\n\";\n }\n}"}, {"source_code": "= $ele && $l <= $ele) $ans[] = $ele ; \r\n\t}\r\n\t// printLine($ans);\r\n\tif(count($ans) < $n) {\r\n\t\tprintLine(\"NO\") ;\r\n\t}\r\n\telse {\r\n\t\tprintLine(\"YES\");\r\n\t\tprintLine(implode(' ', $ans));\r\n\t}\r\n}\r\n\r\n"}], "negative_code": [{"source_code": "= $l ? $i : $x);\n if($x > $r)\n {\n $flag = 0;\n break;\n }\n array_push($ans, $x);\n }\n if(!$flag)\n {\n echo \"NO\\n\";\n }\n else\n {\n echo \"YES\\n\";\n foreach($ans as $c)\n {\n echo $c . ' ';\n }\n echo \"\\n\";\n }\n}"}, {"source_code": " $mod;$i--)\n {\n echo $i . ' ';\n }\n while($l <= $mod)\n {\n echo $l . ' ';\n $l++;\n }\n echo \"\\n\";\n}"}, {"source_code": "= $d)\n {\n $d = $e;\n $c[count($c)] = $d;\n $d++;\n }\n else\n {\n if($d <= $f)\n {\n $c[count($c)] = $d;\n $d++;\n }\n else\n {\n $c[count($c)] = 0;\n }\n }\n }\n print implode(\" \", $c) . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": "= $d)\n {\n $d = $e;\n $c[count($c)] = $d;\n $d++;\n }\n else\n {\n if($d < $f)\n {\n $c[count($c)] = $d;\n $d++;\n }\n else\n {\n $c[count($c)] = 0;\n }\n }\n }\n print implode(\" \", $c) . \"\\n\";\n}\n?>"}], "src_uid": "471f80e349e70339eedd20d45b16e253"} {"nl": {"description": "Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.Wet Shark thinks that two bishops attack each other if they share the same diagonal. Note, that this is the only criteria, so two bishops may attack each other (according to Wet Shark) even if there is another bishop located between them. Now Wet Shark wants to count the number of pairs of bishops that attack each other.", "input_spec": "The first line of the input contains n (1\u2009\u2264\u2009n\u2009\u2264\u2009200\u2009000)\u00a0\u2014 the number of bishops. Each of next n lines contains two space separated integers xi and yi (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u20091000)\u00a0\u2014 the number of row and the number of column where i-th bishop is positioned. It's guaranteed that no two bishops share the same position.", "output_spec": "Output one integer\u00a0\u2014 the number of pairs of bishops which attack each other. ", "sample_inputs": ["5\n1 1\n1 5\n3 3\n5 1\n5 5", "3\n1 1\n2 3\n3 5"], "sample_outputs": ["6", "0"], "notes": "NoteIn the first sample following pairs of bishops attack each other: (1,\u20093), (1,\u20095), (2,\u20093), (2,\u20094), (3,\u20094) and (3,\u20095). Pairs (1,\u20092), (1,\u20094), (2,\u20095) and (4,\u20095) do not attack each other because they do not share the same diagonal."}, "positive_code": [{"source_code": "= 1; $y--)\n {\n $l = $y . \"-\" . $j;\n $j++;\n if($e[$l] == TRUE)\n {\n $k++;\n }\n }\n $i += $a[$k];\n}\nfor($x = 1000; $x > 1; $x--)\n{\n $j = 1000;\n $k = 0;\n for($y = $x; $y <= 1000; $y++)\n {\n $l = $y . \"-\" . $j;\n $j--;\n if($e[$l] == TRUE)\n {\n $k++;\n }\n }\n $i += $a[$k];\n}\nfor($x = 1000; $x >= 1; $x--)\n{\n $j = 1;\n $k = 0;\n for($y = $x; $y <= 1000; $y++)\n {\n $l = $j . \"-\" . $y;\n $j++;\n if($e[$l] == TRUE)\n {\n $k++;\n }\n }\n $i += $a[$k];\n}\nfor($x = 1000; $x > 1; $x--)\n{\n $j = 1;\n $k = 0;\n for($y = $x; $y <= 1000; $y++)\n {\n $l = $y . \"-\" . $j;\n $j++;\n if($e[$l] == TRUE)\n {\n $k++;\n }\n }\n $i += $a[$k];\n}\nprint $i;\n?>"}, {"source_code": " $v) {\n\t$sum += nOfPairs($v);\n}\n\nforeach ($md as $k => $v) {\n\t$sum += nOfPairs($v);\n}\n\necho $sum;\n\n?>"}, {"source_code": " 1) {\n $pairCount += $count * ($count - 1) / 2;\n }\n}\n\nforeach ($backDiagCount as $count) {\n if ($count > 1) {\n $pairCount += $count * ($count - 1) / 2;\n }\n}\n\necho \"$pairCount\\n\";\n"}], "negative_code": [{"source_code": " $n)\n {\n $o = $n - 1;\n $p = $m - $o;\n $q = $n - $o;\n $r = $p . $q;\n $j[$r]++;\n }\n $o2 = $m - 1;\n $p2 = $m - $o2;\n $q2 = $n + $o2;\n $r2 = $p2 . $q2;\n if($i2[$r2] !== NULL)\n {\n $i2[$r2]++;\n }\n else\n {\n $o2 = 1000 - $n;\n $p2 = $m - $o2;\n $q2 = $n + $o2;\n $r2 = $p2 . $q2;\n $j2[$r2]++;\n }\n}\n$s = 0;\nfor($x = 0; $x < 1000; $x++)\n{\n $s += $b[$i[$k[$x]]];\n $s += $b[$j[$l[$x]]];\n $s += $b[$i2[$k2[$x]]];\n $s += $b[$j2[$l2[$x]]];\n}\nprint $s;\n?>"}, {"source_code": " $v) {\n\t$sum += ($v <= 1 ? 0 : $v);\n}\n\nforeach ($md as $k => $v) {\n\t$sum += ($v <= 1 ? 0 : $v);\n}\n\necho $sum;\n\n?>"}], "src_uid": "eb7457fe1e1b571e5ee8dd9689c7d66a"} {"nl": {"description": "Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:There are two arrays of integers $$$a$$$ and $$$b$$$ of length $$$n$$$. It turned out that array $$$a$$$ contains only elements from the set $$$\\{-1, 0, 1\\}$$$.Anton can perform the following sequence of operations any number of times: Choose any pair of indexes $$$(i, j)$$$ such that $$$1 \\le i < j \\le n$$$. It is possible to choose the same pair $$$(i, j)$$$ more than once. Add $$$a_i$$$ to $$$a_j$$$. In other words, $$$j$$$-th element of the array becomes equal to $$$a_i + a_j$$$. For example, if you are given array $$$[1, -1, 0]$$$, you can transform it only to $$$[1, -1, -1]$$$, $$$[1, 0, 0]$$$ and $$$[1, -1, 1]$$$ by one operation.Anton wants to predict if it is possible to apply some number (zero or more) of these operations to the array $$$a$$$ so that it becomes equal to array $$$b$$$. Can you help him?", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10000$$$). The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$) \u00a0\u2014 the length of arrays. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$-1 \\le a_i \\le 1$$$) \u00a0\u2014 elements of array $$$a$$$. There can be duplicates among elements. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$-10^9 \\le b_i \\le 10^9$$$) \u00a0\u2014 elements of array $$$b$$$. There can be duplicates among elements. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case, output one line containing \"YES\" if it's possible to make arrays $$$a$$$ and $$$b$$$ equal by performing the described operations, or \"NO\" if it's impossible. You can print each letter in any case (upper or lower).", "sample_inputs": ["5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n1 1 -1 1 -1"], "sample_outputs": ["YES\nNO\nYES\nYES\nNO"], "notes": "NoteIn the first test-case we can choose $$$(i, j)=(2, 3)$$$ twice and after that choose $$$(i, j)=(1, 2)$$$ twice too. These operations will transform $$$[1, -1, 0] \\to [1, -1, -2] \\to [1, 1, -2]$$$In the second test case we can't make equal numbers on the second position.In the third test case we can choose $$$(i, j)=(1, 2)$$$ $$$41$$$ times. The same about the fourth test case.In the last lest case, it is impossible to make array $$$a$$$ equal to the array $$$b$$$."}, "positive_code": [{"source_code": " 0)\n {\n $f[0][$i] = $f[0][$i - 1] ;\n $f[1][$i] = $f[1][$i - 1] ;\n \n if($arr_a[$i - 1] == 1) $f[0][$i] = true ;\n else if($arr_a[$i - 1] == -1) $f[1][$i] = true ;\n }\n }\n \n if($arr_a[0] != $arr_b[0]) echo \"NO\\n\" ;\n else \n {\n for($i = $n - 1; $i >= 1; $i --)\n {\n if($arr_b[$i] > $arr_a[$i] && !$f[0][$i]) break ;\n if($arr_b[$i] < $arr_a[$i] && !$f[1][$i]) break ;\n }\n \n echo $i >= 1 ? \"NO\\n\" : \"YES\\n\" ;\n }\n }\n?>"}, {"source_code": " $v){\n \n if($bup && $bdown){\n echo \"YES\\n\";\n continue 2;\n }\n if($v < $b[$k] && $bup == false){\n echo \"NO\\n\";\n continue 2;\n }\n if($v > $b[$k] && $bdown == false){\n echo \"NO\\n\";\n continue 2;\n }\n if($v == -1){\n $bdown = true;\n } \n if($v == 1){\n $bup = true;\n }\n }\n echo \"YES\\n\";\n }\n \n?>"}], "negative_code": [], "src_uid": "e425aa498e5a7fc3e518cec25eec6304"} {"nl": {"description": "Let's define $$$S(x)$$$ to be the sum of digits of number $$$x$$$ written in decimal system. For example, $$$S(5) = 5$$$, $$$S(10) = 1$$$, $$$S(322) = 7$$$.We will call an integer $$$x$$$ interesting if $$$S(x + 1) < S(x)$$$. In each test you will be given one integer $$$n$$$. Your task is to calculate the number of integers $$$x$$$ such that $$$1 \\le x \\le n$$$ and $$$x$$$ is interesting.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u00a0\u2014 number of test cases. Then $$$t$$$ lines follow, the $$$i$$$-th line contains one integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$) for the $$$i$$$-th test case.", "output_spec": "Print $$$t$$$ integers, the $$$i$$$-th should be the answer for the $$$i$$$-th test case.", "sample_inputs": ["5\n1\n9\n10\n34\n880055535"], "sample_outputs": ["0\n1\n1\n3\n88005553"], "notes": "NoteThe first interesting number is equal to $$$9$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "8e4194b356500cdaacca2b1d49c2affb"} {"nl": {"description": "You are given a positive integer $$$x$$$. Check whether the number $$$x$$$ is representable as the sum of the cubes of two positive integers.Formally, you need to check if there are two integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b$$$) such that $$$a^3+b^3=x$$$.For example, if $$$x = 35$$$, then the numbers $$$a=2$$$ and $$$b=3$$$ are suitable ($$$2^3+3^3=8+27=35$$$). If $$$x=4$$$, then no pair of numbers $$$a$$$ and $$$b$$$ is suitable.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case contains one integer $$$x$$$ ($$$1 \\le x \\le 10^{12}$$$). Please note, that the input for some test cases won't fit into $$$32$$$-bit integer type, so you should use at least $$$64$$$-bit integer type in your programming language.", "output_spec": "For each test case, output on a separate line: \"YES\" if $$$x$$$ is representable as the sum of the cubes of two positive integers. \"NO\" otherwise. You can output \"YES\" and \"NO\" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).", "sample_inputs": ["7\n1\n2\n4\n34\n35\n16\n703657519796"], "sample_outputs": ["NO\nYES\nNO\nNO\nYES\nYES\nYES"], "notes": "NoteThe number $$$1$$$ is not representable as the sum of two cubes.The number $$$2$$$ is represented as $$$1^3+1^3$$$.The number $$$4$$$ is not representable as the sum of two cubes.The number $$$34$$$ is not representable as the sum of two cubes.The number $$$35$$$ is represented as $$$2^3+3^3$$$.The number $$$16$$$ is represented as $$$2^3+2^3$$$.The number $$$703657519796$$$ is represented as $$$5779^3+7993^3$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $max_x)\n\t\t\t$max_x = $s[$i][0];\n\t\tif ($s[$i][1] > $max_y)\n\t\t\t$max_y = $s[$i][1];\n\t}\n\tfor ($i = 0; $i < $k; $i++) {\n\t\t$f[] = explode(\" \", trim(fgets(STDIN)));\n\t}\n\t$c = 0;\n\tfor ($i = 1; $i < $max_x; $i++) {\n\t\t$ans .= \"U\";\n\t\t$c++;\n\t}\n\n\tfor ($i = 1; $i < $max_y; $i++) {\n\t\t$ans .= \"L\";\n\t\t$c++;\n\t}\n\t$r = true;\n\tfor ($i = 0; $i < $n; $i++) {\n\t\tfor ($j = 0; $j < $m - 1; $j++) {\n\t\t\t$ans .= ($r ? \"R\" : \"L\");\n\t\t\t$c++;\n\t\t}\n\t\t$ans .= \"D\";\n\t\t$c++;\n\t\t$r = !$r;\n\t}\n\tprint \"$c\\n$ans\";\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $max_x)\n\t\t\t$max_x = $s[$i][0];\n\t\tif ($s[$i][1] > $max_y)\n\t\t\t$max_y = $s[$i][1];\n\t}\n\tfor ($i = 0; $i < $k; $i++) {\n\t\t$f[] = explode(\" \", trim(fgets(STDIN)));\n\t}\n\t$c = 0;\n\tfor ($i = 1; $i < $max_x; $i++) {\n\t\t$ans .= \"U\";\n\t\t$c++;\n\t}\n\n\tfor ($i = 1; $i < $max_y; $i++) {\n\t\t$ans .= \"L\";\n\t\t$c++;\n\t}\n\t$r = true;\n\tfor ($i = 0; $i < $n; $i++) {\n\t\tfor ($j = 0; $j < $m; $j++) {\n\t\t\t$ans .= ($r ? \"R\" : \"L\");\n\t\t\t$c++;\n\t\t}\n\t\t$ans .= \"D\";\n\t\t$c++;\n\t\t$r = !$r;\n\t}\n\tprint \"$c\\n$ans\";\n?>\n"}], "src_uid": "90ce515c561872b5e2ec5f8f75cd44fe"} {"nl": {"description": "The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0,\u2009y0) of a rectangular squared field of size x\u2009\u00d7\u2009y, after that a mine will be installed into one of the squares of the field. It is supposed to conduct exactly x\u00b7y tests, each time a mine is installed into a square that has never been used before. The starting cell of the robot always remains the same.After placing the objects on the field the robot will have to run a sequence of commands given by string s, consisting only of characters 'L', 'R', 'U', 'D'. These commands tell the robot to move one square to the left, to the right, up or down, or stay idle if moving in the given direction is impossible. As soon as the robot fulfills all the sequence of commands, it will blow up due to a bug in the code. But if at some moment of time the robot is at the same square with the mine, it will also blow up, but not due to a bug in the code.Moving to the left decreases coordinate y, and moving to the right increases it. Similarly, moving up decreases the x coordinate, and moving down increases it.The tests can go on for very long, so your task is to predict their results. For each k from 0 to length(s) your task is to find in how many tests the robot will run exactly k commands before it blows up.", "input_spec": "The first line of the input contains four integers x, y, x0, y0 (1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u2009500,\u20091\u2009\u2264\u2009x0\u2009\u2264\u2009x,\u20091\u2009\u2264\u2009y0\u2009\u2264\u2009y)\u00a0\u2014 the sizes of the field and the starting coordinates of the robot. The coordinate axis X is directed downwards and axis Y is directed to the right. The second line contains a sequence of commands s, which should be fulfilled by the robot. It has length from 1 to 100\u2009000 characters and only consists of characters 'L', 'R', 'U', 'D'.", "output_spec": "Print the sequence consisting of (length(s)\u2009+\u20091) numbers. On the k-th position, starting with zero, print the number of tests where the robot will run exactly k commands before it blows up.", "sample_inputs": ["3 4 2 2\nUURDRDRL", "2 2 2 2\nULD"], "sample_outputs": ["1 1 0 1 1 1 1 0 6", "1 1 1 1"], "notes": "NoteIn the first sample, if we exclude the probable impact of the mines, the robot's route will look like that: ."}, "positive_code": [{"source_code": " 1) ? $x0 - 1 : $x0;\n\t\t\tbreak;\n\t\tcase\"D\":\n\t\t\t$x0 = ($x0 < $x ) ? $x0 + 1 : $x0;\n\t\t\tbreak;\n\t\tcase\"L\":\n\t\t\t$y0 = ($y0 > 1) ? $y0 - 1 : $y0;\n\t\t\tbreak;\n\t\tcase \"R\":\n\t\t\t$y0 = ($y0 < $y ) ? $y0 + 1 : $y0;\n\t\t\tbreak;\n\t}\n\t//echo $x0, \" \", $y0, \"\\n\";\n\tif($i == strlen($cmd) - 1) { // last step\n\t\techo $t, \"\\n\";\n\t} else {\n\t\tif($visited[$x0][$y0]) {\n\t\t\techo \"0 \";\n\t\t} else {\n\t\t\techo \"1 \";\n\t\t\t$t --;\n\t\t}\n\t}\n\t$visited[$x0][$y0] = true;\n}\n?>"}, {"source_code": " 1) $x0 --;\n break;\n case 'R':\n if ($y0 < $y) $y0 ++;\n break;\n case 'D':\n if ($x0 < $x) $x0 ++;\n break;\n case 'L':\n if ($y0 > 1) $y0 --;\n }\n $tmp = ($x0 - 1) * $y + $y0;\n if ($visit[$tmp]==0) {\n $visit[$tmp] = 1;\n $ans[$step] = 1;\n }\n}\n$ans[$len] += $x * $y - array_sum($visit);\nfor ($i = 0;$i <= $len;$i ++) {\n if($i > 0) echo \" \";\n echo $ans[$i];\n}\necho \"\\n\";\n?>\n"}, {"source_code": " 1) ? $x0 - 1 : $x0;\n break;\n case\"D\":\n $x0 = ($x0 < $x ) ? $x0 + 1 : $x0;\n break;\n case\"L\":\n $y0 = ($y0 > 1) ? $y0 - 1 : $y0;\n break;\n case \"R\":\n $y0 = ($y0 < $y ) ? $y0 + 1 : $y0;\n break;\n }\n //echo $x0, \" \", $y0, \"\\n\";\n if($i == strlen($cmd) - 1) { // last step\n echo $t, \"\\n\";\n } else {\n if($visited[$x0][$y0]) {\n echo \"0 \";\n } else {\n echo \"1 \";\n $t --;\n }\n }\n $visited[$x0][$y0] = true;\n}\n?>"}], "negative_code": [{"source_code": " 1) $x0 --;\n break;\n case 'R':\n if ($y0 < $y) $y0 ++;\n break;\n case 'D':\n if ($x0 < $x) $x0 ++;\n break;\n case 'L':\n if ($y0 > 1) $y0 --;\n }\n $tmp = ($x0 - 1) * $y + $y0;\n if ($visit[$tmp]==0) {\n $visit[$tmp] = 1;\n $ans[$step] = 1;\n }\n}\n$ans[$len - 1] += $x * $y - array_sum($visit);\nfor ($i = 0;$i < $len;$i ++) {\n if($i > 0) echo \" \";\n echo $ans[$i];\n}\necho \"\\n\";\n?>\n"}], "src_uid": "22bebd448f93c0ff07d2be91e873521c"} {"nl": {"description": "You have array a1,\u2009a2,\u2009...,\u2009an. Segment [l,\u2009r] (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n) is good if ai\u2009=\u2009ai\u2009-\u20091\u2009+\u2009ai\u2009-\u20092, for all i (l\u2009+\u20092\u2009\u2264\u2009i\u2009\u2264\u2009r).Let's define len([l,\u2009r])\u2009=\u2009r\u2009-\u2009l\u2009+\u20091, len([l,\u2009r]) is the length of the segment [l,\u2009r]. Segment [l1,\u2009r1], is longer than segment [l2,\u2009r2], if len([l1,\u2009r1])\u2009>\u2009len([l2,\u2009r2]).Your task is to find a good segment of the maximum length in array a. Note that a segment of length 1 or 2 is always good.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of elements in the array. The second line contains integers: a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Print the length of the longest good segment in array a.", "sample_inputs": ["10\n1 2 3 5 8 13 21 34 55 89", "5\n1 1 1 1 1"], "sample_outputs": ["10", "2"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $max) {\n $max=$res;\n }\n $res=2;\n }\n}\nif ($res > $max) {\n $max=$res;\n}\necho $max "}], "negative_code": [{"source_code": ""}, {"source_code": " $max) {\n $max=$res;\n }\n $res=2;\n }\n}\necho $max;\n?>"}, {"source_code": " $max) {\n $max=$res;\n }\n $res=2;\n }\n}\n\necho $max "}], "src_uid": "f99a23bc65a1f5cdbf7909dba573ce51"} {"nl": {"description": "Sayaka Saeki is a member of the student council, which has $$$n$$$ other members (excluding Sayaka). The $$$i$$$-th member has a height of $$$a_i$$$ millimeters.It's the end of the school year and Sayaka wants to take a picture of all other members of the student council. Being the hard-working and perfectionist girl as she is, she wants to arrange all the members in a line such that the amount of photogenic consecutive pairs of members is as large as possible.A pair of two consecutive members $$$u$$$ and $$$v$$$ on a line is considered photogenic if their average height is an integer, i.e. $$$\\frac{a_u + a_v}{2}$$$ is an integer.Help Sayaka arrange the other members to maximize the number of photogenic consecutive pairs.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1\\le t\\le 500$$$) \u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 2000$$$) \u00a0\u2014 the number of other council members. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\le a_i \\le 2 \\cdot 10^5$$$) \u00a0\u2014 the heights of each of the other members in millimeters. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.", "output_spec": "For each test case, output on one line $$$n$$$ integers representing the heights of the other members in the order, which gives the largest number of photogenic consecutive pairs. If there are multiple such orders, output any of them.", "sample_inputs": ["4\n3\n1 1 2\n3\n1 1 1\n8\n10 9 13 15 3 16 9 13\n2\n18 9"], "sample_outputs": ["1 1 2 \n1 1 1 \n13 9 13 15 3 9 16 10 \n9 18"], "notes": "NoteIn the first test case, there is one photogenic pair: $$$(1, 1)$$$ is photogenic, as $$$\\frac{1+1}{2}=1$$$ is integer, while $$$(1, 2)$$$ isn't, as $$$\\frac{1+2}{2}=1.5$$$ isn't integer.In the second test case, both pairs are photogenic."}, "positive_code": [{"source_code": ""}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n}\r\n\r\n$n = IO::str();\r\n$res = array();\r\nwhile ($n--) {\r\n $t = IO::str();\r\n $arr = IO::arr();\r\n $chet = array();\r\n $nchet = array();\r\n\r\n foreach ($arr as $ar) {\r\n if ($ar % 2 == 0) {\r\n $chet[] = $ar;\r\n } else {\r\n $nchet[] = $ar;\r\n }\r\n }\r\n\r\n $res[] = array_merge($chet, $nchet);\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $z) {\r\n echo $z . ' ';\r\n }\r\n echo \"\\n\";\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n}\r\n\r\n$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = IO::arr();\r\n $b = $c = [];\r\n $count = 0;\r\n foreach ($a as $v) {\r\n if ($v % 2 == 0) {\r\n $c[$count] = $v;\r\n } else {\r\n $b[$count] = $v;\r\n }\r\n $count++;\r\n }\r\n $res = array_merge($b + $c);\r\n IO::line(implode(' ', $res));\r\n\r\n}\r\n\r\n?>"}], "negative_code": [], "src_uid": "fe2131c9228a2ec4365fdc3d0faa413a"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ integers.Your task is to determine if $$$a$$$ has some subsequence of length at least $$$3$$$ that is a palindrome.Recall that an array $$$b$$$ is called a subsequence of the array $$$a$$$ if $$$b$$$ can be obtained by removing some (possibly, zero) elements from $$$a$$$ (not necessarily consecutive) without changing the order of remaining elements. For example, $$$[2]$$$, $$$[1, 2, 1, 3]$$$ and $$$[2, 3]$$$ are subsequences of $$$[1, 2, 1, 3]$$$, but $$$[1, 1, 2]$$$ and $$$[4]$$$ are not.Also, recall that a palindrome is an array that reads the same backward as forward. In other words, the array $$$a$$$ of length $$$n$$$ is the palindrome if $$$a_i = a_{n - i - 1}$$$ for all $$$i$$$ from $$$1$$$ to $$$n$$$. For example, arrays $$$[1234]$$$, $$$[1, 2, 1]$$$, $$$[1, 3, 2, 2, 3, 1]$$$ and $$$[10, 100, 10]$$$ are palindromes, but arrays $$$[1, 2]$$$ and $$$[1, 2, 3, 1]$$$ are not.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. Next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$3 \\le n \\le 5000$$$) \u2014 the length of $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$ ($$$\\sum n \\le 5000$$$).", "output_spec": "For each test case, print the answer \u2014 \"YES\" (without quotes) if $$$a$$$ has some subsequence of length at least $$$3$$$ that is a palindrome and \"NO\" otherwise.", "sample_inputs": ["5\n3\n1 2 1\n5\n1 2 2 3 2\n3\n1 1 2\n4\n1 2 2 1\n10\n1 1 2 2 3 3 4 4 5 5"], "sample_outputs": ["YES\nYES\nNO\nYES\nNO"], "notes": "NoteIn the first test case of the example, the array $$$a$$$ has a subsequence $$$[1, 2, 1]$$$ which is a palindrome.In the second test case of the example, the array $$$a$$$ has two subsequences of length $$$3$$$ which are palindromes: $$$[2, 3, 2]$$$ and $$$[2, 2, 2]$$$.In the third test case of the example, the array $$$a$$$ has no subsequences of length at least $$$3$$$ which are palindromes.In the fourth test case of the example, the array $$$a$$$ has one subsequence of length $$$4$$$ which is a palindrome: $$$[1, 2, 2, 1]$$$ (and has two subsequences of length $$$3$$$ which are palindromes: both are $$$[1, 2, 1]$$$).In the fifth test case of the example, the array $$$a$$$ has no subsequences of length at least $$$3$$$ which are palindromes."}, "positive_code": [{"source_code": " 1) && ($y - $e[$c[$y]] > 1))\n {\n $f = 1;\n break;\n }\n }\n if($f == 0)\n {\n print \"NO\\n\";\n }\n else\n {\n print \"YES\\n\";\n }\n}\n?>"}, {"source_code": " $v){\n for($x = $k+2; $x < $n; $x++){\n if($a[$x] == $v){\n $bo = true;\n break 2;\n }\n }\n }\n \n if($bo){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n }\n"}, {"source_code": ""}], "negative_code": [{"source_code": "= count($a)/2; $j--) {\n\t\t\t\tif ($a[$j] == $ch && abs($i - $j) > 1 )\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t$t = trim(fgets(STDIN));\n\n\t$ans = '';\n\n\tfor ($o = 0; $o < $t; $o++) {\n\t\t$n = trim(fgets(STDIN));\n\t\t$a = explode(\" \", trim(fgets(STDIN)));\n\t\t\n\t\t$ans .= find($a) ? \"YES\\n\" : \"NO\\n\";\n\n\t}\n\tprint $ans;\n?>"}], "src_uid": "5139d222fbbfa70d50e990f5d6c92726"} {"nl": {"description": "Recently, Tokitsukaze found an interesting game. Tokitsukaze had $$$n$$$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $$$m$$$ ($$$1 \\le m \\le n$$$) special items of them.These $$$n$$$ items are marked with indices from $$$1$$$ to $$$n$$$. In the beginning, the item with index $$$i$$$ is placed on the $$$i$$$-th position. Items are divided into several pages orderly, such that each page contains exactly $$$k$$$ positions and the last positions on the last page may be left empty.Tokitsukaze would do the following operation: focus on the first special page that contains at least one special item, and at one time, Tokitsukaze would discard all special items on this page. After an item is discarded or moved, its old position would be empty, and then the item below it, if exists, would move up to this empty position. The movement may bring many items forward and even into previous pages, so Tokitsukaze would keep waiting until all the items stop moving, and then do the operation (i.e. check the special page and discard the special items) repeatedly until there is no item need to be discarded. Consider the first example from the statement: $$$n=10$$$, $$$m=4$$$, $$$k=5$$$, $$$p=[3, 5, 7, 10]$$$. The are two pages. Initially, the first page is special (since it is the first page containing a special item). So Tokitsukaze discards the special items with indices $$$3$$$ and $$$5$$$. After, the first page remains to be special. It contains $$$[1, 2, 4, 6, 7]$$$, Tokitsukaze discards the special item with index $$$7$$$. After, the second page is special (since it is the first page containing a special item). It contains $$$[9, 10]$$$, Tokitsukaze discards the special item with index $$$10$$$. Tokitsukaze wants to know the number of operations she would do in total.", "input_spec": "The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \\le n \\le 10^{18}$$$, $$$1 \\le m \\le 10^5$$$, $$$1 \\le m, k \\le n$$$)\u00a0\u2014 the number of items, the number of special items to be discarded and the number of positions in each page. The second line contains $$$m$$$ distinct integers $$$p_1, p_2, \\ldots, p_m$$$ ($$$1 \\le p_1 < p_2 < \\ldots < p_m \\le n$$$)\u00a0\u2014 the indices of special items which should be discarded.", "output_spec": "Print a single integer\u00a0\u2014 the number of operations that Tokitsukaze would do in total.", "sample_inputs": ["10 4 5\n3 5 7 10", "13 4 5\n7 8 9 10"], "sample_outputs": ["3", "1"], "notes": "NoteFor the first example: In the first operation, Tokitsukaze would focus on the first page $$$[1, 2, 3, 4, 5]$$$ and discard items with indices $$$3$$$ and $$$5$$$; In the second operation, Tokitsukaze would focus on the first page $$$[1, 2, 4, 6, 7]$$$ and discard item with index $$$7$$$; In the third operation, Tokitsukaze would focus on the second page $$$[9, 10]$$$ and discard item with index $$$10$$$. For the second example, Tokitsukaze would focus on the second page $$$[6, 7, 8, 9, 10]$$$ and discard all special items at once."}, "positive_code": [{"source_code": ""}, {"source_code": " $p) {\n if (bcdiv(bcsub($p, $off), $k) != $good) {\n $off = $i + 1;\n $good = bcdiv(bcsub($p, $off), $k);\n $result++;\n }\n}\necho $result;\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0)\n {\n $c += $f;\n $e++;\n $f = 0;\n $x--;\n }\n }\n}\nif($f > 0)\n{\n $e++;\n}\nprint $e;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $p) {\n if (bcdiv(bcsub($p, $off), $k) != $good) {\n $off = $i + 1;\n $good = bcdiv(bcsub($p, $off), $k);\n $result++;\n }\n}\necho $result;\n"}], "src_uid": "684273a4c6711295996e520739744b0f"} {"nl": {"description": "Given a positive integer $$$n$$$. Find three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ such that $$$a + b + c = n$$$ and $$$\\operatorname{gcd}(a, b) = c$$$, where $$$\\operatorname{gcd}(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$)\u00a0\u2014 the number of test cases. Description of the test cases follows. The first and only line of each test case contains a single integer $$$n$$$ ($$$10 \\le n \\le 10^9$$$).", "output_spec": "For each test case, output three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.", "sample_inputs": ["6\n18\n63\n73\n91\n438\n122690412"], "sample_outputs": ["6 9 3\n21 39 3\n29 43 1\n49 35 7\n146 219 73\n28622 122661788 2"], "notes": "NoteIn the first test case, $$$6 + 9 + 3 = 18$$$ and $$$\\operatorname{gcd}(6, 9) = 3$$$.In the second test case, $$$21 + 39 + 3 = 63$$$ and $$$\\operatorname{gcd}(21, 39) = 3$$$.In the third test case, $$$29 + 43 + 1 = 73$$$ and $$$\\operatorname{gcd}(29, 43) = 1$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "d4f4d6341f52cceb862faa89e85a42a3"} {"nl": {"description": "A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from $$$1$$$ to $$$9$$$ (inclusive) are round.For example, the following numbers are round: $$$4000$$$, $$$1$$$, $$$9$$$, $$$800$$$, $$$90$$$. The following numbers are not round: $$$110$$$, $$$707$$$, $$$222$$$, $$$1001$$$.You are given a positive integer $$$n$$$ ($$$1 \\le n \\le 10^4$$$). Represent the number $$$n$$$ as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number $$$n$$$ as a sum of the least number of terms, each of which is a round number.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is a line containing an integer $$$n$$$ ($$$1 \\le n \\le 10^4$$$).", "output_spec": "Print $$$t$$$ answers to the test cases. Each answer must begin with an integer $$$k$$$ \u2014 the minimum number of summands. Next, $$$k$$$ terms must follow, each of which is a round number, and their sum is $$$n$$$. The terms can be printed in any order. If there are several answers, print any of them.", "sample_inputs": ["5\n5009\n7\n9876\n10000\n10"], "sample_outputs": ["2\n5000 9\n1\n7 \n4\n800 70 6 9000 \n1\n10000 \n1\n10"], "notes": null}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if($b[$y] != 0)\n {\n $d = $b[$y];\n for($z = $y; $z < strlen($b) - 1; $z++)\n {\n $d .= 0;\n }\n $c[count($c)] = $d;\n }\n }\n print count($c) . \"\\n\";\n print implode(\" \", array_reverse($c)) . \"\\n\";\n}\n?>"}, {"source_code": "= 0; $y--)\n {\n if($b[$y] != 0)\n {\n $d = $b[$y];\n for($z = $y; $z < strlen($b) - 1; $z++)\n {\n $d .= 0;\n }\n $c[count($c)] = $d;\n }\n }\n print implode(\" \", array_reverse($c)) . \"\\n\";\n}\n?>"}, {"source_code": "Scan();\n\t$A = $Scanner->Scan();\n\t$B = $Scanner->Scan();\n\t$Alen = strlen($A);\n\t$Blen = strlen($B);\n\t$A_char = str_split($A);\n\t$B_char = str_split($B);\n\t$Acount = 0;\n\t$Bcount = 0;\n\t$cycle = $Alen * $Blen;\n\t$n = (int)($N / $cycle);\n\t$m = $N % $cycle;\n\tfor ($i = 0; $i < min($cycle, $N); $i++) {\n\t\t$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);\n\t\tif ($temp === -1) $Acount++;\n\t\telseif ($temp === 1) $Bcount++;\n\t\t\n\t\tif ($N > $cycle) {\n\t\t\tif ($i === $m - 1) {\n\t\t\t\t$Ac = $Acount;\n\t\t\t\t$Bc = $Bcount;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif ($N > $cycle) {\n\t\t$Acount = $Acount * $n + $Ac;\n\t\t$Bcount = $Bcount * $n + $Bc;\n\t}\n\n\tprint($Acount. \" \". $Bcount);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>"}, {"source_code": " 0, 2 => 0);\nfor($i=0;$i $lcm_len) {\n $k = intval($n / $lcm_len);\n $res[1] *= $k;\n $res[2] *= $k;\n\n $tail_n = $n%$lcm_len;\n // print \"tail_n: $tail_n | K = $k\\n\";\n for($i=0;$i<$tail_n;$i++) {\n if ($val = _cmp($line1[$i % $line1_len], $line2[$i % $line2_len])) {\n $res[$val]++;\n }\n // print \" = $val\\n\";\n // sleep(1);\n }\n}\n\nreturn $res;\n}\n\n\nfunction _cmp($a, $b) {\n// print \"cmp $a <> $b\";\n if ($a == $b) return 0;\n $w = array('R' => 0,'S' => 1,'P' => 2);\n\n return ($w[$a] + 1) % 3 == $w[$b]\n ? 1\n : 2;\n}\n\nfunction _test_cmp() {\n $a = 'RRRSSSPPP';\n $b = 'RSPRSPRSP';\n for($i=0;$i 'S','S'=>'P','P'=>'R');\n $gcm = $l1*$l2 / gcd($l1,$l2);\n if ($gcm<=$n)\n {\n for ($i=0;$i!=$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n $d1*=(int)($n/$gcm);\n $d2*=(int)($n/$gcm);\n }\n for ($i=0;$i!=$n%$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n fprintf($stdout,\"%d %d\\n\",$d1,$d2);\n?>"}], "negative_code": [{"source_code": "Scan();\n\t$A = $Scanner->Scan();\n\t$B = $Scanner->Scan();\n\t$Alen = strlen($A);\n\t$Blen = strlen($B);\n\t$A_char = str_split($A);\n\t$B_char = str_split($B);\n\t$Acount = 0;\n\t$Bcount = 0;\n\t$cycle = $Alen * $Blen;\n\t$n = (int)($N / $cycle);\n\t$m = $N % $cycle;\n\tfor ($i = 0; $i < min($cycle, $N); $i++) {\n\t\t$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);\n\t\tif ($temp === -1) $Acount++;\n\t\telseif ($temp === 1) $Bcount++;\n\t\t\n\t\tif ($N > $cycle) {\n\t\t\tif ($i === $m - 1) {\n\t\t\t\t$Ac = $Acount;\n\t\t\t\t$Bc = $Bcount;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif ($N > $cycle) {\n\t\t$Acount = $Acount * $n + $Ac;\n\t\t$Bcount *= $Bcount * $n + $Bc;\n\t}\n\n\tprint($Acount. \" \". $Bcount);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>"}, {"source_code": "Scan();\n\t$A = $Scanner->Scan();\n\t$B = $Scanner->Scan();\n\t$Alen = strlen($A);\n\t$Blen = strlen($B);\n\t$A_char = str_split($A);\n\t$B_char = str_split($B);\n\t$Acount = 0;\n\t$Bcount = 0;\n\tfor ($i = 0; $i < $N; $i++) {\n\t\t$temp = winner($A_char[$i % $Alen], $B_char[$i % $Blen]);\n\t\tif ($temp === -1) $Acount++;\n\t\telseif ($temp === 1) $Bcount++;\n\t}\n\t\n\tprint($Acount. \" \". $Bcount);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>"}, {"source_code": "Scan();\n\t$A = $Scanner->Scan();\n\t$B = $Scanner->Scan();\n\t$Alen = strlen($A);\n\t$Blen = strlen($B);\n\t\n\t$newA = $A;\n\tif ($N > $Alen) {\n\t\t$n = $N / $Alen + 1;\n\t\tfor ($i = 2; $i <= $n; $i++) {\n\t\t\t$newA .= $A;\n\t\t}\n\t}\n\n\t$newB = $B;\n\tif ($N > $Blen) {\n\t\t$n = $N / $Blen + 1;\n\t\tfor ($i = 2; $i <= $n; $i++) {\n\t\t\t$newB .= $B;\n\t\t}\n\t}\n\t\n\t$A_char = str_split($newA);\n\t$B_char = str_split($newB);\n\t$Acount = 0;\n\t$Bcount = 0;\n\tfor ($i = 0; $i < $N; $i++) {\n\t\t$temp = winner($A_char[$i], $B_char[$i]);\n\t\tif ($temp === -1) $Acount++;\n\t\telseif ($temp === 1) $Bcount++;\n\t}\n\t\n\tprint($Acount. \" \". $Bcount);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>"}, {"source_code": "'S','S'=>'P','P'=>'R');\n $gcm = $l1*$l2 / gcd($l1,$l2);\n if ($gcm<$n)\n {\n for ($i=0;$i!=$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n $d1*=(int)($n/$gcm);\n $d2*=(int)($n/$gcm);\n }\n for ($i=0;$i!=$n%$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n fprintf($stdout,\"%d %d\\n\",$d1,$d2);\n?>"}, {"source_code": "'S','S'=>'P','P'=>'R');\n $gcm = $l1*$l2 / gcd($l1,$l2);\n if ($gcm<$n)\n {\n for ($i=0;$i!=$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n $d1*=$n/$gcm;\n $d2*=$n/$gcm;\n }\n for ($i=0;$i!=$n%$gcm;++$i)\n {\n if ($s1[$p1]!=$s2[$p2])\n if ($t[$s1[$p1]]==$s2[$p2]) ++$d2; else ++$d1;\n ++$p1;\n if ($p1 == $l1) $p1 = 0;\n ++$p2;\n if ($p2 == $l2) $p2 = 0;\n }\n fprintf($stdout,\"%d %d\\n\",$d1,$d2);\n?>"}], "src_uid": "9a365e26f58ecb22a1e382fad3062387"} {"nl": {"description": "Permutation p is an ordered set of integers p1,\u2009\u2009\u2009p2,\u2009\u2009\u2009...,\u2009\u2009\u2009pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,\u2009\u2009\u2009p2,\u2009\u2009\u2009...,\u2009\u2009\u2009pn.Your task is to find such permutation p of length n, that the group of numbers |p1\u2009-\u2009p2|,\u2009|p2\u2009-\u2009p3|,\u2009...,\u2009|pn\u2009-\u20091\u2009-\u2009pn| has exactly k distinct elements.", "input_spec": "The single line of the input contains two space-separated positive integers n, k (1\u2009\u2264\u2009k\u2009<\u2009n\u2009\u2264\u2009105).", "output_spec": "Print n integers forming the permutation. If there are multiple answers, print any of them.", "sample_inputs": ["3 2", "3 1", "5 2"], "sample_outputs": ["1 3 2", "1 2 3", "1 3 2 4 5"], "notes": "NoteBy |x| we denote the absolute value of number x. "}, "positive_code": [{"source_code": " $g))\n {\n if($e[$h - 1] != $d[$f])\n {\n array_push($e, $d[$f]);\n }\n break;\n }\n else\n {\n $e[$h] = $d[$f];\n $h++;\n $e[$h] = $d[$g];\n $h++;\n $f++;\n $g--;\n }\n }\n for($x = $b + 1; $x < $a; $x++)\n {\n $e[$x] = $d[$x];\n }\n print trim(implode(\" \", $e));\n \n}\n?>"}, {"source_code": "0) {\n\t\tif ($counter%2 == 0) {\n\t\t\t$res[$counter] = $res[$counter-1] - $count;\n\t\t} else {\n\t\t\t$res[$counter] = $res[$counter-1] + $count;\n\t\t}\n\t\t$count--;\n\t\t$counter++;\n\t}\n}\necho implode(\" \", $res);\n?>"}, {"source_code": "0) {\n\t\tif ($i%2 == 0) {\n\t\t\t$result[$i] = $result[$i-1] - $input_k;\n\t\t} else {\n\t\t\t$result[$i] = $result[$i-1] + $input_k;\n\t\t}\n\t\t$input_k--;\n\t\t$i++;\n\t}\n}\necho implode(\" \", $result);\n?>"}, {"source_code": "= $k; $j--)\n echo $j.' ';\n}else{\n $k = floor($i/2) + 1;\n $t = $n - floor($i/2) +1;\n for($j = $k; $j <= $t; $j++)\n echo $j.' ';\n}"}], "negative_code": [{"source_code": " $g))\n {\n array_push($e, $d[$f]);\n break;\n }\n else\n {\n $e[$h] = $d[$f];\n $h++;\n $e[$h] = $d[$g];\n $h++;\n $f++;\n $g--;\n }\n }\n for($x = $b + 1; $x < $a; $x++)\n {\n $e[$x] = $d[$x];\n }\n print trim(implode(\" \", $e));\n \n}\n?>"}, {"source_code": ""}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n\tstatic function compareItem(Item $a_item, Item $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/* 50ms 30ms faster than class static func\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"Item\", \"compareItem\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n/* static \u2192 private?\t\n static function cmp_obj($a, $b) {\n $a_t = $a->getType();\n $b_t = $b->getType();\n $a_p = $a->getType();\n $b_p = $b->getType();\n\n if ($a_t < $b_t) {\n return 1;\n } elseif ($a_t = $b_t) {\n\t\t\tif ($a_p > $b_p) {\n\t\t\t\treturn 1;\n\t\t\t} elseif ($a_p = $b_p) {\n\t\t\t\treturn 0;\n\t\t\t} elseif ($a_p < $b_p) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} \n\t}\n*/\n}\n\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\t//usort($ITEMS, array(\"ITEM\", \"compare\"));\n\tusort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n static function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"Item\", \"compareItem\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n\tstatic function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"Item\", \"compareItem\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t $PRICE = $Scanner->Scan();\n\t\t $TYPE = (int)$Scanner->Scan();\n\t\t if ($TYPE === 1) $STOOLS[$i + 1] = $PRICE;\n\t\t else if ($TYPE === 2) $PENCILS[$i + 1] = $PRICE;\n\t}\n\t\n\t//if (!asort($STOOLS)) print(\"err\");\n\t//In case $STOOLS is null, this is printed;\n\t\n\tasort($STOOLS);\n\tasort($PENCILS);\n\t$min = 0;\n\t$sum = 0;\n\t$num = 0;\n\t$diff = count($STOOLS) - $inp_K;\n\tif ($diff >= 0) {\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\tif ($num <= $diff) {\n\t\t\t\tif ($num === 0) $min = $STOOLS_val / 2;\n\t\t\t\telse $sum += $STOOLS_val;\n\t\t\t\t$KART[0][] = $STOOLS_key;\n\t\t\t} else {\n\t\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t\t$KART[$num - $diff][] = $STOOLS_key;\n\t\t\t}\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\t$PEN_FLAG = 0;\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($PEN_FLAG === 0) {\n\t\t\t\t//$min = min($min, $PENCILS_val / 2) + ;\n\t\t\t\tif ($min > $PENCILS_val / 2) $min = $PENCILS_val / 2 + 2 * $min;\n\t\t\t\telseif ($min <= $PENCILS_val / 2) $min = $PENCILS_val + $min;\n\t\t\t\t$PEN_FLAG = 1;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t}\n\t\t\t$KART[0][] = $PENCILS_key;\n\t\t}\n\t\t$sum = $sum + $min;\n\t} elseif($diff < 0)\t{\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t$KART[$num][] = $STOOLS_key;\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($diff !== 0) {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$num][] = $PENCILS_key;\n\t\t\t\t$diff++;\n\t\t\t\t$num++;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$inp_K - 1][] = $PENCILS_key;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}], "negative_code": [{"source_code": " 1)\n{\n print number_format($i, 1, \".\", \"\") . \"\\n\"; \n for($x = 0; $x < count($t) - 1; $x++)\n {\n print implode(\" \", $t[$x]) . \"\\n\";\n }\n print implode(\" \", $t[$x]);\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n{\n print number_format($i, 1, \".\", \"\") . \"\\n\"; \n for($x = 0; $x < count($t) - 1; $x++)\n {\n print implode(\" \", $t[$x]) . \"\\n\";\n }\n print implode(\" \", $t[$x]);\n}\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\tif ($TYPE === 1) $ITEMS[$i][] = $TYPE + 2;\n\t\telse $ITEMS[$i][] = $TYPE;\n\t\t$ITEMS[$i][] = $PRICE;\n\t}\n\t\n\tarsort($ITEMS);\n\t$keys = array_keys($ITEMS);\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t$KART[$i][] = $keys[$i] + 1;\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $keys[$i] + 1;\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i][0];\n\t\tif ($i < $inp_K - 1 && $type === 3) {\n\t\t\t$sum += $ITEMS[$i][1] / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 3) {\n\t\t\t$sum += $ITEMS[$i][1];\n\t\t}\n\t}\n\n\tif ($keys[$inp_K - 1] === 3) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i][1];\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n static function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t//$Scanner = new Scanner(\"php://stdin\");\n\t$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"Item\", \"compareItem\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\tif ($TYPE === 1) $ITEMS[$i][] = $TYPE + 2;\n\t\telse $ITEMS[$i][] = $TYPE;\n\t\t$ITEMS[$i][] = $PRICE;\n\t}\n\t\n\tarsort($ITEMS);\n\t$keys = array_keys($ITEMS);\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t$KART[$i][] = $keys[$i] + 1;\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $keys[$i] + 1;\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i][0];\n\t\tif ($i < $inp_K - 1 && $type === 3) {\n\t\t\t$sum += $ITEMS[$i][1] / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 3) {\n\t\t\t$sum += $ITEMS[$i][1];\n\t\t}\n\t}\n\n\t\n\t//if ($ITEMS[$inp_K - 1][0] === 3) {\n\tif ($ITEMS[$keys[$inp_K - 1]][0] === 3) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$keys[$i]][1];\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t $PRICE = $Scanner->Scan();\n\t\t $TYPE = (int)$Scanner->Scan();\n\t\t if ($TYPE === 1) $STOOLS[$i + 1] = $PRICE;\n\t\t else if ($TYPE === 2) $PENCILS[$i + 1] = $PRICE;\n\t}\n\t\n\tif (!asort($STOOLS)) print(\"err\");\n\t\n\t$min = 0;\n\t$sum = 0;\n\t$num = 0;\n\t$diff = count($STOOLS) - $inp_K;\n\tif ($diff >= 0) {\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\tif ($num <= $diff) {\n\t\t\t\tif ($num === 0) $min = $STOOLS_val / 2;\n\t\t\t\t$KART[0][] = $STOOLS_key;\n\t\t\t} else {\n\t\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t\t$KART[$num - $diff][] = $STOOLS_key;\n\t\t\t}\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\t$PEN_FLAG = 0;\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($PEN_FLAG === 0) {\n\t\t\t\t//$min = min($min, $PENCILS_val / 2) + ;\n\t\t\t\tif ($min > $PENCILS_val / 2) $min = $PENCILS_val / 2 + 2 * $min;\n\t\t\t\telseif ($min <= $PENCILS_val / 2) $min = $PENCILS_val + $min;\n\t\t\t\t$PEN_FLAG = 1;\n\t\t\t}\n\t\t\t$KART[0][] = $PENCILS_key;\n\t\t}\n\t\t$sum = $sum + $min;\n\t} elseif($diff < 0)\t{\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t$KART[$num][] = $STOOLS_key;\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($diff !== 0) {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$num][] = $PENCILS_key;\n\t\t\t\t$diff++;\n\t\t\t\t$num++;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$inp_K - 1][] = $PENCILS_key;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n/* static \u2192 private?\t\n static function cmp_obj($a, $b) {\n $a_t = $a->getType();\n $b_t = $b->getType();\n $a_p = $a->getType();\n $b_p = $b->getType();\n\n if ($a_t < $b_t) {\n return 1;\n } elseif ($a_t = $b_t) {\n\t\t\tif ($a_p > $b_p) {\n\t\t\t\treturn 1;\n\t\t\t} elseif ($a_p = $b_p) {\n\t\t\t\treturn 0;\n\t\t\t} elseif ($a_p < $b_p) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} \n\t}\n*/\n}\n\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\t//usort($ITEMS, array(\"ITEM\", \"compare\"));\n\tusort($ITEMS, \"compare\");\n\tvar_dump($ITEMS);\t\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n static function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"Item\", \"compare\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t $PRICE = $Scanner->Scan();\n\t\t $TYPE = (int)$Scanner->Scan();\n\t\t if ($TYPE === 1) $STOOLS[$i + 1] = $PRICE;\n\t\t else if ($TYPE === 2) $PENCILS[$i + 1] = $PRICE;\n\t}\n\t\n\t//if (!asort($STOOLS)) print(\"err\");\n\t//In case $STOOLS is null, this is printed;\n\t\n\tasort($STOOLS);\n\t$min = 0;\n\t$sum = 0;\n\t$num = 0;\n\t$diff = count($STOOLS) - $inp_K;\n\tif ($diff >= 0) {\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\tif ($num <= $diff) {\n\t\t\t\tif ($num === 0) $min = $STOOLS_val / 2;\n\t\t\t\telse $sum += $STOOLS_val;\n\t\t\t\t$KART[0][] = $STOOLS_key;\n\t\t\t} else {\n\t\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t\t$KART[$num - $diff][] = $STOOLS_key;\n\t\t\t}\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\t$PEN_FLAG = 0;\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($PEN_FLAG === 0) {\n\t\t\t\t//$min = min($min, $PENCILS_val / 2) + ;\n\t\t\t\tif ($min > $PENCILS_val / 2) $min = $PENCILS_val / 2 + 2 * $min;\n\t\t\t\telseif ($min <= $PENCILS_val / 2) $min = $PENCILS_val + $min;\n\t\t\t\t$PEN_FLAG = 1;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t}\n\t\t\t$KART[0][] = $PENCILS_key;\n\t\t}\n\t\t$sum = $sum + $min;\n\t} elseif($diff < 0)\t{\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t$KART[$num][] = $STOOLS_key;\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($diff !== 0) {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$num][] = $PENCILS_key;\n\t\t\t\t$diff++;\n\t\t\t\t$num++;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$inp_K - 1][] = $PENCILS_key;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n static function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\t//usort($ITEMS, array(\"ITEM\", \"compare\"));\n\tusort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\tif ($TYPE === 1) $ITEMS[$i][] = $TYPE + 2;\n\t\telse $ITEMS[$i][] = $TYPE;\n\t\t$ITEMS[$i][] = $PRICE;\n\t}\n\t\n\tarsort($ITEMS);\n\t$keys = array_keys($ITEMS);\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t$KART[$i][] = $keys[$i] + 1;\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $keys[$i] + 1;\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i][0];\n\t\tif ($i < $inp_K - 1 && $type === 3) {\n\t\t\t$sum += $ITEMS[$i][1] / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 3) {\n\t\t\t$sum += $ITEMS[$i][1];\n\t\t}\n\t}\n\n\t\n\t//if ($ITEMS[$inp_K - 1][0] === 3) {\n\tif ($ITEMS[$keys[$inp_K - 1]][0] === 3) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i][1];\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t $PRICE = $Scanner->Scan();\n\t\t $TYPE = (int)$Scanner->Scan();\n\t\t if ($TYPE === 1) $STOOLS[$i + 1] = $PRICE;\n\t\t else if ($TYPE === 2) $PENCILS[$i + 1] = $PRICE;\n\t}\n\t\n\t//if (!asort($STOOLS)) print(\"err\");\n\t//In case $STOOLS is null, this is printed;\n\t\n\tasort($STOOLS);\n\t$min = 0;\n\t$sum = 0;\n\t$num = 0;\n\t$diff = count($STOOLS) - $inp_K;\n\tif ($diff >= 0) {\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\tif ($num <= $diff) {\n\t\t\t\tif ($num === 0) $min = $STOOLS_val / 2;\n\t\t\t\t$sum += $STOOLS_val;\n\t\t\t\t$KART[0][] = $STOOLS_key;\n\t\t\t} else {\n\t\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t\t$KART[$num - $diff][] = $STOOLS_key;\n\t\t\t}\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\t$PEN_FLAG = 0;\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($PEN_FLAG === 0) {\n\t\t\t\t//$min = min($min, $PENCILS_val / 2) + ;\n\t\t\t\tif ($min > $PENCILS_val / 2) $min = $PENCILS_val / 2 + 2 * $min;\n\t\t\t\telseif ($min <= $PENCILS_val / 2) $min = $PENCILS_val + $min;\n\t\t\t\t$PEN_FLAG = 1;\n\t\t\t}\n\t\t\t$sum += $PENCILS_val;\n\t\t\t$KART[0][] = $PENCILS_key;\n\t\t}\n\t\t$sum = $sum + $min;\n\t} elseif($diff < 0)\t{\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t$KART[$num][] = $STOOLS_key;\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($diff !== 0) {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$num][] = $PENCILS_key;\n\t\t\t\t$diff++;\n\t\t\t\t$num++;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$inp_K - 1][] = $PENCILS_key;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t $PRICE = $Scanner->Scan();\n\t\t $TYPE = (int)$Scanner->Scan();\n\t\t if ($TYPE === 1) $STOOLS[$i + 1] = $PRICE;\n\t\t else if ($TYPE === 2) $PENCILS[$i + 1] = $PRICE;\n\t}\n\t\n\t//if (!asort($STOOLS)) print(\"err\");\n\t//In case $STOOLS is null, this is printed;\n\t\n\tasort($STOOLS);\n\t$min = 0;\n\t$sum = 0;\n\t$num = 0;\n\t$diff = count($STOOLS) - $inp_K;\n\tif ($diff >= 0) {\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\tif ($num <= $diff) {\n\t\t\t\tif ($num === 0) $min = $STOOLS_val / 2;\n\t\t\t\telse $sum += $STOOLS_val;\n\t\t\t\t$KART[0][] = $STOOLS_key;\n\t\t\t} else {\n\t\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t\t$KART[$num - $diff][] = $STOOLS_key;\n\t\t\t}\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\t$PEN_FLAG = 0;\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($PEN_FLAG === 0) {\n\t\t\t\t//$min = min($min, $PENCILS_val / 2) + ;\n\t\t\t\tif ($min > $PENCILS_val / 2) $min = $PENCILS_val / 2 + 2 * $min;\n\t\t\t\telseif ($min <= $PENCILS_val / 2) $min = $PENCILS_val + $min;\n\t\t\t\t$PEN_FLAG = 1;\n\t\t\t}\n\t\t\t$sum += $PENCILS_val;\n\t\t\t$KART[0][] = $PENCILS_key;\n\t\t}\n\t\t$sum = $sum + $min;\n\t} elseif($diff < 0)\t{\n\t\tforeach ($STOOLS as $STOOLS_key => $STOOLS_val) {\n\t\t\t$sum += $STOOLS_val / 2;\n\t\t\t$KART[$num][] = $STOOLS_key;\n\t\t\t$num++;\n\t\t}\n\t\t\n\t\tforeach ($PENCILS as $PENCILS_key => $PENCILS_val) {\n\t\t\tif ($diff !== 0) {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$num][] = $PENCILS_key;\n\t\t\t\t$diff++;\n\t\t\t\t$num++;\n\t\t\t} else {\n\t\t\t\t$sum += $PENCILS_val;\n\t\t\t\t$KART[$inp_K - 1][] = $PENCILS_key;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}, {"source_code": "index = $index;\n\t\t$this->type = $type;\n\t\t$this->price = $price;\n\t}\n\n\tpublic function getIndex() {\n\t\treturn $this->index;\n\t}\n\t\n\tpublic function getPrice() {\n\t\treturn $this->price;\n\t}\n\t\n\tpublic function getType() {\n\t\treturn $this->type;\n\t}\n\n static function compareItem($a_item, $b_item) {\n\t\t$a_t = $a_item->getType();\n\t\t$b_t = $b_item->getType();\n\t\t$a_p = $a_item->getPrice();\n\t\t$b_p = $b_item->getPrice();\n\n\t\tif ($a_t < $b_t) return -1;\n\t\telseif ($a_t > $b_t) return 1;\n\t\telseif ($a_t === $b_t) {\n\t\t\tif ($a_p > $b_p) return -1;\n\t\t\telseif ($a_p === $b_p) return 0;\n\t\t\telseif ($a_p < $b_p) return 1;\n\t\t}\n\t} \n}\n/*\nfunction compare(Item $a_item , Item $b_item){\n\t//$a_t = $a->getType();\n\t//$b_t = $b->getType();\n\t//$a_p = $a->getPrice();\n\t//$b_p = $b->getPrice();\n\t$a_t = $a_item->getType();\n\t$b_t = $b_item->getType();\n\t$a_p = $a_item->getPrice();\n\t$b_p = $b_item->getPrice();\n\n\tif ($a_t < $b_t) {\n\t\treturn -1;\n\t} elseif ($a_t > $b_t) {\n\t\treturn 1;\n\t//} elseif ($a_t = $b_t) {\n\t} elseif ($a_t === $b_t) {\n\t\tif ($a_p > $b_p) {\n\t\t\t//return 1;\n\t\t\treturn -1;\n\t\t//} elseif ($a_p = $b_p) {\n\t\t} elseif ($a_p === $b_p) {\n\t\t\treturn 0;\n\t\t} elseif ($a_p < $b_p) {\n\t\t\t//return -1;\n\t\t\treturn 1;\n\t\t}\n\t} \n}\n*/\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$inp_N = (int)$Scanner->Scan();\n\t$inp_K = (int)$Scanner->Scan();\n\t\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$PRICE = $Scanner->Scan();\n\t\t$TYPE = (int)$Scanner->Scan();\n\t\t$ITEMS[] = new Item($i + 1, $TYPE, $PRICE);\n\t}\n\t\n\tusort($ITEMS, array(\"ITEM\", \"compare\"));\n\t//usort($ITEMS, \"compare\");\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\tif ($i < $inp_K - 1) {\n\t\t\t//$KART[$i] = $ITEMS[$i]->getIndex();\n\t\t\t$KART[$i][] = $ITEMS[$i]->getIndex();\n\t\t} elseif ($i >= $inp_K - 1) {\n\t\t\t$KART[$inp_K - 1][] = $ITEMS[$i]->getIndex();\n\t\t}\n\t}\n\n\tfor ($i = 0; $i < $inp_N; $i++) {\n\t\t$type = $ITEMS[$i]->getType();\n\t\tif ($i < $inp_K - 1 && $type === 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice() / 2;\n\t\t} elseif ($i >= $inp_K - 1 || $type !== 1) {\n\t\t\t$sum += $ITEMS[$i]->getPrice();\n\t\t}\n\t}\n\n\t//$min = 1E9 + 1;\n\tif ($ITEMS[$inp_K - 1]->getType() === 1) {\n\t\t$min = 1E9 + 1;\n\t\tfor ($i = $inp_K - 1; $i < $inp_N; $i++) {\n\t\t\t$temp = $ITEMS[$i]->getPrice();\n\t\t\t$min = min($temp, $min);\n\t\t}\n\t}\n\t$sum -= $min / 2;\n\t\n\tprintf(\"%.1f\", $sum);\n\tprint(\"\\n\");\n\tfor ($i = 0; $i < $inp_K; $i++) {\n\t\t$count = count($KART[$i]);\n\t\t//print($sum);\n\t\tprint($count);\n\t\tprint(\" \");\n\t\t$cou = 0;\n\t\t$c = 0;\n\t\tforeach ($KART[$i] as $as_i) {\n\t\t\tif ($i !== $inp_K - 1) {\n\t\t\t\tprint($as_i);\n\t\t\t\t$cou++;\n\t\t\t\t//if ($cou != $count - 1) {\n\t\t\t\tif ($cou != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t} else {\n\t\t\t\t\tprint(\"\\n\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint($as_i);\n\t\t\t\t$c++;\n\t\t\t\t//if ($c != $count - 1) {\n\t\t\t\tif ($c != $count) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t$Scanner->close();\n}\n\nob_end_clean();\nsolve();\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link or ''php://stdin' err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\n\t\t//err $c_row = array(\"\\n\", \"\\r\", \"\\r\\n\");\n\t\t$c_row = array(\"\\r\\n\", \"\\r\", \"\\n\");\n\t\t$contents = str_replace($c_row, \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Id;\n\t\t$sc = $this->Scanners[$x];\n\t\t$this->Id = ++$x;\n\t\treturn $sc;\n\t}\n\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n/*\n====begin=====\n\n//input $inp_ or upper\n//block $temp_\n//two block$ttemp_\n//as \t $as_\n//instance $(Upper)\n//ref $ref\n//class menba $^Upper\n\n====end=======\n\n===== class begin =====\n\n//error_reporting(0);\n//$Scanner = new Scanner(\"php://stdin\");\n//ref \"#109_div2_B_1230942 laurenceHR\"\nclass LineScanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $LineIds_Of_ScanIds= array();\n\tprivate $LinesScanners = array();\n\tprivate $LastScanIds_Of_LineIds = array();\n\tprivate $Scan_number = 0;\n\tprivate $Scanline_number = 0;\n\t\n\tpublic function __construct($opend){\n\t\tif((!is_file($opend) && !is_link($opend)) && $opend !== \"php://stdin\"){\n \t\t\tprint(\"file or link err\");\n \t\t\texit;\n\t\t}\n\t\t\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t\n\t\t$temp_lines = explode(\"\\n\", $contents);\n\t\t$temp_linescanners = array();\n\t\t$temp_x = 0;\n\t\t$temp_y = 0;\n\t\t//--attention for initting of array--(these is not needed but for easily reading)//\n\t\t$ttemp_scanners = array();\n\t\t//$del = Array(\"\\n\",\"\\r\",\"\\n\\r\");\n\t\tforeach ($temp_lines as $as_line) {\n\t\t\tif (strlen($as_line) === 0) {\n\t\t\t\tprint(\"input err\");\n\t\t\t}\n\t\t\t\n\t\t\t//$as_line = str_replace($del,'',$as_line);\n\t\t\t$temp_linescanners[] = $as_line;\n\t\t\t$ttemp_line_scanners = explode(\" \", $as_line);\n\t\t\t//$ttemp_scanners = array();\n\t\t\tforeach ($ttemp_line_scanners as $as_sc) {\n\t\t\t\t$ttemp_scanners[] = $as_sc;\n\t\t\t\t$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;\n\t\t\t\t$temp_x++;\n\t\t\t}\n\t\t\t$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;\n\t\t\t$temp_y++;\n\t\t}\n\t\t$this->Scanners = $ttemp_scanners;\n\t\t$this->LinesScanners = $temp_linescanners;\n\t}\n\t\n\tfunction Scan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"scan err\");\n\t\t}\n\t\t\t\t\n\t\t$sc = $this->Scanners[$x];\n\t\t//--attention for ++$x//\n\t\t//$this->Scan_number = $x++;\n\t\t$this->Scan_number = ++$x;\n\t\t$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];\n\t\treturn $sc;\n\t}\n\t\n\tfunction LineScan(){\n\t\t$x = $this->Scan_number;\n\t\t$y = $this->Scanline_number;\n\t\tif ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {\n\t\t\tprint(\"linescan err\");\n\t\t}\n\t\t\n\t\t$lsc = $this->LinesScanners[$y];\n\t\t$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;\n\t\t$this->Scanline_number = $y + 1;\n\t\treturn $lsc;\n\t}\n\t\n\tfunction close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\nclass Token{\n\tprivate $token;\n\tprivate $tok;\n\t\n\tpublic function __construct($str_line, $tok) {\n\t\t$this->tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n \tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray() {\n\t\t$temp_arr = array();\n\t\t$flag = -1;\n\t\twhile ($flag !== 1) {\n\t\t\t$thisToken = $this->nextToken();\n\t\t\tif ($thisToken !== false) {\n\t\t\t\t$temp_arr[] = $thisToken;\n\t\t\t} else {\n\t\t\t\t$flag = 1;\n\t\t\t}\n\t\t}\n\t\treturn $temp_arr;\n\t}\n\n\tpublic function nnextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->token;\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n===== class end ======\n\n=== function begin ===\n\nfunction get_line() {\n $stdin = fopen(\"php://stdin\", \"r\"); \n $line = rtrim($stdin, \"\\n\"); \n fclose($stdin); \n return $line; \n}\n\nfunction num_printf($i){\n\tif (is_float($i)) {\n\t\tprintf(\"%.0f\", $i);\n\t}\n\tif (is_int($i)) {\n\t\tprintf(\"%d\", $i);\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\n== function end ======\n*/\n\n?>"}], "src_uid": "06c7834aa4d06d6fcebfa410054f1b8c"} {"nl": {"description": "In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes are characterized by different skills. Unfortunately, the skills that are uncommon for the given character's class are quite difficult to obtain. To avoid this limitation, there is the so-called transmigration. Transmigration is reincarnation of the character in a new creature. His soul shifts to a new body and retains part of his experience from the previous life. As a result of transmigration the new character gets all the skills of the old character and the skill levels are reduced according to the k coefficient (if the skill level was equal to x, then after transmigration it becomes equal to [kx], where [y] is the integral part of y). If some skill's levels are strictly less than 100, these skills are forgotten (the character does not have them any more). After that the new character also gains the skills that are specific for his class, but are new to him. The levels of those additional skills are set to 0. Thus, one can create a character with skills specific for completely different character classes via transmigrations. For example, creating a mage archer or a thief warrior is possible. You are suggested to solve the following problem: what skills will the character have after transmigration and what will the levels of those skills be?", "input_spec": "The first line contains three numbers n, m and k \u2014 the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; n and m are integers, and k is a real number with exactly two digits after decimal point (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u200920, 0.01\u2009\u2264\u2009k\u2009\u2264\u20090.99). Then follow n lines, each of which describes a character's skill in the form \"name exp\" \u2014 the skill's name and the character's skill level: name is a string and exp is an integer in range from 0 to 9999, inclusive. Then follow m lines each of which contains names of skills specific for the class, into which the character transmigrates. All names consist of lowercase Latin letters and their lengths can range from 1 to 20 characters, inclusive. All character's skills have distinct names. Besides the skills specific for the class into which the player transmigrates also have distinct names.", "output_spec": "Print on the first line number z \u2014 the number of skills the character will have after the transmigration. Then print z lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.", "sample_inputs": ["5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost"], "sample_outputs": ["6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " -1) {\n $skills[$name] = bcadd($expK, '0.00', 0);\n }\n}\n\nfor ($i = 0; $i < $m; $i++) {\n $name = trim(fgets($input));\n\n $skills[$name] = $skills[$name] ?? '0';\n}\n\nfwrite($output, count($skills) . PHP_EOL);\n\nksort($skills);\n\nforeach ($skills as $skill => $value) {\n fwrite($output, $skill . ' ' . $value . PHP_EOL);\n}\n"}], "negative_code": [{"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n}\n$i = array();\nfor($x = 0; $x < $b; $x++)\n{\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n}\n$k = array_diff($i, $d);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = 0;\n}\n$m = array_merge($d, $k);\n$n = array_merge($e, $l);\n$o = $m;\nasort($o);\n$p = array_keys($o);\n$q = array();\nsort($o);\nfor($x = 0; $x < count($o); $x++)\n{\n $q[$x] = $n[$p[$x]];\n}\nif(count($o) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n }\n $k = array_diff($i, $d);\n $l = array();\n for($x = 0; $x < count($k); $x++)\n {\n $l[$x] = 0;\n }\n $m = array_merge($d, $k);\n $n = array_merge($e, $l);\n $o = $m;\n asort($o);\n $p = array_keys($o);\n $q = array();\n sort($o);\n for($x = 0; $x < count($o); $x++)\n {\n $q[$x] = $n[$p[$x]];\n }\n if(count($o) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n }\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n }\n $k = array_diff($i, $d);\n $l = array();\n for($x = 0; $x < count($k); $x++)\n {\n $l[$x] = 0;\n }\n $m = array_merge($d, $k);\n $n = array_merge($e, $l);\n $o = $m;\n asort($o);\n $p = array_keys($o);\n $q = array();\n sort($o);\n for($x = 0; $x < count($o); $x++)\n {\n $q[$x] = $n[$p[$x]];\n }\n if(count($o) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n }\n $k = array_diff($i, $d);\n $l = array();\n for($x = 0; $x < count($k); $x++)\n {\n $l[$x] = 0;\n }\n $m = array_merge($d, $k);\n $n = array_merge($e, $l);\n $o = $m;\n asort($o);\n $p = array_keys($o);\n $q = array();\n sort($o);\n for($x = 0; $x < count($o); $x++)\n {\n $q[$x] = $n[$p[$x]];\n }\n if(count($o) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n }\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n}\n$i = array();\nfor($x = 0; $x < $b; $x++)\n{\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n}\n$k = array_diff($i, $d);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = 0;\n}\n$m = array_merge($d, $k);\n$n = array_merge($e, $l);\n$o = $m;\nasort($o);\n$p = array_keys($o);\n$q = array();\nsort($o);\nfor($x = 0; $x < count($o); $x++)\n{\n $q[$x] = $n[$p[$x]];\n}\nif(count($o) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n}\n$i = array();\nfor($x = 0; $x < $b; $x++)\n{\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n}\n$k = array_diff($i, $d);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = 0;\n}\n$m = array_merge($d, $k);\n$n = array_merge($e, $l);\n$o = $m;\nasort($o);\n$p = array_keys($o);\n$q = array();\nsort($o);\nfor($x = 0; $x < count($o); $x++)\n{\n $q[$x] = $n[$p[$x]];\n}\nif(count($o) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n}\n$i = array();\nfor($x = 0; $x < $b; $x++)\n{\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n}\n$k = array_diff($i, $d);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = 0;\n}\n$m = array_merge($d, $k);\n$n = array_merge($e, $l);\n$o = $m;\nasort($o);\n$p = array_keys($o);\n$q = array();\nsort($o);\nfor($x = 0; $x < count($o); $x++)\n{\n $q[$x] = $n[$p[$x]];\n}\nif(count($o) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n }\n $k = array_diff($i, $d);\n $l = array();\n for($x = 0; $x < count($k); $x++)\n {\n $l[$x] = 0;\n }\n $m = array_merge($d, $k);\n $n = array_merge($e, $l);\n $o = $m;\n asort($o);\n $p = array_keys($o);\n $q = array();\n sort($o);\n for($x = 0; $x < count($o); $x++)\n {\n $q[$x] = $n[$p[$x]];\n }\n if(count($o) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n }\n}\n?>"}, {"source_code": "= 100)\n {\n array_push($d, $f);\n array_push($e, $h);\n }\n}\n$i = array();\nfor($x = 0; $x < $b; $x++)\n{\n $j = trim(fgets(STDIN));\n $i[$x] = $j;\n}\n$k = array_diff($i, $d);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = 0;\n}\n$m = array_merge($d, $k);\n$n = array_merge($e, $l);\n$o = $m;\nasort($o);\n$p = array_keys($o);\n$q = array();\nsort($o);\nfor($x = 0; $x < count($o); $x++)\n{\n $q[$x] = $n[$p[$x]];\n}\nif(count($o) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($o) . \"\\n\";\n for($x = 0; $x < count($o) - 1; $x++)\n {\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s . \"\\n\";\n }\n $r = $o[$x];\n $s = $q[$x];\n print $r . \" \" . $s;\n}\n?>"}, {"source_code": "= 100) {\n $skills[$name] = (int)$expK;\n }\n}\n\nfor ($i = 0; $i < $m; $i++) {\n $name = trim(fgets($input));\n\n $skills[$name] = $skills[$name] ?? 0;\n}\n\nfwrite($output, count($skills) . PHP_EOL);\n\nksort($skills);\n\nforeach ($skills as $skill => $value) {\n fwrite($output, $skill . ' ' . $value . PHP_EOL);\n}\n"}, {"source_code": " 100) {\n $skills[$name] = (int)$expK;\n }\n}\n\nfor ($i = 0; $i < $m; $i++) {\n $name = trim(fgets($input));\n\n $skills[$name] = $skills[$name] ?? 0;\n}\n\nfwrite($output, count($skills) . PHP_EOL);\n\nksort($skills);\n\nforeach ($skills as $skill => $value) {\n fwrite($output, $skill . ' ' . $value . PHP_EOL);\n}\n"}, {"source_code": " $value) {\n fwrite($output, $skill . ' ' . $value . PHP_EOL);\n}\n"}], "src_uid": "7da1a5c4c76540e1c7dc06e4c908c8b4"} {"nl": {"description": "Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session number.One day Polycarpus wondered which secretaries are talking via the Spyke and which are not. For each secretary, he wrote out either the session number of his call or a 0 if this secretary wasn't talking via Spyke at that moment.Help Polycarpus analyze these data and find out the number of pairs of secretaries that are talking. If Polycarpus has made a mistake in the data and the described situation could not have taken place, say so.Note that the secretaries can correspond via Spyke not only with each other, but also with the people from other places. Also, Spyke conferences aren't permitted \u2014 that is, one call connects exactly two people.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009103) \u2014 the number of secretaries in Polycarpus's corporation. The next line contains n space-separated integers: id1,\u2009id2,\u2009...,\u2009idn (0\u2009\u2264\u2009idi\u2009\u2264\u2009109). Number idi equals the number of the call session of the i-th secretary, if the secretary is talking via Spyke, or zero otherwise. Consider the secretaries indexed from 1 to n in some way.", "output_spec": "Print a single integer \u2014 the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place.", "sample_inputs": ["6\n0 1 7 1 7 10", "3\n1 1 1", "1\n0"], "sample_outputs": ["2", "-1", "0"], "notes": "NoteIn the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.In the second test sample the described situation is impossible as conferences aren't allowed."}, "positive_code": [{"source_code": " 2)\n {\n print \"-1\";\n }\n else\n {\n $i = 0;\n for($x = 0; $x < count($f); $x++)\n {\n if($f[$x] == 2)\n {\n $i++;\n }\n }\n print $i;\n }\n}\n?>"}, {"source_code": "$v){\n $arr[$k] = trim($v);\n}\nfunction my_find($a){\n $result = 0;\n $t_a = Array();\n foreach($a as $v){\n if($v == 0)\n continue;\n $t_a[$v] += 1;\n if($t_a[$v] == 2){\n $result+=1;\n }elseif($t_a[$v] > 2){\n return -1;\n }\n }\n return $result;\n}\n\nif($num == 1){\n echo '0';\n}elseif($num != count($arr)){\n echo '-1';\n}else{\n echo my_find($arr);\n}\n?>"}, {"source_code": " 0) {\n $c++;\n //echo \"
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": "\nerror_reporting(false);\n$handle = fopen('php://stdin', 'r');\n$c = 0;\n$num = (int)(trim(fgets($handle))*1 / 2);\n$arr = explode(\" \", trim(fgets($handle)));\n$t = array();\nforeach($arr as $val) {\n if ($val != 0) $t[$val]++;\n}\n$c = 0;\nforeach($t as $k=>$id) {\n if ($id > 2 ) die(\"-1\");\n if ($id == 2) $c++;\n}\necho $c;\n?>\n"}, {"source_code": " $key) \n{\nif (!is_numeric($item)) $flag = false;\n\nif ($item<>0) {\n if ($key == 2) $counter += 1;\n if ($key > 2) $flag = false;\n}\n\n}\n\nif ($flag) echo $counter; else echo \"-1\";\n\n?>"}, {"source_code": " 2) {\n $res = -1;\n break;\n }\n}\n\necho $res, PHP_EOL;\n?>"}, {"source_code": ""}, {"source_code": " 2)\n die(\"-1\");\n \n}\n\necho $result;\n\n"}, {"source_code": "0) {\n\t\t$sessi[$sess[$i]]++;\n\t\tif ($sessi[$sess[$i]]==2) { $pairs++; } else if ($sessi[$sess[$i]]>2) { $pairs=-1; $i=$sec_num+10; }\n\t} else {\n\t\t$nope++;\n\t}\n\t$i++;\n}\n\nfwrite(STDOUT, \"$pairs\\n\" );\n\n?>"}, {"source_code": "\n\nerror_reporting(false);\n//error_reporting(E_ALL);\n\n\n\n$handle = fopen('php://stdin', 'r');\n//$handle = fopen('in.txt', 'r');\n\n$c = 0;\n\n$num = (int)(trim(fgets($handle))*1 / 2);\n\n$arr = explode(\" \", trim(fgets($handle)));\n\n\n$t = array();\n\nforeach($arr as $val) {\n if ($val != 0) $t[$val]++;\n}\n\n$c = 0;\nforeach($t as $k=>$id) {\n\n if ($id > 2 ) die(\"-1\");\n if ($id == 2) $c++;\n}\n\necho $c;\n\n\n\n\n\n?>"}, {"source_code": " $value) {\n if ($index == 0) {\n continue;\n } elseif ($value > 2) {\n $answer = -1;\n break;\n }\n $answer += ($value == 2);\n}\n\nprint $answer;\n\nfunction line() {\n return trim(fgets(STDIN));\n}\n"}, {"source_code": " 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\nprint $OUT;\n?>"}, {"source_code": " 2){\n echo -1;\n exit;\n }\n}\necho $count;"}], "negative_code": [{"source_code": " 2){\n return -1;\n }\n }\n return $result;\n}\n\nif($num == 1){\n echo '0';\n}else{\n echo my_find($arr);\n}\n?>"}, {"source_code": " 2){\n return -1;\n }\n }\n return $result;\n}\nif($num == 1){\n echo '0';\n}else{\n echo my_find($arr);\n}\n?>"}, {"source_code": " 2){\n return -1;\n }\n }\n return $result;\n}\n\nif($num == 1){\n echo '0';\n}elseif($num != count($arr)){\n echo '-1';\n}else{\n echo my_find($arr);\n}\n?>"}, {"source_code": "
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": "
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $num_sec;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}*/\necho $num_sec;\n?>"}, {"source_code": "
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $num_sec;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $num_sec;\n?>"}, {"source_code": "
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $num_sec;\n?>"}, {"source_code": " 1) {\n $result = -1;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": "
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n break;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n break 1;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 0) {\n $c++;\n //echo \"
\\$i = \" . $i . \"
\\$j = \" . $j .\n //\"
\\$num_talk_array[\\$i] = \" . $num_talk_array[$i] . \" -- \\$num_talk_array[\\$j] = \" . $num_talk_array[$j] .\n //\"
\\$result = \";\n }\n }\n if ($c > 1) {\n $result = -1;\n echo $result;\n exit;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": " 1) {\n $result = -1;\n break 3;\n } else {\n $result = $result + $c;\n }\n}\necho $result;\n?>"}, {"source_code": "\n$c = 0;\n$num = (int)(trim(fgets($handle))*1 / 2);\n$arr = explode(\" \", trim(fgets($handle)));\n$t = array();\nforeach($arr as $val) {\nif ($val != 0) $t[$val]++;\n}\n$c = 0;\nforeach($t as $k=>$id) {\nif ($id > 2 ) die(\"-1\");\nif ($id == 2) $c++;\n}\necho $c;\n?>"}, {"source_code": " $key) \n{\nif ($key == 2) $counter += 1;\nif ($key > 2) $flag = false;\n}\n\nif ($flag) echo $counter; else echo \"-1\";\n\n?>"}, {"source_code": " $key) \n{\n\nif ($item<>0) {\n if ($key == 2) $counter += 1;\n if ($key > 2) $flag = false;\n}\n\n}\n\nif ($flag) echo $counter; else echo \"-1\";\n\n?>"}, {"source_code": " 2) {\n $res = -1;\n break;\n }\n}\n\necho $res, PHP_EOL;\n?>"}, {"source_code": " 2) {\n $res = -1;\n break;\n }\n}\n\necho $res, PHP_EOL;\n?>"}, {"source_code": ""}, {"source_code": " 2)\n\t\t\tdie(\"-1\");\n\t\t$count = 1;\n\t\t$prev = $val;\n\t}\n}\n\nif ($count == 2)\n\t$result++;\nelseif ($count > 2)\n\tdie(\"-1\");\necho $result;\n"}, {"source_code": "0) {\n\t\t$sessi[$sess[$i]]++;\n\t\tif ($sessi[$sess[$i]]==2) { $pairs++; } else if ($sessi[$sess[$i]]>2) { $i=$sec_num+10; }\n\t} else {\n\t\t$nope++;\n\t}\n\t$i++;\n}\n\nfwrite(STDOUT, \"$pairs\\n\" );\n\n?>"}, {"source_code": "\n\n$handle = fopen('php://stdin', 'r');\n//$handle = fopen('in.txt', 'r');\n\n$c = 0;\n\n$num = (int)(trim(fgets($handle))*1 / 2);\n\n$arr = explode(\" \", trim(fgets($handle)));\n\n\n$t = array();\n\nforeach($arr as $val) {\n if ($val == 0) continue;\n $t[$val]++;\n}\n\n$c = 0;\nforeach($t as $k=>$id) {\n\n if ($id > 2 ) die(\"-1\");\n if ($id == 2) $c++;\n}\n\n?>"}, {"source_code": "\n$handle = fopen('php://stdin', 'r');\n//$handle = fopen('in.txt', 'r');\n\n$c = 0;\n\n$num = (int)(trim(fgets($handle))*1 / 2);\n\n$arr = explode(\" \", trim(fgets($handle)));\n\n\n$t = array();\n\nforeach($arr as $val) {\n $t[$val]++;\n}\n\n$c = 0;\nforeach($t as $id) {\n if ($id > 2 ) die(\"-1\");\n if ($id == 2) $c++;\n}\n\necho $c;\n?>"}, {"source_code": " 2) {\n $answer = -1;\n break;\n }\n $answer += ($cnt == 2);\n}\n\nprint $answer;\n\nfunction line() {\n return trim(fgets(STDIN));\n}\n"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n//$stdout = fopen('php://stdout','w');\n$stdout = fopen(STDOUT);\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,$OUT);\n?>"}, {"source_code": " 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\nprint $OUT;\n?>"}, {"source_code": "\n\n\n\n \n \n\n \n \n \n \n\n"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n/*$stdout = fopen('php://stdout','w');\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,$OUT);*/\n\necho $OUT;\n?>"}, {"source_code": " 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\nprint $OUT;\n?>"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n/*$stdout = fopen('php://stdout','w');\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,$OUT);*/\n\necho $OUT;\n?>"}, {"source_code": " 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\nprint $OUT;\n?>"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n$stdout = fopen('php://stdout','w');\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,(string)$OUT);\n\n//echo $OUT;\n?>"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n/*$stdout = fopen('php://stdout','w');\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,$OUT);*/\n\nprint $OUT;\n?>"}, {"source_code": "= 1 && $IN[1] <= 1000);\n# \u0423\u0441\u043b\u043e\u0432\u0438\u0435 3: \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0435\u0439\n$cond3 = (count($IN[2]) == $IN[1]);\n# \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\nif($cond1 && $cond2 && $cond3){\n\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432)\n\t$acv = array_count_values($IN[2]);\n\t# \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\n\tasort($acv);\n\t# \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\n\tend($acv);\n\t# \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\n\tif(current($acv) > 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\n# \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\n$stdout = fopen('php://stdout','w');\n# \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445\nfwrite($stdout,(string)$OUT);\n?>"}, {"source_code": " 2 && key($acv) != 0){\n\t\t$OUT = -1;\n\t}else{\n\t\t# \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439\n\t\t$acv = array_count_values($acv);\n\t\t# \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0440\u0438, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\n\t\tif(isset($acv[2])){\n\t\t\t$OUT = $acv[2];\n\t\t}else{\n\t\t\t$OUT = 0;\n\t\t}\n\t}\n}else{\n\t$OUT = -1;\n}\n\nprint $OUT;\n?>"}], "src_uid": "45e51f3dee9a22cee86e1a98da519e2d"} {"nl": {"description": "It is well known that Berland has n cities, which form the Silver ring \u2014 cities i and i\u2009+\u20091 (1\u2009\u2264\u2009i\u2009<\u2009n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build was prepared. Each road will connect two cities. Each road should be a curve which lies inside or outside the ring. New roads will have no common points with the ring (except the endpoints of the road).Now the designers of the constructing plan wonder if it is possible to build the roads in such a way that no two roads intersect (note that the roads may intersect at their endpoints). If it is possible to do, which roads should be inside the ring, and which should be outside?", "input_spec": "The first line contains two integers n and m (4\u2009\u2264\u2009n\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009m\u2009\u2264\u2009100). Each of the following m lines contains two integers ai and bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u2009n,\u2009ai\u2009\u2260\u2009bi). No two cities will be connected by more than one road in the list. The list will not contain the roads which exist in the Silver ring.", "output_spec": "If it is impossible to build the roads in such a way that no two roads intersect, output Impossible. Otherwise print m characters. i-th character should be i, if the road should be inside the ring, and o if the road should be outside the ring. If there are several solutions, output any of them.", "sample_inputs": ["4 2\n1 3\n2 4", "6 3\n1 3\n3 5\n5 1"], "sample_outputs": ["io", "ooo"], "notes": null}, "positive_code": [{"source_code": "\n"}], "negative_code": [], "src_uid": "214cdb73c2fb5ab995eb5aec76e5f4fb"} {"nl": {"description": "Vasya has a grid with $$$2$$$ rows and $$$n$$$ columns. He colours each cell red, green, or blue.Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 the number of columns of the grid. The following two lines each contain a string consisting of $$$n$$$ characters, each of which is either R, G, or B, representing a red, green, or blue cell, respectively\u00a0\u2014 the description of the grid.", "output_spec": "For each test case, output \"YES\" if Vasya considers the grid's two rows to be identical, and \"NO\" otherwise. You can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).", "sample_inputs": ["6\n\n2\n\nRG\n\nRB\n\n4\n\nGRBG\n\nGBGB\n\n5\n\nGGGGG\n\nBBBBB\n\n7\n\nBBBBBBB\n\nRRRRRRR\n\n8\n\nRGBRRGBR\n\nRGGRRBGR\n\n1\n\nG\n\nG"], "sample_outputs": ["YES\nNO\nYES\nNO\nYES\nYES"], "notes": "NoteIn the first test case, Vasya sees the second cell of each row as the same because the second cell of the first row is green and the second cell of the second row is blue, so he can't distinguish these two cells. The rest of the rows are equal in colour. Therefore, Vasya will say that the two rows are coloured the same, even though they aren't.In the second test case, Vasya can see that the two rows are different.In the third test case, every cell is green or blue, so Vasya will think they are the same."}, "positive_code": [{"source_code": " 'G']) == strtr($row2, ['B' => 'G'])){\r\n echo \"Yes\\n\";\r\n }\r\n else{\r\n echo \"No\\n\";\r\n }\r\n}\r\n \r\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 'G']) == strtr($row2, ['B' => 'G'])){\r\n echo \"Yes\\n\";\r\n }\r\n else{\r\n echo \"No\\n\";\r\n }\r\n}\r\n \r\n?>"}, {"source_code": " 'G']) == strtr($d, ['B' => 'G'])){\r\n echo \"Yes\";\r\n }\r\n else{\r\n echo \"No\";\r\n }\r\n}"}, {"source_code": " 'G']) == strtr($d, ['B' => 'G'])){\r\n echo \"\u0414\u0410\";\r\n }\r\n else{\r\n echo \"\u041d\u0415\u0422\";\r\n }"}, {"source_code": ""}], "src_uid": "86a2e0854f9faf0b119d0d5e4b8fe952"} {"nl": {"description": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset \u2014 a language called HQ...", "input_spec": "The only line of the input is a string between 1 and 106 characters long.", "output_spec": "Output \"Yes\" or \"No\".", "sample_inputs": ["HHHH", "HQHQH", "HHQHHQH", "HHQQHHQQHH"], "sample_outputs": ["Yes", "No", "No", "Yes"], "notes": "NoteThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "f59aea02181e1c3c7eeda79faf28dccc"} {"nl": {"description": "Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A\u2009=\u2009{a1,\u2009\u2009a2,\u2009\u2009...,\u2009\u2009an}, where the width and the height of the i-th envelope is strictly higher than the width and the height of the (i\u2009\u2009-\u2009\u20091)-th envelope respectively. Chain size is the number of envelopes in the chain. Peter wants to make the chain of the maximum size from the envelopes he has, the chain should be such, that he'll be able to put a card into it. The card fits into the chain if its width and height is lower than the width and the height of the smallest envelope in the chain respectively. It's forbidden to turn the card and the envelopes. Peter has very many envelopes and very little time, this hard task is entrusted to you.", "input_spec": "The first line contains integers n, w, h (1\u2009\u2009\u2264\u2009n\u2009\u2264\u20095000, 1\u2009\u2264\u2009w,\u2009\u2009h\u2009\u2009\u2264\u2009106) \u2014 amount of envelopes Peter has, the card width and height respectively. Then there follow n lines, each of them contains two integer numbers wi and hi \u2014 width and height of the i-th envelope (1\u2009\u2264\u2009wi,\u2009\u2009hi\u2009\u2264\u2009106).", "output_spec": "In the first line print the maximum chain size. In the second line print the numbers of the envelopes (separated by space), forming the required chain, starting with the number of the smallest envelope. Remember, please, that the card should fit into the smallest envelope. If the chain of maximum size is not unique, print any of the answers. If the card does not fit into any of the envelopes, print number 0 in the single line.", "sample_inputs": ["2 1 1\n2 2\n2 2", "3 3 3\n5 4\n12 11\n9 8"], "sample_outputs": ["1\n1", "3\n1 3 2"], "notes": null}, "positive_code": [{"source_code": "w = $w;\n\t\t$this->h = $h;\n\t\t$this->i = $i;\n\t\t$this->p = NULL;\n\t}\n}\n\nfunction cmp($a, $b) {\n\tif ($a->w != $b->w) {\n\t\treturn $a->w < $b->w ? -1 : 1;\n\t} else if ($a->h != $b->h) {\n\t\treturn $a->h > $b->h ? -1 : 1;\n\t} else {\n\t\treturn 0;\n\t}\n}\n\nfscanf(STDIN, \"%d%d%d\", $n, $w, $h);\n$a = Array();\nfor ($i = 1; $i <= $n; ++$i) {\n\tfscanf(STDIN, \"%d%d\", $wi, $hi);\n\tif ($wi > $w && $hi > $h) {\n\t\tarray_push($a, new Envelope($wi, $hi, $i));\n\t}\n}\n\nusort($a, 'cmp');\n$b = Array();\nforeach ($a as $ai) {\n\t$l = 0;\n\t$r = count($b);\n\twhile ($l < $r) {\n\t\t$m = ($l + $r) / 2;\n\t\tif ($ai->h > $b[$m]->h) {\n\t\t\t$l = $m + 1;\n\t\t} else {\n\t\t\t$r = $m;\n\t\t}\n\t}\n\t$ai->p = ($r == 0 ? NULL : $b[$r - 1]);\n\t$b[$r] = $ai;\n}\n\necho count($b) . \"\\n\";\nif (count($b) > 0) {\n\t$c = Array();\n\tfor ($p = array_pop($b); $p != NULL; $p = $p->p) {\n\t\tarray_unshift($c, $p->i);\n\t}\n\tprint implode($c, ' ') . \"\\n\";\n}\n\n/*\n\n*/\n"}], "negative_code": [], "src_uid": "6f88e3f4c8a8a444d44e58505a750d3e"} {"nl": {"description": "Consider a sequence of digits of length $$$2^k$$$ $$$[a_1, a_2, \\ldots, a_{2^k}]$$$. We perform the following operation with it: replace pairs $$$(a_{2i+1}, a_{2i+2})$$$ with $$$(a_{2i+1} + a_{2i+2})\\bmod 10$$$ for $$$0\\le i<2^{k-1}$$$. For every $$$i$$$ where $$$a_{2i+1} + a_{2i+2}\\ge 10$$$ we get a candy! As a result, we will get a sequence of length $$$2^{k-1}$$$.Less formally, we partition sequence of length $$$2^k$$$ into $$$2^{k-1}$$$ pairs, each consisting of 2 numbers: the first pair consists of the first and second numbers, the second of the third and fourth $$$\\ldots$$$, the last pair consists of the ($$$2^k-1$$$)-th and ($$$2^k$$$)-th numbers. For every pair such that sum of numbers in it is at least $$$10$$$, we get a candy. After that, we replace every pair of numbers with a remainder of the division of their sum by $$$10$$$ (and don't change the order of the numbers).Perform this operation with a resulting array until it becomes of length $$$1$$$. Let $$$f([a_1, a_2, \\ldots, a_{2^k}])$$$ denote the number of candies we get in this process. For example: if the starting sequence is $$$[8, 7, 3, 1, 7, 0, 9, 4]$$$ then:After the first operation the sequence becomes $$$[(8 + 7)\\bmod 10, (3 + 1)\\bmod 10, (7 + 0)\\bmod 10, (9 + 4)\\bmod 10]$$$ $$$=$$$ $$$[5, 4, 7, 3]$$$, and we get $$$2$$$ candies as $$$8 + 7 \\ge 10$$$ and $$$9 + 4 \\ge 10$$$.After the second operation the sequence becomes $$$[(5 + 4)\\bmod 10, (7 + 3)\\bmod 10]$$$ $$$=$$$ $$$[9, 0]$$$, and we get one more candy as $$$7 + 3 \\ge 10$$$. After the final operation sequence becomes $$$[(9 + 0) \\bmod 10]$$$ $$$=$$$ $$$[9]$$$. Therefore, $$$f([8, 7, 3, 1, 7, 0, 9, 4]) = 3$$$ as we got $$$3$$$ candies in total.You are given a sequence of digits of length $$$n$$$ $$$s_1, s_2, \\ldots s_n$$$. You have to answer $$$q$$$ queries of the form $$$(l_i, r_i)$$$, where for $$$i$$$-th query you have to output $$$f([s_{l_i}, s_{l_i+1}, \\ldots, s_{r_i}])$$$. It is guaranteed that $$$r_i-l_i+1$$$ is of form $$$2^k$$$ for some nonnegative integer $$$k$$$.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$)\u00a0\u2014 the length of the sequence. The second line contains $$$n$$$ digits $$$s_1, s_2, \\ldots, s_n$$$ ($$$0 \\le s_i \\le 9$$$). The third line contains a single integer $$$q$$$ ($$$1 \\le q \\le 10^5$$$)\u00a0\u2014 the number of queries. Each of the next $$$q$$$ lines contains two integers $$$l_i$$$, $$$r_i$$$ ($$$1 \\le l_i \\le r_i \\le n$$$)\u00a0\u2014 $$$i$$$-th query. It is guaranteed that $$$r_i-l_i+1$$$ is a nonnegative integer power of $$$2$$$.", "output_spec": "Output $$$q$$$ lines, in $$$i$$$-th line output single integer\u00a0\u2014 $$$f([s_{l_i}, s_{l_i + 1}, \\ldots, s_{r_i}])$$$, answer to the $$$i$$$-th query.", "sample_inputs": ["8\n8 7 3 1 7 0 9 4\n3\n1 8\n2 5\n7 7", "6\n0 1 2 3 3 5\n3\n1 2\n1 4\n3 6"], "sample_outputs": ["3\n1\n0", "0\n0\n1"], "notes": "NoteThe first example illustrates an example from the statement.$$$f([7, 3, 1, 7]) = 1$$$: sequence of operations is $$$[7, 3, 1, 7] \\to [(7 + 3)\\bmod 10, (1 + 7)\\bmod 10]$$$ $$$=$$$ $$$[0, 8]$$$ and one candy as $$$7 + 3 \\ge 10$$$ $$$\\to$$$ $$$[(0 + 8) \\bmod 10]$$$ $$$=$$$ $$$[8]$$$, so we get only $$$1$$$ candy.$$$f([9]) = 0$$$ as we don't perform operations with it."}, "positive_code": [{"source_code": ""}, {"source_code": " $v) {\n $sums[] = ($sums[$i - 1] ?? 0) + $v;\n}\n$q = trim(fgets(STDIN));\nwhile ($q--) {\n [$l, $r] = explode(' ', trim(fgets(STDIN)));\n $candies = 0;\n if ($r > $l) {\n $candies = floor(($sums[$r - 1] - ($sums[$l - 2] ?? 0)) / 10);\n }\n echo $candies . PHP_EOL;\n}\n"}], "negative_code": [{"source_code": " $k[$x])\n {\n for($y = $m; $y > $k[$x]; $y--)\n {\n $o -= $b[$y];\n }\n $m = $k[$x];\n }\n $p = floor($o / 10);\n $n[$h[$j[$x]]] = $p;\n}\nksort($n);\nfor($x = 0; $x < count($n); $x++)\n{\n print $n[$x] . \"\\n\";\n}\n?>"}, {"source_code": " $k[$x])\n {\n for($y = $m; $y > $k[$x]; $y--)\n {\n $o -= $b[$y];\n }\n $m = $k[$x];\n }\n $p = floor($o / 10);\n $n[$h[$j[$x]]] = $p;\n}\nksort($n);\nfor($x = 0; $x < count($n); $x++)\n{\n print $n[$x] . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $k[$x])\n {\n for($y = $m + 1; $y > $k[$x]; $y--)\n {\n $o -= $b[$y];\n }\n $m = $k[$x];\n }\n $p = floor($o / 10);\n $n[$h[$j[$x]]] = $p;\n}\nksort($n);\nfor($x = 0; $x < count($n); $x++)\n{\n print $n[$x] . \"\\n\";\n}\n?>"}, {"source_code": " $k[$x])\n {\n for($y = $m; $y > $k[$x]; $y--)\n {\n $o -= $b[$y];\n }\n $m = $k[$x];\n }\n $p = floor($o / 10);\n $n[$h[$j[$x]]] = $p;\n}\nksort($n);\nfor($x = 0; $x < count($n); $x++)\n{\n print $n[$x] . \"\\n\";\n}\n?>"}, {"source_code": " $v) {\n $sums[] = ($sums[$i - 1] ?? 0) + $v;\n}\n$q = trim(fgets(STDIN));\nwhile ($q--) {\n [$l, $r] = explode(' ', trim(fgets(STDIN)));\n $candies = 0;\n if ($r > $l) {\n $candies = floor(($sums[$r - 1] - $sums[$l - 1]) / 10);\n }\n echo $candies . PHP_EOL;\n}\n"}], "src_uid": "2cd91be317328fec207da6773ead4541"} {"nl": {"description": "Sereja loves integer sequences very much. He especially likes stairs.Sequence a1,\u2009a2,\u2009...,\u2009a|a| (|a| is the length of the sequence) is stairs if there is such index i (1\u2009\u2264\u2009i\u2009\u2264\u2009|a|), that the following condition is met: a1\u2009<\u2009a2\u2009<\u2009...\u2009<\u2009ai\u2009-\u20091\u2009<\u2009ai\u2009>\u2009ai\u2009+\u20091\u2009>\u2009...\u2009>\u2009a|a|\u2009-\u20091\u2009>\u2009a|a|.For example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.Sereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?", "input_spec": "The first line contains integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the number of Sereja's cards. The second line contains m integers bi (1\u2009\u2264\u2009bi\u2009\u2264\u20095000) \u2014 the numbers on the Sereja's cards.", "output_spec": "In the first line print the number of cards you can put on the table. In the second line print the resulting stairs.", "sample_inputs": ["5\n1 2 3 4 5", "6\n1 1 2 2 3 3"], "sample_outputs": ["5\n5 4 3 2 1", "5\n1 2 3 2 1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "1);\n\t}else{\n\t\t$ans[$v]++;\n\t}\n}\n$i=0;\n$tar=array();\nforeach ($ans as $k=>&$v) {\n\tif($v!=0){\n\t\t$tar[$i]=$k;\n\t\t$v--;\n\t\t$i++;\n\t}\n}\n$i=0;\n$car=array();\nforeach ($ans as $k=>&$v) {\n\tif($v!=0){\n\t\t$car[$i]=$k;\n\t\t$v--;\n\t\t$i++;\n\t}\n}\nif($tar[0]==$car[0]) unset($tar[0]);\n$car=array_reverse($car);\n\n$num=count($tar)+count($car);\necho $num.\"\\n\";\nforeach ($car as $v) {\n\techo $v.\" \";\n}\nforeach ($tar as $v) {\n\techo $v.\" \";\n}\n\n?>"}, {"source_code": " $b[$k]) {\n\t\t$k++;\n\t\t$b[$k] = $a[$j];\n\t\t$a[$j] = -1;\n\t}\n}\n\nfor ($j = $n-1; $j > 0; $j--) {\n\tif ($a[$j] >= 0 and $a[$j] < $b[$k]) {\n\t\t$k++;\n\t\t$b[$k] = $a[$j];\n\t\t$a[$j] = -1;\n\t}\n}\n\nprint ($k+1).\"\\n\";\nprint implode(' ', $b);"}], "negative_code": [], "src_uid": "5c63f91eb955cb6c3172cb7c8f78976c"} {"nl": {"description": "Polycarpus is a system administrator. There are two servers under his strict guidance \u2014 a and b. To stay informed about the servers' performance, Polycarpus executes commands \"ping a\" and \"ping b\". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x\u2009+\u2009y\u2009=\u200910;\u00a0x,\u2009y\u2009\u2265\u20090). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is \"alive\" or not. Polycarpus thinks that the server is \"alive\", if at least half of the packets that we send to this server reached it successfully along the network.Help Polycarpus, determine for each server, whether it is \"alive\" or not by the given commands and their results.", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers \u2014 the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1\u2009\u2264\u2009ti\u2009\u2264\u20092;\u00a0xi,\u2009yi\u2009\u2265\u20090;\u00a0xi\u2009+\u2009yi\u2009=\u200910). If ti\u2009=\u20091, then the i-th command is \"ping a\", otherwise the i-th command is \"ping b\". Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost. It is guaranteed that the input has at least one \"ping a\" command and at least one \"ping b\" command.", "output_spec": "In the first line print string \"LIVE\" (without the quotes) if server a is \"alive\", otherwise print \"DEAD\" (without the quotes). In the second line print the state of server b in the similar format.", "sample_inputs": ["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"], "sample_outputs": ["LIVE\nLIVE", "LIVE\nDEAD"], "notes": "NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network."}, "positive_code": [{"source_code": "= $f) && ($g >= $h))\n{\n print \"LIVE\" . \"\\n\" . \"LIVE\";\n}\nelseif(($e < $f) && ($g < $h))\n{\n print \"DEAD\" . \"\\n\" . \"DEAD\";\n}\nelseif(($e >= $f) && ($g < $h))\n{\n print \"LIVE\" . \"\\n\" . \"DEAD\";\n}\nelseif(($e < $f) && ($g >= $h))\n{\n print \"DEAD\" . \"\\n\" . \"LIVE\";\n}\n?>"}, {"source_code": "=$ay)?\"LIVE\\n\":\"DEAD\\n\");\necho (($bx>=$by)?\"LIVE\\n\":\"DEAD\\n\");"}, {"source_code": "array('1','0','10'),\n\t'2'=>array('2','0','10'),\n\t'3'=>array('1','10','0'));\n*/\n\n$p[1] = 0;\n$p[2] = 0;\n$p1 = 0;\n$p2 = 0;\nFor($i = 1; $i <= $n; $i++){\n\t$row = $a[$i];\n\t$p[$row[0]] = $p[$row[0]] + $row[1] / 10;\n\tif($row[0] == 1) $p1++; else $p2++;\n}\n$p[1] = $p[1] / $p1;\n$p[2] = $p[2] / $p2;\n\nif($p[1] >= 0.5) echo'LIVE'; else echo 'DEAD';\necho PHP_EOL;\nif($p[2] >= 0.5) echo'LIVE'; else echo 'DEAD';\n\n?>"}, {"source_code": " 0, 'success' => 0);\n\nforeach($lines as $line)\n{\n list($server, $success, $errors) = explode(' ', $line);\n $server = (int) $server;\n \n $servers[$server]['errors'] += (int) $errors;\n $servers[$server]['success'] += (int) $success;\n}\n\necho ($servers[1]['success'] / $servers[1]['errors']) >= 1 ? 'LIVE' : 'DEAD'; \necho PHP_EOL;\necho ($servers[2]['success'] / $servers[2]['errors']) >= 1 ? 'LIVE' : 'DEAD';"}, {"source_code": " 0, 0);\n$cnt = getLine();\nfor ($i=0; $i<$cnt; $i++) {\n list($si, $x, $y) = explode(\" \", getLine());\n $servers[$si] += $x - $y;\n}\n\necho ($servers[1]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;\necho ($servers[2]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;\n\nfunction getLine()\n{\n return trim(fgets(STDIN));\n}"}, {"source_code": " /* BismiLahi Rahmani Rahim */ ?>\n\n\n"}, {"source_code": "\n"}, {"source_code": "= 0)\n $sa = 'LIVE';\nif ($ya >= 0)\n $sb = 'LIVE';\n\necho \"$sa\\n\";\necho \"$sb\\n\";\n\n?>"}], "negative_code": [{"source_code": " 0, 0);\n$cnt = getLine();\nfor ($i=0; $i<$cnt; $i++) {\n list($si, $x, $y) = explode(\" \", getLine());\n $servers[$si] += ($x>=$y) - ($x<$y);\n}\n\necho ($servers[1]>0 ? 'LIVE' : 'DEAD') . PHP_EOL;\necho ($servers[2]>0 ? 'LIVE' : 'DEAD') . PHP_EOL;\n\nfunction getLine()\n{\n return trim(fgets(STDIN));\n}"}, {"source_code": " 0, 0);\n$cnt = getLine();\nfor ($i=0; $i<$cnt; $i++) {\n list($si, $x, $y) = explode(\" \", getLine());\n $servers[$si] += ($x>=$y) - ($x<$y);\n}\n\necho ($servers[1]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;\necho ($servers[2]>=0 ? 'LIVE' : 'DEAD') . PHP_EOL;\n\nfunction getLine()\n{\n return trim(fgets(STDIN));\n}"}, {"source_code": "= intval($y))\n $sa = 'LIVE';\n if ($t == 2)\n if ($x >= intval($y))\n $sb = 'LIVE';\n}\n\necho \"$sa\\n\";\necho \"$sb\\n\";\n\n?>"}], "src_uid": "1d8870a705036b9820227309d74dd1e8"} {"nl": {"description": "One day, Vogons wanted to build a new hyperspace highway through a distant system with $$$n$$$ planets. The $$$i$$$-th planet is on the orbit $$$a_i$$$, there could be multiple planets on the same orbit. It's a pity that all the planets are on the way and need to be destructed.Vogons have two machines to do that. The first machine in one operation can destroy any planet at cost of $$$1$$$ Triganic Pu. The second machine in one operation can destroy all planets on a single orbit in this system at the cost of $$$c$$$ Triganic Pus. Vogons can use each machine as many times as they want.Vogons are very greedy, so they want to destroy all planets with minimum amount of money spent. Can you help them to know the minimum cost of this project?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. Then the test cases follow. Each test case consists of two lines. The first line contains two integers $$$n$$$ and $$$c$$$ ($$$1 \\le n, c \\le 100$$$) \u2014 the number of planets and the cost of the second machine usage. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 100$$$), where $$$a_i$$$ is the orbit of the $$$i$$$-th planet.", "output_spec": "For each test case print a single integer \u2014 the minimum cost of destroying all planets.", "sample_inputs": ["4\n\n10 1\n\n2 1 4 5 2 4 5 5 1 2\n\n5 2\n\n3 2 1 2 2\n\n2 2\n\n1 1\n\n2 2\n\n1 2", "1\n\n1 100\n\n1"], "sample_outputs": ["4\n4\n2\n2", "1"], "notes": "NoteIn the first test case, the cost of using both machines is the same, so you can always use the second one and destroy all planets in orbit $$$1$$$, all planets in orbit $$$2$$$, all planets in orbit $$$4$$$, all planets in orbit $$$5$$$.In the second test case, it is advantageous to use the second machine for $$$2$$$ Triganic Pus to destroy all the planets in orbit $$$2$$$, then destroy the remaining two planets using the first machine.In the third test case, you can use the first machine twice or the second machine once.In the fourth test case, it is advantageous to use the first machine twice."}, "positive_code": [{"source_code": " $v) {\r\n if ($c < $v) {\r\n $cost += $c;\r\n } else\r\n $cost += $v;\r\n\r\n\r\n }\r\n echo $cost.\"\\n\";\r\n}\r\n\r\nreturn;\r\n?>\r\n"}, {"source_code": " $price) {\r\n $result += $price;\r\n continue;\r\n }\r\n $result += $planetCount;\r\n }\r\n print $result . PHP_EOL;\r\n}\r\n"}, {"source_code": "\r\n0);\r\n $arr = explode(\" \", trim(fgets($cin)));\r\n foreach($arr as $val){\r\n $bruh[$val]+=1;\r\n }\r\n $ans = 0;\r\n foreach($bruh as $el){\r\n $ans += min($el, $c);\r\n \r\n }\r\n fprintf($cout, \"%d\\n\", $ans);\r\n}\r\n\r\n?>\r\n\r\n"}, {"source_code": " $c ) {\r\n $ans += $c; \r\n } else {\r\n $ans += $t[$i];\r\n }\r\n }\r\n \r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [{"source_code": "1){\r\n foreach($map as $k=>$v){\r\n if($v>1){\r\n $ex_count+=$v;\r\n }else{\r\n $o_count++;\r\n }\r\n\r\n }\r\n $min= min($ex_count,$c);\r\n\r\n echo $cost = $min+$o_count.\"\\n\";\r\n }else{\r\n echo count($map).\"\\n\";\r\n }\r\n}\r\n\r\nreturn;\r\n?>\r\n"}, {"source_code": "1){\r\n foreach($map as $k=>$v){\r\n if($v>1){\r\n $ex_count+=$v;\r\n }else{\r\n $o_count++;\r\n }\r\n\r\n }\r\n $min= min($ex_count,$c);\r\n\r\n echo $cost = $min+$o_count.\"\\n\";\r\n }else{\r\n echo count($map).\"\\n\";\r\n }\r\n}\r\n\r\nreturn;\r\n?>\r\n"}, {"source_code": " $price) {\r\n $result += $price;\r\n continue;\r\n }\r\n $result += $planetCount;\r\n }\r\n print $result . PHP_EOL;\r\n}"}], "src_uid": "2805d460df1121c4410999a9f36e383a"} {"nl": {"description": "Monocarp has forgotten the password to his mobile phone. The password consists of $$$4$$$ digits from $$$0$$$ to $$$9$$$ (note that it can start with the digit $$$0$$$).Monocarp remembers that his password had exactly two different digits, and each of these digits appeared exactly two times in the password. Monocarp also remembers some digits which were definitely not used in the password.You have to calculate the number of different sequences of $$$4$$$ digits that could be the password for Monocarp's mobile phone (i.\u2009e. these sequences should meet all constraints on Monocarp's password).", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 200$$$)\u00a0\u2014 the number of testcases. The first line of each testcase contains a single integer $$$n$$$ ($$$1 \\le n \\le 8$$$)\u00a0\u2014 the number of digits for which Monocarp remembers that they were not used in the password. The second line contains $$$n$$$ different integers $$$a_1, a_2, \\dots a_n$$$ ($$$0 \\le a_i \\le 9$$$) representing the digits that were not used in the password. Note that the digits $$$a_1, a_2, \\dots, a_n$$$ are given in ascending order.", "output_spec": "For each testcase, print one integer\u00a0\u2014 the number of different $$$4$$$-digit sequences that meet the constraints.", "sample_inputs": ["2\n\n8\n\n0 1 2 4 5 6 8 9\n\n1\n\n8"], "sample_outputs": ["6\n216"], "notes": "NoteIn the first example, all possible passwords are: \"3377\", \"3737\", \"3773\", \"7337\", \"7373\", \"7733\"."}, "positive_code": [{"source_code": " 216,\r\n '2' => 168,\r\n '3' => 126,\r\n '4' => 90,\r\n '5' => 60,\r\n '6' => 36,\r\n '7' => 18,\r\n '8' => 6\r\n ];\r\n $ans = $t[$n];\r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": "\r\n"}], "negative_code": [{"source_code": " 216,\r\n '2' => 162,\r\n '3' => 126,\r\n '4' => 90,\r\n '5' => 60,\r\n '6' => 36,\r\n '7' => 18,\r\n '8' => 6\r\n ];\r\n $ans = $t[$n];\r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "src_uid": "33e751f5716cbd666be36ab8f5e3977e"} {"nl": {"description": "You are given $$$n$$$ words of equal length $$$m$$$, consisting of lowercase Latin alphabet letters. The $$$i$$$-th word is denoted $$$s_i$$$.In one move you can choose any position in any single word and change the letter at that position to the previous or next letter in alphabetical order. For example: you can change 'e' to 'd' or to 'f'; 'a' can only be changed to 'b'; 'z' can only be changed to 'y'. The difference between two words is the minimum number of moves required to make them equal. For example, the difference between \"best\" and \"cost\" is $$$1 + 10 + 0 + 0 = 11$$$.Find the minimum difference of $$$s_i$$$ and $$$s_j$$$ such that $$$(i < j)$$$. In other words, find the minimum difference over all possible pairs of the $$$n$$$ words.", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. The description of test cases follows. The first line of each test case contains $$$2$$$ integers $$$n$$$ and $$$m$$$ ($$$2 \\leq n \\leq 50$$$, $$$1 \\leq m \\leq 8$$$) \u2014 the number of strings and their length respectively. Then follows $$$n$$$ lines, the $$$i$$$-th of which containing a single string $$$s_i$$$ of length $$$m$$$, consisting of lowercase Latin letters.", "output_spec": "For each test case, print a single integer \u2014 the minimum difference over all possible pairs of the given strings.", "sample_inputs": ["6\n\n2 4\n\nbest\n\ncost\n\n6 3\n\nabb\n\nzba\n\nbef\n\ncdu\n\nooo\n\nzzz\n\n2 7\n\naaabbbc\n\nbbaezfe\n\n3 2\n\nab\n\nab\n\nab\n\n2 8\n\naaaaaaaa\n\nzzzzzzzz\n\n3 1\n\na\n\nu\n\ny"], "sample_outputs": ["11\n8\n35\n0\n200\n4"], "notes": "NoteFor the second test case, one can show that the best pair is (\"abb\",\"bef\"), which has difference equal to $$$8$$$, which can be obtained in the following way: change the first character of the first string to 'b' in one move, change the second character of the second string to 'b' in $$$3$$$ moves and change the third character of the second string to 'b' in $$$4$$$ moves, thus making in total $$$1 + 3 + 4 = 8$$$ moves.For the third test case, there is only one possible pair and it can be shown that the minimum amount of moves necessary to make the strings equal is $$$35$$$.For the fourth test case, there is a pair of strings which is already equal, so the answer is $$$0$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }"}], "negative_code": [], "src_uid": "ef2b90d5b1073430795704a7df748ac3"} {"nl": {"description": "Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s\u2009=\u2009s1s2... sn (n is the length of the string), consisting only of characters \".\" and \"#\" and m queries. Each query is described by a pair of integers li,\u2009ri (1\u2009\u2264\u2009li\u2009<\u2009ri\u2009\u2264\u2009n). The answer to the query li,\u2009ri is the number of such integers i (li\u2009\u2264\u2009i\u2009<\u2009ri), that si\u2009=\u2009si\u2009+\u20091.Ilya the Lion wants to help his friends but is there anyone to help him? Help Ilya, solve the problem.", "input_spec": "The first line contains string s of length n (2\u2009\u2264\u2009n\u2009\u2264\u2009105). It is guaranteed that the given string only consists of characters \".\" and \"#\". The next line contains integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integers li,\u2009ri (1\u2009\u2264\u2009li\u2009<\u2009ri\u2009\u2264\u2009n).", "output_spec": "Print m integers \u2014 the answers to the queries in the order in which they are given in the input.", "sample_inputs": ["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"], "sample_outputs": ["1\n1\n5\n4", "1\n1\n2\n2\n0"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\n$str = trim(fgets(STDIN)).\"*\";\n$n = intval(fgets(STDIN));\n$c = 0;\n\n\nfor($i=0; $i "}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": "\n\n$str = trim(fgets(STDIN)).\"+\";\n$n = trim(fgets(STDIN));\n\nfor ($i=0; $i<$n; $i++) {\n $l = fgets(STDIN);\n $t = split(\" \", $l);\n \n if ($i!=0) echo \"\\n\";\n echo g($t[0], $t[1], $str);\n}\n\n\nfunction g($l, $r, $str){\n $c = 0;\n for($i = $l; $i < $r; $i++) \n if ($str[$i-1] == $str[$i]) $c++;\n return $c;\n}\n\n\n?>"}, {"source_code": "\n$str = fgets(STDIN);\n$n = intval(fgets(STDIN));\nfor($i=0; $i "}, {"source_code": "\n\n$str = \"+\".trim(fgets(STDIN));\n$n = trim(fgets(STDIN));\n\nfor ($i=0; $i<$n; $i++) {\n $l = fgets(STDIN);\n $t = split(\" \", $l);\n if ($i!=0) echo \"\\n\";\n echo g($t[0], $t[1], $str);\n}\n\n\nfunction g($l, $r, $str){\n $c = 0;\n for($i = $l; $i < $r; $i++) \n if ($str[$i] == $str[$i+1]) $c++;\n return $c;\n}\n\n\n?>"}, {"source_code": "\n\n$str = trim(fgets(STDIN));\n$n = trim(fgets(STDIN));\n\nfor ($i=0; $i<$n; $i++) {\n $l = fgets(STDIN);\n $t = split(\" \", $l);\n \n if ($i!=0) echo \"\\n\";\n echo g($t[0], $t[1], $str);\n}\n\n\nfunction g($l, $r, $str){\n $c = 0;\n// echo \"$l > $r > \\n\";\n for($i=$l; $i<$r; $i++) {\n if ($str[$i-1] == $str[$i]) $c++;\n }\n return $c;\n}\n\n\n?>"}, {"source_code": "\n\n$str = \"+\".trim(fgets(STDIN)).\"+\";\n$n = trim(fgets(STDIN));\n\nfor ($i=0; $i<$n; $i++) {\n $l = fgets(STDIN);\n $t = split(\" \", $l);\n if ($i!=0) echo \"\\n\";\n echo g($t[0], $t[1], $str);\n}\n\n\nfunction g($l, $r, $str){\n $c = 0;\n for($i = $l; $i < $r; $i++) \n if ($str[$i] == $str[$i+1]) $c++;\n return $c;\n}\n\n\n?>"}], "src_uid": "b30e09449309b999473e4be6643d68cd"} {"nl": {"description": "You are given an integer $$$n$$$. You have to construct a permutation of size $$$n$$$.A permutation is an array where each integer from $$$1$$$ to $$$s$$$ (where $$$s$$$ is the size of permutation) occurs exactly once. For example, $$$[2, 1, 4, 3]$$$ is a permutation of size $$$4$$$; $$$[1, 2, 4, 5, 3]$$$ is a permutation of size $$$5$$$; $$$[1, 4, 3]$$$ is not a permutation (the integer $$$2$$$ is absent), $$$[2, 1, 3, 1]$$$ is not a permutation (the integer $$$1$$$ appears twice).A subsegment of a permutation is a contiguous subsequence of that permutation. For example, the permutation $$$[2, 1, 4, 3]$$$ has $$$10$$$ subsegments: $$$[2]$$$, $$$[2, 1]$$$, $$$[2, 1, 4]$$$, $$$[2, 1, 4, 3]$$$, $$$[1]$$$, $$$[1, 4]$$$, $$$[1, 4, 3]$$$, $$$[4]$$$, $$$[4, 3]$$$ and $$$[3]$$$.The value of the permutation is the number of its subsegments which are also permutations. For example, the value of $$$[2, 1, 4, 3]$$$ is $$$3$$$ since the subsegments $$$[2, 1]$$$, $$$[1]$$$ and $$$[2, 1, 4, 3]$$$ are permutations.You have to construct a permutation of size $$$n$$$ with minimum possible value among all permutations of size $$$n$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 48$$$) \u2014 the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th of them contains one integer $$$n$$$ ($$$3 \\le n \\le 50$$$) representing the $$$i$$$-th test case.", "output_spec": "For each test case, print $$$n$$$ integers \u2014 the permutation of size $$$n$$$ with minimum possible value. If there are multiple such permutations, print any of them.", "sample_inputs": ["2\n\n5\n\n6"], "sample_outputs": ["1 4 3 5 2\n4 1 6 2 5 3"], "notes": "NoteIn the first example, the permutation $$$[1, 4, 3, 5, 2]$$$ is one of the possible answers; its value is $$$2$$$.In the second example, the permutation $$$[4, 1, 6, 2, 5, 3]$$$ is one of the possible answers; its value is $$$2$$$."}, "positive_code": [{"source_code": "0; $i-=2) {\r\n// $temp = $n - $i + 1;\r\n// $ans .= $i . ' ' . $temp . ' ';\r\n// }\r\n for($i=1; $i <= $n / 2; $i++) {\r\n $temp = $n - $i + 1;\r\n $ans .= $i . ' ' . $temp . ' ';\r\n }\r\n if($n % 2 == 1) {\r\n $ans .= ceil($n / 2); \r\n }\r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [], "src_uid": "6fced7d8ac3dd58b1791430ada53332d"} {"nl": {"description": "You are given a board of size $$$n \\times n$$$, where $$$n$$$ is odd (not divisible by $$$2$$$). Initially, each cell of the board contains one figure.In one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a side or a corner with the current cell, i.e. from the cell $$$(i, j)$$$ you can move the figure to cells: $$$(i - 1, j - 1)$$$; $$$(i - 1, j)$$$; $$$(i - 1, j + 1)$$$; $$$(i, j - 1)$$$; $$$(i, j + 1)$$$; $$$(i + 1, j - 1)$$$; $$$(i + 1, j)$$$; $$$(i + 1, j + 1)$$$; Of course, you can not move figures to cells out of the board. It is allowed that after a move there will be several figures in one cell.Your task is to find the minimum number of moves needed to get all the figures into one cell (i.e. $$$n^2-1$$$ cells should contain $$$0$$$ figures and one cell should contain $$$n^2$$$ figures).You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 200$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \\le n < 5 \\cdot 10^5$$$) \u2014 the size of the board. It is guaranteed that $$$n$$$ is odd (not divisible by $$$2$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5 \\cdot 10^5$$$ ($$$\\sum n \\le 5 \\cdot 10^5$$$).", "output_spec": "For each test case print the answer \u2014 the minimum number of moves needed to get all the figures into one cell.", "sample_inputs": ["3\n1\n5\n499993"], "sample_outputs": ["0\n40\n41664916690999888"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0);\n$d = 0;\n$e = 0;\nfor($x = 0; $x < $a; $x++)\n{\n if($b[$x] == 4)\n {\n $c[4]++;\n $d++;\n }\n elseif($b[$x] == 8)\n {\n if($c[4] > $c[8])\n {\n $c[8]++;\n $d++;\n }\n }\n elseif($b[$x] == 15)\n {\n if($c[8] > $c[15])\n {\n $c[15]++;\n $d++;\n }\n }\n elseif($b[$x] == 16)\n {\n if($c[15] > $c[16])\n {\n $c[16]++;\n $d++;\n }\n }\n elseif($b[$x] == 23)\n {\n if($c[16] > $c[23])\n {\n $c[23]++;\n $d++;\n }\n }\n elseif($b[$x] == 42)\n {\n if($c[23] > $c[42])\n {\n $c[42]++;\n $d++;\n $e++;\n }\n }\n}\nprint $a - $e * 6;\n?>"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];\n$delete = $group = 0;\nforeach ($arr as $i => $value) {\n if ($value === '4') {\n $amounts[$value]++;\n } else{\n $amounts[$value] = min($amounts[$prev[$value]], $amounts[$value] + 1);\n }\n}\necho $n - $amounts[42] * 6;\n"}], "negative_code": [{"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0);\n$d = 0;\n$e = 0;\nfor($x = 0; $x < $a; $x++)\n{\n if($b[$x] == 4)\n {\n $c[4]++;\n $d++;\n }\n elseif($b[$x] == 8)\n {\n $c[8]++;\n if($c[4] >= $c[8])\n {\n $d++;\n }\n }\n elseif($b[$x] == 15)\n {\n $c[15]++;\n if(($c[4] >= $c[15]) && ($c[8] >= $c[15]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 16)\n {\n $c[16]++;\n if(($c[4] >= $c[16]) && ($c[8] >= $c[16]) && ($c[15] >= $c[16]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 23)\n {\n $c[23]++;\n if(($c[4] >= $c[23]) && ($c[8] >= $c[23]) && ($c[15] >= $c[23]) && ($c[16] >= $c[23]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 42)\n {\n $c[42]++;\n if(($c[4] >= $c[42]) && ($c[8] >= $c[42]) && ($c[15] >= $c[42]) && ($c[16] >= $c[42]) && ($c[23] >= $c[42]))\n {\n $d++;\n $e++;\n }\n }\n}\nprint $a - $e * 6;\n?>"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0);\n$d = 0;\nfor($x = 0; $x < $a; $x++)\n{\n if($b[$x] == 4)\n {\n $c[4]++;\n $d++;\n }\n elseif($b[$x] == 8)\n {\n $c[8]++;\n if($c[4] >= $c[8])\n {\n $d++;\n }\n }\n elseif($b[$x] == 15)\n {\n $c[15]++;\n if(($c[4] >= $c[15]) && ($c[8] >= $c[15]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 16)\n {\n $c[16]++;\n if(($c[4] >= $c[16]) && ($c[8] >= $c[16]) && ($c[15] >= $c[16]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 23)\n {\n $c[23]++;\n if(($c[4] >= $c[23]) && ($c[8] >= $c[23]) && ($c[15] >= $c[23]) && ($c[16] >= $c[23]))\n {\n $d++;\n }\n }\n elseif($b[$x] == 42)\n {\n $c[42]++;\n if(($c[4] >= $c[42]) && ($c[8] >= $c[42]) && ($c[15] >= $c[42]) && ($c[16] >= $c[42]) && ($c[23] >= $c[42]))\n {\n $d++;\n }\n }\n}\nprint $a - $d;\n?>"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$delete = 0;\nforeach ($arr as $value) {\n if (isset($amounts[$value])) {\n $amounts[$value]++;\n } else {\n $delete++;\n }\n}\n$min = min($amounts);\nif ($min === 0) {\n $delete += array_sum($amounts);\n} else {\n foreach ($amounts as $amount) {\n $delete += $amount - $min;\n }\n}\necho $delete;\n"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];\n$delete = $group = 0;\nforeach ($arr as $i => $value) {\n if ($value === '4') {\n $amounts[$value]++;\n } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {\n $amounts[$value]++;\n }\n if ($value === '42' && $amounts[42] > 0 && $amounts[$prev[$value]] === $amounts[$value]) {\n $group++;\n }\n}\necho $n - $group * 6;\n"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];\n$delete = $group = 0;\nforeach ($arr as $i => $value) {\n if ($value === '4') {\n $amounts[$value]++;\n } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {\n $amounts[$value]++;\n }\n if ($value === '42' && $amounts[$prev[$value]] === $amounts[$value]) {\n $group++;\n }\n}\necho $n - $group * 6;\n"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];\n$delete = $group = 0;\nforeach ($arr as $i => $value) {\n if ($value === 4) {\n $amounts[$value]++;\n } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {\n $amounts[$value]++;\n }\n if ($value === 42 && $amounts[$prev[$value]] === $amounts[$value]) {\n $group++;\n }\n}\necho $n - $group * 6;\n"}, {"source_code": " 0, 8 => 0, 15 => 0, 16 => 0, 23 => 0, 42 => 0];\n$prev = [8 => 4, 15 => 8, 16 => 15, 23 => 16, 42 => 23];\n$delete = $group = 0;\nforeach ($arr as $i => $value) {\n if ($value === '4') {\n $amounts[$value]++;\n } elseif (isset($amounts[$value]) && $amounts[$prev[$value]] > $amounts[$value]) {\n $amounts[$value]++;\n }\n if ($value === '42' && $amounts[42] > 0 && $amounts[$prev[$value]] === $amounts[$value]) {\n $group++;\n }\n}\nvar_dump($amounts);\necho $n - $group * 6;\n"}], "src_uid": "eb3155f0e6ba088308fa942f3572f582"} {"nl": {"description": "\"We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme.\"\"Little Alena got an array as a birthday present...\"The array b of length n is obtained from the array a of length n and two integers l and r\u00a0(l\u2009\u2264\u2009r) using the following procedure:b1\u2009=\u2009b2\u2009=\u2009b3\u2009=\u2009b4\u2009=\u20090.For all 5\u2009\u2264\u2009i\u2009\u2264\u2009n: bi\u2009=\u20090 if ai,\u2009ai\u2009-\u20091,\u2009ai\u2009-\u20092,\u2009ai\u2009-\u20093,\u2009ai\u2009-\u20094\u2009>\u2009r and bi\u2009-\u20091\u2009=\u2009bi\u2009-\u20092\u2009=\u2009bi\u2009-\u20093\u2009=\u2009bi\u2009-\u20094\u2009=\u20091 bi\u2009=\u20091 if ai,\u2009ai\u2009-\u20091,\u2009ai\u2009-\u20092,\u2009ai\u2009-\u20093,\u2009ai\u2009-\u20094\u2009<\u2009l and bi\u2009-\u20091\u2009=\u2009bi\u2009-\u20092\u2009=\u2009bi\u2009-\u20093\u2009=\u2009bi\u2009-\u20094\u2009=\u20090 bi\u2009=\u2009bi\u2009-\u20091 otherwise You are given arrays a and b' of the same length. Find two integers l and r\u00a0(l\u2009\u2264\u2009r), such that applying the algorithm described above will yield an array b equal to b'.It's guaranteed that the answer exists.", "input_spec": "The first line of input contains a single integer n (5\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014 the length of a and b'. The second line of input contains n space separated integers a1,\u2009...,\u2009an (\u2009-\u2009109\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the elements of a. The third line of input contains a string of n characters, consisting of 0 and 1\u00a0\u2014 the elements of b'. Note that they are not separated by spaces.", "output_spec": "Output two integers l and r\u00a0(\u2009-\u2009109\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009109), conforming to the requirements described above. If there are multiple solutions, output any of them. It's guaranteed that the answer exists.", "sample_inputs": ["5\n1 2 3 4 5\n00001", "10\n-10 -9 -8 -7 -6 6 7 8 9 10\n0000111110"], "sample_outputs": ["6 15", "-5 5"], "notes": "NoteIn the first test case any pair of l and r pair is valid, if 6\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009109, in that case b5\u2009=\u20091, because a1,\u2009...,\u2009a5\u2009<\u2009l."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "3d8c881d96c998dce7059384cd882273"} {"nl": {"description": "Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.In total the table Arthur bought has n legs, the length of the i-th leg is li.Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number di\u00a0\u2014\u00a0the amount of energy that he spends to remove the i-th leg.A table with k legs is assumed to be stable if there are more than half legs of the maximum length. For example, to make a table with 5 legs stable, you need to make sure it has at least three (out of these five) legs of the maximum length. Also, a table with one leg is always stable and a table with two legs is stable if and only if they have the same lengths.Your task is to help Arthur and count the minimum number of energy units Arthur should spend on making the table stable.", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014\u00a0the initial number of legs in the table Arthur bought. The second line of the input contains a sequence of n integers li (1\u2009\u2264\u2009li\u2009\u2264\u2009105), where li is equal to the length of the i-th leg of the table. The third line of the input contains a sequence of n integers di (1\u2009\u2264\u2009di\u2009\u2264\u2009200), where di is the number of energy units that Arthur spends on removing the i-th leg off the table.", "output_spec": "Print a single integer \u2014 the minimum number of energy units that Arthur needs to spend in order to make the table stable.", "sample_inputs": ["2\n1 5\n3 2", "3\n2 4 4\n1 1 1", "6\n2 2 1 1 3 3\n4 3 5 5 2 1"], "sample_outputs": ["2", "0", "8"], "notes": null}, "positive_code": [{"source_code": " 0; $j--) {\n if ($count == 0) break;\n if ($f[$j] == 0) continue;\n $min = min($count, $f[$j]);\n $cur += $min * $j;\n $count -= $min;\n }\n foreach($itr as $v) $f[$v]++;\n $ans = min($ans, $sumd - $cur);\n $map[$i] = null;\n }\n echo $ans;"}, {"source_code": " 0; $j--) {\n if ($count == 0) break;\n if ($f[$j] == 0) continue;\n $min = min($count, $f[$j]);\n $cur += $min * $j;\n $count -= $min;\n }\n foreach($itr as $v) $f[$v]++;\n $ans = min($ans, $sumd - $cur);\n }\n echo $ans;"}, {"source_code": " 0; $j--) {\n if ($count == 0) break;\n if ($f[$j] == 0) continue;\n $min = min($count, $f[$j]);\n $cur += $min * $j;\n $count -= $min;\n }\n foreach($itr as $v) $f[$v]++;\n $ans = min($ans, $sumd - $cur);\n $itr = null;\n }\n echo $ans;"}], "negative_code": [], "src_uid": "afd12d95b59b250a0a5af87e5277a3fb"} {"nl": {"description": "Given an array $$$a$$$ of length $$$n$$$ and an integer $$$k$$$, find the number of indices $$$1 \\leq i \\leq n - k$$$ such that the subarray $$$[a_i, \\dots, a_{i+k}]$$$ with length $$$k+1$$$ (not with length $$$k$$$) has the following property: If you multiply the first element by $$$2^0$$$, the second element by $$$2^1$$$, ..., and the ($$$k+1$$$)-st element by $$$2^k$$$, then this subarray is sorted in strictly increasing order. More formally, count the number of indices $$$1 \\leq i \\leq n - k$$$ such that $$$$$$2^0 \\cdot a_i < 2^1 \\cdot a_{i+1} < 2^2 \\cdot a_{i+2} < \\dots < 2^k \\cdot a_{i+k}.$$$$$$ ", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n$$$, $$$k$$$ ($$$3 \\leq n \\leq 2 \\cdot 10^5$$$, $$$1 \\leq k < n$$$)\u00a0\u2014 the length of the array and the number of inequalities. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the elements of the array. The sum of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the number of indices satisfying the condition in the statement.", "sample_inputs": ["6\n\n4 2\n\n20 22 19 84\n\n5 1\n\n9 5 3 2 1\n\n5 2\n\n9 5 3 2 1\n\n7 2\n\n22 12 16 4 3 22 12\n\n7 3\n\n22 12 16 4 3 22 12\n\n9 3\n\n3 9 12 3 9 12 3 9 12"], "sample_outputs": ["2\n3\n2\n3\n1\n0"], "notes": "NoteIn the first test case, both subarrays satisfy the condition: $$$i=1$$$: the subarray $$$[a_1,a_2,a_3] = [20,22,19]$$$, and $$$1 \\cdot 20 < 2 \\cdot 22 < 4 \\cdot 19$$$. $$$i=2$$$: the subarray $$$[a_2,a_3,a_4] = [22,19,84]$$$, and $$$1 \\cdot 22 < 2 \\cdot 19 < 4 \\cdot 84$$$. In the second test case, three subarrays satisfy the condition: $$$i=1$$$: the subarray $$$[a_1,a_2] = [9,5]$$$, and $$$1 \\cdot 9 < 2 \\cdot 5$$$. $$$i=2$$$: the subarray $$$[a_2,a_3] = [5,3]$$$, and $$$1 \\cdot 5 < 2 \\cdot 3$$$. $$$i=3$$$: the subarray $$$[a_3,a_4] = [3,2]$$$, and $$$1 \\cdot 3 < 2 \\cdot 2$$$. $$$i=4$$$: the subarray $$$[a_4,a_5] = [2,1]$$$, but $$$1 \\cdot 2 = 2 \\cdot 1$$$, so this subarray doesn't satisfy the condition. "}, "positive_code": [{"source_code": "= $ar[$i] << 1) {\n $res += max(0, $i - $segSt - $k);\n $segSt = $i;\n }\n }\n\n $res += max(0, $i - $segSt - $k);\n\n echo $res.PHP_EOL;\n}\n\n/*\n1\n6 2\n10 9 8 7 6 5\n// 4\n1\n3 1\n10 9 8\n//2\n\n1\n3 1\n4 2 1\n//0\n\n1\n4 1\n10 10 1 2\n//2\n */\n"}], "negative_code": [], "src_uid": "b5ef56f2eb482682414c32fba83a3949"} {"nl": {"description": "Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1,\u2009a2,\u2009...,\u2009an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to m, but he doesn't really like others. We define as bj the number of songs the group j is going to perform tomorrow. Polycarp wants to change the playlist in such a way that the minimum among the numbers b1,\u2009b2,\u2009...,\u2009bm will be as large as possible.Find this maximum possible value of the minimum among the bj (1\u2009\u2264\u2009j\u2009\u2264\u2009m), and the minimum number of changes in the playlist Polycarp needs to make to achieve it. One change in the playlist is a replacement of the performer of the i-th song with any other group.", "input_spec": "The first line of the input contains two integers n and m (1\u2009\u2264\u2009m\u2009\u2264\u2009n\u2009\u2264\u20092000). The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109), where ai is the performer of the i-th song.", "output_spec": "In the first line print two integers: the maximum possible value of the minimum among the bj (1\u2009\u2264\u2009j\u2009\u2264\u2009m), where bj is the number of songs in the changed playlist performed by the j-th band, and the minimum number of changes in the playlist Polycarp needs to make. In the second line print the changed playlist. If there are multiple answers, print any of them.", "sample_inputs": ["4 2\n1 2 3 2", "7 3\n1 3 2 2 2 2 1", "4 4\n1000000000 100 7 1000000000"], "sample_outputs": ["2 1\n1 2 1 2", "2 1\n1 3 3 2 2 2 1", "1 4\n1 2 3 4"], "notes": "NoteIn the first sample, after Polycarp's changes the first band performs two songs (b1\u2009=\u20092), and the second band also performs two songs (b2\u2009=\u20092). Thus, the minimum of these values equals to 2. It is impossible to achieve a higher minimum value by any changes in the playlist. In the second sample, after Polycarp's changes the first band performs two songs (b1\u2009=\u20092), the second band performs three songs (b2\u2009=\u20093), and the third band also performs two songs (b3\u2009=\u20092). Thus, the best minimum value is 2. "}, "positive_code": [{"source_code": " $b)\n {\n $e++;\n }\n else\n {\n $d[$f]++;\n }\n}\n$f = floor($a / $b);\n$i = 0;\n$l = array();\n$m = array();\n$n = 0;\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] > $b)\n {\n array_push($o, $c[$x]);\n }\n}\n$p = 0;\nwhile(TRUE)\n{\n $g = min($d);\n if($g == $f)\n {\n break;\n }\n else\n {\n if($e > 0)\n {\n $e--;\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $g)\n {\n $l[$n] = $o[$p];\n $m[$n] = $x;\n $n++;\n $p++;\n $d[$x]++;\n break;\n }\n }\n }\n else\n {\n $h = max($d);\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $h)\n {\n $l[$n] = $x;\n $d[$x]--;\n break;\n }\n }\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $g)\n {\n $m[$n] = $x;\n $d[$x]++;\n break;\n }\n }\n $n++;\n }\n }\n $i++;\n}\nprint min($d) . \" \" . $i . \"\\n\";\narray_unshift($l, \" \");\nunset($l[0]);\narray_unshift($m, \" \");\nunset($m[0]);\nfor($x = 1; $x <= count($l); $x++)\n{\n $o = $l[$x];\n $p = array_search($o, $c2);\n if($p == TRUE)\n {\n $c2[$p] = $m[$x];\n }\n}\nprint implode(\" \", $c2);\n?>"}], "negative_code": [{"source_code": " $b)\n {\n $e++;\n }\n else\n {\n $d[$f]++;\n }\n}\n$f = floor($a / $b);\n$i = 0;\nwhile(TRUE)\n{\n $g = min($d);\n if($g == $f)\n {\n break;\n }\n else\n {\n if($e > 0)\n {\n $e--;\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $g)\n {\n $d[$x]++;\n break;\n }\n }\n }\n else\n {\n $h = max($d);\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $h)\n {\n $d[$x]--;\n break;\n }\n }\n for($x = 1; $x <= $b; $x++)\n {\n if($d[$x] == $g)\n {\n $d[$x]++;\n break;\n }\n }\n }\n }\n $i++;\n}\nprint min($d) . \" \" . $i . \"\\n\";\n$j = array();\n$k = 0;\nfor($x = 1; $x <= $b; $x++)\n{\n for($y = 0; $y < $d[$x]; $y++)\n {\n $j[$k] = $x;\n $k++;\n }\n}\nif($e > 0)\n{\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] > $b)\n {\n $j[$k] = $c[$x];\n $k++;\n break;\n }\n }\n}\nprint implode(\" \", $j);\n?>"}], "src_uid": "0d89602f5ed765adf6807f86df1205bd"} {"nl": {"description": "Given an array $$$a$$$ of $$$n$$$ elements, print any value that appears at least three times or print -1 if there is no such value.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot10^5$$$)\u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\leq a_i \\leq n$$$)\u00a0\u2014 the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each test case, print any value that appears at least three times or print -1 if there is no such value.", "sample_inputs": ["7\n\n1\n\n1\n\n3\n\n2 2 2\n\n7\n\n2 2 3 3 4 2 2\n\n8\n\n1 4 3 4 3 2 4 1\n\n9\n\n1 1 1 2 2 2 3 3 3\n\n5\n\n1 5 2 4 3\n\n4\n\n4 4 4 4"], "sample_outputs": ["-1\n2\n2\n4\n3\n-1\n4"], "notes": "NoteIn the first test case there is just a single element, so it can't occur at least three times and the answer is -1.In the second test case, all three elements of the array are equal to $$$2$$$, so $$$2$$$ occurs three times, and so the answer is $$$2$$$.For the third test case, $$$2$$$ occurs four times, so the answer is $$$2$$$.For the fourth test case, $$$4$$$ occurs three times, so the answer is $$$4$$$.For the fifth test case, $$$1$$$, $$$2$$$ and $$$3$$$ all occur at least three times, so they are all valid outputs.For the sixth test case, all elements are distinct, so none of them occurs at least three times and the answer is -1."}, "positive_code": [{"source_code": "= 3) {\r\n for($i = 0; $i < $n; $i++) {\r\n if(isset($res[$a[$i]])) {\r\n $res[$a[$i]] += 1;\r\n if($res[$a[$i]] >= 3) {\r\n $q1 = $a[$i];\r\n break;\r\n }\r\n }else {\r\n $res[$a[$i]] = 1;\r\n }\r\n }\r\n }\r\n echo $q1 . \"\\n\";\r\n }"}, {"source_code": ""}, {"source_code": " true, 2 => true]\r\n )) ? reset($a) : -1\r\n );\r\n}"}], "negative_code": [{"source_code": "= 3) {\r\n for($i = 0; $i < $n; $i++) {\r\n if(isset($res[$a[$i]])) {\r\n $res[$a[$i]] = $a[$i] + 1;\r\n if($res[$a[$i]] >= 3) {\r\n $q1 = $a[$i];\r\n break;\r\n }\r\n }else {\r\n $res[$a[$i]] = 1;\r\n }\r\n }\r\n }\r\n echo $q1 . \"\\n\";\r\n }"}, {"source_code": "= 3) {\r\n $a = mergeSort($a1);\r\n for($i = 0; $i < $n; $i++) {\r\n if(isset($res[$a[$i]])) {\r\n $res[$a[$i]] = $a[$i] + 1;\r\n if($res[$a[$i]] == 3) {\r\n $q1 = $a[$i];\r\n break;\r\n }\r\n }else {\r\n $res[$a[$i]] = 1;\r\n }\r\n }\r\n }\r\n echo $q1 . \"\\n\";\r\n }\r\n function pushRes($w) {\r\n \r\n }\r\n function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i]; \r\n }\r\n for($i = $n; $i "}, {"source_code": ""}, {"source_code": "100000000000){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n\t$res = bcadd($res, $l);\n\t\n\techo bcmul($res, \"2\");\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": "$p;$i-=$m) {\n\t\t\n\t\t$l += abs($a[$i] - $v);\n\t}\n\t\n\techo $l*2;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$long || $l<-$long){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n\t$res = bcadd($res, $l);\n\t\n\techo bcmul($l, \"2\");\n?>"}, {"source_code": "10000000000){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n$l-=$long;\n\t\n\techo bcmul($l, \"2\");\n?>"}, {"source_code": ""}, {"source_code": "100000000){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n\t$res = bcadd($res, $l);\n\t\n\techo bcmul($l, \"2\");\n?>"}, {"source_code": "$long || $l<-$long){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n\t$res = bcadd($res, $l);\n\t\n\techo bcmul($l, \"2\");\n?>"}, {"source_code": "100000000){\n\t\t\t$res = bcadd($res, $l);\n\t\t\t$l=0;\n\t\t}\n\t\t\n\t\t$i += $m;\n\t\t$j -= $m;\n\t}\n$l-=$long;\n\t\n\techo bcmul($l, \"2\");\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "47a8fd4c1f4e7b1d4fd15fbaf5f6fda8"} {"nl": {"description": "During the \"Russian Code Cup\" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x\u00a0\u2014 the number of different solutions that are sent before the first solution identical to A, and k \u2014 the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x\u2009>\u20090) of the participant with number k, then the testing system has a solution with number x\u2009-\u20091 of the same participant stored somewhere before.During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.", "input_spec": "The first line of the input contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014 the number of solutions. Each of the following n lines contains two integers separated by space x and k (0\u2009\u2264\u2009x\u2009\u2264\u2009105; 1\u2009\u2264\u2009k\u2009\u2264\u2009105)\u00a0\u2014 the number of previous unique solutions and the identifier of the participant.", "output_spec": "A single line of the output should contain \u00abYES\u00bb if the data is in chronological order, and \u00abNO\u00bb otherwise.", "sample_inputs": ["2\n0 1\n1 1", "4\n0 1\n1 2\n1 1\n0 2", "4\n0 1\n1 1\n0 1\n0 2"], "sample_outputs": ["YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": " 1))\n {\n $b = 1;\n break;\n }\n elseif(($c[$e] == FALSE) && ($d == 1))\n {\n $c[$e] = $d;\n }\n elseif($c[$e] == TRUE)\n {\n if($d <= $c[$e])\n {\n $c[$e] = max($c[$e], $d);\n }\n elseif($d - $c[$e] == 1)\n {\n $c[$e] = $d;\n }\n elseif($d - $c[$e] > 1)\n {\n $b = 1;\n break;\n }\n }\n}\nif($b == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " $aa[$p] + 1) || (! @isset($aa[$p]) && $u != 0) )\n\t{\n\t\techo \"NO\" . PHP_EOL;\n\t\texit;\n\t}\n\t\n\tif(! @isset($aa[$p]))\n\t\t$aa[$p] = 0;\n\t\n\t$aa[$p] = max($u, $aa[$p]);\n}\n\n/*\nfor($i = 1; $i < sizeof($a); $i++)\n{\n\tif($a[$i - 1] > $a[$i])\n\t{\n\t\techo \"NO\" . PHP_EOL;\n\t\texit;\n\t}\n\t\n\t$a[$i] = max($a[$i], $a[$i - 1]);\n}\n*/\necho \"YES\" . PHP_EOL;"}, {"source_code": " $sends){\n $exist[$user][]=$sends[0];\n if ($sends[0]>0){\n $r='NO';\n echo $r;\n return;\n };\n $max=max($exist[$user]);\n for($i=1; $i "}, {"source_code": " 1))\n {\n $b = 1;\n break;\n }\n elseif(($c[$e] == FALSE) && ($d == 1))\n {\n $c[$e] = $d;\n }\n elseif($c[$e] == TRUE)\n {\n if($d <= $c[$e])\n {\n $c[$e] = $d;\n }\n elseif($d - $c[$e] == 1)\n {\n $c[$e] = $d;\n }\n elseif($d - $c[$e] > 1)\n {\n $b = 1;\n break;\n }\n }\n}\nif($b == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " $a[$i][$j])\n\t\t{\n\t\t\techo \"NO\" . PHP_EOL;\n\t\t\texit;\n\t\t}\n\t\t\n\t\t$a[$i][$j] = max($a[$i][$j], $a[$i][$j - 1]);\n\t}\n}\n\necho \"YES\" . PHP_EOL;"}, {"source_code": " $a[$i])\n\t{\n\t\techo \"NO\" . PHP_EOL;\n\t\texit;\n\t}\n\t\n\t$a[$i] = max($a[$i], $a[$i - 1]);\n}\n\necho \"YES\" . PHP_EOL;"}, {"source_code": " $sends){\n $exist[$user]=array();\n for($i=0; $i $a){\n $r='NO';\n echo $r;\n return;\n }\n $exist[$user][]=$a;\n }\n}\necho $r;"}, {"source_code": " $sends){\n $exist[$user][]=$sends[0];\n for($i=1; $i $sends){\n $exist[$user]=array();\n for($i=0; $i =1){\n $r='NO';\n echo $r;\n return;\n }\n $exist[$user][]=$a;\n }\n}\necho $r;"}], "src_uid": "6f6f56d3106e09d51ebb3a206fa4be3c"} {"nl": {"description": "For an array $$$a$$$ of integers let's denote its maximal element as $$$\\max(a)$$$, and minimal as $$$\\min(a)$$$. We will call an array $$$a$$$ of $$$k$$$ integers interesting if $$$\\max(a) - \\min(a) \\ge k$$$. For example, array $$$[1, 3, 4, 3]$$$ isn't interesting as $$$\\max(a) - \\min(a) = 4 - 1 = 3 < 4$$$ while array $$$[7, 3, 0, 4, 3]$$$ is as $$$\\max(a) - \\min(a) = 7 - 0 = 7 \\ge 5$$$.You are given an array $$$a$$$ of $$$n$$$ integers. Find some interesting nonempty subarray of $$$a$$$, or tell that it doesn't exist.An array $$$b$$$ is a subarray of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.", "input_spec": "The first line contains integer number $$$t$$$ ($$$1 \\le t \\le 10\\,000$$$). Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$2\\le n \\le 2\\cdot 10^5$$$)\u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$0\\le a_i \\le 10^9$$$)\u00a0\u2014 the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, output \"NO\" in a separate line if there is no interesting nonempty subarray in $$$a$$$. Otherwise, output \"YES\" in a separate line. In the next line, output two integers $$$l$$$ and $$$r$$$ ($$$1\\le l \\le r \\le n$$$)\u00a0\u2014 bounds of the chosen subarray. If there are multiple answers, print any. You can print each letter in any case (upper or lower).", "sample_inputs": ["3\n5\n1 2 3 4 5\n4\n2 0 1 9\n2\n2019 2020"], "sample_outputs": ["NO\nYES\n1 4\nNO"], "notes": "NoteIn the second test case of the example, one of the interesting subarrays is $$$a = [2, 0, 1, 9]$$$: $$$\\max(a) - \\min(a) = 9 - 0 = 9 \\ge 4$$$."}, "positive_code": [{"source_code": " =2)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($j+1).\" \".($j+2).\"\\n\";\n break;\n }\n }\n if(!$ok)\n {\n echo \"NO\".\"\\n\";\n }\n \n }\n \n ?>"}, {"source_code": "= 2)\n {\n $d = 1;\n break;\n }\n }\n if($d == 0)\n {\n print \"NO\\n\";\n }\n else\n {\n print \"YES\\n\";\n print ($y + 1) . \" \" . ($y + 2) . \"\\n\";\n }\n}\n?>"}, {"source_code": " 1){\n\t\t\techo \"YES\\n\";\n\t\t\techo ($i) . ' ' . ($i + 1) . \"\\n\";\n\t\t\treturn;\n\t\t}\n\t}\n\techo \"NO\\n\";\n};\n\nfor (; $t != 0; $t--) {\n\t$n = intval(trim(fgets(STDIN)));\n\t$a = explode(' ', trim(fgets(STDIN)));\n\n\t$iterate($a, $n);\n}\n\n\n"}], "negative_code": [{"source_code": "$p[$j])\n {\n $min=$p[$j];\n $l=$j;\n }\n }\n if($max-$min>=(abs($r-$l)+1))\n {\n echo \"YES\".\"\\n\";\n echo min($l+1,$r+1).\" \".max($l+1,$r+1).\"\\n\";\n }else\n {\n echo \"NO\".\"\\n\";\n }\n\n}\n\n?>\n"}, {"source_code": "$a[$i])\n {\n $min=$a[$i];\n }\n if($max<$a[$i])\n {\n $max=$a[$i];\n }\n }\n return $max-$min;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;\n $min=10000000009;\n $max=0;\n while( $l<=$x-1)\n { if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n //echo $max.\" \".$min.\"
\";\n if($max-$min>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n $r++;\n\n if($r==$x)\n {\n $l++;\n $min=10000000009;\n $max=0;\n $r=$l;\n $count=1;\n }\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else if($check==false)\n {\n $l++;\n $count--;\n $check=true;\n }else if($check==true)\n {\n $r--;\n $count--;\n $check=false;\n }\n }\n $sum=0;$l=0;$r=$x-1;$count=$x;$check=true;$ok=false;\n while($l<$r)\n {\n if($p[$r]-$p[$l]>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else if($check==false)\n {\n $l++;\n $count--;\n $check=true;\n }else if($check==true)\n {\n $r--;\n $count--;\n $check=false;\n }\n }\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": " =2)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($i+1).\" \".($i+2).\"\\n\";\n }\n }\n if(!$ok)\n {\n echo \"NO\".\"\\n\";\n }\n \n }\n \n ?>"}, {"source_code": "$a[$i])\n {\n $min=$a[$i];\n }\n if($max<$a[$i])\n {\n $max=$a[$i];\n }\n }\n return $max-$min;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;\n $min=$p[0];\n $max=$p[0];\n while($l<$x-1)\n {\n if($max-$min>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n\n $r++;\n if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n if($r==$x-1)\n {\n\n $l++;\n $max=$p[$l];\n $min=$p[$l];\n $r=$l;\n $count=1;\n }\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "$p[$j])\n {\n $min=$p[$j];\n $l=$j;\n }\n }\n if($max-$min>=($r-$l+1))\n {\n echo \"YES\".\"\\n\";\n echo min($l+1,$r+1).\" \".max($l+1,$r+1).\"\\n\";\n }else\n {\n echo \"NO\".\"\\n\";\n }\n\n}\n\n?>\n"}, {"source_code": "$a[$i])\n {\n $min=$a[$i];\n }\n if($max<$a[$i])\n {\n $max=$a[$i];\n }\n }\n return $max-$min;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;\n $min=$p[0];\n $max=$p[0];\n while($l<$x-1)\n {\n if(getb($p,$l,$r)>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n $r++;\n if($r==$x-1)\n {\n $l++;\n $r=$l;\n $count=1;\n }\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "$a[$i])\n {\n $min=$a[$i];\n }\n if($max<$a[$i])\n {\n $max=$a[$i];\n }\n }\n return $max-$min;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;\n $min=$a[0];\n $max=$a[0];\n while($l<$x-1)\n {\n if($max-$min>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n\n $r++;\n if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n if($r==$x-1)\n {\n\n $l++;\n $max=$p[$l];\n $min=$p[$l];\n $r=$l;\n $count=1;\n }\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "$a[$i])\n {\n $min=$a[$i];\n }\n if($max<$a[$i])\n {\n $max=$a[$i];\n }\n }\n return $max-$min;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n $sum=0;$l=0;$r=0;$count=1;$check=false;$ok=false;\n $min=10000000009;\n $max=0;\n while( $l<=$x-1)\n { if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n //echo $max.\" \".$min.\"
\";\n if($max-$min>=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n if($max<$p[$r])$max=$p[$r];\n if($min>$p[$r])$min=$p[$r];\n $r++;\n\n if($r==$x)\n {\n $l++;\n $min=10000000009;\n $max=0;\n $r=$l;\n }\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n if($p[$r]-$p[$l+1]>$p[$r-1]-$p[$l])\n {\n $l++;\n $count--;\n }else\n {\n $r--;\n $count--;\n }\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else if($check==false)\n {\n $l++;\n $count--;\n $check=true;\n }else if($check==true)\n {\n $r--;\n $count--;\n $check=false;\n }\n\n }\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "= 2)\n {\n $d = 1;\n break;\n }\n }\n if($d == 0)\n {\n print \"NO\\n\";\n }\n else\n {\n print \"YES\\n\";\n print $y . \" \" . ($y + 1) . \"\\n\";\n }\n}\n?>"}, {"source_code": " $j - $i) {\n\t\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ($min > $a[$j]) {\n\t\t\t\t\t\t$min = $a[$j];\n\t\t\t\t\t\tif ($max - $min > $j - $i) {\n\t\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif($delta < $j - $i){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$delta = $max - $min;\n\t\t}\n\t\treturn false;\n\t};\n\n\t$res = $iterate();\n\n\tif ($res === false) {\n\t\techo \"NO\\n\";\n\t} else {\n\t\techo \"YES\\n\";\n\t\techo ($res[0] + 1) . ' ' . ($res[1] + 1) . \"\\n\";\n\t}\n\n\n}\n\n\n"}, {"source_code": " $i; $j-- ){\n\t\t\t\tif($max < $a[$j]){\n\t\t\t\t\t$max = $a[$j];\n\t\t\t\t\tif($max - $min >= ($j - $i) + 1){\n\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t}\n\t\t\t\t} else if($min > $a[$j]){\n\t\t\t\t\t$min = $a[$j];\n\t\t\t\t\tif($max - $min >= ($j - $i) + 1){\n\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t};\n\n\t$res = $iterate();\n\n\tif($res===false){\n\t\techo \"NO\\n\";\n\t} else {\n\t\techo \"YES\\n\";\n\t\techo (min($res)+1).' '.(max($res)+1).\"\\n\";\n\t}\n}\n\n\n"}, {"source_code": " $j - $i) {\n\t\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ($min > $a[$j]) {\n\t\t\t\t\t\t$min = $a[$j];\n\t\t\t\t\t\tif ($max - $min > $j - $i) {\n\t\t\t\t\t\t\treturn [$i, $j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif($delta <= $j - $i){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$delta = $max - $min;\n\t\t}\n\t\treturn false;\n\t};\n\n\t$res = $iterate();\n\n\tif ($res === false) {\n\t\techo \"NO\\n\";\n\t} else {\n\t\techo \"YES\\n\";\n\t\techo ($res[0] + 1) . ' ' . ($res[1] + 1) . \"\\n\";\n\t}\n\n\n}\n\n\n"}, {"source_code": "$k)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo min($k+1,$j+1).\" \".max($j+1,$k+1).\"\\n\";\n break;\n }\n\n }\n if($ok==true)break;\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n if($p[$r]-$p[$l+1]>$p[$r-1]-$p[$l])\n {\n $l++;\n $count--;\n }else\n {\n $r--;\n $count--;\n }\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=sizeof($temp))\n {\n echo \"YES\".\"\\n\";\n echo $i.\" \".$j.\"\\n\";\n return true;\n }\n }\n }\n return false;\n}\n$server = \"php://stdin\";\n$local = \"input.txt\";\n$handle = fopen($server, \"r\");\n$t = trim(fgets($handle));\n\nfor ($i=0;$i<$t;$i++)\n{\n $x = trim(fgets($handle));\n $a = trim(fgets($handle));\n $p = explode(' ', $a);\n\n if(!subArray($p,$x))\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=$count)\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo ($l+1).\" \".($r+1).\"\\n\";\n break;\n }else {\n if($r==$x-1)\n {\n $l++;\n $r=$l;\n $count=1;\n }\n $r++;\n $count++;\n }\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}, {"source_code": "=($k+1))\n {\n $ok=true;\n echo \"YES\".\"\\n\";\n echo min($k+1,$j+1).\" \".max($j+1,$k+1).\"\\n\";\n break;\n }\n\n }\n if($ok==true)break;\n }\n\n if(!$ok)\n echo \"NO\".\"\\n\";\n\n}\n\n?>\n"}], "src_uid": "fa16d33fb9447eea06fcded0026c6e31"} {"nl": {"description": "Pasha loves his phone and also putting his hair up... But the hair is now irrelevant.Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of n row with m pixels in each row. Initially, all the pixels are colored white. In one move, Pasha can choose any pixel and color it black. In particular, he can choose the pixel that is already black, then after the boy's move the pixel does not change, that is, it remains black. Pasha loses the game when a 2\u2009\u00d7\u20092 square consisting of black pixels is formed. Pasha has made a plan of k moves, according to which he will paint pixels. Each turn in his plan is represented as a pair of numbers i and j, denoting respectively the row and the column of the pixel to be colored on the current move.Determine whether Pasha loses if he acts in accordance with his plan, and if he does, on what move the 2\u2009\u00d7\u20092 square consisting of black pixels is formed.", "input_spec": "The first line of the input contains three integers n,\u2009m,\u2009k (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091000, 1\u2009\u2264\u2009k\u2009\u2264\u2009105)\u00a0\u2014 the number of rows, the number of columns and the number of moves that Pasha is going to perform. The next k lines contain Pasha's moves in the order he makes them. Each line contains two integers i and j (1\u2009\u2264\u2009i\u2009\u2264\u2009n, 1\u2009\u2264\u2009j\u2009\u2264\u2009m), representing the row number and column number of the pixel that was painted during a move.", "output_spec": "If Pasha loses, print the number of the move when the 2\u2009\u00d7\u20092 square consisting of black pixels is formed. If Pasha doesn't lose, that is, no 2\u2009\u00d7\u20092 square consisting of black pixels is formed during the given k moves, print 0.", "sample_inputs": ["2 2 4\n1 1\n1 2\n2 1\n2 2", "2 3 6\n2 3\n2 2\n1 3\n2 2\n1 2\n1 1", "5 3 7\n2 3\n1 2\n1 1\n4 1\n3 1\n5 3\n3 2"], "sample_outputs": ["4", "5", "0"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "0dc5469831c1d5d34aa3b7b172e3237b"} {"nl": {"description": "You are given $$$n$$$ sticks with positive integral length $$$a_1, a_2, \\ldots, a_n$$$.You can perform the following operation any number of times (possibly zero): choose one stick, then either increase or decrease its length by $$$1$$$. After each operation, all sticks should have positive lengths. What is the minimum number of operations that you have to perform such that it is possible to select three of the $$$n$$$ sticks and use them without breaking to form an equilateral triangle?An equilateral triangle is a triangle where all of its three sides have the same length.", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$3 \\le n \\le 300$$$)\u00a0\u2014 the number of sticks. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$)\u00a0\u2014 the lengths of the sticks. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$300$$$. ", "output_spec": "For each test case, print one integer on a single line\u00a0\u2014 the minimum number of operations to be made.", "sample_inputs": ["4\n\n3\n\n1 2 3\n\n4\n\n7 3 7 3\n\n5\n\n3 4 2 1 1\n\n8\n\n3 1 4 1 5 9 2 6"], "sample_outputs": ["2\n4\n1\n1"], "notes": "NoteIn the first test case, you can increase the length of the first stick by $$$1$$$, then decrease the length of the third stick by $$$1$$$. In total, you perform $$$2$$$ operations, such that the three sticks form an equilateral triangle of side length $$$2$$$.In the fourth test case, you can decrease the length of the seventh stick by $$$1$$$. An equilateral triangle of side length $$$1$$$ can be selected and formed by the second, fourth, and seventh sticks."}, "positive_code": [{"source_code": "$a[$j])\r\n {\r\n $x=$a[$i];\r\n $a[$i]=$a[$j];\r\n $a[$j]=$x;\r\n }\r\n $ans=10000000000000000;\r\n for($i=1;$i<$n-1;$i++)\r\n {\r\n $x=$a[$i+1]-$a[$i-1];\r\n if($x<$ans)\r\n $ans=$x;\r\n }\r\n echo $ans.\"\\n\";\r\n}\r\n?>"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [{"source_code": " 0; $i--) {\n echo $i . ' ' . 1 .' ' . $i . ' ' . 2 . PHP_EOL;\n}\n"}], "negative_code": [], "src_uid": "19190fd248eb2c621ac2c78b803049a8"} {"nl": {"description": "Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it. ", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092000)\u00a0\u2014 the length of the encoded word. The second line contains the string s of length n consisting of lowercase English letters\u00a0\u2014 the encoding.", "output_spec": "Print the word that Polycarp encoded.", "sample_inputs": ["5\nlogva", "2\nno", "4\nabba"], "sample_outputs": ["volga", "no", "baba"], "notes": "NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba."}, "positive_code": [{"source_code": ""}, {"source_code": "= 0 ; $i-=2)\n\t@$result.=$input[$i];\nfor ($i=$n-1; $i>=0;$i-=2)\n\t@$r.=$input[$i];\necho $result.strrev($r);"}, {"source_code": ""}, {"source_code": " 0) {\n\n $median = floor(strlen($letters) / 2) + (strlen($letters) % 2 == 1);\n \n while(isset($word[$median])) {\n $median++;\n if($median == ($n + 1)) {\n $median = 0;\n }\n }\n \n \n \n //for($median = floor(($n - $ii) / 2); isset($word[$median]); $median++);\n $word[$median] = $letters[0];\n //$n--;\n $letters = substr($letters, 1);\n \n}\n\nksort($word);\n\necho implode($word);"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "2a414730d1bc7eef50bdb631ea966366"} {"nl": {"description": "Let's define a string <x> as an opening tag, where x is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where x is the same letter.Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair.Let's define the notion of a XML-text: an empty string is a XML-text if s is a XML-text, then s'=<a>+s+</a> also is a XML-text, where a is any small Latin letter if s1, s2 are XML-texts, then s1+s2 also is a XML-text You are given a XML-text (it is guaranteed that the text is valid), your task is to print in the following form: each tag (opening and closing) is located on a single line print before the tag 2\u2009*\u2009h spaces, where h is the level of the tag's nestedness. ", "input_spec": "The input data consists on the only non-empty string \u2014 the XML-text, its length does not exceed 1000 characters. It is guaranteed that the text is valid. The text contains no spaces.", "output_spec": "Print the given XML-text according to the above-given rules.", "sample_inputs": ["<a><b><c></c></b></a>", "<a><b></b><d><c></c></d></a>"], "sample_outputs": ["<a>\n <b>\n <c>\n </c>\n </b>\n</a>", "<a>\n <b>\n </b>\n <d>\n <c>\n </c>\n </d>\n</a>"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "\n$str=trim(fgets(STDIN));\n$open=preg_match_all('/<\\w>/',$str,$mopen);\n$all=preg_match_all('/(<\\w>|<\\/\\w>)/',$str,$mall);\nfunction numspace($n){\n $str=\"\";\n for($i=0; $i<$n; $i++)\n $str.=\" \";\n return $str; \n}\n$lvl=0;\nfor($i=0; $i/',$mall[0][$i])) {\n $space=numspace($lvl*2);\n $lvl++;\n } else{\n $lvl--;\n $space=numspace($lvl*2);\n } \n echo $space.$mall[0][$i].\"\\n\";\n}\n?>"}], "negative_code": [], "src_uid": "45207d5ff60bbb6897feb1d9a3f85a65"} {"nl": {"description": "You are given two integers $$$n$$$ and $$$k$$$. Your task is to find if $$$n$$$ can be represented as a sum of $$$k$$$ distinct positive odd (not divisible by $$$2$$$) integers or not.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$) \u2014 the number of test cases. The next $$$t$$$ lines describe test cases. The only line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 10^7$$$).", "output_spec": "For each test case, print the answer \u2014 \"YES\" (without quotes) if $$$n$$$ can be represented as a sum of $$$k$$$ distinct positive odd (not divisible by $$$2$$$) integers and \"NO\" otherwise.", "sample_inputs": ["6\n3 1\n4 2\n10 3\n10 2\n16 4\n16 5"], "sample_outputs": ["YES\nYES\nNO\nYES\nYES\nNO"], "notes": "NoteIn the first test case, you can represent $$$3$$$ as $$$3$$$.In the second test case, the only way to represent $$$4$$$ is $$$1+3$$$.In the third test case, you cannot represent $$$10$$$ as the sum of three distinct positive odd integers.In the fourth test case, you can represent $$$10$$$ as $$$3+7$$$, for example.In the fifth test case, you can represent $$$16$$$ as $$$1+3+5+7$$$.In the sixth test case, you cannot represent $$$16$$$ as the sum of five distinct positive odd integers."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "a4c82fffb31bc7e42870fd84e043e815"} {"nl": {"description": "Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly $$$1$$$ problem, during the second day \u2014 exactly $$$2$$$ problems, during the third day \u2014 exactly $$$3$$$ problems, and so on. During the $$$k$$$-th day he should solve $$$k$$$ problems.Polycarp has a list of $$$n$$$ contests, the $$$i$$$-th contest consists of $$$a_i$$$ problems. During each day Polycarp has to choose exactly one of the contests he didn't solve yet and solve it. He solves exactly $$$k$$$ problems from this contest. Other problems are discarded from it. If there are no contests consisting of at least $$$k$$$ problems that Polycarp didn't solve yet during the $$$k$$$-th day, then Polycarp stops his training.How many days Polycarp can train if he chooses the contests optimally?", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of contests. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 2 \\cdot 10^5$$$) \u2014 the number of problems in the $$$i$$$-th contest.", "output_spec": "Print one integer \u2014 the maximum number of days Polycarp can train if he chooses the contests optimally.", "sample_inputs": ["4\n3 1 4 1", "3\n1 1 1", "5\n1 1 1 2 2"], "sample_outputs": ["3", "1", "2"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $sV){\n if($i <= $sV){\n $k++;\n $i++;\n }\n\n}\necho $k;"}, {"source_code": " $result) {\n $result++;\n }\n}\necho $result;\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $c){\n\t\t\t$c++;\n\t\t}\n\t}\n\n\techo $c-1;\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": " $sV){\n if($i <= $sV){\n $k++;\n }\n $i++;\n}\necho $k;"}, {"source_code": ""}, {"source_code": "$n ? $n : $c);\n?>"}, {"source_code": ""}], "src_uid": "4f02ac641ab112b9d6aee222e1365c09"} {"nl": {"description": "There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downwards, then to the left and so on). Every time he walks (n\u2009+\u20091) meters, he draws a cross (see picture for clarifications).John Doe stops only when the lower left corner of the square has two crosses. How many crosses will John draw? The figure shows the order in which John draws crosses for a square with side 4. The lower left square has two crosses. Overall John paints 17 crosses. ", "input_spec": "The first line contains integer t (1\u2009\u2264\u2009t\u2009\u2264\u2009104) \u2014 the number of test cases. The second line contains t space-separated integers ni (1\u2009\u2264\u2009ni\u2009\u2264\u2009109) \u2014 the sides of the square for each test sample.", "output_spec": "For each test sample print on a single line the answer to it, that is, the number of crosses John will draw as he will move along the square of the corresponding size. Print the answers to the samples in the order in which the samples are given in the input. Please do not use the %lld specifier to read or write 64-bit integers in \u0421++. It is preferred to use the cin, cout streams or the %I64d specifier. ", "sample_inputs": ["3\n4 8 100"], "sample_outputs": ["17\n33\n401"], "notes": null}, "positive_code": [{"source_code": "in();\n\t\n\tfor ($i = 0; $i < $tc; $i++)\n\t{\n\t\t$n = (int)$Input->in();\n\n\t\tif ($n % 2 == 0) print(4 * $n + 1);\n\t\telse\n\t\t{\n\t\t\t$g = gcd($n * 2, intval(($n + 1)/2));\n\t\t\tprintf(\"%.0f\",lcm($n * 4, intval(($n + 1)/2), $g) / ($n + 1) + 1);\n\t\t}\n\t\t\n\t\tif ($i !== $tc - 1) print(\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}, {"source_code": "in();\n\t\n\tfor ($i = 0; $i < $tc; $i++) {\n\t\t\n\t\t$n = (int)$Input->in();\n\n\t\tprint($n * 4 + 1);\n\t\t\n\t\tif ($i !== $tc - 1) print(\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "src_uid": "168dbc4994529f5407a440b0c71086da"} {"nl": {"description": "Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.There is a set $$$S$$$ containing very important numbers on his dad's desk. The minute Johnny heard about it, he decided that it's a good idea to choose a positive integer $$$k$$$ and replace each element $$$s$$$ of the set $$$S$$$ with $$$s \\oplus k$$$ ($$$\\oplus$$$ denotes the exclusive or operation). Help him choose such $$$k$$$ that Johnny's dad will not see any difference after his son is done playing (i.e. Johnny will get the same set as before playing). It is possible that no such number exists. It is also possible that there are many of them. In such a case, output the smallest one. Note that the order of elements in a set doesn't matter, i.e. set $$$\\{1, 2, 3\\}$$$ equals to set $$$\\{2, 1, 3\\}$$$.Formally, find the smallest positive integer $$$k$$$ such that $$$\\{s \\oplus k | s \\in S\\} = S$$$ or report that there is no such number.For example, if $$$S = \\{1, 3, 4\\}$$$ and $$$k = 2$$$, new set will be equal to $$$\\{3, 1, 6\\}$$$. If $$$S = \\{0, 1, 2, 3\\}$$$ and $$$k = 1$$$, after playing set will stay the same.", "input_spec": "In the first line of input, there is a single integer $$$t$$$ ($$$1 \\leq t \\leq 1024$$$), the number of test cases. In the next lines, $$$t$$$ test cases follow. Each of them consists of two lines. In the first line there is a single integer $$$n$$$ ($$$1 \\leq n \\leq 1024$$$) denoting the number of elements in set $$$S$$$. Second line consists of $$$n$$$ distinct integers $$$s_i$$$ ($$$0 \\leq s_i < 1024$$$), elements of $$$S$$$. It is guaranteed that the sum of $$$n$$$ over all test cases will not exceed $$$1024$$$.", "output_spec": "Print $$$t$$$ lines; $$$i$$$-th line should contain the answer to the $$$i$$$-th test case, the minimal positive integer $$$k$$$ satisfying the conditions or $$$-1$$$ if no such $$$k$$$ exists.", "sample_inputs": ["6\n4\n1 0 2 3\n6\n10 7 14 8 3 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 1023"], "sample_outputs": ["1\n4\n2\n-1\n-1\n1023"], "notes": "NoteIn the first test case, the answer is $$$1$$$ because it is a minimum positive integer and it satisfies all the conditions."}, "positive_code": [{"source_code": "= $n) break ;\n }\n \n if($i > 1023) echo \"-1\\n\" ;\n else echo $i . \"\\n\" ;\n }\n?>"}], "negative_code": [], "src_uid": "3ecb65a8be42f882ae6b528fd86243cd"} {"nl": {"description": "You've got an undirected graph, consisting of n vertices and m edges. We will consider the graph's vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an integer ci.Let's consider all vertices of the graph, that are painted some color k. Let's denote a set of such as V(k). Let's denote the value of the neighbouring color diversity for color k as the cardinality of the set Q(k)\u2009=\u2009{cu\u00a0:\u2009\u00a0cu\u2009\u2260\u2009k and there is vertex v belonging to set V(k) such that nodes v and u are connected by an edge of the graph}.Your task is to find such color k, which makes the cardinality of set Q(k) maximum. In other words, you want to find the color that has the most diverse neighbours. Please note, that you want to find such color k, that the graph has at least one vertex with such color.", "input_spec": "The first line contains two space-separated integers n,\u2009m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105) \u2014 the number of vertices end edges of the graph, correspondingly. The second line contains a sequence of integers c1,\u2009c2,\u2009...,\u2009cn (1\u2009\u2264\u2009ci\u2009\u2264\u2009105) \u2014 the colors of the graph vertices. The numbers on the line are separated by spaces. Next m lines contain the description of the edges: the i-th line contains two space-separated integers ai,\u2009bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u2009n;\u00a0ai\u2009\u2260\u2009bi) \u2014 the numbers of the vertices, connected by the i-th edge. It is guaranteed that the given graph has no self-loops or multiple edges.", "output_spec": "Print the number of the color which has the set of neighbours with the maximum cardinality. It there are multiple optimal colors, print the color with the minimum number. Please note, that you want to find such color, that the graph has at least one vertex with such color.", "sample_inputs": ["6 6\n1 1 2 3 5 8\n1 2\n3 2\n1 4\n4 3\n4 5\n4 6", "5 6\n4 2 5 2 4\n1 2\n2 3\n3 1\n5 3\n5 4\n3 4"], "sample_outputs": ["3", "2"], "notes": null}, "positive_code": [{"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\telseif (count($i) == $jj and $ii > $j) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n}\n\nif ($ii == 0) {\n\tfor ($j = 0; $j < $n; $j++) {\n\t\tif ($ii == 0 or $ii > $a[$j]) {\n\t\t\t$ii = $a[$j];\n\t\t}\n\t}\n}\n\nprint $ii;\n"}], "negative_code": [{"source_code": " $i) { \tif (count($i) > $jj) { \t\t$jj = count($i); \t\t$ii = $j; \t} } print $ii;"}, {"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\telseif (count($i) == $jj and $ii > $j) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\n}\n\nprint $ii;\n"}, {"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\telseif (count($i) == $jj and $ii > $j) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n}\n\nif ($ii == 0) {\n\tfor ($j = 0; $j < $n; $j++) {\n\t\tif ($ii == 0 or $ii > $a[$j]) {\n\t\t\t$ii = $a[$j];\n\t\t}\n\t}\n}\n\nprint $ii;\n"}, {"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\telseif (count($i) == $jj and $ii < $j) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\n}\n\nprint $ii;\n"}, {"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\n}\n\nprint $ii;\n"}, {"source_code": " $i) {\n\tif (count($i) > $jj) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n\telseif (count($i) == $jj and $ii > $j) {\n\t\t$jj = count($i);\n\t\t$ii = $j;\n\t}\n}\n\nif ($ii == 0) {\n\tfor ($j = 0; $j < $n; $j++) {\n\t\tif ($ii == 0 or $ii > $a[$j]) {\n\t\t\t$ii = $a[$j];\n\t\t}\n\t}\n}\n\nprint $ii;\n"}], "src_uid": "89c27a5c76f4ddbd14af2d30ac8b6330"} {"nl": {"description": "After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements: There is at least one digit in the string, There is at least one lowercase (small) letter of the Latin alphabet in the string, There is at least one of three listed symbols in the string: '#', '*', '&'. Considering that these are programming classes it is not easy to write the password.For each character of the password we have a fixed string of length m, on each of these n strings there is a pointer on some character. The i-th character displayed on the screen is the pointed character in the i-th string. Initially, all pointers are on characters with indexes 1 in the corresponding strings (all positions are numbered starting from one).During one operation Dasha can move a pointer in one string one character to the left or to the right. Strings are cyclic, it means that when we move the pointer which is on the character with index 1 to the left, it moves to the character with the index m, and when we move it to the right from the position m it moves to the position 1.You need to determine the minimum number of operations necessary to make the string displayed on the screen a valid password. ", "input_spec": "The first line contains two integers n, m (3\u2009\u2264\u2009n\u2009\u2264\u200950,\u20091\u2009\u2264\u2009m\u2009\u2264\u200950) \u2014 the length of the password and the length of strings which are assigned to password symbols. Each of the next n lines contains the string which is assigned to the i-th symbol of the password string. Its length is m, it consists of digits, lowercase English letters, and characters '#', '*' or '&'. You have such input data that you can always get a valid password.", "output_spec": "Print one integer \u2014 the minimum number of operations which is necessary to make the string, which is displayed on the screen, a valid password. ", "sample_inputs": ["3 4\n1**2\na3*0\nc4**", "5 5\n#*&#*\n*a1c&\n&q2w*\n#a3c#\n*&#*&"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first test it is necessary to move the pointer of the third string to one left to get the optimal answer. In the second test one of possible algorithms will be: to move the pointer of the second symbol once to the right. to move the pointer of the third symbol twice to the right. "}, "positive_code": [{"source_code": ""}, {"source_code": " (int)($m/2)){\n return $m - $i;\n }\n return $i;\n}\n\nforeach ($strings as $key => $string){\n for($i=0;$i<$m;$i++){\n $steps = steps($i, $m);\n $type = type($string[$i]);\n if($dp[$type][$key] > $steps){\n $dp[$type][$key] = $steps;\n }\n }\n}\n$min = PHP_INT_MAX;\n\nfor ($i=0; $i<$n;$i++){\n for ($j=0; $j<$n;$j++){\n for ($k=0; $k<$n;$k++){\n if($i != $j && $i != $k && $j != $k){\n $cur = $dp[0][$i] + $dp[1][$j] + $dp[2][$k];\n if($min > $cur){\n $min = $cur;\n }\n }\n }\n }\n}\n\necho $min;\n"}], "negative_code": [{"source_code": " (int)($m/2)){\n return $m - $i;\n }\n return $i;\n}\n\nforeach ($strings as $key => $string){\n for($i=0;$i<$m;$i++){\n $steps = steps($i, $m);\n $type = type($string[$i]);\n if($dp[$type][$key] > $steps || $dp[$type][$key] == -1){\n $dp[$type][$key] = $steps;\n }\n }\n}\n$min = PHP_INT_MAX;\n\nfor ($i=0; $i<$n;$i++){\n for ($j=0; $j<$n;$j++){\n for ($k=0; $k<$n;$k++){\n if($i != $j && $i != $k && $j != $k){\n $cur = $dp[0][$i] + $dp[1][$j] + $dp[2][$k];\n if($min > $cur){\n $min = $cur;\n }\n }\n }\n }\n}\n\necho $min;\n"}], "src_uid": "b7ff1ded73a9f130312edfe0dafc626d"} {"nl": {"description": "Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to each other.Dima and Inna are using a secret code in their text messages. When Dima wants to send Inna some sentence, he writes out all words, inserting a heart before each word and after the last word. A heart is a sequence of two characters: the \"less\" characters (<) and the digit three (3). After applying the code, a test message looks like that: <3word1<3word2<3 ... wordn<3.Encoding doesn't end here. Then Dima inserts a random number of small English characters, digits, signs \"more\" and \"less\" into any places of the message.Inna knows Dima perfectly well, so she knows what phrase Dima is going to send her beforehand. Inna has just got a text message. Help her find out if Dima encoded the message correctly. In other words, find out if a text message could have been received by encoding in the manner that is described above.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of words in Dima's message. Next n lines contain non-empty words, one word per line. The words only consist of small English letters. The total length of all words doesn't exceed 105. The last line contains non-empty text message that Inna has got. The number of characters in the text message doesn't exceed 105. A text message can contain only small English letters, digits and signs more and less.", "output_spec": "In a single line, print \"yes\" (without the quotes), if Dima decoded the text message correctly, and \"no\" (without the quotes) otherwise.", "sample_inputs": ["3\ni\nlove\nyou\n<3i<3love<23you<3", "7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3"], "sample_outputs": ["yes", "no"], "notes": "NotePlease note that Dima got a good old kick in the pants for the second sample from the statement."}, "positive_code": [{"source_code": " 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n }\n $m--;\n $c = \" \" . $c;\n $g = strpos($c, $i[$x]);\n if($g > 0)\n {\n $c = substr($c, $g + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n if($m == 0)\n {\n $k = 0;\n }\n}\nif($c != \"\")\n{\n $c = \" \" . $c;\n $e = strpos($c, \"<\");\n if($e > 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n }\n if($c != \"\")\n {\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n }\n }\n else\n {\n $h = 1;\n }\n if($h == 1)\n {\n print \"no\";\n }\n else\n {\n print \"yes\";\n }\n}\nelse\n{\n print \"no\";\n}\n?>"}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n\n$z = $f[0];\n\nfor($i=1;$i<=$z;$i++) {\n\t$word[] = $f[$i];\n}\n\n\n$r = $f[$i];\n\n$q = strlen($r);\n\n\n$i = $l = $w = 0;\n$letter = $word[$w][$l];\n\ndo {\n\t$s = $r[$i++];\n\n\tif ($heart) {\n\t\tif ($s==$letter) {\n\t\t\tif (strlen($word[$w])==++$l) {\n\t\t\t\tif ($z == ++$w) {\n\t\t\t\t\t$good = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\t$letter = $word[$w][$l = 0];\n\t\t\t\t\t$heart = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$letter = $word[$w][$l];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif ($half) {\n\t\t\tif ($s=='3') {\n\t\t\t\t$half = false;\n\t\t\t\t$heart = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif ($s=='<') {\n\t\t\t\t$half = true;\n\t\t\t}\n\t\t}\n\n\t}\n} while ($i < $q);\n\n\nif ($good && preg_match('/.*?<.*?3/', substr($r,$i-1))) {\n\techo 'yes';\n\texit;\n}\n\necho 'no';\n"}], "negative_code": [{"source_code": " 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n }\n $m--;\n $c = \" \" . $c;\n $g = strpos($c, $i[$x]);\n if($g > 0)\n {\n $c = substr($c, $g + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n if($m == 0)\n {\n $k = 0;\n }\n}\nif(strlen($c) != \"0\")\n{\n $c = \" \" . $c;\n $e = strpos($c, \"<\");\n if($e > 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n}\nif($h == 1)\n{\n print \"no\";\n}\nelse\n{\n print \"yes\";\n}\nprint \"\\n\" . $c;\n?>"}, {"source_code": " 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $g = strpos($c, $d[$x]);\n if($g > 0)\n {\n $c = substr($c, $g + strlen($d[$x]));\n }\n else\n {\n $h = 1;\n break;\n }\n}\n$c = \" \" . $c;\n$e = strpos($c, \"<\");\nif($e > 0)\n{\n $c = substr($c, $e + 1);\n}\nelse\n{\n $h = 1;\n}\n$c = \" \" . $c;\n$f = strpos($c, \"3\");\nif($f > 0)\n{\n $c = substr($c, $f + 1);\n}\nelse\n{\n $h = 1;\n}\nif($h == 1)\n{\n print \"no\";\n}\nelse\n{\n print \"yes\";\n}\n?>"}, {"source_code": " 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n }\n $m--;\n $c = \" \" . $c;\n $g = strpos($c, $i[$x]);\n if($g > 0)\n {\n $c = substr($c, $g + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n if($m == 0)\n {\n $k = 0;\n }\n}\nif(strlen($c) != \"0\")\n{\n $c = \" \" . $c;\n $e = strpos($c, \"<\");\n if($e > 0)\n {\n $c = substr($c, $e + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n $c = \" \" . $c;\n $f = strpos($c, \"3\");\n if($f > 0)\n {\n $c = substr($c, $f + 1);\n }\n else\n {\n $h = 1;\n break;\n }\n}\nif($h == 1)\n{\n print \"no\";\n}\nelse\n{\n print \"yes\";\n}\n?>"}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n$q = $f[0];\n\nfor($i=1;$i<=$q;$i++) {\n\t$w[] = $f[$i];\n}\n\n$r = $f[$i];\n\n$r = preg_replace('/<([^<3]*)3/', '<3', $r);\n\nif (!preg_match('/^<3.*?<3$/', $r)) {\n\techo 'no';\n} else {\n\n\t$o = explode('<3',substr($r,2,-2));\n\n\tif (sizeof($o)!=sizeof($w)) {\n\t\t$no = true;\n\t} else {\n\t\tforeach ($w as $i=>$word) {\n\t\t\t$word = str_split($word);\n\n\t\t\tforeach ($word as $letter) {\n\t\t\t\t$found = false;\n\t\t\t\tfor($j=0;$j $word) {\n\t\t$word = str_split($word);\n\n\t\tforeach ($word as $letter) {\n\t\t\t$found = false;\n\t\t\tfor($j=0;$j $word) {\n\t\t\t$word = str_split($word);\n\n\t\t\tforeach ($word as $letter) {\n\t\t\t\t$found = false;\n\t\t\t\tfor($j=0;$j "}], "negative_code": [], "src_uid": "fe5c302d844b0b94d030b180e017b9b2"} {"nl": {"description": "Don't you tell me what you think that I can beIf you say that Arkady is a bit old-fashioned playing checkers, you won't be right. There is also a modern computer game Arkady and his friends are keen on. We won't discuss its rules, the only feature important to this problem is that each player has to pick a distinct hero in the beginning of the game.There are $$$2$$$ teams each having $$$n$$$ players and $$$2n$$$ heroes to distribute between the teams. The teams take turns picking heroes: at first, the first team chooses a hero in its team, after that the second team chooses a hero and so on. Note that after a hero is chosen it becomes unavailable to both teams.The friends estimate the power of the $$$i$$$-th of the heroes as $$$p_i$$$. Each team wants to maximize the total power of its heroes. However, there is one exception: there are $$$m$$$ pairs of heroes that are especially strong against each other, so when any team chooses a hero from such a pair, the other team must choose the other one on its turn. Each hero is in at most one such pair.This is an interactive problem. You are to write a program that will optimally choose the heroes for one team, while the jury's program will play for the other team. Note that the jury's program may behave inefficiently, in this case you have to take the opportunity and still maximize the total power of your team. Formally, if you ever have chance to reach the total power of $$$q$$$ or greater regardless of jury's program choices, you must get $$$q$$$ or greater to pass a test.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 10^3$$$, $$$0 \\le m \\le n$$$)\u00a0\u2014 the number of players in one team and the number of special pairs of heroes. The second line contains $$$2n$$$ integers $$$p_1, p_2, \\ldots, p_{2n}$$$ ($$$1 \\le p_i \\le 10^3$$$)\u00a0\u2014 the powers of the heroes. Each of the next $$$m$$$ lines contains two integer $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 2n$$$, $$$a \\ne b$$$)\u00a0\u2014 a pair of heroes that are especially strong against each other. It is guaranteed that each hero appears at most once in this list. The next line contains a single integer $$$t$$$ ($$$1 \\le t \\le 2$$$)\u00a0\u2014 the team you are to play for. If $$$t = 1$$$, the first turn is yours, otherwise you have the second turn. Hacks In order to hack, use the format described above with one additional line. In this line output $$$2n$$$ distinct integers from $$$1$$$ to $$$2n$$$\u00a0\u2014 the priority order for the jury's team. The jury's team will on each turn select the first possible hero from this list. Here possible means that it is not yet taken and does not contradict the rules about special pair of heroes.", "output_spec": null, "sample_inputs": ["3 1\n1 2 3 4 5 6\n2 6\n1\n\n2\n\n4\n\n1", "3 1\n1 2 3 4 5 6\n1 5\n2\n6\n\n1\n\n3"], "sample_outputs": ["6\n\n5\n\n3", "5\n\n4\n\n2"], "notes": "NoteIn the first example the first turn is yours. In example, you choose $$$6$$$, the other team is forced to reply with $$$2$$$. You choose $$$5$$$, the other team chooses $$$4$$$. Finally, you choose $$$3$$$ and the other team choose $$$1$$$.In the second example you have the second turn. The other team chooses $$$6$$$, you choose $$$5$$$, forcing the other team to choose $$$1$$$. Now you choose $$$4$$$, the other team chooses $$$3$$$ and you choose $$$2$$$."}, "positive_code": [{"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$e] = $f;\n $d[$f] = $e;\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n break;\n }\n }\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$x]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n while(TRUE)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n unset($c[$x]);\n break;\n }\n }\n flush();\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n unset($c[$x]);\n break;\n }\n }\n flush();\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $o)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $d[$i])\n {\n unset($c[$d[$i]]);\n }\n }\n unset($d[$i]);\n unset($d[$d[$i]]);\n }\n else\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $d[$i])\n {\n unset($c[$d[$i]]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = $d[$h];\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = $c[1];\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n if($c[$x] = $i)\n {\n unset($c[$d[$i]]);\n }\n }\n unset($d[$j]);\n unset($d[$i]);\n }\n else\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n if($c[$x] = $i)\n {\n unset($c[$d[$i]]);\n }\n }\n unset($d[$d[$i]]);\n unset($d[$i]);\n }\n else\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h;\n print \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n print \"\\n\";\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0];\n print \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n print \"\\n\";\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\nprint_r($c2);\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n $h = max($d);\n print ($h + 1) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h + 1]);\n unset($d[$i]);\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $h)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $i)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n }\n else\n {\n print ($c2[0] + 1) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n array_splice($c2, 0, 1);\n array_splice($c2, 0, 1);\n }\n if(count($c2) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$e] = $f;\n $d[$f] = $e;\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($w == 354)\n{\n print $g . \"\\n\";\n}\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n break;\n }\n }\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$x]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0))\n {\n $l = 1;\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $h)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $i)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n }\n else\n {\n print ($c2[0] + 1) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n array_splice($c2, 0, 1);\n array_splice($c2, 0, 1);\n }\n if(count($c2) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n unset($d[$i]);\n unset($d[$j]);\n }\n elseif(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = $d[$h];\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = $c[1];\n flush();\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $d[$i])\n {\n unset($c[$d[$i]]);\n }\n }\n unset($d[$i]);\n unset($d[$d[$i]]);\n }\n else\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $d[$i])\n {\n unset($c[$d[$i]]);\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n unset($d[$i]);\n unset($d[$j]);\n }\n elseif(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print intval($h);\n print \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n if(count($c) > 0)\n {\n print intval($c[0]);\n print \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$e] = $f;\n $d[$f] = $e;\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n break;\n }\n }\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$x]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n $w = current($c);\n print $w . \"\\n\";\n unset($c[key($c)]);\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$w]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n else\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n array_splice($c, 0, 1);\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": ""}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\nprint_r($c);\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n else\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($x == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n print \"\\n\";\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n print \"\\n\";\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n unset($d[$i]);\n unset($d[$j]);\n }\n elseif(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n $k = $a;\n $w = 1;\n while(TRUE)\n {\n if($w == 1)\n {\n $l = trim(fgets(STDIN));\n if($d[$l] == TRUE)\n {\n rsort($c);\n $m = $d[$d[$l]];\n print $m . \"\\n\";\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $l)\n {\n unset($c[$x]);\n }\n if($c[$x] == $m)\n {\n unset($c[$x]);\n }\n }\n unset($d[$d[$l]]);\n unset($d[$l]);\n $k -= 2;\n }\n else\n {\n rsort($c);\n if(count($d) > 0)\n {\n $m = max($d);\n print $m . \"\\n\";\n flush();\n $n = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $l)\n {\n unset($c[$x]);\n }\n if($c[$x] == $m)\n {\n unset($c[$x]);\n }\n if($c[$x] == $n)\n {\n unset($c[$x]);\n }\n }\n unset($d[$l]);\n unset($d[$m]);\n unset($d[$n]);\n $k -= 3;\n $w = 2;\n }\n else\n {\n $m = $c[1];\n print $m . \"\\n\";\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $l)\n {\n unset($c[$x]);\n }\n if($c[$x] == $m)\n {\n unset($c[$x]);\n }\n }\n $k - 2;\n }\n }\n }\n else\n {\n rsort($c);\n if(count($d) > 0)\n {\n $m = max($d);\n print $m . \"\\n\";\n flush();\n $n = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $m)\n {\n unset($c[$x]);\n }\n if($c[$x] == $n)\n {\n unset($c[$x]);\n }\n }\n unset($d[$n]);\n unset($d[$m]);\n $k -= 2;\n $w = 2;\n }\n else\n {\n $w = 1;\n }\n }\n if($k == 0)\n {\n break;\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n $h = max($d);\n print ($h + 1) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h + 1]);\n unset($d[$i]);\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $h)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c2); $x++)\n {\n if($c2[$x] == $i)\n {\n array_splice($c2, $x, 1);\n break;\n }\n }\n }\n else\n {\n print ($c2[0] + 1) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n array_splice($c2, 0, 1);\n array_splice($c2, 0, 1);\n }\n if(count($c2) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$c2[$e]] = $c2[$f];\n $d[$c2[$f]] = $c2[$e];\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\n$g = trim(fgets(STDIN));\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n $w = reset($c);\n print $w . \"\\n\";\n unset($c[key($c)]);\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$w]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $i)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n while(TRUE)\n {\n $j = max($d);\n print $j . \"\\n\";\n flush();\n $k = trim(fgets(STDIN));\n unset($d[$j]);\n unset($d[$k]);\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $j)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $k)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $h)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n print $c[0] . \"\\n\";\n flush();\n array_splice($c, 0, 1);\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < count($c); $x++)\n {\n if($c[$x] == $o)\n {\n array_splice($c, $x, 1);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = max($d);\n print intval($h) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n if(count($c) > 0)\n {\n print intval($c[0]) . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $c2[$c[$c3]] = $x;\n $c3++;\n}\n$c4 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c4[$x] = $c2[$c5[$x]];\n}\n$d = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $d[$e] = $f;\n $d[$f] = $e;\n}\n$c = $c4;\narsort($c);\n$c2 = array_keys($c);\n$c3 = array();\nfor($x = 0; $x < $a * 2; $x++)\n{\n $c3[$x] = $c2[$x] + 1;\n}\n$c = $c3;\nif($w == 354)\n{\n print $g . \"\\n\";\n}\nif($g == 1)\n{\n while(TRUE)\n {\n if(count($d) != 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n else\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n break;\n }\n }\n flush();\n $i = trim(fgets(STDIN));\n unset($c[$x]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n}\nelse\n{\n $l = 0;\n while(TRUE)\n {\n if($l == 0)\n {\n $h = trim(fgets(STDIN));\n if($d[$h] == TRUE)\n {\n $i = $d[$h];\n print $i . \"\\n\";\n flush();\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) > 0))\n {\n $l = 1;\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n while(TRUE)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($d[$c[$x]] == TRUE)\n {\n $h = $c[$x];\n break;\n }\n }\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n unset($d[$h]);\n unset($d[$i]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n break;\n }\n }\n if(count($d) == 0)\n {\n break;\n }\n }\n }\n elseif(($d[$h] == FALSE) && (count($d) == 0))\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n break;\n }\n }\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n unset($c[$x]);\n break;\n }\n }\n flush();\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n else\n {\n $m = 0;\n while(TRUE)\n {\n $n = $m % 2;\n $m++;\n if($n == 0)\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] != NULL)\n {\n print $c[$x] . \"\\n\";\n unset($c[$x]);\n break;\n }\n }\n flush();\n }\n else\n {\n $o = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $o)\n {\n unset($c[$x]);\n break;\n }\n }\n }\n if(count($c) == 0)\n {\n break;\n }\n }\n break;\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n unset($d[$i]);\n unset($d[$j]);\n }\n elseif(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n for($y = 0; $y < $a; $y++)\n {\n rsort($c);\n $i = trim(fgets(STDIN));\n if($d[$i] == TRUE)\n {\n $j = $d[$d[$i]];\n print $j . \"\\n\";\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n if($c[$x] == $d[$d[$i]])\n {\n unset($d[$d[$i]]);\n }\n }\n unset($c[$x]);\n unset($d[$d[$i]]);\n }\n else\n {\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n rsort($c);\n $j = $c[0];\n print $j . \"\\n\";\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " 0)\n {\n $h = max($d);\n print $h . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n flush();\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $h)\n {\n unset($c[$x]);\n }\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n unset($d[$h]);\n unset($d[$i]);\n }\n else\n {\n rsort($c);\n if(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $i = trim(fgets(STDIN));\n flush();\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] == $i)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0)\n {\n $i = max($d);\n print $i . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $i)\n {\n unset($c[$x]);\n }\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n unset($d[$i]);\n unset($d[$j]);\n }\n elseif(count($c) > 0)\n {\n print $c[0] . \"\\n\";\n flush();\n $j = trim(fgets(STDIN));\n unset($c[0]);\n for($x = 0; $x < $a * 2; $x++)\n {\n if($c[$x] = $j)\n {\n unset($c[$x]);\n }\n }\n }\n }\n}\nelse\n{\n \n}\n?>"}], "src_uid": "5e07da229bc2762f3a68bc083e34b9a1"} {"nl": {"description": "\"Duel!\"Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.There are $$$n$$$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others are with color sides facing down. Then they take turns flipping cards, in which Tokitsukaze moves first. In each move, one should choose exactly $$$k$$$ consecutive cards and flip them to the same side, which means to make their color sides all face up or all face down. If all the color sides of these $$$n$$$ cards face the same direction after one's move, the one who takes this move will win.Princess Claris wants to know who will win the game if Tokitsukaze and Quailty are so clever that they won't make mistakes.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 10^5$$$). The second line contains a single string of length $$$n$$$ that only consists of $$$0$$$ and $$$1$$$, representing the situation of these $$$n$$$ cards, where the color side of the $$$i$$$-th card faces up if the $$$i$$$-th character is $$$1$$$, or otherwise, it faces down and the $$$i$$$-th character is $$$0$$$.", "output_spec": "Print \"once again\" (without quotes) if the total number of their moves can exceed $$$10^9$$$, which is considered a draw. In other cases, print \"tokitsukaze\" (without quotes) if Tokitsukaze will win, or \"quailty\" (without quotes) if Quailty will win. Note that the output characters are case-sensitive, and any wrong spelling would be rejected.", "sample_inputs": ["4 2\n0101", "6 1\n010101", "6 5\n010101", "4 1\n0011"], "sample_outputs": ["quailty", "once again", "tokitsukaze", "once again"], "notes": "NoteIn the first example, no matter how Tokitsukaze moves, there would be three cards with color sides facing the same direction after her move, and Quailty can flip the last card to this direction and win.In the second example, no matter how Tokitsukaze moves, Quailty can choose the same card and flip back to the initial situation, which can allow the game to end in a draw.In the third example, Tokitsukaze can win by flipping the leftmost five cards up or flipping the rightmost five cards down.The fourth example can be explained in the same way as the second example does."}, "positive_code": [{"source_code": " $k) {\n echo 'once again';\n} else {\n $amountZero = 0;\n $amountOne = 0;\n for ($i = 0; $i < $n; $i++) {\n if ($str[$i] === '0') {\n $amountZero++;\n $amountOne = 0;\n } else {\n $amountZero = 0;\n $amountOne++;\n }\n if (max($amountZero, $amountOne) >= $k) {\n die('once again');\n }\n }\n echo 'quailty';\n}\n"}], "negative_code": [{"source_code": " $k) {\n echo 'once again';\n} else {\n $amountZero = 0;\n $amountOne = 0;\n for ($i = 0; $i < $n; $i++) {\n if ($str[$i] === '0') {\n $amountZero++;\n $amountOne = 0;\n } else {\n $amountOne++;\n $amountZero = 0;\n }\n if (max($amountZero, $amountOne) >= $k) {\n die('once again');\n }\n }\n echo 'quailty';\n}\n"}, {"source_code": " $k) {\n echo 'once again';\n} else {\n $amountZero = 0;\n $amountOne = 0;\n for ($i = 0; $i < $n; $i++) {\n if ($str[$i] === '0') {\n $amountZero++;\n $amountOne = 0;\n } else {\n $amountOne++;\n $amountZero = 0;\n }\n if (min($amountZero, $amountOne) >= $k) {\n die('once again');\n }\n }\n echo 'quailty';\n}\n"}], "src_uid": "5e73099c7ec0b82aee54f0841c00f15e"} {"nl": {"description": "Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the tournament.It is known that in a match between two players, the one whose skill is greater will win. The skill of the $$$i$$$-th player is equal to $$$s_i$$$ and all skill levels are pairwise different (i.\u2009e. there are no two identical values in the array $$$s$$$).The tournament is called fair if the two players with the highest skills meet in the finals.Determine whether the given tournament is fair.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. A single line of test case contains four integers $$$s_1, s_2, s_3, s_4$$$ ($$$1 \\le s_i \\le 100$$$)\u00a0\u2014 skill of the players. It is guaranteed that all the numbers in the array are different.", "output_spec": "For each testcase, output YES if the tournament is fair, or NO otherwise.", "sample_inputs": ["4\n3 7 9 5\n4 5 6 9\n5 3 8 1\n6 5 3 2"], "sample_outputs": ["YES\nNO\nYES\nNO"], "notes": "NoteConsider the example: in the first test case, players $$$2$$$ and $$$3$$$ with skills $$$7$$$ and $$$9$$$ advance to the finals; in the second test case, players $$$2$$$ and $$$4$$$ with skills $$$5$$$ and $$$9$$$ advance to the finals. The player with skill $$$6$$$ does not advance, but the player with skill $$$5$$$ advances to the finals, so the tournament is not fair; in the third test case, players $$$1$$$ and $$$3$$$ with skills $$$5$$$ and $$$8$$$ advance to the finals; in the fourth test case, players $$$1$$$ and $$$3$$$ with skills $$$6$$$ and $$$3$$$ advance to the finals. The player with skill $$$5$$$ does not advance, but the player with skill $$$3$$$ advances to the finals, so the tournament is not fair. "}, "positive_code": [{"source_code": "\";\r\n\t\t$m2 = max($c, $d);\r\n\t\t$arr = array($a, $b, $c, $d);\r\n\t\trsort($arr);\r\n//\t\tvar_dump($arr);\r\n//\t\techo \"
\";\r\n\t\tif (($m1 == $arr[0]|| $m1 == $arr[1])&& ($m2 == $arr[0]|| $m2 == $arr[1])) {\r\n\t\t\techo \"YES\".\"\\n\";\r\n\t\t}else echo \"NO\".\"\\n\";\r\n\t}\r\n\r\n\r\n\r\n?>"}, {"source_code": " $minR && $minL < $maxR)\r\n echo \"YES\\n\";\r\n else\r\n echo \"NO\\n\";\r\n}\r\n\r\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": "\";\r\n\t\t$m2 = max($c, $d);\r\n\t\t$arr = array($a, $b, $c, $d);\r\n\t\trsort($arr);\r\n//\t\tvar_dump($arr);\r\n//\t\techo \"
\";\r\n\t\tif (($m1 == $arr[0]|| $m1 == $arr[1])&& ($m2 == $arr[0]|| $m2 == $arr[1])) {\r\n\t\t\techo \"YES\".\"
\";\r\n\t\t}else echo \"NO\".\"
\";\r\n\t}\r\n\r\n\r\n\r\n?>"}], "src_uid": "cb24509580ff9b2f1a11103a0e4cdcbd"} {"nl": {"description": "Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $$$i$$$-th page contains some mystery that will be explained on page $$$a_i$$$ ($$$a_i \\ge i$$$).Ivan wants to read the whole book. Each day, he reads the first page he didn't read earlier, and continues to read the following pages one by one, until all the mysteries he read about are explained and clear to him (Ivan stops if there does not exist any page $$$i$$$ such that Ivan already has read it, but hasn't read page $$$a_i$$$). After that, he closes the book and continues to read it on the following day from the next page.How many days will it take to read the whole book?", "input_spec": "The first line contains single integer $$$n$$$ ($$$1 \\le n \\le 10^4$$$) \u2014 the number of pages in the book. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$i \\le a_i \\le n$$$), where $$$a_i$$$ is the number of page which contains the explanation of the mystery on page $$$i$$$.", "output_spec": "Print one integer \u2014 the number of days it will take to read the whole book.", "sample_inputs": ["9\n1 3 3 6 7 6 8 8 9"], "sample_outputs": ["4"], "notes": "NoteExplanation of the example test:During the first day Ivan will read only the first page. During the second day Ivan will read pages number $$$2$$$ and $$$3$$$. During the third day \u2014 pages $$$4$$$-$$$8$$$. During the fourth (and the last) day Ivan will read remaining page number $$$9$$$."}, "positive_code": [{"source_code": " $d)\n {\n $d = $b[$x];\n }\n if(($b[$x] == $x + 1) && ($b[$x] == $d))\n {\n $c++;\n }\n}\nprint $c;\n?>"}, {"source_code": " $r)\n $r = $a[$i];\n if ($r == $i + 1)\n $days++;\n}\n\necho $days . \"\\n\";\n"}], "negative_code": [], "src_uid": "291601d6cdafa4113c1154f0dda3470d"} {"nl": {"description": "You are given a string $$$t$$$ consisting of $$$n$$$ lowercase Latin letters and an integer number $$$k$$$.Let's define a substring of some string $$$s$$$ with indices from $$$l$$$ to $$$r$$$ as $$$s[l \\dots r]$$$.Your task is to construct such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ positions $$$i$$$ such that $$$s[i \\dots i + n - 1] = t$$$. In other words, your task is to construct such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ substrings of $$$s$$$ equal to $$$t$$$.It is guaranteed that the answer is always unique.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 50$$$) \u2014 the length of the string $$$t$$$ and the number of substrings. The second line of the input contains the string $$$t$$$ consisting of exactly $$$n$$$ lowercase Latin letters.", "output_spec": "Print such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ substrings of $$$s$$$ equal to $$$t$$$. It is guaranteed that the answer is always unique.", "sample_inputs": ["3 4\naba", "3 2\ncat"], "sample_outputs": ["ababababa", "catcat"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": "= 0; $x--)\n {\n if($c[$x] == $c[0])\n {\n $f++;\n }\n else\n {\n break;\n }\n }\n if($e < $f)\n {\n $g = implode(array_slice(str_split($c), $e));\n $c .= $g;\n for($x = 2; $x < $b; $x++)\n {\n $c .= $g;\n }\n }\n elseif($e == $f)\n {\n $g = implode(array_slice(str_split($c), 1));\n $c .= $g;\n for($x = 2; $x < $b; $x++)\n {\n $c .= $g;\n }\n }\n elseif($e > $f)\n {\n $g = implode(array_slice(str_split($c), 0, $a - $f));\n $c = $g . $c;\n for($x = 2; $x < $b; $x++)\n {\n $c = $g . $c;\n }\n }\n print $c;\n}\nelse\n{\n $e = \"\";\n for($x = 1; $x <= $b; $x++)\n {\n $e .= $c; \n }\n print $e;\n}\n?>"}, {"source_code": ""}], "src_uid": "34dd4c8400ff7a67f9feb1487f2669a6"} {"nl": {"description": "You had $$$n$$$ positive integers $$$a_1, a_2, \\dots, a_n$$$ arranged in a circle. For each pair of neighboring numbers ($$$a_1$$$ and $$$a_2$$$, $$$a_2$$$ and $$$a_3$$$, ..., $$$a_{n - 1}$$$ and $$$a_n$$$, and $$$a_n$$$ and $$$a_1$$$), you wrote down: are the numbers in the pair equal or not.Unfortunately, you've lost a piece of paper with the array $$$a$$$. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array $$$a$$$ which is consistent with information you have about equality or non-equality of corresponding pairs?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains a non-empty string $$$s$$$ consisting of characters E and/or N. The length of $$$s$$$ is equal to the size of array $$$n$$$ and $$$2 \\le n \\le 50$$$. For each $$$i$$$ from $$$1$$$ to $$$n$$$: if $$$s_i =$$$ E then $$$a_i$$$ is equal to $$$a_{i + 1}$$$ ($$$a_n = a_1$$$ for $$$i = n$$$); if $$$s_i =$$$ N then $$$a_i$$$ is not equal to $$$a_{i + 1}$$$ ($$$a_n \\neq a_1$$$ for $$$i = n$$$). ", "output_spec": "For each test case, print YES if it's possible to choose array $$$a$$$ that are consistent with information from $$$s$$$ you know. Otherwise, print NO. It can be proved, that if there exists some array $$$a$$$, then there exists an array $$$a$$$ of positive integers with values less or equal to $$$10^9$$$.", "sample_inputs": ["4\nEEE\nEN\nENNEENE\nNENN"], "sample_outputs": ["YES\nNO\nYES\nYES"], "notes": "NoteIn the first test case, you can choose, for example, $$$a_1 = a_2 = a_3 = 5$$$.In the second test case, there is no array $$$a$$$, since, according to $$$s_1$$$, $$$a_1$$$ is equal to $$$a_2$$$, but, according to $$$s_2$$$, $$$a_2$$$ is not equal to $$$a_1$$$.In the third test case, you can, for example, choose array $$$a = [20, 20, 4, 50, 50, 50, 20]$$$.In the fourth test case, you can, for example, choose $$$a = [1, 3, 3, 7]$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": " 0 && substr_count($input, \"N\") % 2 == 0 ) {\r\n print \"NO\\n\";\r\n } else {\r\n print \"YES\\n\";\r\n }\r\n } else {\r\n print \"NO\\n\";\r\n }\r\n}\r\n\r\n?>"}, {"source_code": ""}], "src_uid": "e744184150bf55a30568060cca69de04"} {"nl": {"description": "You are given a sequence $$$a$$$, initially consisting of $$$n$$$ integers.You want to transform this sequence so that all elements in it are equal (i.\u00a0e. it contains several occurrences of the same element).To achieve this, you choose some integer $$$x$$$ that occurs at least once in $$$a$$$, and then perform the following operation any number of times (possibly zero): choose some segment $$$[l, r]$$$ of the sequence and remove it. But there is one exception: you are not allowed to choose a segment that contains $$$x$$$. More formally, you choose some contiguous subsequence $$$[a_l, a_{l + 1}, \\dots, a_r]$$$ such that $$$a_i \\ne x$$$ if $$$l \\le i \\le r$$$, and remove it. After removal, the numbering of elements to the right of the removed segment changes: the element that was the $$$(r+1)$$$-th is now $$$l$$$-th, the element that was $$$(r+2)$$$-th is now $$$(l+1)$$$-th, and so on (i.\u00a0e. the remaining sequence just collapses).Note that you can not change $$$x$$$ after you chose it.For example, suppose $$$n = 6$$$, $$$a = [1, 3, 2, 4, 1, 2]$$$. Then one of the ways to transform it in two operations is to choose $$$x = 1$$$, then: choose $$$l = 2$$$, $$$r = 4$$$, so the resulting sequence is $$$a = [1, 1, 2]$$$; choose $$$l = 3$$$, $$$r = 3$$$, so the resulting sequence is $$$a = [1, 1]$$$. Note that choosing $$$x$$$ is not an operation. Also, note that you can not remove any occurrence of $$$x$$$.Your task is to find the minimum number of operations required to transform the sequence in a way described above.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 2 \\cdot 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \\cdot 10^5$$$ ($$$\\sum n \\le 2 \\cdot 10^5$$$).", "output_spec": "For each test case, print the answer \u2014 the minimum number of operations required to transform the given sequence in a way described in the problem statement. It can be proven that it is always possible to perform a finite sequence of operations so the sequence is transformed in the required way.", "sample_inputs": ["5\n3\n1 1 1\n5\n1 2 3 4 5\n5\n1 2 3 2 1\n7\n1 2 3 1 2 3 1\n11\n2 2 1 2 3 2 1 2 3 1 2"], "sample_outputs": ["0\n1\n1\n2\n3"], "notes": null}, "positive_code": [{"source_code": " 0];\n $bAll = true;\n for ($i = 1; $i < $n; $i++) {\n if ($a[$i] != $a[$i-1]) {\n $bAll = false;\n }\n if (isset($ex[$a[$i]])) {\n if ($a[$i] != $a[$i-1]) {\n $ex[$a[$i]] = $ex[$a[$i]] + 1;\n }\n } else {\n $ex[$a[$i]] = 0;\n }\n }\n\n if ($bAll) {\n echo \"0\\n\";\n } else {\n foreach($ex as $sValue => $iCount) {\n /* if ($a[$n-1] == $sValue && $sValue == $a[0]) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }*/\n if ($a[$n-1] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[0] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n }\n echo min($ex).\"\\n\";\n }\n\n}"}, {"source_code": ""}, {"source_code": " 1];\n $prev_value = $arr[0];\n for ($i = 1; $i < $n; $i++) {\n if ($arr[$i] != $prev_value) {\n isset($path[$arr[$i]]) or $path[$arr[$i]] = 0;\n $path[$arr[$i]] += 1;\n $prev_value = $arr[$i];\n }\n }\n $a = $arr[0];\n $b = $arr[$n-1];\n $arr = array_diff($arr, [$a, $b]);\n ($a == $b) and $path[$a] -= 1;\n foreach (array_unique($arr) as $value) {\n $path[$value] += 1;\n }\n printf(\"%d\\n\", min($path) ?? 0);\n}"}], "negative_code": [{"source_code": " 0,\n $a[$n-1] => 0,\n ];\n $bAll = true;\n for ($i = 1; $i < ($n-1); $i++) {\n if ($a[$i] != $a[$i+1]) {\n $bAll = false;\n }\n if (isset($ex[$a[$i]])) {\n if ($a[$i] != $a[$i+1]) {\n $ex[$a[$i]] = $ex[$a[$i]] + 1;\n }\n } else {\n $ex[$a[$i]] = 0;\n }\n }\n\n if ($bAll) {\n echo \"0\\n\";\n } else {\n foreach($ex as $sValue => $iCount) {\n if ($a[$n-1] == $sValue && $sValue == $a[0]) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[$n-1] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[0] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n }\n echo min($ex).\"\\n\";\n }\n\n}"}, {"source_code": " $iCount) {\n if ($a[$n-1] == $sValue && $sValue == $a[0]) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[$n-1] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[0] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n }\n echo min($ex).\"\\n\";\n }\n\n}"}, {"source_code": " $sValue) {\n if ($a[$n-1] != $sKey) {\n $ex[$sKey] = $sValue + 1;\n }\n }\n \n echo $bStatus ? 0 : min($ex);\n echo \"\\n\";\n}"}, {"source_code": " $iCount) {\n if ($a[$n-1] == $sValue && $sValue == $a[0]) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[$n-1] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n if ($a[0] != $sValue) {\n $ex[$sValue] = $ex[$sValue] + 1;\n }\n }\n echo min($ex).\"\\n\";\n }\n\n}"}, {"source_code": " 1];\n $prev_value = $arr[0];\n for ($i = 1; $i < $n; $i++) {\n if ($arr[$i] != $prev_value) {\n isset($path[$arr[$i]]) or $path[$arr[$i]] = 0;\n $path[$arr[$i]] += 1;\n $prev_value = $arr[$i];\n }\n }\n $a = $arr[0];\n $b = $arr[$n-1];\n $arr = array_diff($arr, [$arr[0], $arr[$n-1]])\n and ($a == $b) and $path[$a] -= 1;\n foreach (array_unique($arr) as $value) {\n $path[$value] += 1;\n }\n printf(\"%d\\n\", $arr ? min($path) : 0);\n}"}], "src_uid": "080eb61cbc4b0ffcbab10b86918f70fe"} {"nl": {"description": "Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak,\u2009i,\u2009j; 1 being black and 0 being white. Now Magnus wants to change color of some squares in such a way that he recolors minimum number of squares and obtained pieces form a valid chessboard. Every square has its color different to each of the neightbouring by side squares in a valid board. Its size should be 2n by 2n. You are allowed to move pieces but not allowed to rotate or flip them.", "input_spec": "The first line contains odd integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty line.", "output_spec": "Print one number \u2014 minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.", "sample_inputs": ["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"], "sample_outputs": ["1", "2"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "= 0; --$i) {\n $newitems = $items;\n $newperms = $perms;\n list($foo) = array_splice($newitems, $i, 1);\n array_unshift($newperms, $foo);\n pc_permute($newitems, $newperms, $p);\n }\n }\n}\n\n$perms = [];\npc_permute([0,1,2,3], [], $perms);\n\n$minToChange = $n*$n*4;\n\nfor ($p = 0; $p < 24; $p++) {\n $desk = [];\n for ($i = 0; $i < $n; $i++) {\n $desk[$i] = $a[$perms[$p][0]][$i] . $a[$perms[$p][1]][$i];\n }\n\n for ($i = 0; $i < $n; $i++) {\n $desk[$n + $i] = $a[$perms[$p][2]][$i] . $a[$perms[$p][3]][$i];\n }\n\n $toChange = 0;\n for ($i = 0; $i < 2*$n; $i++) {\n for ($j = 0; $j < 2*$n; $j++) {\n if (($i + $j) % 2 != $desk[$i][$j]) {\n $toChange ++;\n }\n }\n }\n\n if ($toChange > 4*$n*$n/2) {\n //echo $n . \" \" . ($n*$n) , \" \\n\";\n $toChange = 4*$n*$n - $toChange;\n //echo $toChange . \"\\n\";\n }\n\n if ($toChange < $minToChange) {\n $minToChange = $toChange;\n }\n\n}\n\necho $minToChange . \"\\n\";\n\n"}], "negative_code": [{"source_code": ""}], "src_uid": "dc46c6cb6b4b9b5e7e6e5b4b7d034874"} {"nl": {"description": "Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Each student i (1\u2009\u2264\u2009i\u2009\u2264\u2009n) has a best friend p[i] (1\u2009\u2264\u2009p[i]\u2009\u2264\u2009n). In fact, each student is a best friend of exactly one student. In other words, all p[i] are different. It is possible that the group also has some really \"special individuals\" for who i\u2009=\u2009p[i].Each student wrote exactly one notebook of lecture notes. We know that the students agreed to act by the following algorithm: on the first day of revising each student studies his own Mathematical Analysis notes, in the morning of each following day each student gives the notebook to his best friend and takes a notebook from the student who calls him the best friend. Thus, on the second day the student p[i] (1\u2009\u2264\u2009i\u2009\u2264\u2009n) studies the i-th student's notes, on the third day the notes go to student p[p[i]] and so on. Due to some characteristics of the boys' friendship (see paragraph 1), each day each student has exactly one notebook to study.You are given two sequences that describe the situation on the third and fourth days of revising: a1,\u2009a2,\u2009...,\u2009an, where ai means the student who gets the i-th student's notebook on the third day of revising; b1,\u2009b2,\u2009...,\u2009bn, where bi means the student who gets the i-th student's notebook on the fourth day of revising. You do not know array p, that is you do not know who is the best friend to who. Write a program that finds p by the given sequences a and b.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of students in the group. The second line contains sequence of different integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n). The third line contains the sequence of different integers b1,\u2009b2,\u2009...,\u2009bn (1\u2009\u2264\u2009bi\u2009\u2264\u2009n).", "output_spec": "Print sequence n of different integers p[1],\u2009p[2],\u2009...,\u2009p[n] (1\u2009\u2264\u2009p[i]\u2009\u2264\u2009n). It is guaranteed that the solution exists and that it is unique.", "sample_inputs": ["4\n2 1 4 3\n3 4 2 1", "5\n5 2 3 1 4\n1 3 2 4 5", "2\n1 2\n2 1"], "sample_outputs": ["4 3 1 2", "4 3 2 5 1", "2 1"], "notes": null}, "positive_code": [{"source_code": "in();\n\tfor ($i = 0; $i < $N; $i++) {\n\t\t$A[] = (int)$Input->in();\n\t}\n\tfor ($i = 0; $i < $N; $i++) {\n\t\t$B[] = (int)$Input->in();\n\t}\n\tfor ($i = 0; $i < $N; $i++) {\n\t\t$p[$A[$i]] = $B[$i];\n\t}\n\n\tksort($p);\n\t\n\tprint(implode($p, \" \"));\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "negative_code": [], "src_uid": "a133b2c63e1025bdf13d912497f9b6a4"} {"nl": {"description": "There is an array $$$a$$$ with $$$n-1$$$ integers. Let $$$x$$$ be the bitwise XOR of all elements of the array. The number $$$x$$$ is added to the end of the array $$$a$$$ (now it has length $$$n$$$), and then the elements are shuffled.You are given the newly formed array $$$a$$$. What is $$$x$$$? If there are multiple possible values of $$$x$$$, you can output any of them.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \\leq n \\leq 100$$$)\u00a0\u2014 the number of integers in the resulting array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\le a_i \\le 127$$$)\u00a0\u2014 the elements of the newly formed array $$$a$$$. Additional constraint on the input: the array $$$a$$$ is made by the process described in the statement; that is, some value of $$$x$$$ exists.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the value of $$$x$$$, as described in the statement. If there are multiple possible values of $$$x$$$, output any of them.", "sample_inputs": ["4\n\n4\n\n4 3 2 5\n\n5\n\n6 1 10 7 10\n\n6\n\n6 6 6 6 6 6\n\n3\n\n100 100 0"], "sample_outputs": ["3\n7\n6\n0"], "notes": "NoteIn the first test case, one possible array $$$a$$$ is $$$a=[2, 5, 4]$$$. Then $$$x = 2 \\oplus 5 \\oplus 4 = 3$$$ ($$$\\oplus$$$ denotes the bitwise XOR), so the new array is $$$[2, 5, 4, 3]$$$. Afterwards, the array is shuffled to form $$$[4, 3, 2, 5]$$$.In the second test case, one possible array $$$a$$$ is $$$a=[1, 10, 6, 10]$$$. Then $$$x = 1 \\oplus 10 \\oplus 6 \\oplus 10 = 7$$$, so the new array is $$$[1, 10, 6, 10, 7]$$$. Afterwards, the array is shuffled to form $$$[6, 1, 10, 7, 10]$$$.In the third test case, all elements of the array are equal to $$$6$$$, so $$$x=6$$$.In the fourth test case, one possible array $$$a$$$ is $$$a=[100, 100]$$$. Then $$$x = 100 \\oplus 100 = 0$$$, so the new array is $$$[100, 100, 0]$$$. Afterwards, the array is shuffled to form $$$[100, 100, 0]$$$. (Note that after the shuffle, the array can remain the same.)"}, "positive_code": [{"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [], "src_uid": "329ac6671e26b73ab70749ca509f5b09"} {"nl": {"description": "One not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game.He took a checkered white square piece of paper, consisting of n\u2009\u00d7\u2009n cells. After that, he started to paint the white cells black one after the other. In total he painted m different cells on the piece of paper. Since Valera was keen on everything square, he wondered, how many moves (i.e. times the boy paints a square black) he should make till a black square with side 3 can be found on the piece of paper. But Valera does not know the answer to this question, so he asks you to help him.Your task is to find the minimum number of moves, till the checkered piece of paper has at least one black square with side of 3. Otherwise determine that such move does not exist.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009m\u2009\u2264\u2009min(n\u00b7n,\u2009105)) \u2014 the size of the squared piece of paper and the number of moves, correspondingly. Then, m lines contain the description of the moves. The i-th line contains two integers xi, yi (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009n) \u2014 the number of row and column of the square that gets painted on the i-th move. All numbers on the lines are separated by single spaces. It is guaranteed that all moves are different. The moves are numbered starting from 1 in the order, in which they are given in the input. The columns of the squared piece of paper are numbered starting from 1, from the left to the right. The rows of the squared piece of paper are numbered starting from 1, from top to bottom.", "output_spec": "On a single line print the answer to the problem \u2014 the minimum number of the move after which the piece of paper has a black square with side 3. If no such move exists, print -1.", "sample_inputs": ["4 11\n1 1\n1 2\n1 3\n2 2\n2 3\n1 4\n2 4\n3 4\n3 2\n3 3\n4 1", "4 12\n1 1\n1 2\n1 3\n2 2\n2 3\n1 4\n2 4\n3 4\n3 2\n4 2\n4 1\n3 1"], "sample_outputs": ["10", "-1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " $n-3) $x = $n-4;\n if ($y > $n-3) $y = $n-4;\n \n for ($j = $x; $j < $x+2; ++$j) {\n for ($k = $y; $k < $y+2; ++$k) {\n if (\n $matrix[$j][$k] && $matrix[$j][$k+1] && $matrix[$j][$k+2]\n && $matrix[$j+1][$k] && $matrix[$j+1][$k+1] && $matrix[$j+1][$k+2]\n && $matrix[$j+2][$k] && $matrix[$j+2][$k+1] && $matrix[$j+2][$k+2]\n ) return $i+1;\n }\n }\n }\n \n return -1;\n}\n\n$in = explode(\"\\n\", file_get_contents('php://stdin'));\n$n; $m; $move = array();\n\nfor ($i = 0; $i < count($in); $i++) {\n $arr = explode(' ', $in[$i]);\n if ($i == 0) {\n $n = $arr[0];\n $m = $arr[1];\n } else {\n $move[$i-1] = array($arr[0], $arr[1]);\n }\n}\n\necho B($n, $m, $move);\n?>"}, {"source_code": " $value) {\n $move[] = array($value[0], $value[2]);\n}*/\n\n\n$a = <<< p\n4 11\n1 1\n1 2\n1 3\n2 2\n2 3\n1 4\n2 4\n3 4\n3 2\n3 3\n4 1\np;\n$in = explode(' ', file_get_contents('php://stdin'));\n$n; $m; $move;\n\nfor ($i = 0; $i < count($in); $i++) {\n $arr = explode(' ', $in[$i]);\n if ($i == 0) {\n $n = $arr[0];\n $m = $arr[1];\n $move = array($m);\n } else {\n $move[$i-1] = array($arr[0], $arr[1]);\n }\n}\n\necho B($n, $m, $move);\n?>"}, {"source_code": " $n-2) $x = (n-2);\n if ($y > $n-2) $y = (n-2);\n \n for ($j = $x; $j < $x+3; ++$j) {\n for ($k = $y; $k < $y+3; ++$k) {\n if (\n $matrix[$j][$k] && $matrix[$j][$k+1] && $matrix[$j][$k+2]\n && $matrix[$j+1][$k] && $matrix[$j+1][$k+1] && $matrix[$j+1][$k+2]\n && $matrix[$j+2][$k] && $matrix[$j+2][$k+1] && $matrix[$j+2][$k+2]\n ) return $i;\n }\n }\n }\n \n return -1;\n}\n\n$in = explode(\"\\n\", file_get_contents('php://stdin'));\n$n; $m; $move = array();\n\nfor ($i = 0; $i < count($in); $i++) {\n $arr = explode(' ', $in[$i]);\n if ($i == 0) {\n $n = $arr[0];\n $m = $arr[1];\n } else {\n $move[$i-1] = array($arr[0], $arr[1]);\n }\n}\n\necho B($n, $m, $move);\n?>"}], "src_uid": "8a4a46710104de78bdf3b9d5462f12bf"} {"nl": {"description": "A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum?", "input_spec": "The first line contains number n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009106) \u2014 the values of the banknotes.", "output_spec": "Print a single line \u2014 the minimum unfortunate sum. If there are no unfortunate sums, print \u2009-\u20091.", "sample_inputs": ["5\n1 2 3 4 5"], "sample_outputs": ["-1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 0){$line = str_replace($del,'',$line);$dataex[] = $line;$text = explode(\" \",$line);\nforeach($text as $txt){$arr_txt[] = $txt;$this->linex[$id] = $il;$this->liney[$il] = $id;$id++;}}$il++;}$this->arr_line = $dataex;$this->arr_txt = $arr_txt;}\nfunction G(){$ret = $this->arr_txt[$this->ntxt++];$this->nline = $this->linex[$this->ntxt];return $ret;}\nfunction GL(){$this->ntxt = $this->liney[$this->nline]+1;return $this->arr_line[$this->nline++];}} /*init*/ \n$dxs = new stdIn();\n\n$n = $dxs->G();\n$ok = false;\nfor($i = 0; $i < $n; $i++) {\n $x = $dxs->G();\n if($x == 1) {\n $ok = true;\n }\n}\n\nif($ok) {\n echo -1;\n} else {\n echo 1;\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "59d4c66892fa3157d1163225a550a368"} {"nl": {"description": "DZY has a sequence a, consisting of n integers.We'll call a sequence ai,\u2009ai\u2009+\u20091,\u2009...,\u2009aj (1\u2009\u2264\u2009i\u2009\u2264\u2009j\u2009\u2264\u2009n) a subsegment of the sequence a. The value (j\u2009-\u2009i\u2009+\u20091) denotes the length of the subsegment.Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.You only need to output the length of the subsegment you find.", "input_spec": "The first line contains integer n\u00a0(1\u2009\u2264\u2009n\u2009\u2264\u2009105). The next line contains n integers a1,\u2009a2,\u2009...,\u2009an\u00a0(1\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "In a single line print the answer to the problem \u2014 the maximum length of the required subsegment.", "sample_inputs": ["6\n7 2 3 1 5 6"], "sample_outputs": ["5"], "notes": "NoteYou can choose subsegment a2,\u2009a3,\u2009a4,\u2009a5,\u2009a6 and change its 3rd element (that is a4) to 4."}, "positive_code": [{"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a == 1)\n{\n print \"1\";\n}\nelseif($a == 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($b[$c[$x] - 1] == TRUE) && ($b[$c[$x]] != 0))\n {\n $j++;\n }\n elseif($b[$d[$x] + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && (($b[$d[$x] + 1] - $b[$d[$x] - 1] > 1) || ($b[$c[$x + 1] + 1] - $b[$c[$x + 1] - 1] > 1)))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}], "negative_code": [{"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a <= 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($c[$x - 1] == TRUE) && ($b[$c[$x]] != 1))\n {\n $j++;\n }\n elseif($d[$x + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && ($b[$c[$x + 1] + 1] - $b[$c[$x + 1] - 1] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}, {"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a == 1)\n{\n print \"1\";\n}\nelseif($a == 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($b[$c[$x] - 1] == TRUE) && ($b[$c[$x]] != 1))\n {\n $j++;\n }\n elseif($b[$d[$x] + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && ($b[$c[$x + 1] + 1] - $b[$c[$x + 1] - 1] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}, {"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a <= 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($b[$c[$x] - 1] == TRUE) && ($b[$c[$x]] != 1))\n {\n $j++;\n }\n elseif($b[$d[$x] + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && ($b[$c[$x + 1] + 1] - $b[$c[$x + 1] - 1] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}, {"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a == 1)\n{\n print \"1\";\n}\nelseif($a == 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($b[$c[$x] - 1] == TRUE) && ($b[$c[$x]] != 0))\n {\n $j++;\n }\n elseif($b[$d[$x] + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && ($b[$d[$x] + 1] - $b[$d[$x] - 1] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}, {"source_code": " $b[$x])\n {\n $d++;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n else\n {\n $c = max($c, $d);\n $d = 1;\n }\n}\nif($c != $a)\n{\n $c++;\n}\n$d = 1;\n$e = 0;\nfor($x = 0; $x < $a - 1; $x++)\n{\n if($b[$x + 1] > $b[$x])\n {\n $d++;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n elseif(($e == 0) && ($b[$x + 2] > $b[$x]) && (($b[$x + 2] - $b[$x]) > 1))\n {\n $d += 2;\n $x++;\n $e = 1;\n $f = $x;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n else\n {\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n $c = max($c, $d);\n $d = 1;\n $e = 0;\n if($e == 1)\n {\n $x = $f;\n }\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d++;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n else\n {\n $c = max($c, $d);\n $d = 1;\n }\n}\nif($c != $a)\n{\n $c++;\n}\n$d = 1;\n$e = 0;\nfor($x = 0; $x < $a - 1; $x++)\n{\n if($b[$x + 1] > $b[$x])\n {\n $d++;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n elseif(($e == 0) && ($b[$x + 2] > $b[$x]) && (($b[$x + 2] - $b[$x]) > 1))\n {\n $d += 2;\n $x++;\n $e = 1;\n $f = $x;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n else\n {\n $c = max($c, $d);\n $d = 1;\n $e = 0;\n if($e == 1)\n {\n $x = $f;\n }\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d++;\n }\n else\n {\n $c = max($c, $d);\n $d = 1;\n }\n}\nif($c != $a)\n{\n $c++;\n}\n$d = 1;\n$e = 0;\nfor($x = 0; $x < $a - 1; $x++)\n{\n if($b[$x + 1] > $b[$x])\n {\n $d++;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n elseif(($e == 0) && ($b[$x + 2] > $b[$x]) && (($b[$x + 2] - $b[$x]) > 1))\n {\n $d += 2;\n $x ++;\n $e = 1;\n if($x == ($a - 2))\n {\n $c = max($c, $d);\n }\n }\n else\n {\n $c = max($c, $d);\n $d = 1;\n $e = 0;\n }\n}\nprint $c;\n?>"}, {"source_code": ""}, {"source_code": " $b[$x]) && ($g == 0))\n {\n $c[$e] = $x;\n $e++;\n $g = 1;\n }\n elseif(($b[$x + 1] <= $b[$x]) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n elseif(($x == $a - 1) && ($g == 1))\n {\n $d[$f] = $x;\n $f++;\n $g = 0;\n }\n}\nif($a == 1)\n{\n print \"1\";\n}\nelseif($a == 2)\n{\n print \"2\";\n}\nelseif(count($c) == 0)\n{\n print \"2\";\n}\nelse\n{\n $h = array();\n $i = 0;\n for($x = 0; $x < count($c); $x++)\n {\n $j = $d[$x] - $c[$x] + 1;\n if(($b[$c[$x] - 1] == TRUE) && ($b[$c[$x]] != 0))\n {\n $j++;\n }\n elseif($b[$d[$x] + 1] == TRUE)\n {\n $j++;\n }\n $h[$i] = $j;\n $i++;\n }\n for($x = 0; $x < count($c) - 1; $x++)\n {\n if(($c[$x + 1] - $d[$x] == 1) && ($b[$c[$x + 1] + 1] - $b[$c[$x + 1] - 1] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n elseif(($c[$x + 1] - $d[$x] == 2) && ($b[$c[$x + 1]] - $b[$d[$x]] > 1))\n {\n $k = $d[$x + 1] - $c[$x] + 1;\n $h[$i] = $k;\n $i++;\n }\n }\n print max($h);\n}\n?>"}], "src_uid": "9e0d271b9bada1364dfcb47297549652"} {"nl": {"description": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti: If Petya has visited this room before, he writes down the minute he was in this room last time; Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105) \u2014 then number of notes in Petya's logbook. The second line contains n non-negative integers t1,\u2009t2,\u2009...,\u2009tn (0\u2009\u2264\u2009ti\u2009<\u2009i) \u2014 notes in the logbook.", "output_spec": "In the only line print a single integer \u2014 the minimum possible number of rooms in Paris catacombs.", "sample_inputs": ["2\n0 0", "5\n0 1 0 1 3"], "sample_outputs": ["2", "3"], "notes": "NoteIn the first sample, sequence of rooms Petya visited could be, for example 1\u2009\u2192\u20091\u2009\u2192\u20092, 1\u2009\u2192\u20092\u2009\u2192\u20091 or 1\u2009\u2192\u20092\u2009\u2192\u20093. The minimum possible number of rooms is 2.In the second sample, the sequence could be 1\u2009\u2192\u20092\u2009\u2192\u20093\u2009\u2192\u20091\u2009\u2192\u20092\u2009\u2192\u20091."}, "positive_code": [{"source_code": " 1);\n$d = 2;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $b[$x];\n if($c[$e] == TRUE)\n {\n $f = $c[$e];\n unset($c[$e]);\n $g = $x + 1;\n $c[$g] = $f;\n }\n else\n {\n $g = $x + 1;\n $c[$g] = $d;\n $d++;\n }\n}\nprint count($c);\n?>"}], "negative_code": [], "src_uid": "81c6342b7229892d71cb43e72aee99e9"} {"nl": {"description": "You are given two strings $$$s$$$ and $$$t$$$ both of length $$$2$$$ and both consisting only of characters 'a', 'b' and 'c'.Possible examples of strings $$$s$$$ and $$$t$$$: \"ab\", \"ca\", \"bb\".You have to find a string $$$res$$$ consisting of $$$3n$$$ characters, $$$n$$$ characters should be 'a', $$$n$$$ characters should be 'b' and $$$n$$$ characters should be 'c' and $$$s$$$ and $$$t$$$ should not occur in $$$res$$$ as substrings.A substring of a string is a contiguous subsequence of that string. So, the strings \"ab\", \"ac\" and \"cc\" are substrings of the string \"abacc\", but the strings \"bc\", \"aa\" and \"cb\" are not substrings of the string \"abacc\".If there are multiple answers, you can print any of them.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$) \u2014 the number of characters 'a', 'b' and 'c' in the resulting string. The second line of the input contains one string $$$s$$$ of length $$$2$$$ consisting of characters 'a', 'b' and 'c'. The third line of the input contains one string $$$t$$$ of length $$$2$$$ consisting of characters 'a', 'b' and 'c'.", "output_spec": "If it is impossible to find the suitable string, print \"NO\" on the first line. Otherwise print \"YES\" on the first line and string $$$res$$$ on the second line. $$$res$$$ should consist of $$$3n$$$ characters, $$$n$$$ characters should be 'a', $$$n$$$ characters should be 'b' and $$$n$$$ characters should be 'c' and $$$s$$$ and $$$t$$$ should not occur in $$$res$$$ as substrings. If there are multiple answers, you can print any of them.", "sample_inputs": ["2\nab\nbc", "3\naa\nbc", "1\ncb\nac"], "sample_outputs": ["YES\nacbbac", "YES\ncacbacbab", "YES\nabc"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "7f45fba2c06fe176a2b634e8988076c2"} {"nl": {"description": "On an $$$8 \\times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the cells through which it passes.Determine which color was used last. The red stripe was painted after the blue one, so the answer is R. ", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 4000$$$)\u00a0\u2014 the number of test cases. The description of test cases follows. There is an empty line before each test case. Each test case consists of $$$8$$$ lines, each containing $$$8$$$ characters. Each of these characters is either 'R', 'B', or '.', denoting a red square, a blue square, and an unpainted square, respectively. It is guaranteed that the given field is obtained from a colorless one by drawing horizontal red rows and vertical blue columns. At least one stripe is painted.", "output_spec": "For each test case, output 'R' if a red stripe was painted last, and 'B' if a blue stripe was painted last (without quotes).", "sample_inputs": ["4\n\n\n\n\n....B...\n\n....B...\n\n....B...\n\nRRRRRRRR\n\n....B...\n\n....B...\n\n....B...\n\n....B...\n\n\n\n\nRRRRRRRB\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nB......B\n\nRRRRRRRB\n\n\n\n\nRRRRRRBB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\nRRRRRRBB\n\n.B.B..BB\n\n.B.B..BB\n\n\n\n\n........\n\n........\n\n........\n\nRRRRRRRR\n\n........\n\n........\n\n........\n\n........"], "sample_outputs": ["R\nB\nB\nR"], "notes": "NoteThe first test case is pictured in the statement.In the second test case, the first blue column is painted first, then the first and last red rows, and finally the last blue column. Since a blue stripe is painted last, the answer is B."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "2c7add49d423de44a2bc09de56ffacf1"} {"nl": {"description": "Bob programmed a robot to navigate through a 2d maze.The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'.There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a single exit in the maze. Its position is denoted with the character 'E'. This position has no obstacle in it.The robot can only move up, left, right, or down.When Bob programmed the robot, he wrote down a string of digits consisting of the digits 0 to 3, inclusive. He intended for each digit to correspond to a distinct direction, and the robot would follow the directions in order to reach the exit. Unfortunately, he forgot to actually assign the directions to digits.The robot will choose some random mapping of digits to distinct directions. The robot will map distinct digits to distinct directions. The robot will then follow the instructions according to the given string in order and chosen mapping. If an instruction would lead the robot to go off the edge of the maze or hit an obstacle, the robot will crash and break down. If the robot reaches the exit at any point, then the robot will stop following any further instructions.Bob is having trouble debugging his robot, so he would like to determine the number of mappings of digits to directions that would lead the robot to the exit.", "input_spec": "The first line of input will contain two integers n and m (2\u2009\u2264\u2009n,\u2009m\u2009\u2264\u200950), denoting the dimensions of the maze. The next n lines will contain exactly m characters each, denoting the maze. Each character of the maze will be '.', '#', 'S', or 'E'. There will be exactly one 'S' and exactly one 'E' in the maze. The last line will contain a single string s (1\u2009\u2264\u2009|s|\u2009\u2264\u2009100)\u00a0\u2014 the instructions given to the robot. Each character of s is a digit from 0 to 3.", "output_spec": "Print a single integer, the number of mappings of digits to directions that will lead the robot to the exit.", "sample_inputs": ["5 6\n.....#\nS....#\n.#....\n.#....\n...E..\n333300012", "6 6\n......\n......\n..SE..\n......\n......\n......\n01232123212302123021", "5 3\n...\n.S.\n###\n.E.\n...\n3"], "sample_outputs": ["1", "14", "0"], "notes": "NoteFor the first sample, the only valid mapping is , where D is down, L is left, U is up, R is right."}, "positive_code": [{"source_code": " $o, \"R\" => $p, \"U\" => $q, \"D\" => $r);\n $t = array_flip($s);\n for($u = 0; $u < strlen($l); $u++)\n {\n if($t[$l[$u]] == \"L\")\n {\n $g2--;\n }\n elseif($t[$l[$u]] == \"R\")\n {\n $g2++;\n }\n elseif($t[$l[$u]] == \"U\")\n {\n $h2++;\n }\n elseif($t[$l[$u]] == \"D\")\n {\n $h2--;\n }\n if($c[$g2][$h2] == $c[$i][$j])\n {\n $m++;\n break;\n }\n elseif($c[$g2][$h2] == \"#\")\n {\n break;\n }\n }\n }\n }\n }\n }\n}\nprint $m;\n?>"}, {"source_code": "= $height || $x >= $width || $lines[$y][$x] === '#')\n {\n break;\n }\n\n if ($x === $endX && $y === $endY)\n {\n $result++;\n break;\n }\n }\n }\n }\n }\n}\n\necho $result;\n"}], "negative_code": [], "src_uid": "8a1799f4ca028d48d5a12e8ac4b8bee1"} {"nl": {"description": "Haiku is a genre of Japanese traditional poetry.A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words.To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: \"a\", \"e\", \"i\", \"o\" and \"u\".Three phases from a certain poem are given. Determine whether it is haiku or not.", "input_spec": "The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification.", "output_spec": "Print \"YES\" (without the quotes) if the poem is a haiku. Otherwise, print \"NO\" (also without the quotes).", "sample_inputs": ["on codeforces \nbeta round is running\n a rustling of keys", "how many gallons\nof edo s rain did you drink\n cuckoo"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " "}, {"source_code": ""}], "negative_code": [], "src_uid": "46d734178b3acaddf2ee3706f04d603d"} {"nl": {"description": "Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1,\u2009a2,\u2009...,\u2009an megabytes. The file size is equal to m megabytes. Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.", "input_spec": "The first line contains positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of USB flash drives. The second line contains positive integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the size of Sean's file. Each of the next n lines contains positive integer ai (1\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 the sizes of USB flash drives in megabytes. It is guaranteed that the answer exists, i. e. the sum of all ai is not less than m.", "output_spec": "Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.", "sample_inputs": ["3\n5\n2\n1\n3", "3\n6\n2\n3\n2", "2\n5\n5\n10"], "sample_outputs": ["2", "3", "1"], "notes": "NoteIn the first example Sean needs only two USB flash drives \u2014 the first and the third.In the second example Sean needs all three USB flash drives.In the third example Sean needs only one USB flash drive and he can use any available USB flash drive \u2014 the first or the second."}, "positive_code": [{"source_code": ""}, {"source_code": " 0) {\n $total_size -= $usbs_size[$i];\n $i++;\n}\necho $i;"}, {"source_code": "$a){\n $sum+= $a;\n if($sum >= $size){\n fprintf(STDOUT, '%d', $k + 1); exit;\n }\n}\n?>"}, {"source_code": "= $m){\n $res = $i + 1;\n break;\n }\n }\n echo($res);\n?>"}, {"source_code": "$a){\n $sum+= $a;\n if($sum >= $size){\n fprintf(STDOUT, '%d', $k + 1); exit;\n }\n}\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": "$a){\n $sum+= $a;\n if($sum >= $size){\n fprintf(STDOUT, '%d', $k); exit;\n }\n}\n?>"}, {"source_code": "$a){\n $sum+= $a;\n if($sum > $size){\n fprintf(STDOUT, '%d', $k); exit;\n }\n}\n?>"}], "src_uid": "a02a9e37a4499f9c86ac690a3a427466"} {"nl": {"description": "A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.You are given a string $$$s$$$ of length $$$n$$$, consisting of digits.In one operation you can delete any character from string $$$s$$$. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.You need to determine whether there is such a sequence of operations (possibly empty), after which the string $$$s$$$ becomes a telephone number.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the length of string $$$s$$$. The second line of each test case contains the string $$$s$$$ ($$$|s| = n$$$) consisting of digits.", "output_spec": "For each test print one line. If there is a sequence of operations, after which $$$s$$$ becomes a telephone number, print YES. Otherwise, print NO.", "sample_inputs": ["2\n13\n7818005553535\n11\n31415926535"], "sample_outputs": ["YES\nNO"], "notes": "NoteIn the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535."}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if(($c[$y] == \"8\") && ($b - $y >= 11))\n {\n $d = 1;\n break;\n }\n }\n if($d == 0)\n {\n print \"NO\\n\";\n }\n else\n {\n print \"YES\\n\";\n }\n}\n?>"}, {"source_code": "= 11){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n\n?>"}, {"source_code": "0; $n--)\n{\n\t$x = readline();\n\t$y = readline();\n\tif($x<11)\n\t{\n\t echo \"NO\\n\";\n\t continue;\n\t}\n\tfor($i=0; $i<=$x-11; $i++)\n\t{\n\t\tif($y[$i] == '8')\n\t\t{\n\t\t\techo \"Yes\\n\";;\n\t\t\tbreak;\n\t\t}\n\t\tif($i == $x-11) echo \"NO\\n\";\n\t}\n}"}, {"source_code": " 0 && $testCasesCount <= 100) {\n for ($i = 0; $i < $testCasesCount; $i++) {\n $testCasesArray[$i]['numberLength'] = intval(trim(fgets(STDIN)));\n $testCasesArray[$i]['number'] = trim(fgets(STDIN));\n }\n for ($i = 0; $i < $testCasesCount; $i++) {\n $numberLength = $testCasesArray[$i]['numberLength'];\n $number = $testCasesArray[$i]['number'];\n if ($numberLength < 11) {\n echo \"NO\\n\";\n continue;\n }\n $eightNumberPos = strpos($number, '8');\n if ($eightNumberPos === false) {\n echo \"NO\\n\";\n continue;\n } elseif (($numberLength - 11) >= $eightNumberPos) {\n echo \"YES\\n\";\n continue;\n } else {\n echo \"NO\\n\";\n continue;\n }\n }\n}\n"}, {"source_code": "= 11){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n\n?>"}, {"source_code": "= 10)\n \t$result[]=\"YES\";\n else\n \t$result[]=\"NO\";\n }else{\n \t$result[]=\"NO\";\n }\n} \nforeach ($result as $value) {\n\techo($value.\"\\n\");\n}"}, {"source_code": "=11)\n\t\t\t\t{\n\t\t\t\t\t$flag=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t }\n\t\t if($flag==1)\n\t\t \techo \"YES\\n\";\n\t\t else\n\t\t \techo \"NO\\n\";\n\n}"}, {"source_code": "= 11 && strlen($pos)) {\n echo \"YES\\n\";\n continue;\n } else {\n echo \"NO\\n\";\n continue;\n }\n }"}, {"source_code": "= 10 ? 'YES' : 'NO').\"\\n\"; \n}\n\necho $ans;"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": "0; $n--)\n{\n\t$x = readline();\n\t$y = readline();\n\tfor($i=0; $i<=$x-10; $i++)\n\t{\n\t\tif($y[$i] == '8')\n\t\t{\n\t\t\techo \"Yes\\n\";;\n\t\t\tbreak;\n\t\t}\n\t\tif($i == $x-10) echo \"NO\\n\";\n\t}\n}"}, {"source_code": "0; $n--)\n{\n\t$x = readline();\n\t$y = readline();\n\tfor($i=0; $i<=$x-11; $i++)\n\t{\n\t\tif($y[$i] == '8')\n\t\t{\n\t\t\techo \"Yes\\n\";;\n\t\t\tbreak;\n\t\t}\n\t\tif($i == $x-10) echo \"NO\\n\";\n\t}\n}"}, {"source_code": "0; $n--)\n{\n\t$x = readline();\n\t$y = readline();\n\tfor($i=0; $i<=$x-11; $i++)\n\t{\n\t\tif($y[$i] == '8')\n\t\t{\n\t\t\techo \"Yes\\n\";;\n\t\t\tbreak;\n\t\t}\n\t\tif($i == $x-11) echo \"NO\\n\";\n\t}\n}"}, {"source_code": " ['numberLength' => 13, 'number' => 7818005553535],\n 1 => ['numberLength' => 11, 'number' => 31415926535]\n];\nif (is_int($testCasesCount) && $testCasesCount > 0) {\n// for ($i = 0; $i < $testCasesCount; $i++) {\n// $testCasesArray[$i]['numberLength'] = trim(fgets(STDIN));\n// $testCasesArray[$i]['number'] = trim(fgets(STDIN));\n// }\n for ($i = 0; $i < $testCasesCount; $i++) {\n $numberLength = $testCasesArray[$i]['numberLength'];\n $number = $testCasesArray[$i]['number'];\n if ($numberLength < 11) {\n //echo 'NO' . PHP_EOL;\n echo \"NO\\n\";\n continue;\n }\n $eightNumberPos = strpos(((string) $number), '8');\n if ($eightNumberPos === false) {\n //echo 'NO' . PHP_EOL;\n echo \"NO\\n\";\n continue;\n } elseif (($numberLength - 11) >= $eightNumberPos) {\n //echo 'YES' . PHP_EOL;\n echo \"YES\\n\";\n continue;\n } else {\n //echo 'NO' . PHP_EOL;\n echo \"NO\\n\";\n continue;\n }\n }\n}\n"}, {"source_code": " 0 && $testCasesCount <= 100) {\n for ($i = 0; $i < $testCasesCount; $i++) {\n $testCasesArray[$i]['numberLength'] = trim(fgets(STDIN));\n $testCasesArray[$i]['number'] = trim(fgets(STDIN));\n }\n for ($i = 0; $i < $testCasesCount; $i++) {\n $numberLength = $testCasesArray[$i]['numberLength'];\n $number = $testCasesArray[$i]['number'];\n if ($numberLength < 11) {\n echo \"NO\\n\";\n continue;\n }\n $eightNumberPos = strpos(((string) $number), '8');\n if ($eightNumberPos === false) {\n echo \"NO\\n\";\n continue;\n } elseif (($numberLength - 11) >= $eightNumberPos) {\n echo \"YES\\n\";\n continue;\n } else {\n echo \"NO\\n\";\n continue;\n }\n }\n}\n"}, {"source_code": " 0 && $testCasesCount <= 100) {\n for ($i = 0; $i < $testCasesCount; $i++) {\n $testCasesArray[$i]['numberLength'] = intval(trim(fgets(STDIN)));\n $testCasesArray[$i]['number'] = intval(trim(fgets(STDIN)));\n }\n for ($i = 0; $i < $testCasesCount; $i++) {\n $numberLength = $testCasesArray[$i]['numberLength'];\n $number = $testCasesArray[$i]['number'];\n if ($numberLength < 11) {\n echo \"NO\\n\";\n continue;\n }\n $eightNumberPos = strpos(((string) $number), '8');\n if ($eightNumberPos === false) {\n echo \"NO\\n\";\n continue;\n } elseif (($numberLength - 11) >= $eightNumberPos) {\n echo \"YES\\n\";\n continue;\n } else {\n echo \"NO\\n\";\n continue;\n }\n }\n}\n"}, {"source_code": " 0 && $testCasesCount <= 100) {\n for ($i = 0; $i < $testCasesCount; $i++) {\n $testCasesArray[$i]['numberLength'] = trim(fgets(STDIN));\n $testCasesArray[$i]['number'] = trim(fgets(STDIN));\n }\n for ($i = 0; $i < $testCasesCount; $i++) {\n $numberLength = $testCasesArray[$i]['numberLength'];\n $number = $testCasesArray[$i]['number'];\n if ($numberLength < 11) {\n echo 'NO' . PHP_EOL;\n continue;\n }\n $eightNumberPos = strpos(((string) $number), '8');\n if ($eightNumberPos === false) {\n echo 'NO' . PHP_EOL;\n continue;\n } elseif (($numberLength - 11) >= $eightNumberPos) {\n echo 'YES' . PHP_EOL;\n continue;\n } else {\n echo 'NO' . PHP_EOL;\n continue;\n }\n }\n}\n"}, {"source_code": "=11){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 12){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n\n?>"}, {"source_code": "=11){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n }\n}\n\n?>"}, {"source_code": "= 11)\n \t$result[]=\"YES\";\n else\n \t$result[]=\"NO\";\n} \nforeach ($result as $value) {\n\techo($value.\"\\n\");\n}"}, {"source_code": "= 11)\n \t$result[]=\"YES\";\n else\n \t$result[]=\"NO\";\n} \nforeach ($result as $value) {\n\techo($value.\"\\n\");\n}"}, {"source_code": "= 10)\n \t$result[]=\"YES\";\n else\n \t$result[]=\"NO\";\n} \nforeach ($result as $value) {\n\techo($value.\"\\n\");\n}"}, {"source_code": "= 11)\n \t$result[]=\"YES\";\n else\n \t$result[]=\"NO\";\n} \nforeach ($result as $value) {\n\techo($value.\"\\n\");\n}"}, {"source_code": "=11)\n\t\t \techo \"YES\\n\";\n\t\t else\n\t\t \techo \"NO\\n\";\n\n}"}, {"source_code": "=11)\n\t\t \techo \"YES\\n\";\n\t\t else\n\t\t \techo \"NO\\n\";\n\n}"}, {"source_code": ""}, {"source_code": "$handle = fopen (\"php://stdin\",\"r\");\n$t = fgets($handle);\nfor($i=0; $i<$t; $i++) {\n\t$n = fgets($handle);\n\t$s = fgets($handle);\n\t$n = (int)$n;\n\tvar_dump($n);\n\tif($n < 11) {\n\t\techo \"NO\\n\";\n\t} else if($n === 11) {\n\t\techo $s[0] === \"8\" ? \"YES\\n\" : \"NO\\n\";\n\t} else {\n\t\t$odd = $n - 11;\n\t\techo strpos($s, \"8\") <= $odd ? \"YES\\n\" : \"NO\\n\";\n\t}\n}"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "bcdd7862b718d6bcc25c9aba8716d487"} {"nl": {"description": "Maria participates in a bicycle race.The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.Let's introduce a system of coordinates, directing the Ox axis from west to east, and the Oy axis from south to north. As a starting position of the race the southernmost point of the track is selected (and if there are several such points, the most western among them). The participants start the race, moving to the north. At all straight sections of the track, the participants travel in one of the four directions (north, south, east or west) and change the direction of movement only in bends between the straight sections. The participants, of course, never turn back, that is, they do not change the direction of movement from north to south or from east to west (or vice versa).Maria is still young, so she does not feel confident at some turns. Namely, Maria feels insecure if at a failed or untimely turn, she gets into the water. In other words, Maria considers the turn dangerous if she immediately gets into the water if it is ignored.Help Maria get ready for the competition\u00a0\u2014 determine the number of dangerous turns on the track.", "input_spec": "The first line of the input contains an integer n (4\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the number of straight sections of the track. The following (n\u2009+\u20091)-th line contains pairs of integers (xi,\u2009yi) (\u2009-\u200910\u2009000\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u200910\u2009000). The first of these points is the starting position. The i-th straight section of the track begins at the point (xi,\u2009yi) and ends at the point (xi\u2009+\u20091,\u2009yi\u2009+\u20091). It is guaranteed that: the first straight section is directed to the north; the southernmost (and if there are several, then the most western of among them) point of the track is the first point; the last point coincides with the first one (i.e., the start position); any pair of straight sections of the track has no shared points (except for the neighboring ones, they share exactly one point); no pair of points (except for the first and last one) is the same; no two adjacent straight sections are directed in the same direction or in opposite directions. ", "output_spec": "Print a single integer\u00a0\u2014 the number of dangerous turns on the track.", "sample_inputs": ["6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0", "16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1"], "sample_outputs": ["1", "6"], "notes": "NoteThe first sample corresponds to the picture: The picture shows that you can get in the water under unfortunate circumstances only at turn at the point (1,\u20091). Thus, the answer is 1."}, "positive_code": [{"source_code": " $e) && ($g > $d))\n {\n $f++;\n }\n elseif(($e > $c) && ($d > $g))\n {\n $f++;\n }\n elseif(($d > $b) && ($h > $e))\n {\n $f++;\n }\n elseif(($b > $d) && ($e > $h))\n {\n $f++;\n }\n $b = $d;\n $c = $e;\n $d = $g;\n $e = $h;\n}\nprint $f;\n?>"}, {"source_code": " $lastX) {\n $parts[$i] = 'R';\n } else if ($x < $lastX) {\n $parts[$i] = 'L';\n } else if ($y > $lastY) {\n $parts[$i] = 'T';\n } else {\n $parts[$i] = 'B';\n }\n \n if (isset($parts[$i-1])) {\n $situation = $parts[$i-1].$parts[$i];\n if (in_array($situation, array('RT','TL','LB', 'BR'))) {\n $danger++;\n }\n }\n }\n \n $lastX = $x;\n $lastY = $y;\n\n}\necho $danger;\n\n?>"}], "negative_code": [{"source_code": " $lastX) {\n $parts[$i] = 'R';\n } else if ($x < $lastX) {\n $parts[$i] = 'L';\n } else if ($y > $lastY) {\n $parts[$i] = 'T';\n } else {\n $parts[$i] = 'B';\n }\n \n if (isset($parts[$i-1])) {\n $situation = $parts[$i-1].$parts[$i];\n if (in_array($situation, array('RT','TL','LB', 'BR'))) {\n $danger++;\n }\n }\n }\n \n $lastX = $x;\n $lastY = $y;\n\n}\necho $danger;\n\n?>"}], "src_uid": "0054f9e2549900487d78fae9aa4c2d65"} {"nl": {"description": "Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: They are equal. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: a1 is equivalent to b1, and a2 is equivalent to b2 a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.Gerald has already completed this home task. Now it's your turn!", "input_spec": "The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200\u2009000 and consists of lowercase English letters. The strings have the same length.", "output_spec": "Print \"YES\" (without the quotes), if these two strings are equivalent, and \"NO\" (without the quotes) otherwise.", "sample_inputs": ["aaba\nabaa", "aabb\nabab"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample you should split the first string into strings \"aa\" and \"ba\", the second one \u2014 into strings \"ab\" and \"aa\". \"aa\" is equivalent to \"aa\"; \"ab\" is equivalent to \"ba\" as \"ab\" = \"a\" + \"b\", \"ba\" = \"b\" + \"a\".In the second sample the first string can be splitted into strings \"aa\" and \"bb\", that are equivalent only to themselves. That's why string \"aabb\" is equivalent only to itself and to string \"bbaa\"."}, "positive_code": [{"source_code": " 0 ? $right.$left : $left.$right;\n}\n\n$input = array_map('trim', explode(\"\\n\", file_get_contents('php://stdin')));\n$a = order(array_shift($input));\n$b = order(array_shift($input));\n\nif ($a == $b)\n\techo 'YES', PHP_EOL;\nelse\n\techo 'NO', PHP_EOL;\n"}, {"source_code": " 0 ? $right.$left : $left.$right;\n}\n\n$input = array_map('trim', explode(\"\\n\", file_get_contents('php://stdin')));\n$a = order(array_shift($input));\n$b = order(array_shift($input));\n\nif ($a == $b)\n\techo 'YES', PHP_EOL;\nelse\n\techo 'NO', PHP_EOL;\n"}, {"source_code": " $b)\n {\n $c[$x] = $d;\n }\n}\n$g = min($c);\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == $g)\n {\n print $x + 1;\n break;\n }\n}\n?>"}, {"source_code": " $busDatum) {\n if ($servalTime === $busDatum) {\n $result = $busIndex;\n break 2;\n }\n if ($time === $busDatum) {\n if ($time >= $servalTime) {\n $result = $busIndex;\n break 2;\n }\n $busArrival[$busIndex] += $busShift[$busIndex];\n }\n }\n $time = min($busArrival);\n}\necho $result;\n"}, {"source_code": " $b)\n {\n if($e < $c)\n {\n $c = $e;\n $d = $x;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $b)\n {\n $c[$x] = $d - $b;\n }\n}\n$g = min($c);\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == $g)\n {\n print $x + 1;\n break;\n }\n}\n?>"}, {"source_code": " $b)\n {\n $c[$x] = $d;\n }\n}\n$g = min($c);\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == $g)\n {\n print $x + 1;\n break;\n }\n}\n?>"}, {"source_code": " $b)\n {\n if($e - $b < $c)\n {\n $c = $e - $b;\n $d = $x;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $b)\n {\n if($e < $c)\n {\n $c = $e;\n $d = $x;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $b)\n {\n $c[$x] = $d - $b;\n }\n}\n$g = min($c);\nfor($x = 0; $x < $a; $x++)\n{\n if($c[$x] == $g)\n {\n print $x + 1;\n break;\n }\n}\n?>"}, {"source_code": " $b)\n {\n if($e - $b < $c)\n {\n $c = $e - $b;\n $d = $x;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $b)\n {\n if($e < $c)\n {\n $c = $e;\n $d = $x;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $busArrival) {\n $maxTime = $busArrival;\n $result = $i;\n }\n continue;\n }\n $delta = ($servalTime - $busArrival) / $busShift;\n if (($servalTime - $busArrival) % $busShift !==0) {\n $delta++;\n }\n $shift = $busArrival + $delta * $busShift;\n if ($shift < $maxTime) {\n $maxTime = $shift;\n $result = $i;\n }\n}\necho $result;\n"}, {"source_code": " $arrivalTime) {\n $waiting = $servalTime - $arrivalTime;\n $minimalWaiting = $waiting - floor($waiting / $busShift[$busIndex]) * $busShift[$busIndex];\n $busArrival[$busIndex] = (int)($minimalWaiting ?: $servalTime);\n}\n$time = min($busArrival);\nwhile ($time<= $servalTime) {\n foreach ($busArrival as $busIndex => $busDatum) {\n if ($servalTime === $busDatum) {\n echo $busIndex;\n break 2;\n }\n if ($time === $busDatum) {\n if ($time >= $servalTime) {\n echo $busIndex;\n break 2;\n }\n $busArrival[$busIndex] += $busShift[$busIndex];\n }\n }\n $time = min($busArrival);\n}\n"}, {"source_code": " $busArrival) {\n $maxTime = $busArrival;\n $result = $i;\n }\n continue;\n }\n $delta = ($servalTime - $busArrival) / $busShift;\n if (($servalTime - $busArrival) % $busShift !== 0) {\n $delta++;\n }\n $shift = $busArrival + $delta * $busShift;\n if ($shift < $maxTime) {\n $maxTime = $shift;\n $result = $i;\n }\n}\necho $result;\n"}, {"source_code": " $arrivalTime) {\n if ($servalTime > $arrivalTime) {\n $waiting = $servalTime - $arrivalTime;\n $minimalWaiting = $waiting - floor($waiting / $busShift[$busIndex]) * $busShift[$busIndex];\n $busArrival[$busIndex] = (int)($minimalWaiting ?: $servalTime);\n }\n}\n$time = min([-1 => $servalTime] + $busArrival);\n$result = 0;\nwhile ($result === 0) {\n foreach ($busArrival as $busIndex => $busDatum) {\n if ($servalTime === $busDatum) {\n $result = $busIndex;\n break 2;\n }\n if ($time === $busDatum) {\n if ($time >= $servalTime) {\n $result = $busIndex;\n break 2;\n }\n $busArrival[$busIndex] += $busShift[$busIndex];\n }\n }\n $time = min($busArrival);\n}\necho $result;\n"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($n,$k) = IO::arr();\r\n $arr = IO::arr();\r\n $cnt = 0;\r\n $total = 0;\r\n $end = count($arr) - 1;\r\n while (true) {\r\n if ($end == $cnt || $k == 0) {\r\n break;\r\n }\r\n\r\n\r\n if ($k - $arr[$cnt] > 0) {\r\n $k = $k - $arr[$cnt];\r\n $total += $arr[$cnt];\r\n $arr[$cnt] = 0;\r\n } else {\r\n $total += $k;\r\n $arr[$cnt] -= $k;\r\n $k = 0;\r\n }\r\n\r\n $cnt++;\r\n }\r\n\r\n $arr[$end] += $total;\r\n $res[] = $arr;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $i) {\r\n echo $i . ' ';\r\n }\r\n echo \"\\n\";\r\n}\r\n"}, {"source_code": " 0 && $i < $n - 1){\r\n\t\t$delta = min($k, $a[$i]);\r\n\t\t$a[$i] -= $delta;\r\n\t\t$a[$n-1] += $delta;\r\n\t\t$k -= $delta;\r\n\t\t$i++;\r\n\t}\r\n\treturn $a;\r\n};\r\n\r\n\r\n$t = intval(fgets(STDIN));\r\nfor (; $t > 0; $t--) {\r\n\r\n\tlist ($n, $k) = explode(' ', fgets(STDIN));\r\n\t$a = array_map(function($itm){ return intval($itm); }, explode(' ', trim(fgets(STDIN))));\r\n\t\r\n\t$a = $solve($n, $k, $a);\r\n\techo implode(' ', $a);\r\n\techo \"\\n\";\r\n\r\n}\r\n"}, {"source_code": "= 1) { \r\n $a[$s] = $a[$s] - 1; \r\n $a[$e - 1] = $a[$e - 1] + 1;\r\n } else { \r\n if ($a[$e - 2] == 0) { break; }\r\n $s++; $j--;\r\n }\r\n }\r\n \r\n for ($j = 0; $j < $n; $j++) { echo $a[$j].' '; }\r\n echo PHP_EOL;\r\n } else {\r\n for ($j = 0; $j < $n - 1; $j++) { echo '0 '; }\r\n echo $sum + $a[$n - 1];\r\n echo PHP_EOL;\r\n }\r\n \r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($n,$k) = IO::arr();\r\n $arr = IO::arr();\r\n $cnt = 0;\r\n $total = 0;\r\n $end = count($arr) - 1;\r\n while ($k--) {\r\n if ($cnt == $end) {\r\n break;\r\n }\r\n\r\n if ($arr[$cnt] > 0) {\r\n $arr[$cnt]--;\r\n if ($arr[$cnt] == 0) {\r\n $cnt++;\r\n }\r\n $total++;\r\n } else {\r\n $cnt++;\r\n }\r\n }\r\n\r\n $arr[$end] += $total;\r\n $res[] = $arr;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $i) {\r\n echo $i . ' ';\r\n }\r\n echo \"\\n\";\r\n}\r\n"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($n,$k) = IO::arr();\r\n $arr = IO::arr();\r\n $cnt = 0;\r\n $total = 0;\r\n $end = count($arr) - 1;\r\n while ($k--) {\r\n if ($cnt == $end) {\r\n break;\r\n }\r\n\r\n if ($arr[$cnt] > 0) {\r\n $arr[$cnt]--;\r\n if ($arr[$cnt] == 0) {\r\n $cnt++;\r\n }\r\n $total++;\r\n }\r\n }\r\n\r\n $arr[$end] += $total;\r\n $res[] = $arr;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $i) {\r\n echo $i . ' ';\r\n }\r\n echo \"\\n\";\r\n}\r\n"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($n,$k) = IO::arr();\r\n $arr = IO::arr();\r\n $cnt = 0;\r\n $total = 0;\r\n $end = count($arr) - 1;\r\n while ($k--) {\r\n if ($cnt == $end) {\r\n break;\r\n }\r\n\r\n if ($arr[$cnt] > 0) {\r\n $arr[$cnt]--;\r\n $total++;\r\n } else {\r\n $cnt++;\r\n }\r\n }\r\n $arr[$end] += $total;\r\n $res[] = $arr;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $i) {\r\n echo $i . ' ';\r\n }\r\n echo \"\\n\";\r\n}\r\n"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list($n,$k) = IO::arr();\r\n $arr = IO::arr();\r\n if ($k < $arr[0]) {\r\n $s = $k;\r\n } else {\r\n $s = $arr[0];\r\n }\r\n\r\n $arr[0] = $arr[0] - $s;\r\n\r\n $arr[count($arr) - 1] = $arr[count($arr) - 1] + $s;\r\n\r\n $res[] = $arr;\r\n}\r\n\r\nforeach ($res as $r) {\r\n foreach ($r as $i) {\r\n echo $i . ' ';\r\n }\r\n echo \"\\n\";\r\n}\r\n"}, {"source_code": " 0 && $i < $n - 1){\r\n\t\t$delta = min($k, $a[$i]);\r\n\t\t$a[$i] -= $delta;\r\n\t\t$a[$n-1] += $delta;\r\n\t\t$k -= $delta;\r\n\t\t$i++;\r\n\t}\r\n\treturn $a;\r\n};\r\n\r\n\r\n$t = intval(fgets(STDIN));\r\nfor (; $t > 0; $t--) {\r\n\r\n\tlist ($n, $k) = explode(' ', fgets(STDIN));\r\n\t$a = array_map(function($itm){ return intval($itm); }, explode(' ', trim(fgets(STDIN))));\r\n\techo implode(' ', $a) . \"\\n\";\r\n\t$a = $solve($n, $k, $a);\r\n\techo implode(' ', $a);\r\n\r\n\techo \"\\n\";\r\n\r\n}\r\n"}], "src_uid": "6854ad3597f9f41d475aacb774b823ed"} {"nl": {"description": "You are given the array of integer numbers a0,\u2009a1,\u2009...,\u2009an\u2009-\u20091. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105) \u2014 length of the array a. The second line contains integer elements of the array separated by single spaces (\u2009-\u2009109\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Print the sequence d0,\u2009d1,\u2009...,\u2009dn\u2009-\u20091, where di is the difference of indices between i and nearest j such that aj\u2009=\u20090. It is possible that i\u2009=\u2009j.", "sample_inputs": ["9\n2 1 0 3 0 0 3 2 4", "5\n0 1 2 3 4", "7\n5 6 0 1 -2 3 4"], "sample_outputs": ["2 1 0 1 0 0 1 2 3", "0 1 2 3 4", "2 1 0 1 2 3 4"], "notes": null}, "positive_code": [{"source_code": " 0)\n {\n $d .= $f . \" \";\n }\n else\n {\n $d .= \"0 \";\n $e++;\n }\n }\n elseif($e == count($c))\n {\n $f = $x - $c[$e - 1];\n $d .= $f . \" \";\n }\n elseif($x < $c[$e])\n {\n $f = $x - $c[$e - 1];\n $g = $c[$e] - $x;\n $h = min($f, $g);\n $d .= $h . \" \";\n if($h == 0)\n {\n $e++;\n }\n }\n elseif($x == $c[$e])\n {\n $d .= \"0 \";\n $e++;\n }\n}\nprint $d;\n?>"}], "negative_code": [], "src_uid": "2031f2ac5652609fda77830e93ffcc2c"} {"nl": {"description": "Given an array $$$a$$$ of positive integers with length $$$n$$$, determine if there exist three distinct indices $$$i$$$, $$$j$$$, $$$k$$$ such that $$$a_i + a_j + a_k$$$ ends in the digit $$$3$$$.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$3 \\leq n \\leq 2 \\cdot 10^5$$$)\u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the elements of the array. The sum of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "Output $$$t$$$ lines, each of which contains the answer to the corresponding test case. Output \"YES\" if there exist three distinct indices $$$i$$$, $$$j$$$, $$$k$$$ satisfying the constraints in the statement, and \"NO\" otherwise. You can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).", "sample_inputs": ["6\n\n4\n\n20 22 19 84\n\n4\n\n1 11 1 2022\n\n4\n\n1100 1100 1100 1111\n\n5\n\n12 34 56 78 90\n\n4\n\n1 9 8 4\n\n6\n\n16 38 94 25 18 99"], "sample_outputs": ["YES\nYES\nNO\nNO\nYES\nYES"], "notes": "NoteIn the first test case, you can select $$$i=1$$$, $$$j=4$$$, $$$k=3$$$. Then $$$a_1 + a_4 + a_3 = 20 + 84 + 19 = 123$$$, which ends in the digit $$$3$$$.In the second test case, you can select $$$i=1$$$, $$$j=2$$$, $$$k=3$$$. Then $$$a_1 + a_2 + a_3 = 1 + 11 + 1 = 13$$$, which ends in the digit $$$3$$$.In the third test case, it can be proven that no such $$$i$$$, $$$j$$$, $$$k$$$ exist. Note that $$$i=4$$$, $$$j=4$$$, $$$k=4$$$ is not a valid solution, since although $$$a_4 + a_4 + a_4 = 1111 + 1111 + 1111 = 3333$$$, which ends in the digit $$$3$$$, the indices need to be distinct.In the fourth test case, it can be proven that no such $$$i$$$, $$$j$$$, $$$k$$$ exist.In the fifth test case, you can select $$$i=4$$$, $$$j=3$$$, $$$k=1$$$. Then $$$a_4 + a_3 + a_1 = 4 + 8 + 1 = 13$$$, which ends in the digit $$$3$$$.In the sixth test case, you can select $$$i=1$$$, $$$j=2$$$, $$$k=6$$$. Then $$$a_1 + a_2 + a_6 = 16 + 38 + 99 = 153$$$, which ends in the digit $$$3$$$."}, "positive_code": [{"source_code": "= 30) {\n break;\n }\n }\n if (check3Sum($realNumArray)) {\n echo('YES'.PHP_EOL);\n } else {\n echo('NO'.PHP_EOL);\n }\n }\n\n function check3Sum($numArray)\n {\n for ($i = 0; $i < count($numArray); $i++) {\n $numMap = [];\n for ($j = $i + 1; $j < count($numArray); $j++) {\n $tempSum = $numArray[$i] + $numArray[$j];\n if ($tempSum <= 3) {\n if ($numMap[3 - $tempSum]) {\n return true;\n }\n } else {\n if ($numMap[10 - (($tempSum - 3) % 10)]) {\n return true;\n }\n }\n $numMap[$numArray[$j]] = true;\n }\n }\n return false;\n }\n"}, {"source_code": " 0 ) {\r\n $we[$rr[$j]] -= 1;\r\n $pp++;\r\n }\r\n \r\n }\r\n if($pp == 3) {\r\n $ans = 'YES';\r\n break;\r\n } else {\r\n $pp = 0;\r\n }\r\n}\r\nIO::pr($ans);\r\n}\r\n\r\n\r\nclass IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}\r\n\r\nclass Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;\r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n\r\n return $d == $n;\r\n }\r\n\r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n\r\n}\r\n\r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;\r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n\r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n\r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i$count) {\n $count = min($count, 3);\n\n while ($count--) {\n $simplified[] = $item;\n }\n }\n\n $y = false;\n\n for ($i = 0, $iM = count($simplified); $i < $iM; ++$i) {\n for ($j = $i + 1; $j < $iM; ++$j) {\n for ($k = $j + 1; $k < $iM; ++$k) {\n if (($simplified[$i] + $simplified[$j] + $simplified[$k]) % 10 === 3) {\n fprintf(STDOUT, \"%s\\n\", 'YES');\n $y = true;\n break 3;\n }\n }\n }\n }\n\n if (!$y) {\n fprintf(STDOUT, \"%s\\n\", 'NO');\n }\n}\n/*\n\n1\n3\n1 1 1\n\n1\n5\n1 1 1 3 3\n\n1\n3\n13 0 0\n\n1\n3\n5 5 3\n\n\n */\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0)\n {\n $s=trim(fgets($handle));\n $arr=explode('_',$s);\n $newStr= $arr[sizeof($arr)-1];\n\n if($newStr[strlen($newStr)-1]=='o')\n {\n echo \"FILIPINO\";\n echo \"\\n\";\n }else if($newStr[strlen($newStr)-1]=='u')\n {\n echo \"JAPANESE\";\n echo \"\\n\";\n }else\n {\n echo \"KOREAN\";\n echo \"\\n\";\n }\n\n --$t;\n }\n\n\n}\n\nsolve();\n?>"}], "negative_code": [{"source_code": "';\n }elseif (ord($char) == 117) {\n return 'JAPANESE
';\n }elseif (ord($char) == 97) {\n return 'KOREAN
';\n } \n}\n \n// keep this function call here\n$file = fopen('php://stdin', 'r');\n$num = fgets($file);\nfor ($i=0; $i < $num; $i++) { \n $str = fgets($file);\n echo FirstReverse($str); \n // return 0;\n}\n// echo FirstReverse(fgets(fopen('input.txt', 'r')));\n// echo FirstReverse(fgets(fopen('php://stdin', 'r'))); \n\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "816907d873bce3573ce1e5ae3f494768"} {"nl": {"description": "Phoenix has $$$n$$$ coins with weights $$$2^1, 2^2, \\dots, 2^n$$$. He knows that $$$n$$$ is even.He wants to split the coins into two piles such that each pile has exactly $$$\\frac{n}{2}$$$ coins and the difference of weights between the two piles is minimized. Formally, let $$$a$$$ denote the sum of weights in the first pile, and $$$b$$$ denote the sum of weights in the second pile. Help Phoenix minimize $$$|a-b|$$$, the absolute value of $$$a-b$$$.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$2 \\le n \\le 30$$$; $$$n$$$ is even)\u00a0\u2014 the number of coins that Phoenix has. ", "output_spec": "For each test case, output one integer\u00a0\u2014 the minimum possible difference of weights between the two piles.", "sample_inputs": ["2\n2\n4"], "sample_outputs": ["2\n6"], "notes": "NoteIn the first test case, Phoenix has two coins with weights $$$2$$$ and $$$4$$$. No matter how he divides the coins, the difference will be $$$4-2=2$$$.In the second test case, Phoenix has four coins of weight $$$2$$$, $$$4$$$, $$$8$$$, and $$$16$$$. It is optimal for Phoenix to place coins with weights $$$2$$$ and $$$16$$$ in one pile, and coins with weights $$$4$$$ and $$$8$$$ in another pile. The difference is $$$(2+16)-(4+8)=6$$$."}, "positive_code": [{"source_code": " 2) {\n for ($i = 1; $i < $coinsCount / 2; $i++) {\n $firstPileWeight += pow(2, $i);\n $secondPileWeight += pow(2, $coinsCount - 1 - $i);\n }\n }\n \n return abs($firstPileWeight - $secondPileWeight);\n}"}, {"source_code": " $n)\n {\n $g -= $e[$o];\n $f += $e[$o];\n $o++;\n $m--;\n $n++;\n }\n print abs($g - $f) . \"\\n\";\n}\n?>"}, {"source_code": "= $leftSize; $j--) {\n\t\t$num = pow(2, $j);\n\n\t\t$left += $num;\n\t}\n\n\techo max($left, $right) - min($left, $right);\n\techo PHP_EOL;\n}"}], "negative_code": [{"source_code": "= 1; $power--) {\n if ($pile1 > $pile2) $pile2[] = pow(2, $power);\n else $pile1[] = pow(2, $power);\n }\n\n return abs(array_sum($pile1) - array_sum($pile2));\n}"}, {"source_code": "= 1000000000) {\n $temp = floor($sumLo / 1000000000);\n $sumHi += floor($sumLo / 1000000000);\n $sumLo -= $temp * 1000000000;\n }\n if($x>1)\n $x--;\n}\n\nif ($sumHi) {\n echo $sumHi . substr('' .($sumLo + 1000000000), 1);\n} else {\n echo $sumLo;\n}"}, {"source_code": " 1) {\n $x_sort--;\n }\n}\n\nfor ($i = 0; $i < $n; $i++) {\n $sum_rsort = bcadd($sum_rsort, $x_rsort * $c_rsort[$i]);\n if ($x_rsort > 1) {\n $x_rsort--;\n }\n}\n\n$result = $sum_sort < $sum_rsort ? $sum_sort : $sum_rsort;\n\necho (string)$result;"}], "negative_code": [{"source_code": "1)\n $x--;\n}\n\necho $sum;"}, {"source_code": "= 1000000000) {\n $temp = floor($sumLo / 1000000000);\n $sumHi += floor($sumLo / 1000000000);\n $sumLo -= $temp * 1000000000;\n }\n if($x>1)\n $x--;\n}\n\necho $sumHi . substr('' .($sumLo + 1000000000), 1);"}, {"source_code": " 1) {\n $x_sort--;\n }\n}\n\nfor ($i = 0; $i < $n; $i++) {\n $sum_rsort += $x_rsort * $c_rsort[$i];\n if ($x_rsort > 1) {\n $x_rsort--;\n }\n}\n\n$result = $sum_sort < $sum_rsort ? $sum_sort : $sum_rsort;\n\necho (string)$result;"}, {"source_code": " 1) {\n $x_sort--;\n }\n}\n\nfor ($i = 0; $i < $n; $i++) {\n $sum_rsort += $x_rsort * $c_rsort[$i];\n if ($x_rsort > 1) {\n $x_rsort--;\n }\n}\n\necho $sum_sort < $sum_rsort ? $sum_sort : $sum_rsort;"}], "src_uid": "ce27e56433175ebf9d3bbcb97e71091e"} {"nl": {"description": "Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right, Maxim tries to buy every game in that order.When Maxim stands at the position $$$i$$$ in the shop, he takes the first bill from his wallet (if his wallet is empty then he proceeds to the next position immediately) and tries to buy the $$$i$$$-th game using this bill. After Maxim tried to buy the $$$n$$$-th game, he leaves the shop.Maxim buys the $$$i$$$-th game if and only if the value of the first bill (which he takes) from his wallet is greater or equal to the cost of the $$$i$$$-th game. If he successfully buys the $$$i$$$-th game, the first bill from his wallet disappears and the next bill becomes first. Otherwise Maxim leaves the first bill in his wallet (this bill still remains the first one) and proceeds to the next game.For example, for array $$$c = [2, 4, 5, 2, 4]$$$ and array $$$a = [5, 3, 4, 6]$$$ the following process takes place: Maxim buys the first game using the first bill (its value is $$$5$$$), the bill disappears, after that the second bill (with value $$$3$$$) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because $$$c_2 > a_2$$$, the same with the third game, then he buys the fourth game using the bill of value $$$a_2$$$ (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value $$$a_3$$$.Your task is to get the number of games Maxim will buy.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 1000$$$) \u2014 the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \\dots, c_n$$$ ($$$1 \\le c_i \\le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th game. The third line of the input contains $$$m$$$ integers $$$a_1, a_2, \\dots, a_m$$$ ($$$1 \\le a_j \\le 1000$$$), where $$$a_j$$$ is the value of the $$$j$$$-th bill from the Maxim's wallet.", "output_spec": "Print a single integer \u2014 the number of games Maxim will buy.", "sample_inputs": ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"], "sample_outputs": ["3", "0", "4"], "notes": "NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter until he runs out of bills in his wallet."}, "positive_code": [{"source_code": "= $c[$x])\n {\n $e++;\n $f++;\n }\n}\nprint $e;\n?>"}, {"source_code": " $value){\n if($currentBillIndex >= $a[1]){\n break;\n }\n if($value > $bills[$currentBillIndex]){\n continue;\n }\n\n $count++;\n $currentBillIndex++;\n}\necho \"$count\";\n\n?>"}, {"source_code": ""}, {"source_code": " $value){\n if($currentBillIndex >= $a[1]){\n break;\n }\n if($value > $bills[$currentBillIndex]){\n continue;\n }\n\n $count++;\n $currentBillIndex++;\n}\necho \"$count\";\n\n?>"}], "negative_code": [], "src_uid": "c3f080681e3da5e1290ef935ff91f364"} {"nl": {"description": "Lolek and Bolek are about to travel abroad by plane. The local airport has a special \"Choose Your Plane\" offer. The offer's conditions are as follows: it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x\u2009>\u20090) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091000) \u2014 the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1,\u2009a2,\u2009...,\u2009am (1\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets. The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total.", "output_spec": "Print two integers \u2014 the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.", "sample_inputs": ["4 3\n2 1 1", "4 3\n2 2 2"], "sample_outputs": ["5 5", "7 6"], "notes": "NoteIn the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person \u2014 to the 2-nd plane, the 3-rd person \u2014 to the 3-rd plane, the 4-th person \u2014 to the 1-st plane. The sum is minimized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person \u2014 to the 1-st plane, the 3-rd person \u2014 to the 2-nd plane, the 4-th person \u2014 to the 2-nd plane."}, "positive_code": [{"source_code": "= $d[$f + 1]) && ($d[$f] == $d[0]) && ($f != 0))\n {\n $f = 0;\n }\n if($d[$f] >= $d[$f + 1])\n {\n $e += $d[$f];\n $d[$f]--;\n }\n else\n {\n $f++;\n $x--;\n }\n}\n$g = $c;\nsort($g);\n$h = 0;\n$i = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n if($g[$i] != 0)\n {\n $h += $g[$i];\n $g[$i]--;\n }\n else\n {\n $i++;\n $x--;\n }\n}\nprint $e . \" \" . $h;\n?>"}, {"source_code": "= 0; $y--) {\n\t\tif ($b[$y] > $b[$y-1]) {\n\t\t\t$max += $b[$y];\n\t\t\t$b[$y]--;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n$b = merge_sort($a);\n$b[-1] = 0;\n$min = 0;\nfor ($x = 0; $x < $n; $x++) {\n\tfor ($y = 0; $y < $m; $y++) {\n\t\tif ($b[$y] != 0) {\n\t\t\t$min += $b[$y];\n\t\t\t$b[$y]--;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\necho $max . \" \" . $min;\n\nfunction merge_sort($m) {\n if (count($m) <= 1) {\n return $m;\n\t}\n\t$mid = round((count($m) - 1) / 2, 0, PHP_ROUND_HALF_UP);\n for ($x = 0; $x < $mid; $x++) {\n\t\t$left[$x] = $m[$x];\n\t}\n for ($x = 0; $x <= $mid; $x++) {\n\t\tif ($mid + $x < count($m)) {$right[$x] = $m[$mid + $x];}\n\t}\n\t$left = merge_sort($left);\n\t$right = merge_sort($right);\n\t\n\t$l = 0;\n\t$r = 0;\n\tfor ($x = 0; $x < count($m); $x++) {\n\t\tif (($l < count($left)) && ($r < count($right))) {\n\t\t\tif ($left[$l] <= $right[$r]) {\n\t\t\t\t$res[$x] = $left[$l];\n\t\t\t\t$l++;\n\t\t\t} else {\n\t\t\t\t$res[$x] = $right[$r];\n\t\t\t\t$r++;\n\t\t\t}\n\t\t} else if ($l >= count($left)) {\n\t\t\t$res[$x] = $right[$r];\n\t\t\t$r++;\n\t\t} else {\n\t\t\t$res[$x] = $left[$l];\n\t\t\t$l++;\n\t\t}\n\t}\n\t\n\treturn $res;\n}\n\n// End of submission file\n// Submission by chaotic_iak\n?>"}, {"source_code": " $f) {\n\t\t\n\t\tif( $f == 0 ) continue;\n\t\t\n\t\tif( $max_free_value < $f ) {\n\t\t\t$max_free_index = $k;\n\t\t\t$max_free_value = $f;\n\t\t}\n\t}\n\t\n\t$mx[ $max_free_index ]--;\n\t\n\t$max += $max_free_value;\n}\n\n// Min\n$mn = $free;\n\nfor( $i = 1; $i <= $n; $i++ ) {\n\t\n\t$min_free_index = 0;\n\t$min_free_value = 1000;\n\t\n\tforeach ($mn as $k => $f) {\n\t\t\n\t\tif( $f == 0 ) continue;\n\t\t\n\t\tif( $min_free_value > $f ) {\n\t\t\t\n\t\t\t$min_free_index = $k;\n\t\t\t$min_free_value = $f;\n\t\t}\n\t}\n\t\n\t$mn[ $min_free_index ]--;\n\t\n\t$min += $min_free_value;\n}\n\n$result = \"$max $min\";\n\necho $result;"}, {"source_code": "0)\n if($a_min[$min]>0) {\n --$n_min;\n $out_min+=$a_min[$min];\n --$a_min[$min];\n }\n else $min++;\nwhile($n_max>0) {\n --$n_max;\n rsort($a_max);\n $out_max+=$a_max[0];\n $a_max[0]--;\n}\nprint \"$out_max $out_min\";\n"}], "negative_code": [{"source_code": "= $d[$f + 1])\n {\n $e += $d[$f];\n $d[$f]--;\n }\n else\n {\n $f++;\n $x--;\n }\n}\n$g = $c;\nsort($g);\n$h = 0;\n$i = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n if($g[$i] != 0)\n {\n $h += $g[$i];\n $g[$i]--;\n }\n else\n {\n $i++;\n $x--;\n }\n}\nprint $e . \" \" . $h;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$f + 1])\n {\n $e += $d[$f];\n $d[$f]--;\n }\n else\n {\n $f++;\n $x--;\n }\n}\n$g = $c;\nsort($g);\n$h = 0;\n$i = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n if($g[$i] != 0)\n {\n $h += $g[$i];\n $g[$i]--;\n }\n else\n {\n $i++;\n $x--;\n }\n}\nprint $e . \" \" . $h;\n?>"}, {"source_code": "\nlist($n,$m)=explode(\" \",trim(fgets(STDIN)));\n//$a_min=explode(\" \",fgets(STDIN));\nfor($i=0;$i<$m;$i++) $s.=\"%d \";\n$a_min=fscanf(STDIN,\"$s\");\nsort($a_min); $a_max=$a_min; //rsort($a_max);\n$n_min=$n;$n_max=$n;\n$min=0; $max=$m-1;\nwhile($n_min>0 or $n_max>0){\n if($a_min[$min]>0) {--$n_min; $out_min+=$a_min[$min]; --$a_min[$min]; }\n else $min++;\n if($a_max[$max]>0 && !($a_max[$max]<$a_max[$max-1])) {--$n_max; $out_max+=$a_max[$max]; --$a_max[$max]; }\n else $max--;\n\n}\nprint \"$out_max $out_min\";\n"}, {"source_code": "\n$in=fopen('input.txt','r');\n$out=fopen('output.txt','w');\n$n=fgets($in);\nif($n==2) $sq=1;\n else $sq=ceil(sqrt($n)); fwrite($out,floor($sq).\"\\n\");\n$dn=ceil($n/2);\nfwrite($out, $dn.\" \");for($q=1;$q<=$dn;$q++) { $a[$q]=$q; fwrite($out, $a[$q].\" \");}\n$i=1; $dd=$dn;$z=0;\nwhile ($i<$sq)\n{\n $zz=$z; fwrite($out,\"\\n\");\n \n for($q=$dd;$q>$dd-$sq+1;--$q)\n {\n if($a[$q]>$dn) $a[$q]=$dn-$zz;\n else $a[$q]=$n-$zz;\n $zz++; \n }\n // if($n==5)$a[1]=1;\n fwrite($out, $dn.\" \");for($e=1;$e<=$dn;$e++) fwrite($out, $a[$e].\" \");\n $dd--;$i++;$z++;\n\n}\nfclose($in);\nfclose($out);\n"}, {"source_code": "\nlist($n,$m)=explode(\" \",trim(fgets(STDIN)));\n//$a_min=explode(\" \",fgets(STDIN));\nfor($i=0;$i<$m;$i++) $s.=\"%d \";\n$a_min=fscanf(STDIN,\"$s\");\nsort($a_min); $a_max=$a_min; //rsort($a_max);\n$n_min=$n;$n_max=$n;\n$min=0; $max=$m-1;\nwhile($n_min>0) if($a_min[$min]>0) {--$n_min; $out_min+=$a_min[$min]; --$a_min[$min]; }\n else $min++;\nwhile($n_max>0) if($a_max[$max]>0 && !($a_max[$max]<$a_max[$max-1])) {--$n_max; $out_max+=$a_max[$max]; --$a_max[$max]; }\n elseif ($a_max[$max]==0 && !($a_max[$max-1])) $max++;\n else $max--;\n\n\nprint \"$out_max $out_min\";\n"}], "src_uid": "6dea4611ca210b34ae2da93ebfa9896c"} {"nl": {"description": "Roma works in a company that sells TVs. Now he has to prepare a report for the last year.Roma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the company is the sum of all integers in sequence. Roma decided to perform exactly k changes of signs of several numbers in the sequence. He can also change the sign of a number one, two or more times.The operation of changing a number's sign is the operation of multiplying this number by -1.Help Roma perform the changes so as to make the total income of the company (the sum of numbers in the resulting sequence) maximum. Note that Roma should perform exactly k changes.", "input_spec": "The first line contains two integers n and k (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u2009105), showing, how many numbers are in the sequence and how many swaps are to be made. The second line contains a non-decreasing sequence, consisting of n integers ai (|ai|\u2009\u2264\u2009104). The numbers in the lines are separated by single spaces. Please note that the given sequence is sorted in non-decreasing order.", "output_spec": "In the single line print the answer to the problem \u2014 the maximum total income that we can obtain after exactly k changes.", "sample_inputs": ["3 2\n-1 -1 1", "3 1\n-1 -1 1"], "sample_outputs": ["3", "1"], "notes": "NoteIn the first sample we can get sequence [1, 1, 1], thus the total income equals 3.In the second test, the optimal strategy is to get sequence [-1, 1, 1], thus the total income equals 1."}, "positive_code": [{"source_code": " 0)\n {\n array_push($e, $c[$x]);\n }\n elseif($c[$x] == 0)\n {\n $g = 1;\n }\n}\nsort($d);\nsort($e);\nif((count($d) == 0) && (count($e) == 0) && ($g == 1)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u043b\u044c\n{\n $f = 0;\n}\nelseif((count($d) == 0) && (count($e) != 0) && ($g == 0)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b.\n{\n if(($b % 2) == 0)\n {\n $f = array_sum($e);\n }\n else\n {\n $e[0] *= -1;\n $f = array_sum($e);\n }\n}\nelseif((count($d) == 0) && (count($e) != 0) && ($g == 1)) // \u043f\u043e\u043b. \u0438 \u043d\u043e\u043b\u044c\n{\n $f = array_sum($e);\n}\nelseif((count($e) == 0) && (count($d) != 0) && ($g == 0)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0440.\n{\n if($b <= count($d))\n {\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n }\n else\n {\n $h = $b - count($d) + 1;\n for($y = 0; $y < $b - $h; $y++)\n {\n $d[$y] *= -1;\n }\n if(($h % 2) != 0)\n {\n $d[count($d) - 1] *= -1;\n }\n $f = array_sum($d);\n }\n}\nelseif((count($e) == 0) && (count($d) != 0) && ($g == 1)) // \u043e\u0442\u0440. \u0438 \u043d\u043e\u043b\u044c\n{\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n}\nelseif((count($e) != 0) && (count($d) != 0) && ($g == 0)) // \u043f\u043e\u043b. \u0438 \u043e\u0442\u0440.\n{\n if(abs($d[count($d) - 1]) <= $e[0])\n {\n if($b <= count($d))\n {\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n }\n else\n {\n $h = $b - count($d) + 1;\n for($y = 0; $y < $b - $h; $y++)\n {\n $d[$y] *= -1;\n }\n if(($h % 2) != 0)\n {\n $d[count($d) - 1] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n }\n }\n else\n {\n if($b < count($d))\n {\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n }\n else\n {\n for($y = 0; $y < count($d); $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $i = $b - count($d);\n if(($i % 2) != 0)\n {\n $e[0] *= -1;\n }\n $f += array_sum($e);\n }\n }\n}\nelseif((count($e) != 0) && (count($d) != 0) && ($g == 1)) // \u043f\u043e\u043b., \u043e\u0442\u0440. \u0438 \u043d\u043e\u043b\u044c\n{\n for($y = 0; $y < count($d); $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n}\nprint $f;\n?>"}, {"source_code": " 0) {\n\t\tif ($c1 < 0) {\n\t\t\t$sum -= $c1; $k--;\n\t\t} else {\n\t\t\tif ($c1 > 0) {\n\t\t\t\tif ($k % 2 == 0) {\n\t\t\t\t\t$sum += $c1;\n\t\t\t\t} else {\n\t\t\t\t\tif ($i > 0) {\n\t\t\t\t\t\t$c2 = $c[$i - 1] + 0;\n\t\t\t\t\t\t$sum = ($c1 > -$c2)?$sum+2*$c2 + $c1:$sum-$c1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$sum -= $c1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t$k = 0;\n\t\t}\n\t} else {\n\t\t$sum += $c1;\n\t}\n}\nif ($k % 2 == 1) {\n\t$sum += 2 * ($c[$n-1] + 0);\n}\nfwrite($f2, $sum);\nfclose($f2);"}], "negative_code": [{"source_code": " 0)\n {\n array_push($e, $c[$x]);\n }\n elseif($c[$x] == 0)\n {\n $g = 1;\n }\n}\nsort($d);\nsort($e);\nif((count($d) == 0) && (count($e) == 0) && ($g == 1)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u043b\u044c\n{\n $f = 0;\n}\nelseif((count($d) == 0) && (count($e) != 0) && ($g == 0)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b.\n{\n if(($b % 2) == 0)\n {\n $f = array_sum($e);\n }\n else\n {\n $e[0] *= -1;\n $f = array_sum($e);\n }\n}\nelseif((count($d) == 0) && (count($e) != 0) && ($g == 1)) // \u043f\u043e\u043b. \u0438 \u043d\u043e\u043b\u044c\n{\n $f = array_sum($e);\n}\nelseif((count($e) == 0) && (count($d) != 0) && ($g == 0)) // \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0440.\n{\n if($b <= count($d))\n {\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n }\n else\n {\n $h = $b - count($d) + 1;\n for($y = 0; $y < $b - $h; $y++)\n {\n $d[$y] *= -1;\n }\n if(($h % 2) != 0)\n {\n $d[count($d) - 1] *= -1;\n }\n $f = array_sum($d);\n }\n}\nelseif((count($e) == 0) && (count($d) != 0) && ($g == 1)) // \u043e\u0442\u0440. \u0438 \u043d\u043e\u043b\u044c\n{\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n}\nelseif((count($e) != 0) && (count($d) != 0) && ($g == 0)) // \u043f\u043e\u043b. \u0438 \u043e\u0442\u0440.\n{\n if(abs($d[count($d) - 1]) <= $e[0])\n {\n \n if($b <= count($d))\n {\n for($y = 0; $y < $b; $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n }\n else\n {\n $h = $b - count($d) + 1;\n for($y = 0; $y < $b - $h; $y++)\n {\n $d[$y] *= -1;\n }\n if(($h % 2) != 0)\n {\n $d[count($d) - 1] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n }\n }\n else\n {\n for($y = 0; $y < count($d); $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $i = $b - count($d);\n if(($i % 2) != 0)\n {\n $e[0] *= -1;\n }\n $f += array_sum($e);\n }\n}\nelseif((count($e) != 0) && (count($d) != 0) && ($g == 1)) // \u043f\u043e\u043b., \u043e\u0442\u0440. \u0438 \u043d\u043e\u043b\u044c\n{\n for($y = 0; $y < count($d); $y++)\n {\n $d[$y] *= -1;\n }\n $f = array_sum($d);\n $f += array_sum($e);\n}\nprint $f;\n?>"}, {"source_code": " 0) {\n\t\tif ($c1 < 0) {\n\t\t\t$sum -= $c1; $k--;\n\t\t} else {\n\t\t\tif ($c1 == 0) {\n\t\t\t\t$k = 0;\n\t\t\t} else {\n\t\t\t\tif ($k % 2 == 0) {\n\t\t\t\t\t$k = 0; $sum += $c1;\n\t\t\t\t} else {\n\t\t\t\t\t$k = 0;\n\t\t\t\t\tif ($i > 0) {\n\t\t\t\t\t\t$c2 = $c[$i - 1];\n\t\t\t\t\t\t$sum = ($c1 > -$c2)?$sum+2*$c2:$sum-$c1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$sum -= $c1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t$sum += $c1;\n\t}\n}\nfwrite($f2, $sum);\nfclose($f2);"}, {"source_code": " 0) {\n\t\tif ($c1 < 0) {\n\t\t\t$sum -= $c1; $k--;\n\t\t} else {\n\t\t\tif ($c1 == 0) {\n\t\t\t\t$k = 0;\n\t\t\t} else {\n\t\t\t\tif ($k % 2 == 0) {\n\t\t\t\t\t$k = 0; $sum += $c1;\n\t\t\t\t} else {\n\t\t\t\t\t$k = 0;\n\t\t\t\t\tif ($i > 0) {\n\t\t\t\t\t\t$c2 = $c[$i - 1];\n\t\t\t\t\t\t$sum = ($c1 > -$c2)?$sum+2*$c2:$sum-$c1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$sum -= $c1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t$sum += $c1;\n\t}\n}\nif ($k % 2 == 1) {\n\t$sum += 2 * ($c[$n-1] + 0);\n}\nfwrite($f2, $sum);\nfclose($f2);"}, {"source_code": " 0) {\n\t\tif ($c1 < 0) {\n\t\t\t$sum -= $c1; $k--;\n\t\t} else {\n\t\t\tif ($c1 == 0) {\n\t\t\t\t$k = 0;\n\t\t\t} else {\n\t\t\t\tif ($k % 2 == 0) {\n\t\t\t\t\t$k = 0; $sum += $c1;\n\t\t\t\t} else {\n\t\t\t\t\t$k = 0;\n\t\t\t\t\tif ($i > 0) {\n\t\t\t\t\t\t$c2 = $c[$i - 1];\n\t\t\t\t\t\t$sum = ($c1 > -$c2)?$sum+2*$c2:$sum-$c1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$sum -= $c1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t$sum += $c1;\n\t}\n}\nif ($k % 2 == 1) {\n\t$sum -= 2 * ($c[$n-1] + 0);\n}\nfwrite($f2, $sum);\nfclose($f2);"}, {"source_code": " 0) {\n\t\tif ($c1 < 0) {\n\t\t\t$sum -= $c1; $k--;\n\t\t} else {\n\t\t\tif ($c1 == 0) {\n\t\t\t\t$k = 0;\n\t\t\t} else {\n\t\t\t\tif ($k % 2 == 0) {\n\t\t\t\t\t$k = 0; $sum += c1;\n\t\t\t\t} else {\n\t\t\t\t\t$k = 0;\n\t\t\t\t\tif ($i > 0) {\n\t\t\t\t\t\t$c2 = $c[$i - 1];\n\t\t\t\t\t\t$sum = ($c1 > -$c2)?$sum+2*$c2:$sum-$c1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$sum -= $c1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t$sum += $c1;\n\t}\n}\nfwrite($f2, $sum);\nfclose($f2);"}], "src_uid": "befd3b1b4afe19ff619c0b34ed1a4966"} {"nl": {"description": "Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n\u2009\u00d7\u2009m. There are n\u2009+\u2009m inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from 1 to n from top to bottom, while columns are numbered with integers from 1 to m from left to right.Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of q turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.", "input_spec": "The first line of the input contains three integers n, m and q (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009q\u2009\u2264\u200910\u2009000)\u00a0\u2014 dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1\u2009\u2264\u2009ti\u2009\u2264\u20093) that defines the type of the operation. For the operation of first and second type integer ri (1\u2009\u2264\u2009ri\u2009\u2264\u2009n) or ci (1\u2009\u2264\u2009ci\u2009\u2264\u2009m) follows, while for the operations of the third type three integers ri, ci and xi (1\u2009\u2264\u2009ri\u2009\u2264\u2009n, 1\u2009\u2264\u2009ci\u2009\u2264\u2009m, \u2009-\u2009109\u2009\u2264\u2009xi\u2009\u2264\u2009109) are given. Operation of the first type (ti\u2009=\u20091) means that signal comes to the input corresponding to row ri, that is it will shift cyclically. Operation of the second type (ti\u2009=\u20092) means that column ci will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row ri and column ci stores value xi.", "output_spec": "Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.", "sample_inputs": ["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"], "sample_outputs": ["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"], "notes": null}, "positive_code": [{"source_code": "= 2; $y--)\n {\n $d[$j[1]][$y] = $d[$j[1]][$y - 1];\n }\n $d[$j[1]][1] = $l;\n }\n elseif($j[0] == 2)\n {\n $l = $d[$a][$j[1]];\n for($y = $a; $y >= 2; $y--)\n {\n $d[$y][$j[1]] = $d[$y - 1][$j[1]];\n }\n $d[1][$j[1]] = $l;\n }\n elseif($j[0] == 3)\n {\n $d[$j[1]][$j[2]] = $j[3];\n }\n}\nfor($x = 1; $x < $a; $x++)\n{\n $m = $d[$x];\n print implode(\" \", $m) . \"\\n\";\n}\n$m = $d[$x];\nprint implode(\" \", $m);\n?>"}], "negative_code": [{"source_code": "= 2; $y--)\n {\n $e[$j[1]][$y] = $e[$j[1]][$y - 1];\n }\n $e[$j[1]][1] = $l;\n }\n elseif($j[0] == 2)\n {\n $l = $e[$a][$j[1]];\n for($y = $a; $y >= 2; $y--)\n {\n $e[$y][$j[1]] = $e[$y - 1][$j[1]];\n }\n $e[1][$j[1]] = $l;\n }\n elseif($j[0] == 3)\n {\n $e[$j[1]][$j[2]] = $j[3];\n }\n}\nfor($x = 1; $x < $a; $x++)\n{\n $m = $e[$x];\n print implode(\" \", $m) . \"\\n\";\n}\n$m = $e[$x];\nprint implode(\" \", $m);\n?>"}], "src_uid": "f710958b96d788a19a1dda436728b9eb"} {"nl": {"description": "Highway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into $$$n$$$ sub-tracks. You are given an array $$$a$$$ where $$$a_i$$$ represents the number of traffic cars in the $$$i$$$-th sub-track. You define the inconvenience of the track as $$$\\sum\\limits_{i=1}^{n} \\sum\\limits_{j=i+1}^{n} \\lvert a_i-a_j\\rvert$$$, where $$$|x|$$$ is the absolute value of $$$x$$$. You can perform the following operation any (possibly zero) number of times: choose a traffic car and move it from its current sub-track to any other sub-track.Find the minimum inconvenience you can achieve.", "input_spec": "The first line of input contains a single integer $$$t$$$ ($$$1\\leq t\\leq 10\\,000$$$) \u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\\leq n\\leq 2\\cdot 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0\\leq a_i\\leq 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot 10^5$$$.", "output_spec": "For each test case, print a single line containing a single integer: the minimum inconvenience you can achieve by applying the given operation any (possibly zero) number of times.", "sample_inputs": ["3\n3\n1 2 3\n4\n0 1 1 0\n10\n8 3 6 11 5 2 1 7 10 4"], "sample_outputs": ["0\n4\n21"], "notes": "NoteFor the first test case, you can move a car from the $$$3$$$-rd sub-track to the $$$1$$$-st sub-track to obtain $$$0$$$ inconvenience.For the second test case, moving any car won't decrease the inconvenience of the track."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "935bceb69117d06eb75121c805bff69c"} {"nl": {"description": "The Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move the player can remove an arbitrary letter from string s. If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string \"abba\" is a palindrome and string \"abc\" isn't. Determine which player will win, provided that both sides play optimally well \u2014 the one who moves first or the one who moves second.", "input_spec": "The input contains a single line, containing string s (1\u2009\u2264\u2009|s|\u2009\u2009\u2264\u2009\u2009103). String s consists of lowercase English letters.", "output_spec": "In a single line print word \"First\" if the first player wins (provided that both players play optimally well). Otherwise, print word \"Second\". Print the words without the quotes.", "sample_inputs": ["aba", "abca"], "sample_outputs": ["First", "Second"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0) + ($sma >= 0)] . PHP_EOL;\r\n}\r\n"}, {"source_code": " $value)\r\n\t{\r\n\t\tif($key % 2 == 0)\r\n\t\t{\r\n\t\t\tif($value % 2 == 0)\r\n\t\t\t\t$A += $value;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif($value % 2 != 0)\r\n\t\t\t\t$B += $value;\r\n\t\t}\r\n\t}\r\n\r\n\tif($A == $B)\r\n\t\t$res = \"Tie\";\r\n\telseif($A > $B)\r\n\t\t$res = \"Alice\";\r\n\telse\r\n\t\t$res = \"Bob\";\r\n\treturn $res;\r\n}\r\n\r\n$t = fgets(STDIN);\r\nfor($i=0;$i<$t;$i++)\r\n{\r\n\t$arr = array();\r\n\t$n = fgets(STDIN);\r\n\t$arr_str = fgets(STDIN);\r\n\t$arr = explode(\" \", trim($arr_str));\r\n\tprint(startPlay($arr).\"\\r\\n\");\r\n}\r\n$end = fgets(STDIN);\r\n?>"}, {"source_code": " $iCountBob) {\r\n echo 'Alice';\r\n } else {\r\n echo 'Bob';\r\n }\r\n}\r\n\r\n$t = trim(fgets(STDIN));\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n?>\r\n"}], "negative_code": [], "src_uid": "b1e911fbc33fb031b2398cdd545f502a"} {"nl": {"description": "There is an infinite 2-dimensional grid. The robot stands in cell $$$(0, 0)$$$ and wants to reach cell $$$(x, y)$$$. Here is a list of possible commands the robot can execute: move north from cell $$$(i, j)$$$ to $$$(i, j + 1)$$$; move east from cell $$$(i, j)$$$ to $$$(i + 1, j)$$$; move south from cell $$$(i, j)$$$ to $$$(i, j - 1)$$$; move west from cell $$$(i, j)$$$ to $$$(i - 1, j)$$$; stay in cell $$$(i, j)$$$. The robot wants to reach cell $$$(x, y)$$$ in as few commands as possible. However, he can't execute the same command two or more times in a row.What is the minimum number of commands required to reach $$$(x, y)$$$ from $$$(0, 0)$$$?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of testcases. Each of the next $$$t$$$ lines contains two integers $$$x$$$ and $$$y$$$ ($$$0 \\le x, y \\le 10^4$$$)\u00a0\u2014 the destination coordinates of the robot.", "output_spec": "For each testcase print a single integer\u00a0\u2014 the minimum number of commands required for the robot to reach $$$(x, y)$$$ from $$$(0, 0)$$$ if no command is allowed to be executed two or more times in a row.", "sample_inputs": ["5\n5 5\n3 4\n7 1\n0 0\n2 0"], "sample_outputs": ["10\n7\n13\n0\n3"], "notes": "NoteThe explanations for the example test:We use characters N, E, S, W and 0 to denote going north, going east, going south, going west and staying in the current cell, respectively.In the first test case, the robot can use the following sequence: NENENENENE.In the second test case, the robot can use the following sequence: NENENEN.In the third test case, the robot can use the following sequence: ESENENE0ENESE.In the fourth test case, the robot doesn't need to go anywhere at all.In the fifth test case, the robot can use the following sequence: E0E."}, "positive_code": [{"source_code": " $num[1] ? $num[0] : $num[1];\n $mn = $num[0] < $num[1] ? $num[0] : $num[1];\n// echo $mx . ' ' . $mn;\n if ($mx == $mn) {\n $res[] = $mx + $mn . \"\\n\";\n } else {\n $res[] = (2*$mn) + (2*($mx-$mn)-1) . \"\\n\";\n }\n}\n\nforeach ($res as $r) {\n echo $r;\n}"}, {"source_code": ""}], "negative_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$f[$x]];\n $e = (strlen($a) + 1) - $d;\n $b[$f[$x]] = $x + 1;\n $c[$f[$x]] = max($c[$f[$x]], $e);\n}\nprint min($c);\n?>"}], "negative_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$g = array();\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n if($d == \"b\")\n {\n $g[count($g)] = $x;\n }\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\nif(min($c) == 3847)\n{\n print_r($g);\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$g = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n if($a[$x] == \"b\")\n {\n $g++;\n }\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\nif(min($c) == 3847)\n{\n print $g;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$g = array();\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n if($a[$x] == \"b\")\n {\n $g[count($g)] = $x;\n }\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\nif(min($c) == 3847)\n{\n print_r($g);\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$g = array();\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n if($d == \"n\")\n {\n $g[count($g)] = $x;\n }\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\nif(min($c) == 3847)\n{\n print_r($g);\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$a[$x]];\n $e = (strlen($a) + 1) - $d;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n if($c[$f[$x]] == 0)\n {\n unset($c[$f[$x]]);\n }\n}\nprint min($c);\nif(min($c) == 3847)\n{\n print_r($c);\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d = $b[$a[$x]];\n $e = ($x + 1) - $d;\n $b[$a[$x]] = $x + 1;\n $c[$a[$x]] = max($c[$a[$x]], $e);\n}\n$f = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\nfor($x = 0; $x < 26; $x++)\n{\n $d = $b[$f[$x]];\n $e = strlen($a) - $d;\n $b[$f[$x]] = $x + 1;\n $c[$f[$x]] = max($c[$f[$x]], $e);\n}\nprint min($c);\n?>"}], "src_uid": "81a558873e39efca5066ef91a9255f11"} {"nl": {"description": "Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: \"Given string s, determine if the memory of the mechanism contains string t that consists of the same number of characters as s and differs from s in exactly one position\".Watto has already compiled the mechanism, all that's left is to write a program for it and check it on the data consisting of n initial lines and m queries. He decided to entrust this job to you.", "input_spec": "The first line contains two non-negative numbers n and m (0\u2009\u2264\u2009n\u2009\u2264\u20093\u00b7105, 0\u2009\u2264\u2009m\u2009\u2264\u20093\u00b7105) \u2014 the number of the initial strings and the number of queries, respectively. Next follow n non-empty strings that are uploaded to the memory of the mechanism. Next follow m non-empty strings that are the queries to the mechanism. The total length of lines in the input doesn't exceed 6\u00b7105. Each line consists only of letters 'a', 'b', 'c'.", "output_spec": "For each query print on a single line \"YES\" (without the quotes), if the memory of the mechanism contains the required string, otherwise print \"NO\" (without the quotes).", "sample_inputs": ["2 3\naaaaa\nacacaca\naabaa\nccacacc\ncaaac"], "sample_outputs": ["YES\nNO\nNO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "\n$n = trim(fgets(STDIN));\n\n$arr = $arr = explode(' ',trim(fgets(STDIN)));\nsort($arr,SORT_NUMERIC);\n\n$sum = 0 ;\n//print_r($arr);\nfor($i=0;$i<$n/2;$i++){\n\t//echo $arr[$i].\" \".$arr[$n-$i-1].\"\\n\";\n\t$sum += ($arr[$i]+$arr[$n-$i-1])*($arr[$i]+$arr[$n-$i-1]);\n}\n\necho $sum;\n"}], "negative_code": [], "src_uid": "28c555fefd5c36697a5082c61d8a82b3"} {"nl": {"description": "It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts k days!When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last n days. So now he has a sequence a1,\u2009a2,\u2009...,\u2009an, where ai is the sleep time on the i-th day.The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider k consecutive days as a week. So there will be n\u2009-\u2009k\u2009+\u20091 weeks to take into consideration. For example, if k\u2009=\u20092, n\u2009=\u20093 and a\u2009=\u2009[3,\u20094,\u20097], then the result is .You should write a program which will calculate average sleep times of Polycarp over all weeks.", "input_spec": "The first line contains two integer numbers n and k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105). The second line contains n integer numbers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009105).", "output_spec": "Output average sleeping time over all weeks. The answer is considered to be correct if its absolute or relative error does not exceed 10\u2009-\u20096. In particular, it is enough to output real number with at least 6 digits after the decimal point.", "sample_inputs": ["3 2\n3 4 7", "1 1\n10", "8 2\n1 2 4 100000 123 456 789 1"], "sample_outputs": ["9.0000000000", "10.0000000000", "28964.2857142857"], "notes": "NoteIn the third example there are n\u2009-\u2009k\u2009+\u20091\u2009=\u20097 weeks, so the answer is sums of all weeks divided by 7."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "838e643a978adbeed791a24ac1046ab5"} {"nl": {"description": "Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.In the beginning, uncle Bogdan wrote on a board a positive integer $$$x$$$ consisting of $$$n$$$ digits. After that, he wiped out $$$x$$$ and wrote integer $$$k$$$ instead, which was the concatenation of binary representations of digits $$$x$$$ consists of (without leading zeroes). For example, let $$$x = 729$$$, then $$$k = 111101001$$$ (since $$$7 = 111$$$, $$$2 = 10$$$, $$$9 = 1001$$$).After some time, uncle Bogdan understood that he doesn't know what to do with $$$k$$$ and asked Denis to help. Denis decided to wipe last $$$n$$$ digits of $$$k$$$ and named the new number as $$$r$$$.As a result, Denis proposed to find such integer $$$x$$$ of length $$$n$$$ that $$$r$$$ (as number) is maximum possible. If there are multiple valid $$$x$$$ then Denis is interested in the minimum one.All crew members, including captain Flint himself, easily solved the task. All, except cabin boy Kostya, who was too drunk to think straight. But what about you?Note: in this task, we compare integers ($$$x$$$ or $$$k$$$) as numbers (despite what representations they are written in), so $$$729 < 1999$$$ or $$$111 < 1000$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. Next $$$t$$$ lines contain test cases\u00a0\u2014 one per test case. The one and only line of each test case contains the single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$)\u00a0\u2014 the length of the integer $$$x$$$ you need to find. It's guaranteed that the sum of $$$n$$$ from all test cases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, print the minimum integer $$$x$$$ of length $$$n$$$ such that obtained by Denis number $$$r$$$ is maximum possible.", "sample_inputs": ["2\n1\n3"], "sample_outputs": ["8\n998"], "notes": "NoteIn the second test case (with $$$n = 3$$$), if uncle Bogdan had $$$x = 998$$$ then $$$k = 100110011000$$$. Denis (by wiping last $$$n = 3$$$ digits) will obtain $$$r = 100110011$$$.It can be proved that the $$$100110011$$$ is the maximum possible $$$r$$$ Denis can obtain and $$$998$$$ is the minimum $$$x$$$ to obtain it."}, "positive_code": [{"source_code": " $min; $i -- ) {\n\n\t\t$x = (string) $i;\n\t\t$k = '';\n\t\tfor ( $j = 0; $j < strlen( $x ); $j ++ ) {\n\t\t\t$k .= decbin( $x[ $j ] );\n\t\t}\n\t\techo \"K= $k\".PHP_EOL;\n\n\t\t$r = substr( $k, 0, $n * - 1 );\n\t\tif ( strlen($r) >= $maximum ) {\n\t\t\t$maximum = strlen($r);\n\t\t\t$answer = $x;\n\t\t}else{\n\t\t\tbreak;\n\t\t}\n\t}\n\t$answers[]= $answer;\n\n\t$time_elapsed_secs = microtime(true) - $start;\n\t#echo 'Execution Time: ' . number_format($time_elapsed_secs,2) .'s'.PHP_EOL;\n\n\t#echo \"x: \" . $answer . PHP_EOL;\n\t#echo \"k (bin): \" . $answer_k . PHP_EOL;\n\t#echo \"r (bin): \" . $answer_bin . PHP_EOL;\n\t#echo \"r (dec): \". $maximum . PHP_EOL;\n}\nforeach ($answers as $a) echo $a.PHP_EOL;"}, {"source_code": "$maximum){\n\t\t$maximum = bindec($r);\n\t\t$answer_bin = $r;\n\t\t$answer_k = $k;\n\t\t$answer_x = $x;\n\t}\n}\necho $answer_x;"}], "src_uid": "80c75a4c163c6b63a614075e094ad489"} {"nl": {"description": "You're given two arrays $$$a[1 \\dots n]$$$ and $$$b[1 \\dots n]$$$, both of the same length $$$n$$$.In order to perform a push operation, you have to choose three integers $$$l, r, k$$$ satisfying $$$1 \\le l \\le r \\le n$$$ and $$$k > 0$$$. Then, you will add $$$k$$$ to elements $$$a_l, a_{l+1}, \\ldots, a_r$$$.For example, if $$$a = [3, 7, 1, 4, 1, 2]$$$ and you choose $$$(l = 3, r = 5, k = 2)$$$, the array $$$a$$$ will become $$$[3, 7, \\underline{3, 6, 3}, 2]$$$.You can do this operation at most once. Can you make array $$$a$$$ equal to array $$$b$$$?(We consider that $$$a = b$$$ if and only if, for every $$$1 \\le i \\le n$$$, $$$a_i = b_i$$$)", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 20$$$) \u2014 the number of test cases in the input. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 100\\ 000$$$) \u2014 the number of elements in each array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 1000$$$). The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \\ldots, b_n$$$ ($$$1 \\le b_i \\le 1000$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case, output one line containing \"YES\" if it's possible to make arrays $$$a$$$ and $$$b$$$ equal by performing at most once the described operation or \"NO\" if it's impossible. You can print each letter in any case (upper or lower).", "sample_inputs": ["4\n6\n3 7 1 4 1 2\n3 7 3 6 3 2\n5\n1 1 1 1 1\n1 2 1 3 1\n2\n42 42\n42 42\n1\n7\n6"], "sample_outputs": ["YES\nNO\nYES\nNO"], "notes": "NoteThe first test case is described in the statement: we can perform a push operation with parameters $$$(l=3, r=5, k=2)$$$ to make $$$a$$$ equal to $$$b$$$.In the second test case, we would need at least two operations to make $$$a$$$ equal to $$$b$$$.In the third test case, arrays $$$a$$$ and $$$b$$$ are already equal.In the fourth test case, it's impossible to make $$$a$$$ equal to $$$b$$$, because the integer $$$k$$$ has to be positive."}, "positive_code": [{"source_code": ""}, {"source_code": "=0;$i--)\n {\n if($arr1[$i]!=$arr2[$i])\n {\n $l=$i;\n }\n }\n $ans=1;\n $count=$arr2[$l]-$arr1[$l];\n if($count>=0)\n for ($i=$l;$i<$r+1;$i++)\n {\n if($arr2[$i]-$arr1[$i]!=$count)\n {\n $ans=0;\n break;\n }\n }\n else\n {\n $ans=0;\n }\n\n if($ans)\n {\n echo \"YES\\n\";\n }else\n {\n echo \"NO\\n\";\n }\n }\n}\n\nsolve();\n?>"}, {"source_code": " 0)\n\t\t\t{\n\t\t\t\t$ok = 0;\n\t\t\t\t$ans .= \"NO\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ($a[$j] - $b[$j] != $diff) {\n\t\t\t\t$ok = 0;\n\t\t\t\t$ans .= \"NO\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tif ($is_diff == 1)\n\t\t\t\t$is_diff = 2;\n\t\t}\n\t}\n\tif ($ok == 1)\n\t\t$ans .= \"YES\\n\";\n}\n\necho $ans;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " 0)\n\t\t\t{\n\t\t\t\t$ok = 0;\n\t\t\t\t$ans .= \"NO\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ($a[$j] - $b[$j] != $diff) {\n\t\t\t\t$ok = 0;\n\t\t\t\t$ans .= \"NO\\n\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tif ($is_diff == 1)\n\t\t\t\t$is_diff = 2;\n\t\t}\n\t}\n\tif ($ok == 1)\n\t\t$ans .= \"YES\\n\";\n}\n\necho $ans;\n?>"}], "src_uid": "0e0ef011ebe7198b7189fce562b7d6c1"} {"nl": {"description": "Let's define the value of the permutation $$$p$$$ of $$$n$$$ integers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array where each element from $$$1$$$ to $$$n$$$ occurs exactly once) as follows: initially, an integer variable $$$x$$$ is equal to $$$0$$$; if $$$x < p_1$$$, then add $$$p_1$$$ to $$$x$$$ (set $$$x = x + p_1$$$), otherwise assign $$$0$$$ to $$$x$$$; if $$$x < p_2$$$, then add $$$p_2$$$ to $$$x$$$ (set $$$x = x + p_2$$$), otherwise assign $$$0$$$ to $$$x$$$; ... if $$$x < p_n$$$, then add $$$p_n$$$ to $$$x$$$ (set $$$x = x + p_n$$$), otherwise assign $$$0$$$ to $$$x$$$; the value of the permutation is $$$x$$$ at the end of this process. For example, for $$$p = [4, 5, 1, 2, 3, 6]$$$, the value of $$$x$$$ changes as follows: $$$0, 4, 9, 0, 2, 5, 11$$$, so the value of the permutation is $$$11$$$.You are given an integer $$$n$$$. Find a permutation $$$p$$$ of size $$$n$$$ with the maximum possible value among all permutations of size $$$n$$$. If there are several such permutations, you can print any of them.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 97$$$)\u00a0\u2014 the number of test cases. The only line of each test case contains one integer $$$n$$$ ($$$4 \\le n \\le 100$$$).", "output_spec": "For each test case, print $$$n$$$ integers\u00a0\u2014 the permutation $$$p$$$ of size $$$n$$$ with the maximum possible value among all permutations of size $$$n$$$.", "sample_inputs": ["3\n\n4\n\n5\n\n6"], "sample_outputs": ["2 1 3 4\n1 2 3 4 5\n4 5 1 2 3 6"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $b) {\n $fMin = $b;\n }\n}\n$m = trim(fgets(STDIN));\n$sMin = -1;\n$sMax = -1;\nfor($i = 0; $i < $m; $i++) {\n list($a, $b) = explode(' ', trim(fgets(STDIN)));\n if($sMax == -1 || $sMax < $a) {\n $sMax = $a;\n }\n if($sMin == -1 || $sMin > $b) {\n $sMin = $b;\n }\n}\n$r = 0;\nif($fMin < $sMax) {\n $r = max($r, $sMax - $fMin);\n}\nif($sMin < $fMax) {\n $r = max($r, $fMax - $sMin);\n}\necho $r;"}], "negative_code": [{"source_code": " $b) {\n $fMin = $b;\n }\n}\n$m = trim(fgets(STDIN));\n$sMin = -1;\n$sMax = -1;\nfor($i = 0; $i < $m; $i++) {\n list($a, $b) = explode(' ', trim(fgets(STDIN)));\n if($sMax == -1 || $sMax < $a) {\n $sMax = $a;\n }\n if($sMin == -1 || $sMin > $b) {\n $sMin = $b;\n }\n}\n//echo $fMin, $sMax, $sMin, $fMax;\nif($fMin < $sMax) {\n echo $sMax - $fMin;\n}\nelse if($sMin < $fMax) {\n echo $fMax - $sMin;\n}\nelse {\n echo 0;\n}"}], "src_uid": "4849a1f65afe69aad12c010302465ccd"} {"nl": {"description": "On a random day, Neko found $$$n$$$ treasure chests and $$$m$$$ keys. The $$$i$$$-th chest has an integer $$$a_i$$$ written on it and the $$$j$$$-th key has an integer $$$b_j$$$ on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.The $$$j$$$-th key can be used to unlock the $$$i$$$-th chest if and only if the sum of the key number and the chest number is an odd number. Formally, $$$a_i + b_j \\equiv 1 \\pmod{2}$$$. One key can be used to open at most one chest, and one chest can be opened at most once.Find the maximum number of chests Neko can open.", "input_spec": "The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n, m \\leq 10^5$$$)\u00a0\u2014 the number of chests and the number of keys. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the numbers written on the treasure chests. The third line contains $$$m$$$ integers $$$b_1, b_2, \\ldots, b_m$$$ ($$$1 \\leq b_i \\leq 10^9$$$)\u00a0\u2014 the numbers written on the keys.", "output_spec": "Print the maximum number of chests you can open.", "sample_inputs": ["5 4\n9 14 6 2 11\n8 4 7 20", "5 1\n2 4 6 8 10\n5", "1 4\n10\n20 30 40 50"], "sample_outputs": ["3", "1", "0"], "notes": "NoteIn the first example, one possible way to unlock $$$3$$$ chests is as follows: Use first key to unlock the fifth chest, Use third key to unlock the second chest, Use fourth key to unlock the first chest. In the second example, you can use the only key to unlock any single chest (note that one key can't be used twice).In the third example, no key can unlock the given chest."}, "positive_code": [{"source_code": " $sV) {\n if($sV % 2 == 0) {\n $jup++;\n }\n }\n foreach($z as $sK1 => $sV1) {\n if($sV1 % 2 !== 0){\n $tak++;\n }\n }\n $a = $n[0] - $jup;\n $b = $n[1] - $tak;\n if($a == 0 && $tak == 0) { echo '0'; exit;}\n if($b == 0 && $jup == 0) { echo '0'; exit;}\n if($jup > $tak){\n $summ += $tak;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n } else {\n $summ += $jup;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n }\n echo $summ;\n \n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $sV){\n $sV % 2 === 1 ? $iEven++ : $iOdd++;\n}\n\nforeach ($aChests as $sK => $sVal){\n $sVal % 2 === 1 ? $jEven++ : $jOdd++;\n}\n\nif($jOdd >= $iEven){\n $iTotal += $iEven;\n} else {\n $iTotal += $jOdd;\n}\n\nif($jEven >= $iOdd){\n $iTotal += $iOdd;\n} else {\n $iTotal += $jEven;\n}\necho $iTotal;\n\n\n\n"}, {"source_code": " $sV) {\n if($sV % 2 == 0) {\n $jup++;\n }\n }\n foreach($z as $sK1 => $sV1) {\n if($sV1 % 2 !== 0){\n $tak++;\n }\n }\n $a = $n[0] - $jup;\n $b = $n[1] - $tak;\n if($ja == 0 || $tak == 0) { echo '0'; exit;}\n if($jb == 0 || $jup == 0) { echo '0'; exit;}\n if($jup > $tak){\n $summ += $tak;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n } else {\n $summ += $jup;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n }\n echo $summ;\n \n?>"}, {"source_code": " $sV) {\n if($sV % 2 == 0){\n $jup++;\n }\n }\n foreach($z as $sK1 => $sV1) {\n if($sV1 % 2 !== 0){\n $tak++;\n }\n }\n $a = $n[0] - $jup;\n $b = $n[1] - $tak;\n if($jup == 0 || $tak == 0) { echo '0'; exit;}\n if($jup > $tak){\n $summ += $tak;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n } else {\n $summ += $jup;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n }\n echo $summ;\n \n?>"}, {"source_code": " $sV) {\n if($sV % 2 == 0) {\n $jup++;\n }\n }\n foreach($z as $sK1 => $sV1) {\n if($sV1 % 2 !== 0){\n $tak++;\n }\n }\n $a = $n[0] - $jup;\n $b = $n[1] - $tak;\n if($a == 0 || $tak == 0) { echo '0'; exit;}\n if($b == 0 || $jup == 0) { echo '0'; exit;}\n if($jup > $tak){\n $summ += $tak;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n } else {\n $summ += $jup;\n if($a > $b) {\n $summ += $b;\n } else {\n $summ += $a;\n }\n }\n echo $summ;\n \n?>"}], "src_uid": "bc532d5c9845940b5f59485394187bf6"} {"nl": {"description": "We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that $$$a$$$ yuan for $$$b$$$ kilos (You don't need to care about what \"yuan\" is), the same as $$$a/b$$$ yuan for a kilo.Now imagine you'd like to buy $$$m$$$ kilos of apples. You've asked $$$n$$$ supermarkets and got the prices. Find the minimum cost for those apples.You can assume that there are enough apples in all supermarkets.", "input_spec": "The first line contains two positive integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\leq 5\\,000$$$, $$$1 \\leq m \\leq 100$$$), denoting that there are $$$n$$$ supermarkets and you want to buy $$$m$$$ kilos of apples. The following $$$n$$$ lines describe the information of the supermarkets. Each line contains two positive integers $$$a, b$$$ ($$$1 \\leq a, b \\leq 100$$$), denoting that in this supermarket, you are supposed to pay $$$a$$$ yuan for $$$b$$$ kilos of apples.", "output_spec": "The only line, denoting the minimum cost for $$$m$$$ kilos of apples. Please make sure that the absolute or relative error between your answer and the correct answer won't exceed $$$10^{-6}$$$. Formally, let your answer be $$$x$$$, and the jury's answer be $$$y$$$. Your answer is considered correct if $$$\\frac{|x - y|}{\\max{(1, |y|)}} \\le 10^{-6}$$$.", "sample_inputs": ["3 5\n1 2\n3 4\n1 3", "2 1\n99 100\n98 99"], "sample_outputs": ["1.66666667", "0.98989899"], "notes": "NoteIn the first sample, you are supposed to buy $$$5$$$ kilos of apples in supermarket $$$3$$$. The cost is $$$5/3$$$ yuan.In the second sample, you are supposed to buy $$$1$$$ kilo of apples in supermarket $$$2$$$. The cost is $$$98/99$$$ yuan."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "=ceil($n/2);$i-=1){\n $temp=$arr[$j][$i];\n $arr[$j][$i]=$arr[$j][$i-1];\n $arr[$j][$i-1]=$temp;\n}\n}\necho implode (' ',$arr[$j]).PHP_EOL;\n}"}, {"source_code": " 0; $i--) {\n $res.= $i.' ';\n }\n } else {\n for ($i = $n; $i > ceil($n/2); $i--) {\n $res.=$i.' ';\n }\n\n for ($i = 1; $i < ceil($n/2); $i++) {\n $res.=$i.' ';\n }\n $res.= ceil($n/2);\n }\n\n echo trim($res).\"\\n\";\n}"}, {"source_code": "=2)\n\t\t\t echo \"$i \";\n\t\t\t\n\t\t}\n\t\techo \"1\".\"\\n\";\n}"}, {"source_code": "=1 ; $i--)\n\t\t { \n\t\t \tif($i==1)\n\t\t\techo \"$i\".\"\\n\";\n\t\t else\n\t\t \techo \"$i \";\n\t\t }\n\t}\n}"}, {"source_code": "= 1; $i--) {\n\t\t\tif ($n % 2 != 0 && $i == intdiv($n, 2) + 1)\n\t\t\t\tcontinue;\t\n\t\t\t$ans .= $i.\" \";\n\t\t\n\t\t}\n\t\tif ($n % 2 != 0)\n\t\t\t$ans .= intdiv($n, 2) + 1;\n\t\tprint trim($ans).\"\\n\";\n\t}\n?>"}, {"source_code": "= 1; $j--) {\n if ($isOdd && $j === 1) {\n echo \"$middle \";\n } elseif ($isOdd && $j === $middle) {\n echo \"1 \";\n } else {\n echo \"$j \";\n }\n }\n echo \"\\n\";\n}\n"}], "negative_code": [{"source_code": "=ceil($n[$j]/2);$i-=1){\n $temp[$j]=$arr[$j][$i];\n $arr[$j][$i]=$arr[$j][$i-1];\n $arr[$j][$i-1]=$temp[$j];\n}\n}\necho implode (' ',$arr[$j]).PHP_EOL;\n}"}, {"source_code": "=ceil($n/2);$i-=1){\n $temp=$arr[$i];\n $arr[$i]=$arr[$i-1];\n $arr[$i-1]=$temp;\n}\n}\necho implode (' ',$arr).PHP_EOL;\n}"}, {"source_code": "2){\nfor($i=ceil($n/2);$i<$n-1;$i++){\n $temp=$arr[$i];\n $arr[$i]=$arr[$i+1];\n $arr[$i+1]=$temp;\n}\n}\necho implode (' ',$arr).PHP_EOL;\n}"}, {"source_code": "=ceil($n/2);$i-=1){\n $temp=$arr[$i];\n $arr[$i]=$arr[$i-1];\n $arr[$i-1]=$temp;\n}\n}\necho implode (' ',$arr).PHP_EOL;\n}"}, {"source_code": " 0; $i--) {\n $res.=$i.' ';\n }\n echo trim($res).\"\\n\";\n}"}, {"source_code": " 0; $i--) {\n $res.= $i.' ';\n }\n } else {\n for ($i = $n; $i > ceil($n/2); $i--) {\n $res.=$i.' ';\n }\n\n for ($i = 1; $i < ceil($n/2); $i++) {\n $res.=$i.' ';\n }\n $res.= ceil($n/2);\n }\n\n echo trim($res);\n}"}, {"source_code": "=1 ; $i--)\n\t { \n\t \tif($i==1)\n\t\techo \"$i\".\"\\n\";\n\t else\n\t \techo \"$i \";\n\t }\n}"}, {"source_code": "=1 ; $i--)\n\t\t { \n\t\t \tif($i==1)\n\t\t\techo \"$i\".\"\\n\";\n\t\t else\n\t\t \techo \"$i \";\n\t\t }\n\t}\n}"}, {"source_code": ""}, {"source_code": "= 1; $j--) {\n if ($isOdd && $j === $n) {\n echo \"$middle \";\n } elseif ($isOdd && $j === $middle) {\n echo \"1 \";\n } else {\n echo \"$j \";\n }\n }\n echo \"\\n\";\n}\n"}], "src_uid": "f4779e16e0857e6507fdde55e6d4f982"} {"nl": {"description": "One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's value with the value of some other j-th cell, if |i\u2009-\u2009j|\u2009=\u2009di, where di is a favourite number of i-th cell. Cells make moves in any order, the number of moves is unlimited.The favourite number of each cell will be given to you. You will also be given a permutation of numbers from 1 to n. You are to determine whether the game could move to this state.", "input_spec": "The first line contains positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of cells in the array. The second line contains n distinct integers from 1 to n \u2014 permutation. The last line contains n integers from 1 to n \u2014 favourite numbers of the cells.", "output_spec": "If the given state is reachable in the described game, output YES, otherwise NO.", "sample_inputs": ["5\n5 4 3 2 1\n1 1 1 1 1", "7\n4 3 5 1 2 7 6\n4 6 6 1 6 6 1", "7\n4 2 5 1 3 7 6\n4 6 6 1 6 6 1"], "sample_outputs": ["YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": "= 1) && ($f <= $a))\n {\n $h = $d[$f];\n $i = $d[$x];\n array_push($h, $x);\n array_push($i, $f);\n $d[$f] = $h;\n $d[$x] = $i; \n \n }\n if(($g >= 1) && ($g <= $a))\n {\n $j = $d[$g];\n $k = $d[$x];\n array_push($j, $x);\n array_push($k, $g);\n $d[$g] = $j;\n $d[$x] = $k;\n }\n}\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 1; $y <= $a; $y++)\n {\n if($x != $y)\n {\n $l = $d[$x];\n $m = $d[$y];\n $n = array_intersect($l, $m);\n if(count($n) != 0)\n {\n $l = array_merge($l, $m);\n $l = array_unique($l);\n sort($l);\n $d[$x] = $l;\n unset($d[$y]);\n $x = 1;\n }\n }\n }\n}\nsort($d);\n$o = array();\nfor($x = 0; $x < count($d); $x++)\n{\n $p = array();\n $q = $d[$x];\n for($y = 0; $y < count($q); $y++)\n {\n array_push($p, $b[$q[$y]]);\n }\n sort($p);\n $o[$x] = $p;\n}\n$r = 0;\nfor($x = 0; $x < count($d); $x++)\n{\n $s = $d[$x];\n $t = $o[$x];\n if($s != $t)\n {\n $r = 1;\n break;\n }\n}\nif($r == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "negative_code": [{"source_code": "= 1) && ($f <= $a))\n {\n $h = $d[$f];\n $i = $d[$x];\n array_push($h, $x);\n array_push($i, $f);\n $d[$f] = $h;\n $d[$x] = $i; \n \n }\n if(($g >= 1) && ($g <= $a))\n {\n $j = $d[$g];\n $k = $d[$x];\n array_push($j, $x);\n array_push($k, $g);\n $d[$g] = $j;\n $d[$x] = $k;\n }\n}\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 1; $y <= $a; $y++)\n {\n if($x != $y)\n {\n $l = $d[$x];\n $m = $d[$y];\n $n = array_intersect($l, $m);\n if(count($n) != 0)\n {\n $l = array_merge($l, $m);\n $l = array_unique($l);\n sort($l);\n $d[$x] = $l;\n unset($d[$y]);\n }\n }\n }\n}\nsort($d);\n$o = array();\nfor($x = 0; $x < count($d); $x++)\n{\n $p = array();\n $q = $d[$x];\n for($y = 0; $y < count($q); $y++)\n {\n array_push($p, $b[$q[$y]]);\n }\n sort($p);\n $o[$x] = $p;\n}\n$r = 0;\nfor($x = 0; $x < count($d); $x++)\n{\n $s = $d[$x];\n $t = $o[$x];\n if($s != $t)\n {\n $r = 1;\n break;\n }\n}\nif($r == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "src_uid": "c4b7265ff4332225c0d5617c3233a910"} {"nl": {"description": "The winner of the card game popular in Berland \"Berlogging\" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a player gains or loses a particular number of points. In the course of the game the number of points is registered in the line \"name score\", where name is a player's name, and score is the number of points gained in this round, which is an integer number. If score is negative, this means that the player has lost in the round. So, if two or more players have the maximum number of points (say, it equals to m) at the end of the game, than wins the one of them who scored at least m points first. Initially each player has 0 points. It's guaranteed that at the end of the game at least one player has a positive number of points.", "input_spec": "The first line contains an integer number n (1\u2009\u2009\u2264\u2009\u2009n\u2009\u2009\u2264\u2009\u20091000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in \"name score\" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer number between -1000 and 1000, inclusive.", "output_spec": "Print the name of the winner.", "sample_inputs": ["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"], "sample_outputs": ["andrew", "andrew"], "notes": null}, "positive_code": [{"source_code": " $score){\n if($score > $max) $max = $score;\n }\n\n foreach($stack as $name => $score){\n if($score == $max) $maxItems[$name] = 1;\n }\n\n $stack = array();\n\n foreach($inputs as $input){\n\n $name = $input[0];\n $score = $input[1];\n\n if (!isset($stack[$name])) $stack[$name] = $score;\n else $stack[$name] += $score;\n\n if(isset($maxItems[$name]) && $stack[$name] >= $max){\n echo $name;\n exit();\n }\n }\n\n}\n\n"}, {"source_code": " $best) $best = $val;\n$second = array();\nforeach (range(1, $n) as $i) {\n $second[$name[$i]] += $gain[$i];\n if ($score[$name[$i]] == $best && $second[$name[$i]] >= $best) break;\n}\n\necho $name[$i];"}, {"source_code": " $name,\n 'score' => intval($score),\n ];\n $plays[] = $play;\n if (isset($scores[$play['name']])) {\n $scores[$play['name']] += $play['score'];\n } else {\n $scores[$play['name']] = $play['score'];\n }\n}\n\n$best = 0;\nforeach ($scores as $score) {\n if ($score > $best) $best = $score;\n}\n\n$second = [];\nforeach ($plays as $play) {\n $name = $play['name'];\n $score = $play['score'];\n if(isset($second[$name])) {\n $second[$name] += $score;\n } else {\n $second[$name] = $score;\n }\n if ($scores[$name] == $best && $second[$name] >= $best) {\n echo $name;\n break;\n }\n}\n\n"}, {"source_code": " 0,\n\t\t\t'history' => array(),\n\t\t);\n\t}\n\t$scores[$name]['score'] += intval($score);\n\t$scores[$name]['history'][] = array('round' => $i, 'score' => $scores[$name]['score']);\n}\n\nuasort($scores, function($a, $b){\n\tif($a['score'] > $b['score']){\n\t\treturn -1;\n\t} elseif($a['score'] == $b['score']){\n\t\t$ai = $bi = 0;\n\t\tforeach($a['history'] as $s){\n\t\t\tif($s['score'] >= $a['score']){\n\t\t\t\t$ai = $s['round'];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tforeach($b['history'] as $s){\n\t\t\tif($s['score'] >= $b['score']){\n\t\t\t\t$bi = $s['round'];\n\t\t\t\tbreak;\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn ($ai < $bi) ? -1 : 1;\n\t} else {\n\t\treturn 1;\n\t}\n});\n\n$names = array_keys($scores);\necho reset($names);"}, {"source_code": " $name, 'score' => $num);\n if (!isset($end_scores[$name])) {\n $end_scores[$name] = 0;\n }\n $end_scores[$name] += $num;\n }\n\n $end_max_score = max($end_scores);\n\n foreach($end_scores as $player => $score) {\n if ($score == $end_max_score)\n $list_winners[] = $player;\n }\n\n $sum = array();\n foreach ($res as $data) {\n if (!isset($sum[$data['name']])) {\n $sum[$data['name']] = 0;\n }\n $sum[$data['name']] += $data['score'];\n if ($sum[$data['name']] >= $end_max_score && in_array($data['name'], $list_winners)) {\n echo $data['name'];\n exit();\n }\n }\n?>"}, {"source_code": "$v)\n {\n $p=$v;\n break;\n }\n \n $tie = array();\n $i=0;\n foreach($a as $key=>$value)\n {\n if($value==$p)\n {\n $tie[$i++]=$key;\n }\n }\n \n $a = array();\n // var_dump($tie);\n for($i=1;$i=$p&&nameExists($ee[0],$tie))\n {\n echo($ee[0]);\n exit;\n }\n }\n \n \n ?>"}, {"source_code": " [],\n];\n$maxPerson = null;\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 1; $i <= $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n $t[$i] = $t[$i - 1];\n\n if (isset($t[$i][$person])) {\n $t[$i][$person] += $points;\n } else {\n $t[$i][$person] = $points;\n }\n}\n\n$end = end($t);\n$finalsMax = max($end);\n$leaders = array_keys($end, $finalsMax);\n\n//dd($t, $end, $finalsMax, $leaders);\n\nforeach ($t as $k => $v) {\n foreach ($v as $person => $points) {\n if ($points >= $finalsMax && in_array($person, $leaders)) {\n $maxPerson = $person;\n break;\n }\n }\n\n if ($maxPerson) {\n break;\n }\n}\n\n//dd($t, $end, $finalsMax);\n\nfwrite($output, $maxPerson);"}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$players[] = $player;\nif (isset($total[$player[0]])){\n$total[$player[0]] += $player[1];\n} else {\n$total[$player[0]] = $player[1];\n}\n}\n}\n$higher_score = null;\n$same_player = array();\n$winner = \"\";\nforeach($total as $key =>$value) {\nif ($higher_score === null) {\n$higher_score = $value;\n}\nif ($value > $higher_score) {\n$higher_score = $value;\n$winner = $key;\n$same_player = array();\n} else if ($value == $higher_score) {\n$same_player[] = $winner;\n$same_player[] = $key;\n}\n}\nif (!empty($same_player)){\nforeach($same_player as $key =>$value) {\n$same_player_score[$value] = 0;\n}\nforeach($players as $key =>$value) {\nif (in_array($value[0], $same_player)) {\n$same_player_score[$value[0]]+= $value[1];\nif ($same_player_score[$value[0]] >= $higher_score) {\n$winner = $value[0];\nbreak;\n}\n}\n}\n}\necho $winner;\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $winnerCandidates = $max = array();\n\n\n foreach($resultNames as $k=>$name){\n\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n $max[$name] += $addScore;\n\n if($max[$name] >= $maxScore) {\n $winnerCandidates[$name] = 0;\n }\n }\n\n //var_dump($winnerCandidates, $max, $maxScore);\n\n foreach($winnerCandidates as $name=>$result) {\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n\n"}, {"source_code": " $v) {\n if ($v['score'] > $max) {\n $max = $v['score'];\n $name = $k;\n } else if ($v['score'] == $max) {\n $sum1 = $sum2 = 0;\n $key1 = $key2 = 0;\n foreach ($list as $keys => $val) {\n if ($val[0] == $name) {\n $sum1 += $val[1];\n }\n if ($sum1 >= $max) {\n if (!$key1) {\n $key1 = $keys+1;\n }\n }\n\n if ($val[0] == $k) {\n $sum2 += $val[1];\n }\n\n if ($sum2 >= $max) {\n if (!$key2) {\n $key2 = $keys+1;\n }\n }\n if ($key1 && $key2) break;\n }\n if ($key1 > $key2) {\n $name = $k;\n }\n }\n }\n echo $name;\n}\n\nwhile ($row = fscanf(STDIN,\"%s %i\")) {\n $data[] = $row;\n}\n\n$line = array_shift($data);\n\n$max = 0;\n$name = '';\n$list = [];\nfor ($i=0;$i<$line[0];$i++) {\n $list[$data[$i][0]]['score'] += $data[$i][1];\n}\n\n\n_max($list,$data);"}, {"source_code": "$value)\n{\n\tif($value > $max){\n\t\t$winner_list = array($key);\n\t\t$max = $value;\n\t}else if($value == $max){\n\t\t$winner_list[] = $key;\n\t}\n}\n\n$min = $n;\n\nforeach($winner_list as $name){\n\tfor($i=0; $i = $max){\n\t\t\tif($player_hs[$name][$i][1] < $min){\n\t\t\t\t$min = $player_hs[$name][$i][1];\n\t\t\t\t$winner = $name;\n\t\t\t}\n\t\t}\n\t}\n}\n\necho $winner.\"\\n\";\n?>\n"}, {"source_code": " $maxScore)\n $maxScore = $score;\n$tmpScores = array();\nfor ($i = 0; $i < $n; $i++) {\n $tmpScores[$historyNames[$i]] += intval($historyScores[$i]);\n if ($scores[$historyNames[$i]] == $maxScore && $tmpScores[$historyNames[$i]] >= $maxScore)\n break;\n}\nprintf(\"%s\", $historyNames[$i]);\n?>"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] >= $max AND $new[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] >= $max AND $new[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n \n}"}, {"source_code": " 0);\n }\n\n $max[$name][0] += $point;\n $max[$name][$j] = $max[$name][0];\n}\n\n$max_names = array();\n$m = -999999999;\n\n$min_user = '';\n$min_step = 1000;\n\nforeach ($max as $name => $points) {\n if ($m < $points[0]) $m = $points[0];\n}\n\nforeach ($max as $name => $points) {\n if ($m == $points[0]) {\n $max_names[$name] = $points;\n }\n}\n\nforeach ($max_names as $name => $points) {\n $j = 1;\n\n while ($points[$j] < $m) {\n $j++;\n if ($j > 1000) break;\n }\n\n if ($min_step > $j) {\n $min_step = $j;\n $min_user = $name;\n }\n\n}\n\nprint $min_user;\n"}, {"source_code": "= $m && in_array($name, $winnerNames)) {\n echo $name;\n exit;\n }\n}\n"}, {"source_code": " $pi){\n $fi = explode(' ', $pi);\n $sorted[$fi[0]] += (int)trim($fi[1]);\n }\n $max = max($sorted); \n foreach($ps as $key => $pi){\n $fi = explode(' ', $pi);\n $scores[$fi[0]] += (int)trim($fi[1]);\n if($scores[$fi[0]] >= $max && $sorted[$fi[0]] == $max){\n echo $fi[0];\n return;\n }\n }"}, {"source_code": "\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nforeach (range(1, $n) as $i) {\n $dat = explode(' ', fgets(STDIN));\n $name[$i] = $dat[0];\n $gain[$i] = intval($dat[1]);\n $score[$name[$i]] += $gain[$i];\n}\nforeach ($score as $val)\n if ($val > $best) $best = $val;\n$second = array();\nforeach (range(1, $n) as $i) {\n $second[$name[$i]] += $gain[$i];\n if ($score[$name[$i]] == $best && $second[$name[$i]] >= $best) break;\n}\n\nprint $name[$i].chr(10);\n?>"}, {"source_code": "name = $array[0];\n $line[$i]->point = $array[1];\n\n if(isset($names[$array[0]]))\n {\n $names[$array[0]] = $names[$array[0]] + $array[1];\n }\n else\n {\n $names += array($array[0] => $array[1]);\n }\n}\n\n\n$max=0;\nforeach ($names as $key => $val) \n{\n if($max < $val)\n $max = $val;\n}\nunset($val);\n\n$str;\n$pnt;\nforeach ($line as &$val) \n{\n $str = $val->name;\n $pnt = $val->point;\n\n if(isset($winner[$str]))\n {\n $winner[$str] = $winner[$str] + $pnt;\n }\n else\n {\n $winner += array($str => $pnt);\n }\n\n if($winner[$str] >= $max && $names[$str] == $max)\n {\n echo $str;\n break;\n }\n\n}\nunset($val);\n\n"}, {"source_code": "name = $array[0];\n $list[$i]->point = $array[1];\n\n if(isset($names[$array[0]]))\n $names[$array[0]] = $names[$array[0]] + $array[1];\n else\n $names += array($array[0] => $array[1]);\n}\n\n$max=0;\nforeach ($names as $key => $val) \n{\n if($max < $val)\n $max = $val;\n}\nunset($val);\n\n$winner = array();\nforeach ($list as &$val) \n{\n $str = $val->name;\n $pnt = $val->point;\n\n if(isset($winner[$str]))\n $winner[$str] = $winner[$str] + $pnt;\n else\n $winner += array($str => $pnt);\n\n if($winner[$str] >= $max && $names[$str] == $max)\n {\n echo $str;\n break;\n }\n\n}\nunset($val);\nfclose($fr);\n?>\n"}, {"source_code": "name = $array[0];\n $list[$i]->point = $array[1];\n\n if(isset($names[$array[0]]))\n $names[$array[0]] = $names[$array[0]] + $array[1];\n else\n $names += array($array[0] => $array[1]);\n}\n\n\n$max=0;\nforeach ($names as $key => $val) \n{\n if($max < $val)\n $max = $val;\n}\nunset($val);\n\n$winner = array();\nforeach ($list as &$val) \n{\n $str = $val->name;\n $pnt = $val->point;\n\n if(isset($winner[$str]))\n $winner[$str] = $winner[$str] + $pnt;\n else\n $winner += array($str => $pnt);\n\n if($winner[$str] >= $max && $names[$str] == $max)\n {\n echo $str;\n break;\n }\n\n}\nunset($val);\n\n"}, {"source_code": " $name) {\n $score = $points[$i];\n $currentScores[$name] += $score;\n if ($currentScores[$name] >= $max && $scores[$name] == $max) {\n exit($name);\n }\n }"}, {"source_code": " $max) $max = $v;\n}\n\n$w = array();\nforeach($g as $k => $v){\n if($v == $max) $w[$k] = $v;\n}\n\nif(count($w) == 1){\n print array_search($max, $w);\n exit(0);\n}\n\n$g = array();\nforeach($s as $v){\n list($player, $score) = explode(' ',$v);\n if(!array_key_exists($player,$w)) continue;\n $g[$player] += $score;\n if($g[$player] >= $max){\n print $player;\n exit(0);\n }\n}\n\n\n?>"}, {"source_code": " $max)\n $max = end($score);\n foreach($scores as $name=>$score)\n if(end($score) == $max)\n foreach($score as $time=>$value)\n if($value >= $max && $time <= $n){ \n $n = $time;\n $win = $name;\n }\n echo $win;\n?>"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nforeach (range(1, $n) as $i) {\n $dat = explode(' ', fgets(STDIN));\n $name[$i] = $dat[0];\n $gain[$i] = intval($dat[1]);\n $score[$name[$i]] += $gain[$i];\n}\nforeach ($score as $val)\n if ($val > $best) $best = $val;\n$second = array();\nforeach (range(1, $n) as $i) {\n $second[$name[$i]] += $gain[$i];\n if ($score[$name[$i]] == $best && $second[$name[$i]] >= $best) break;\n}\n\nprint $name[$i].chr(10);\n?>"}, {"source_code": " $p_results) {\n\t\t\t$player_score = 0;\n\n\t\t\tforeach($p_results as $round_number => $round_result) {\n\t\t\t\t$player_score += $round_result;\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t$players[$p_name][$number_of_rounds + 1] = $player_score;\n\t\t\tif ($player_score > $highest_result) {\n\t\t\t\t$highest_result = $player_score;\n\t\t\t}\n\t\t}\n\t}\n\n\t$current_round++;\n}\n\nfunction findOverallWinner($winners_array, $winning_score) \n{\n\t$temp_winners = array();\n\tglobal $number_of_rounds;\t\n\t$winning_round = $number_of_rounds + 1;\n\n\tforeach($winners_array as $w_name => $w_score) {\n\t\tif ($w_score[$number_of_rounds + 1] == $winning_score) {\n\t\t\t$temp_score = 0;\n\n\t\t\tforeach($w_score as $t_round => $t_score) {\n\t\t\t\tif ($t_round >= $winning_round) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t$temp_score += $t_score;\n\n\t\t\t\tif($temp_score >= $winning_score) {\n\t\t\t\t\t$winning_round = $t_round;\n\t\t\t\t\t$winner_name = $w_name;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $winner_name;\n}\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\t\tsaveResult($matches[1], $matches[2]);\t\n\t}\n}\nfprintf($fw, findOverallWinner($players, $highest_result));\n"}, {"source_code": "= $max && $scores[$name] == $max) {\n $winner = $name;\n break;\n }\n}\n\necho $winner;\n?>"}, {"source_code": " $j[$l[1]])\n {\n print $i[$k[$l[0]]];\n }\n else\n {\n for($x = 0; $x < count($j); $x++)\n {\n if($j[$x] == $j[$l[0]])\n {\n array_push($p, $i[$k[$x]]);\n }\n }\n for($x = 0; $x < count($f); $x++)\n {\n if(($f[$x] >= $j[$l[0]]) && ($s == 0))\n {\n for($y = 0; $y < count($p); $y++)\n {\n if($p[$y] == $r[$x])\n {\n print $p[$y];\n $s = 1;\n break;\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $value) {\n \tif($data[$name]['score'] > $maxScore) {\n \t\t$maxScore = $data[$name]['score'];\n \t\t$winName = $name;\n \t\t$testCheck = 0;\n \t\tforeach ($data[$name]['log'] as $check => $s) {\n \t\t\t$testCheck += $s;\n \t\t\tif($testCheck >= $maxScore) {\n \t\t\t\t$maxCheck = $check;\n \t\t\t\tbreak;\n \t\t\t}\n \t\t}\n \t}\n \telseif($data[$name]['score'] == $maxScore) {\n \t\t$testCheck = 0;\n \t\tforeach ($data[$name]['log'] as $check => $s) {\n \t\t\t$testCheck += $s;\n \t\t\tif($testCheck >= $maxScore) {\n \t\t\t\tif($check < $maxCheck) {\n \t\t\t\t\t$maxCheck = $check;\n \t\t\t\t\t$winName = $name;\n \t\t\t\t}\n \t\t\t\tbreak;\n \t\t\t}\n \t\t}\n \t}\n }\n\n printf(\"%s\", $winName);\n?>"}, {"source_code": " $scor) {\n if ($scor > $maxScore) {$maxScore = $scor;}\n}\n\n$winners = array();\n\nforeach ($scoremap as $nume => $scor) {\n if ($scor >= $maxScore) {array_push($winners, $nume);}\n}\n\n// foreach ($scoremap as $nume => $scor) {\n// echo $nume . \":\" . $scor . \"
\";\n// }\n\nunset($scoremap);\n$scoremap = array();\n\n$newMaxScore = 0;\n$newWinner = \"\";\nfor ($i = 0; $i < $n; ++$i) {\n if (!isset($scoremap[$comitsname[$i]])) {\n $scoremap[$comitsname[$i]] = 0;\n }\n $scoremap[$comitsname[$i]] += $comitsvalue[$i];\n // if ($scoremap[$comitsname[$i]] > $newMaxScore) {\n // $newMaxScore = $scoremap[$comitsname[$i]];\n // $newWinner = $comitsname[$i];\n // }\n if ($scoremap[$comitsname[$i]] >= $maxScore) {\n if (array_search($comitsname[$i], $winners) !== false) {\n //echo \"zz\";\n $winner = $comitsname[$i];\n //echo $winner;\n break;\n }\n }\n}\n\nfprintf($fileOut, $winner . \"\\n\");\n\nfclose($fileIN);\nfclose($fileOut);\n\n?>"}], "negative_code": [{"source_code": " $max) {\n $max = $newMax;\n $maxPerson = $person;\n }\n}\n\n$a = $b = [];\n$max = -10000000000;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $b, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $b[max($a)][0]);\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n if($resultScore[$k] <0) {\n continue;\n }\n $max[$name] += $resultScore[$k];\n }\n\n $maxScore = max($max);\n $max = array();\n\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $v) {\n if ($v[0] > $max) {\n $max = $v[0];\n $name = $k;\n $key = $v[1];\n } else if ($v == $max) {\n if ($key > $v[1]) {\n $name = $k;\n $key = $v[1];\n }\n }\n }\n return $name;\n}\n\n$in = fopen(STDIN,'r');\nwhile ($row = fscanf($in,\"%s %i\")) {\n $data[] = $row;\n}\n\n$line = array_shift($data);\n\n$max = 0;\n$name = '';\n$list = [];\nfor ($i=0;$i<$line[0];$i++) {\n if (!$list[$data[$i][0]]) {\n $list[$data[$i][0]] = [\n $data[$i][1],$i\n ];\n } else {\n $list[$data[$i][0]][0] += $data[$i][1];\n $list[$data[$i][0]][1] = $i;\n }\n}\n\necho _max($list);"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n if(isset($bad[$name]) && $resultScore[$k] <0) {\n $bad[$name] = 1;\n continue;\n }\n $max[$name] += $resultScore[$k];\n }\n\n $maxScore = max($max);\n $max = array();\n\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $max) {\n $max = $newMax;\n $maxPerson = $person;\n }\n}\n\n$a = [];\n$max = 0;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $maxPerson);\n"}, {"source_code": "$value)\n{\n\tif($value > $max){\n\t\t$winner_list = array($key);\n\t\t$max = $value;\n\t}else if($value == $max){\n\t\t$winner_list[] = $key;\n\t}\n}\n\n$min = $n;\nforeach($winner_list as $name){\n\tfor($i=0; $i\n"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": "$value)\n{\n\tif(($value > $max) || (($value == $max) && $player_hs[$key]<$winner_t) ){\n\t\t$max = $value;\n\t\t$winner = $key;\n\t\t$winner_t = $player_hs[$key];\n\t}\n}\n\necho $winner.\"\\n\";\n?>\n"}, {"source_code": " $scor) {\n if ($scor > $maxScore) {$maxScore = $scor;}\n}\n\n$winners = array();\n\nforeach ($scoremap as $nume => $scor) {\n if ($scor == $maxScore) {array_push($winners, $nume);}\n}\n\nunset($scoremap);\n$scoremap = array();\n\nfor ($i = 0; $i < $n; ++$i) {\n if (!isset($scoremap[$comitsname[$i]])) {\n $scoremap[$comitsname[$i]] = 0;\n }\n $scoremap[$comitsname[$i]] += $comitsvalue[$i];\n if ($scoremap[$comitsname[$i]] == $maxScore) {\n if (array_search($comitsname[$i], $winners) == true) {\n //echo \"zz\";\n $winner = $comitsname[$i];\n break;\n }\n }\n}\n\nfprintf($fileOut, $winner . \"\\n\");\n\nfclose($fileIN);\nfclose($fileOut);\n\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n /*if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }*/\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n\n $addScore = $resultScore[$k];\n if($addScore>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": "$value)\n {\n if($value>$point)\n {\n $winner=$key;\n $point = $value;\n }\n \n // echo($winner.\"\\n\");\n }\n \n \n }\n \n echo($winner);\n ?>"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1]);\n}\n$best = $dat[0];\nforeach ($score as $name => $val) {\n if ($val > $score[$best] || ($val == $score[$best] && $name < $best))\n $best = $name;\n}\nprint $best.chr(10);\n?>"}, {"source_code": ""}, {"source_code": "= $max) {\n echo $res[$i][0];\n exit();\n }\n }\n?>"}, {"source_code": ""}, {"source_code": " $m) {\n $winner = $name;\n $m = $a[$name];\n }\n}\nif ($m == max($a) && count($winnerNames = array_keys($a, $m)) == 1) {\n echo $winnerNames[0];\n} else {\n echo $winner;\n}\n"}, {"source_code": " $m) {\n $winner = $name;\n $m = $a[$name];\n }\n}\nif ($m == max($a) && count($winnerNames = array_keys($a, $m)) == 1) {\n echo $winnerNames[0];\n} else {\n echo $winner;\n}\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n /*if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }*/\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n\n if($addScore<$maxScore) {\n $max[$name] += $addScore;\n }\n\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $maxScore) {\n $maxScore = $scoremap[$lineSplit[0]];\n $winner = $lineSplit[0];\n }\n}\n\nfprintf($fileOut, $winner . \"\\n\");\n\nfclose($fileIN);\nfclose($fileOut);\n\n?>"}, {"source_code": ""}, {"source_code": " $max) {\n $max = $newMax;\n $maxPerson = $person;\n }\n}\n\n$a = [];\n$max = 0;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $maxPerson);\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n if($resultScore[$k] <0) {\n continue;\n }\n $max[$name] += $resultScore[$k];\n }\n\n $maxScore = max($max);\n $max = array();\n\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $p_result) {\n\t\tif ($p_name == $name) {\n\t\t\t$players[$p_name][] = $players[$p_name][$round -1] + $result;\n\t\t\t$added = true;\n\t\t} else {\n\t\t\t$players[$p_name][] = $players[$p_name][$round -1];\n\t\t}\n\t}\n\n\tif (!$added) {\n\t\tfor($i = 0; $i <= $round; $i++) {\n\t\t\t$players[$name][] = ($i == $round -1) ? $result : 0; \n\t\t}\n\t}\n\n\t$round++;\n}\n\nfunction findHighest()\n{\t\t\n\tglobal $players, $round;\n\t$highest_score = -1001;\n\t$leader_name = \"Pawel\";\n\n\tforeach($players as $player => $score) {\n\t\t$final_score = $score[$round - 1];\n\n\t\tif ($final_score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $final_score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($final_score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\nfunction findOverallWinner($winners_array, $winning_score) \n{\n\t$temp_winners = array();\n\tglobal $round;\t\n\t$winning_round = $round - 1;\n\n\tforeach($winners_array as $w_name => $w_score) {\n\t\tif ($w_score[$round] == $winning_score) {\n\t\t\tforeach($w_score as $t_round => $t_score) {\n\t\t\t\tif($t_score >= $winning_score && $t_round < $winning_round) {\n\t\t\t\t\t$winning_round = $t_round;\n\t\t\t\t\t$winner_name = $w_name;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\treturn $winner_name;\n}\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\t\tsaveResult($matches[1], $matches[2]);\t\n\t}\n}\n\n$winner = findHighest();\n$overall_winner = ($winner[2]) ? findOverallWinner($players, $winner[1]) : $winner[0];\nfprintf($fw, $overall_winner);\n"}, {"source_code": " $v) {\n if ($v[0] > $max) {\n $max = $v[0];\n $name = $k;\n $key = $v[1];\n } else if ($v == $max) {\n if ($key > $v[1]) {\n $name = $k;\n $key = $v[1];\n }\n }\n }\n return $name;\n}\n\n$in = fopen(STDIN,'r');\nwhile ($row = fscanf($in,\"%s %i\")) {\n $data[] = $row;\n}\n\n$line = array_shift($data);\n\n$max = 0;\n$name = '';\n$list = [];\nfor ($i=0;$i<$line[0];$i++) {\n if (!$list[$data[$i][0]]) {\n $list[$data[$i][0]] = [\n $data[$i][1],$i\n ];\n } else {\n $list[$data[$i][0]][0] += $data[$i][1];\n $list[$data[$i][0]][1] = $i;\n }\n}\n\necho _max($list);"}, {"source_code": "= $max) {\n //echo $line[0];\n exit();\n }\n }\n?>"}, {"source_code": ""}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif (isset($total[$player[0]])){\n$total[$player[0]] += $player[1];\n} else {\n$total[$player[0]] = $player[1];\n}\nif ($total[$player[0]]>$higher_score){\n if ($prev_winner == \"\"){\n $prev_winner = $player[0];\n $prev_higher_score = $total[$player[0]];\n }\n else {\n $prev_winner = $winner;\n $prev_higher_score = $higher_score;\n $winner = $player[0];\n $higher_score = $total[$player[0]];\n }\n} else if($total[$player[0]]<0 && $winner == $player[0]) {\n $winner = $prev_winner;\n $higher_score = $prev_higher_score;\n}\n}\n}\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$winner = $player[0];\n}\n}\n}\necho $winner;\n?>"}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif (isset($total[$player[0]])){\n$total[$player[0]] += $player[1];\n} else {\n$total[$player[0]] = $player[1];\n}\nif ($total[$player[0]]>$higher_score){\n if ($prev_winner == \"\"){\n $prev_winner = $player[0];\n $prev_higher_score = $total[$player[0]];\n }\n else {\n $prev_winner = $winner;\n $prev_higher_score = $higher_score;\n $winner = $player[0];\n $higher_score = $total[$player[0]];\n }\n} else if($total[$player[0]]<0 && $winner == $player[0]) {\n $winner = $prev_winner;\n $higher_score = $prev_higher_score;\n}\n}\n}\nif ($av) {\nforeach($total as $key => $str) {\necho $key.\"=\".$value;\necho \"\\n\";\n\n}\n}\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$winner = $player[0];\n}\n}\n}\necho $winner;\n?>"}, {"source_code": "$value)\n {\n if($value>$point)\n {\n $winner=$key;\n $point = $value;\n }\n \n // echo($winner.\"\\n\");\n }\n \n \n }\n \n echo($winner);\n ?>"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\n$ub = array();\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1])*1000;\n $score[$dat[0]] += $n - $score[$dat[0]]%1000;\n if (floor($score[$dat[0]] / 1000) == floor($ub[$dat[0]] / 1000))\n $score[$dat[0]] = $ub[$dat[0]];\n if (floor($score[$dat[0]] / 1000) > floor($ub[$dat[0]] / 1000))\n $ub[$dat[0]] = $score[$dat[0]];\n}\n$best = '';\nforeach ($score as $name => $val)\n if ($val > $score[$best]) $best = $name;\n\nprint $best.chr(10);\n?>"}, {"source_code": " $players[$winner]) {\n $winner = $name;\n }\n}\n\necho $winner;"}, {"source_code": "$v)\n {\n echo $k;\n break;\n }\n ?>"}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t$current_leader = $temp_leader;\n\t\t}\t\n\t}\n}\n\n$last_check = findHighest($players);\nif ($current_leader[1] > $last_check[1]) {\n\tfprintf($fw, $current_leader[0]);\n} else {\n\tfprintf($fw, $last_check[0]);\n}\n\n"}, {"source_code": " $pi){\n $fi = explode(' ', $pi);\n $sorted[$fi[0]] += (int)trim($fi[1]);\n }\n $max = max($sorted); \n $winner = $fi[0];\n foreach($ps as $key => $pi){\n $fi = explode(' ', $pi);\n $scores[$fi[0]] += (int)trim($fi[1]);\n if($scores[$fi[0]] == $max){\n if($scores[$fi[0]] > $scores[$winner]){\n $winner = $fi[0];\n }\n }\n }\n echo $winner;"}, {"source_code": " 0,\n\t\t);\n\t}\n\t$scores[$name]['score'] += intval($score);\n\t$scores[$name]['round'] = $i;\n}\n\nuasort($scores, function($a, $b){\n\tif($a['score'] > $b['score']){\n\t\treturn -1;\n\t} elseif($a['score'] == $b['score']){\n\t\treturn ($a['round'] < $b['round']) ? -1 : 1;\n\t} else {\n\t\treturn 1;\n\t}\n});\n\n$names = array_keys($scores);\necho reset($names);"}, {"source_code": "= $max) {\n echo $line[0];\n exit();\n }\n }\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n if(isset($bad[$name]) && $resultScore[$k] <0) {\n $bad[$name] = 1;\n continue;\n }\n $max[$name] += $resultScore[$k];\n }\n\n $maxScore = max($max);\n $max = array();\n\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $winnerScore) {\n $winner = $name;\n $winnerScore = $a[$name];\n }\n}\necho $winner;\n\n"}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[2] > 0) {\n\t\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t\t$current_leader = $temp_leader;\n\t\t\t}\t\n\t\t}\n\t}\n}\n\nfprintf($fw, $current_leader[0]);\n\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif (isset($total[$player[0]])){\n$total[$player[0]]['score'] += $player[1];\n$total[$player[0]]['turn'] = $turn;\n} else {\n$total[$player[0]]['score'] = $player[1];\n$total[$player[0]]['turn'] = $turn;\n}\n$turn++;\n}\n}\n$is_first = true;\n$winner_turn = 0;\nforeach($total as $key => $str) {\nif ($is_first) {\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\n\n}\nif ($str['score']>$higher_score) {\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\n\n} else if (intval($str['score']) == $higher_score && $winner_turn > $str['turn']){\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\n}\n$is_first = false;\n}\n// var_dump($char_array2);die();\n// foreach($text as $key => $str) {\n// if (strlen($str)>0){\n// $player = explode(\" \",$str);\n// if (isset($total[$player[0]])){\n// $total[$player[0]] += $player[1];\n// } else {\n// $total[$player[0]] = $player[1];\n// }\n// if ($total[$player[0]]>$higher_score){\n // if ($prev_winner == \"\"){\n // $prev_winner = $player[0];\n // $prev_higher_score = $total[$player[0]];\n // }\n // else {\n // $prev_winner = $winner;\n // $prev_higher_score = $higher_score;\n // $winner = $player[0];\n // $higher_score = $total[$player[0]];\n // }\n// } else if($total[$player[0]]<0 && $winner == $player[0]) {\n // $winner = $prev_winner;\n // $higher_score = $prev_higher_score;\n// }\n// }\n// }\n\n\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$winner = $player[0];\n}\n}\n}\necho $winner;\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n if(isset($bad[$name]) && $resultScore[$k] <0) {\n $bad[$name] = 1;\n continue;\n }\n $max[$name] += $resultScore[$k];\n }\n\n $maxScore = max($max);\n $max = array();\n\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": "=$point && $ee[0] != \"\")\n {\n $winner=$ee[0];\n $point = $a[$ee[0]];\n }\n\n \n}\necho($winner);\n?>"}, {"source_code": ""}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t$current_leader = $temp_leader;\n\t\t}\t\n\t}\n}\n\n$last_check = findHighest($players);\nif ($current_leader[1] > $last_check[1]) {\n\tfprintf($fw, $current_leader[0]);\n} else {\n\tfprintf($fw, $last_check[0]);\n}\n\n"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1]);\n}\n$best = $dat[0];\nforeach ($score as $name => $val) {\n if ($val > $score[$best] || ($val == $score[$best] && $name < $best))\n $best = $name;\n}\nprint $best.chr(10);\n?>"}, {"source_code": " $value) {\n if($data[$name]['score'] > $maxScore) {\n $maxScore = $data[$name]['score'];\n $winName = $name;\n $testCheck = 0;\n foreach ($data[$name]['log'] as $check => $s) {\n $testCheck += $s;\n if($testCheck >= $maxScore) {\n $maxCheck = $check;\n break;\n }\n }\n }\n elseif($data[$name]['score'] == $maxScore) {\n foreach ($data[$name]['log'] as $check => $s) {\n $testCheck += $s;\n if($testCheck >= $maxScore) {\n if($check < $maxCheck) {\n $maxCheck = $check;\n $winName = $name;\n }\n break;\n }\n }\n }\n }\n\n printf(\"%s\", $winName);\n?>"}, {"source_code": " $s) {\n if($n != $name) {\n if($data[$name] > $s) $check++;\n }\n }\n if($check == count($data) - 1) $winName = $name;\n\n }\n printf(\"%s\", $winName);\n?>"}, {"source_code": " $player_hs[$name][0])\n\t\t\t$player_hs[$name] = array($score,$i);\n\n\t}else{\n\t\t$player[$name] = $score;\n\t\t$player_hs[$name] = array($score,$i);\n\t}\n\n}\n\n$max = 0;\n$winner = \"\";\n$winner_t = 0;\n\nforeach($player as $key=>$value)\n{\n\tif(($value > $max) || (($value == $max) && $player_hs[$key][1]<$winner_t) ){\n\t\t$max = $value;\n\t\t$winner = $key;\n\t\t$winner_t = $player_hs[$key][1];\n\t}\n}\n\necho $winner.\"\\n\";\n?>\n"}, {"source_code": " $maxScore) {\n $maxScore = $scoremap[$lineSplit[0]];\n $winner = $lineSplit[0];\n }\n}\n\nfprintf($fileOut, $winner . \"\\n\");\n\nfclose($fileIN);\nfclose($fileOut);\n\n?>"}, {"source_code": ""}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif ($player[1]<0) {\nif ($player[0] == $winner) {\n$winner = $prev_winner;\n$higher_score = $prev_higher_score;\n}\n$total[$player[0]] = \"loser\";\ncontinue;\n}\nif ($total[$player[0]] =='loser') continue;\nif (isset($total[$player[0]]) && $total[$player[0]] !='loser'){\n$total[$player[0]] += $player[1];\n} else {\n$total[$player[0]] = $player[1];\n}\nif ($total[$player[0]]>$higher_score){\nif ($prev_winner == \"\"){\n$prev_winner = $player[0];\n$prev_higher_score = $total[$player[0]];\n}\nelse {\n$prev_winner = $winner;\n$prev_higher_score = $higher_score;\n$winner = $player[0];\n$higher_score = $total[$player[0]];\n}\n}\n}\n}\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);$winner = $player[0];\n\n}\n}\n} else {\necho $winner;\n}\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1]);\n}\n$best = $dat[0];\nforeach ($score as $name => $val) {\n if ($val > $score[$best] || ($val == $score[$best] && $name < $best))\n $best = $name;\n}\nprint $best.chr(10);\n?>"}, {"source_code": "$point)\n {\n $winner=$ee[0];\n $point = $a[$ee[0]];\n }\n\n \n}\necho($winner);\n?>"}, {"source_code": "= $m) {\n echo $name;\n exit;\n }\n}\n"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max AND $new[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif ($player[1]<0) {\nif ($player[0] == $winner) {\n$winner = $prev_winner;\n$higher_score = $prev_higher_score;\n}\n$total[$player[0]] = \"loser\";\ncontinue;\n}\nif ($total[$player[0]] =='loser') continue;\nif (isset($total[$player[0]]) && $total[$player[0]] !='loser'){\n$total[$player[0]] += $player[1];\n} else {\n$total[$player[0]] = $player[1];\n}\nif ($total[$player[0]]>$higher_score){\nif ($prev_winner == \"\"){\n$prev_winner = $player[0];\n$prev_higher_score = $total[$player[0]];\n}\nelse {\n$prev_winner = $winner;\n$prev_higher_score = $higher_score;\n$winner = $player[0];\n$higher_score = $total[$player[0]];\n}\n}\n}\n}\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$winner = $player[0];\n}\n}\n}\necho $winner;\n?>"}, {"source_code": " 0; $x++, $z--)\n{\n $n = $z / 1000;\n $p = \".\" . $z;\n for($y = 0; $y < count($i); $y++)\n {\n if($i[$y] == $e[$x])\n {\n if($j[$e[$x]] >= 0)\n {\n $j[$e[$x]] = floor($j[$e[$x]]);\n }\n else\n {\n $j[$e[$x]] = ceil($j[$e[$x]]);\n }\n $j[$e[$x]] = floor($j[$e[$x]]);\n $j[$e[$x]] = $j[$e[$x]] + $f[$x];\n $j[$e[$x]] = $j[$e[$x]] . $p;\n }\n }\n arsort($j);\n $m = array_keys($j);\n}\nprint_r($j);\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $winnerCandidates = $max = array();\n\n\n foreach($resultNames as $k=>$name){\n\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n $max[$name] += $addScore;\n\n if($max[$name] >= $maxScore) {\n $winnerCandidates[$name] = 0;\n }\n }\n\n //var_dump($winnerCandidates, $max, $maxScore);\n\n foreach($max as $name=>$result) {\n if($result>=$maxScore && isset($winnerCandidates[$name])) {\n exit($name);\n }\n }\n\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n /*if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }*/\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n\n $max[$name] += $addScore;\n\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n /*if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }*/\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n\n if($addScore<$maxScore) {\n $max[$name] += $addScore;\n } else {\n exit($name);\n }\n\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max AND $new[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\n$best = '';\n$score[$best] = -10000000;\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1]);\n if ($score[$dat[0]] > $score[$best])\n $best = $dat[0];\n}\nprint $best.chr(10);\n?>"}, {"source_code": "= $m) {\n echo $winner;\n exit;\n }\n}\n"}, {"source_code": "$value)\n{\n\tif(($value > $max) || (($value == $max) && $player_hs[$key]<$winner_t) ){\n\t\t$max = $value;\n\t\t$winner = $key;\n\t\t$winner_t = $player_hs[$key];\n\t}\n}\n\necho $winner.\"\\n\";\n?>\n"}, {"source_code": " $max) {\n $max = $a[$person];\n $maxPerson = $person;\n }\n}\n\n$a = $b = [];\n$max = -10000000000;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $b, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $b[max($a)][0]);"}, {"source_code": ""}, {"source_code": " $max) {\n $max = $res[$name];\n $winner = $name;\n }\n }\n \n fprintf(STDOUT, \"%s\", $winner);\n?>"}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t$current_leader = $temp_leader;\n\t\t}\t\n\t}\n}\n\n$last_check = findHighest($players);\nif ($last_check[1] > $players[$current_leader[0]]) {\n\tfprintf($fw, $last_check[2]);\n} else {\n\tfprintf($fw, $current_leader[2]);\n}\n\n"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n if ( $istr[1] < 0 ) {\n unset( $in[$key] );\n } else {\n $new[$istr[0]] += $istr[1];\n }\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[2] > 0) {\n\t\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t\t$current_leader = $temp_leader;\n\t\t\t}\t\n\t\t}\n\t}\n}\n\nfprintf($fw, $current_leader[0]);\n\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif (isset($total[$player[0]])){\n$total[$player[0]]['score'] += $player[1];\n$total[$player[0]]['turn'] = $turn;\n} else {\n$total[$player[0]]['score'] = $player[1];\n$total[$player[0]]['turn'] = $turn;\n}\n$turn++;\n}\n}\n$is_first = true;\n$winner_turn = 0;\nforeach($total as $key => $str) {\nif ($is_first) {\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\ncontinue;\n}\nif ($str['score']>$higher_score) {\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\n} else if ($str['score'] == $higher_score && $winner_turn > $str['turn']){\n$winner = $key;\n$higher_score = $str['score'];\n$winner_turn = $str['turn'];\n}\n$is_first = false;\n}\n// var_dump($char_array2);die();\n// foreach($text as $key => $str) {\n// if (strlen($str)>0){\n// $player = explode(\" \",$str);\n// if (isset($total[$player[0]])){\n// $total[$player[0]] += $player[1];\n// } else {\n// $total[$player[0]] = $player[1];\n// }\n// if ($total[$player[0]]>$higher_score){\n // if ($prev_winner == \"\"){\n // $prev_winner = $player[0];\n // $prev_higher_score = $total[$player[0]];\n // }\n // else {\n // $prev_winner = $winner;\n // $prev_higher_score = $higher_score;\n // $winner = $player[0];\n // $higher_score = $total[$player[0]];\n // }\n// } else if($total[$player[0]]<0 && $winner == $player[0]) {\n // $winner = $prev_winner;\n // $higher_score = $prev_higher_score;\n// }\n// }\n// }\n\n\nif ($winner == \"\") {\nforeach($text as $key => $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\n$winner = $player[0];\n}\n}\n}\necho $winner;\n?>"}, {"source_code": " $score) {\n\t\tif ($score > $highest_score) {\n\t\t\t$leader_name = $player;\n\t\t\t$highest_score = $score;\n\t\t\t$multiple_leaders = false;\n\t\t} else if ($score == $highest_score) {\n\t\t\t$multiple_leaders = true; \n\t\t}\n\t}\n\t\n\treturn array($leader_name, $highest_score, $multiple_leaders);\n}\n\n$players = $top_scores = array();\n$current_leader = $temp_leader = array(\"Pawel\", -1001, 0);\n$players[$temp_leader[0]] = $temp_leader[1];\n$top_scores[$temp_leader[0]] = $temp_leader[1];\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\n\t\tif (isset($players[$matches[1]])) {\n\t\t\t$players[$matches[1]] += $matches[2];\n\t\t} else {\n\t\t\t$players[$matches[1]] = $matches[2];\n\t\t}\n\t\t\n//\t\tif ($top_scores[$matches[1]] < $players[$matches[1]]) {\n//\t\t\t$top_scores[$matches[1]] = $players[$matches[1]];\n//\t\t}\n\n\t\t$temp_leader = findHighest($players);\n\n\t\tif ($temp_leader[2] > 0) {\n\t\t\tif ($temp_leader[1] > $current_leader[1]) {\n\t\t\t\t$current_leader = $temp_leader;\n\t\t\t}\t\n\t\t}\n\t}\n}\n\nfprintf($fw, $current_leader[0]);\n\n"}, {"source_code": "name = $array[0];\n $line[$i]->point = $array[1];\n\n if(isset($names[$array[0]]))\n {\n $names[$array[0]] = $names[$array[0]] + $array[1];\n }\n else\n {\n $names += array($array[0] => $array[1]);\n }\n}\n\n\n$max=0;\nforeach ($line as &$val) \n{\n if($max < $val->point)\n $max = $val->point;\n}\nunset($val);\n\n$str;\n$pnt;\nforeach ($line as &$val) \n{\n $str = $val->name;\n $pnt = $val->point;\n\n\n if(isset($winner[$str]))\n {\n $winner[$str] = $winner[$str] + $pnt;\n }\n else\n {\n $winner += array($str => $pnt);\n }\n\n if($winner[$str] >= $max && $names[$str] == $max)\n {\n echo $str;\n break;\n }\n\n}\nunset($val);\n\n\n"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n /*if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }*/\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n\n if($addScore<$maxScore) {\n $max[$name] += $addScore;\n } else {\n exit($name);\n }\n\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}, {"source_code": ""}, {"source_code": "$value)\n{\n\tif($value > $max){\n\t\t$winner_list = array($key);\n\t\t$max = $value;\n\t}else if($value == $max){\n\t\t$winner_list[] = $key;\n\t}\n}\n\n$min = $n;\nforeach($winner_list as $name){\n\tfor($i=0; $i \n"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\nforeach (range(1, $n) as $i) {\n $dat = explode(' ', fgets(STDIN));\n $name[$i] = $dat[0];\n $gain[$i] = intval($dat[1]);\n $score[$name[$i]] += $gain[$i];\n}\nforeach ($score as $val)\n if ($val > $best) $best = $val;\n$second = array();\nforeach (range(1, $n) as $i) {\n $second[$name[$i]] += $gain[$i];\n if ($score[$name[$i]] == $best && $second[$name[$i]] == $best) break;\n}\n\nprint $name[$i].chr(10);\n?>"}, {"source_code": "= $max) {\n //echo $line[0];\n exit();\n }\n }\n?>"}, {"source_code": " $max) {\n $max = $newMax;\n $maxPerson = $person;\n }\n}\n\n$a = $b = [];\n$max = -10000000000;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $b, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $b[max($a)][0]);\n"}, {"source_code": " 0; $x++, $z--)\n{\n $n = $z / 1000;\n $p = \".\" . $z;\n for($y = 0; $y < count($i); $y++)\n {\n if($i[$y] == $e[$x])\n {\n if($j[$e[$x]] >= 0)\n {\n $j[$e[$x]] = floor($j[$e[$x]]);\n }\n else\n {\n $j[$e[$x]] = ceil($j[$e[$x]]);\n }\n $j[$e[$x]] = floor($j[$e[$x]]);\n $j[$e[$x]] = $j[$e[$x]] + $f[$x];\n $j[$e[$x]] = $j[$e[$x]] . $p;\n }\n }\n arsort($j);\n $m = array_keys($j);\n}\nprint $m[0];\n?>"}, {"source_code": " $str) {\nif (strlen($str)>0){\n$player = explode(\" \",$str);\nif ($player[1]<0) {\n$total[$player[0]] = \"loser\";\ncontinue;\n}\nif (isset($total[$player[0]]) && $total[$player[0]] !='loser'){\n$total[$player[0]] += $player[1];\n}else {\n$total[$player[0]] = $player[1];\n}\n}\n}\n$winner = \"\";\n$higher_score = 0;\nforeach ($total as $key=> $value) {\nif ($value != \"loser\" && $value>$higher_score) {\n$winner = $key;\n}\n}\necho $winner;\n?>"}, {"source_code": " $p_results) {\n\t\t\t$player_score = 0;\n\n\t\t\tforeach($p_results as $round_number => $round_result) {\n\t\t\t\t$player_score += $round_result;\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t$players[$p_name][$number_of_rounds + 1] = $player_score;\n\t\t\tif ($player_score > $highest_result) {\n\t\t\t\t$highest_result = $player_score;\n\t\t\t}\n\t\t}\n\t}\n\n\t$current_round++;\n}\n\nfunction findOverallWinner($winners_array, $winning_score) \n{\n\t$temp_winners = array();\n\tglobal $number_of_rounds;\t\n\t$winning_round = $number_of_rounds;\n\n\tforeach($winners_array as $w_name => $w_score) {\n\t\tif ($w_score[$number_of_rounds + 1] == $winning_score) {\n\t\t\t$temp_score = 0;\n\n\t\t\tforeach($w_score as $t_round => $t_score) {\n\t\t\t\tif ($t_round >= $winning_round) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t$temp_score += $t_score;\n\n\t\t\t\tif($t_score >= $winning_score) {\n\t\t\t\t\t$winning_round = $t_round;\n\t\t\t\t\t$winner_name = $w_name;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $winner_name;\n}\n\n\nwhile(($line = fgets($fr)) !== false) {\n\tif (preg_match('/([a-z]+)\\s+([\\-0-9]+)/', $line, $matches)) {\n\t\tsaveResult($matches[1], $matches[2]);\t\n\t}\n}\n\nfprintf($fw, findOverallWinner($players, $highest_result));\n"}, {"source_code": " $value) {\n if($data[$name]['score'] > $maxScore) {\n $maxScore = $data[$name]['score'];\n $winName = $name;\n $testCheck = 0;\n foreach ($data[$name]['log'] as $check => $s) {\n $testCheck += $s;\n if($testCheck >= $maxScore) {\n $maxCheck = $check;\n break;\n }\n }\n }\n elseif($data[$name]['score'] == $maxScore) {\n foreach ($data[$name]['log'] as $check => $s) {\n $testCheck += $s;\n if($testCheck >= $maxScore) {\n if($check < $maxCheck) {\n $maxCheck = $check;\n $winName = $name;\n }\n break;\n }\n }\n }\n }\n\n printf(\"%s\", $winName);\n?>"}, {"source_code": "#!/usr/bin/env php\n\nerror_reporting(0);\n$n = intval(fgets(STDIN));\n$score = array();\n$ub = array();\nwhile ($n--) {\n $dat = explode(' ', fgets(STDIN));\n $score[$dat[0]] += intval($dat[1])*1000;\n $score[$dat[0]] += $n - $score[$dat[0]]%1000;\n if (floor($score[$dat[0]] / 1000) == floor($ub[$dat[0]] / 1000))\n $score[$dat[0]] = $ub[$dat[0]];\n if (floor($score[$dat[0]] / 1000) > floor($ub[$dat[0]] / 1000))\n $ub[$dat[0]] = $score[$dat[0]];\n}\n$best = '';\nforeach ($score as $name => $val)\n if ($val > $score[$best]) $best = $name;\n\nprint $best.chr(10);\n?>"}, {"source_code": " $value) {\n if($data[$name]['score'] > $maxScore) {\n $maxScore = $data[$name]['score'];\n $maxDeep = $data[$name]['log'];\n $winName = $name;\n }\n elseif($data[$name]['score'] == $maxScore) {\n if($maxDeep > $data[$name]['log']) {\n $winName = $name;\n $maxDeep = $data[$name]['log'];\n }\n }\n }\n \n printf(\"%s\", $winName);\n?>"}, {"source_code": " $v) {\n if ($v[0] > $max) {\n $max = $v[0];\n $name = $k;\n $key = $v[1];\n } else if ($v == $max) {\n if ($key > $v[1]) {\n $name = $k;\n $key = $v[1];\n }\n }\n }\n return $name;\n}\n\n$in = fopen(STDIN,'r');\nwhile ($row = fscanf($in,\"%s %i\")) {\n $data[] = $row;\n}\n\n$line = array_shift($data);\n\n$max = 0;\n$name = '';\n$list = [];\nfor ($i=0;$i<$line[0];$i++) {\n if (!$list[$data[$i][0]]) {\n $list[$data[$i][0]] = [\n $data[$i][1],$i\n ];\n } else {\n $list[$data[$i][0]][0] += $data[$i][1];\n $list[$data[$i][0]][1] = $i;\n }\n}\n\necho _max($list);"}, {"source_code": " $j[$l[1]])\n {\n print $i[$k[$l[0]]];\n }\n else\n {\n $n = array_search($j[$k[0]], $m);\n print $i[$k[$l[$n]]];\n }\n}\n?>"}, {"source_code": " $max) {\n $max = $newMax;\n $maxPerson = $person;\n }\n}\n\n$a = $b = [];\n$max = -10000000000;\n$maxPerson = '';\n\nlist($n) = fscanf($input, \"%d\\n\");\n\nfor ($i = 0; $i < $n; ++$i) {\n list($person, $points) = fscanf($input, \"%s %d\\n\");\n\n foo($a, $b, $max, $maxPerson, $person, $points);\n}\n\nfwrite($output, $b[max($a)][0]);\n"}, {"source_code": " $players[$winner]) {\n $winner = $name;\n }\n}\n\necho $winner;"}, {"source_code": " $max) $max = $v;\n}\n\n$w = array();\nforeach($g as $k => $v){\n if($v == $max) $w[$k] = $v;\n}\n\nif(count($w) == 1){\n print array_search($max, $w);\n exit(0);\n}\n\n$g = array();\nforeach($s as $v){\n list($player, $score) = explode(' ',$v);\n $g[$player] += $score;\n if($g[$player] >= $max){\n print $player;\n exit(0);\n }\n}\n\n\n?>"}, {"source_code": " $str ) {\n $istr = explode( \" \", $str );\n $new[$istr[0]] += $istr[1];\n}\n\n$max = max($new);\n\nforeach( $in as $str ) {\n $istr = explode( \" \", $str );\n $new1[$istr[0]] += $istr[1];\n \n if ( $new1[$istr[0]] == $max AND $new[$istr[0]] == $max ) {\n echo $istr[0];\n break;\n }\n}"}, {"source_code": " $pi){\n $fi = explode(' ', $pi);\n $sorted[$fi[0]] += $fi[1];\n }\n $max = max($sorted);\n foreach($ps as $key => $pi){\n $fi = explode(' ', $pi);\n $scores[$fi[0]] += $fi[1];\n if($scores[$fi[0]] == $max){\n echo $fi[0];\n return;\n }\n }"}, {"source_code": " $j[$l[1]])\n {\n print $i[$k[$l[0]]];\n }\n else\n {\n $n = array_search($j[$k[0]], $m);\n print $i[$k[$l[$n]]];\n }\n}\n?>"}, {"source_code": "$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = intval($resultScore[$k]);\n if($addScore<0) {\n unset($resultNames[$k]);\n continue;\n }\n $max[$name] += $addScore;\n }\n\n $maxScore = max($max);\n\n $max = array();\n foreach($resultNames as $k=>$name){\n if(!isset($max[$name])) {\n $max[$name] = 0;\n }\n\n $addScore = $resultScore[$k];\n $max[$name] += $addScore;\n if($max[$name]>=$maxScore) {\n exit($name);\n }\n }\n"}], "src_uid": "c9e9b82185481951911db3af72fd04e7"} {"nl": {"description": "In order to write a string, Atilla needs to first learn all letters that are contained in the string.Atilla needs to write a message which can be represented as a string $$$s$$$. He asks you what is the minimum alphabet size required so that one can write this message.The alphabet of size $$$x$$$ ($$$1 \\leq x \\leq 26$$$) contains only the first $$$x$$$ Latin letters. For example an alphabet of size $$$4$$$ contains only the characters $$$\\texttt{a}$$$, $$$\\texttt{b}$$$, $$$\\texttt{c}$$$ and $$$\\texttt{d}$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 the length of the string. The second line of each test case contains a string $$$s$$$ of length $$$n$$$, consisting of lowercase Latin letters.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the minimum alphabet size required to so that Atilla can write his message $$$s$$$.", "sample_inputs": ["5\n\n1\n\na\n\n4\n\ndown\n\n10\n\ncodeforces\n\n3\n\nbcf\n\n5\n\nzzzzz"], "sample_outputs": ["1\n23\n19\n6\n26"], "notes": "NoteFor the first test case, Atilla needs to know only the character $$$\\texttt{a}$$$, so the alphabet of size $$$1$$$ which only contains $$$\\texttt{a}$$$ is enough.For the second test case, Atilla needs to know the characters $$$\\texttt{d}$$$, $$$\\texttt{o}$$$, $$$\\texttt{w}$$$, $$$\\texttt{n}$$$. The smallest alphabet size that contains all of them is $$$23$$$ (such alphabet can be represented as the string $$$\\texttt{abcdefghijklmnopqrstuvw}$$$)."}, "positive_code": [{"source_code": ""}, {"source_code": " $ans)\r\n {\r\n $ans = ord($s[$i]) - 96;\r\n }\r\n }\r\n\r\n print($ans . \"\\n\");\r\n }"}, {"source_code": ""}, {"source_code": " $max){\r\n $max = strpos($alphabet, $letter[0][$j]) + 1;\r\n }\r\n }\r\n InOutPut::print($max);\r\n}\r\n\r\nclass InOutPut {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArr()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function print($string)\r\n {\r\n echo $string . \"\\n\";\r\n }\r\n}\r\n?>"}, {"source_code": "= $x ) {\r\n if($y % $x == 0) {\r\n $tc = $y/ $x;\r\n $a = $tc; \r\n $b = 1;\r\n } \r\n }\r\n echo $b, ' ', $a, $inter;\r\n \r\n// echo $ans, $inter;\r\n \r\n \r\n\r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\n function ComandR($aCordinate) {\r\n return [$aCordinate[0] + 1, $aCordinate[1]];\r\n }\r\n function ComandL($aCordinate) {\r\n return [$aCordinate[0] - 1, $aCordinate[1]];\r\n }\r\n function ComandU($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] + 1];\r\n }\r\n function ComandD($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] - 1];\r\n }\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } "}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": "= $x ) {\r\n if($y % $x == 0) {\r\n $tc = $y/ $x;\r\n $a = $tc; \r\n $b = 1;\r\n } \r\n }\r\n echo $a, ' ', $b, $inter;\r\n \r\n// echo $ans, $inter;\r\n \r\n \r\n\r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\n function ComandR($aCordinate) {\r\n return [$aCordinate[0] + 1, $aCordinate[1]];\r\n }\r\n function ComandL($aCordinate) {\r\n return [$aCordinate[0] - 1, $aCordinate[1]];\r\n }\r\n function ComandU($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] + 1];\r\n }\r\n function ComandD($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] - 1];\r\n }\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } "}], "src_uid": "f7defb09175c842de490aa13a4f5a0c9"} {"nl": {"description": "Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a clean square, it will become dirty, and if she sweeps over a dirty square, it will become clean. She wants to sweep some columns of the room to maximize the number of rows that are completely clean. It is not allowed to sweep over the part of the column, Ohana can only sweep the whole column.Return the maximum number of rows that she can make completely clean.", "input_spec": "The first line of input will be a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). The next n lines will describe the state of the room. The i-th line will contain a binary string with n characters denoting the state of the i-th row of the room. The j-th character on this line is '1' if the j-th square in the i-th row is clean, and '0' if it is dirty.", "output_spec": "The output should be a single line containing an integer equal to a maximum possible number of rows that are completely clean.", "sample_inputs": ["4\n0101\n1000\n1111\n0101", "3\n111\n111\n111"], "sample_outputs": ["2", "3"], "notes": "NoteIn the first sample, Ohana can sweep the 1st and 3rd columns. This will make the 1st and 4th row be completely clean.In the second sample, everything is already clean, so Ohana doesn't need to do anything."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "f48ddaf1e1db5073d74a2aa318b46704"} {"nl": {"description": "You are given an array of n elements, you must make it a co-prime array in as few moves as possible.In each move you can insert any positive integral number you want not greater than 109 in any place in the array.An array is co-prime if any two adjacent numbers of it are co-prime.In the number theory, two integers a and b are said to be co-prime if the only positive integer that divides both of them is 1.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of elements in the given array. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109) \u2014 the elements of the array a.", "output_spec": "Print integer k on the first line \u2014 the least number of elements needed to add to the array a to make it co-prime. The second line should contain n\u2009+\u2009k integers aj \u2014 the elements of the array a after adding k elements to it. Note that the new array should be co-prime, so any two adjacent values should be co-prime. Also the new array should be got from the original array a by adding k elements to it. If there are multiple answers you can print any one of them.", "sample_inputs": ["3\n2 7 28"], "sample_outputs": ["1\n2 7 9 28"], "notes": null}, "positive_code": [{"source_code": " 0) {\n return gcd($m, $n % $m);\n } else {\n return abs($n);\n }\n}\n$c = trim(fgets(STDIN));\n$d = explode(\" \", trim(fgets(STDIN)));\n$f = 0;\nfor($x = 0; $x < $c - 1; $x++)\n{\n $e = gcd($d[$x], $d[$x + 1]);\n if($e != 1)\n {\n $d[$x] = $d[$x] . \" 1\";\n $f++;\n }\n}\nprint $f . \"\\n\";\nprint implode(\" \", $d);\n?>"}, {"source_code": " 1) {\n\t\t++$cnt;\n\t\t$ans[] = 1;\n\t}\n\t$ans[] = $arr[$i];\n}\necho $cnt.\"\\n\";\nforeach ($ans as $key => $value) {\n\tif($key == $n + $cnt - 1) {\n\t\techo $value.\"\\n\";\n\t} else {\n\t\techo $value.' ';\n\t}\n}\n?>"}], "negative_code": [{"source_code": " 0) {\n return gcd($m, $n % $m);\n } else {\n return abs($n);\n }\n}\n$c = trim(fgets(STDIN));\n$d = explode(\" \", trim(fgets(STDIN)));\nfor($x = 0; $x < $c - 1; $x++)\n{\n $e = gcd($d[$x], $d[$x + 1]);\n if($e != 1)\n {\n $f = array_slice($d, 0, $x + 1);\n $g = array_slice($d, $x + 1);\n $d = array_merge($f, array(1), $g);\n $x = -1;\n }\n}\nprint (count($d) - $c) . \"\\n\";\nprint implode(\" \", $d);\n?>"}, {"source_code": ""}], "src_uid": "b0b4cadc46f9fd056bf7dc36d1cf51f2"} {"nl": {"description": "Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.Help Yaroslav.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of elements in the array. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 the array elements.", "output_spec": "In the single line print \"YES\" (without the quotes) if Yaroslav can obtain the array he needs, and \"NO\" (without the quotes) otherwise.", "sample_inputs": ["1\n1", "3\n1 1 2", "4\n7 7 7 7"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteIn the first sample the initial array fits well.In the second sample Yaroslav can get array: 1, 2, 1. He can swap the last and the second last elements to obtain it.In the third sample Yarosav can't get the array he needs. "}, "positive_code": [{"source_code": "= $e)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "2c58d94f37a9dd5fb09fd69fc7788f0d"} {"nl": {"description": "The great hero guards the country where Homer lives. The hero has attack power $$$A$$$ and initial health value $$$B$$$. There are $$$n$$$ monsters in front of the hero. The $$$i$$$-th monster has attack power $$$a_i$$$ and initial health value $$$b_i$$$. The hero or a monster is said to be living, if his or its health value is positive (greater than or equal to $$$1$$$); and he or it is said to be dead, if his or its health value is non-positive (less than or equal to $$$0$$$).In order to protect people in the country, the hero will fight with monsters until either the hero is dead or all the monsters are dead. In each fight, the hero can select an arbitrary living monster and fight with it. Suppose the $$$i$$$-th monster is selected, and the health values of the hero and the $$$i$$$-th monster are $$$x$$$ and $$$y$$$ before the fight, respectively. After the fight, the health values of the hero and the $$$i$$$-th monster become $$$x-a_i$$$ and $$$y-A$$$, respectively. Note that the hero can fight the same monster more than once.For the safety of the people in the country, please tell them whether the great hero can kill all the monsters (even if the great hero himself is dead after killing the last monster).", "input_spec": "Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \\le t \\le 10^5$$$)\u00a0\u2014 the number of test cases. Description of the test cases follows. The first line of each test case contains three integers $$$A$$$ ($$$1 \\leq A \\leq 10^6$$$), $$$B$$$ ($$$1 \\leq B \\leq 10^6$$$) and $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$) \u2014 the attack power of the great hero, the initial health value of the great hero, and the number of monsters. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\leq a_i \\leq 10^6$$$), where $$$a_i$$$ denotes the attack power of the $$$i$$$-th monster. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$1 \\leq b_i \\leq 10^6$$$), where $$$b_i$$$ denotes the initial health value of the $$$i$$$-th monster. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case print the answer: \"YES\" (without quotes) if the great hero can kill all the monsters. Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["5\n3 17 1\n2\n16\n10 999 3\n10 20 30\n100 50 30\n1000 1000 4\n200 300 400 500\n1000 1000 1000 1000\n999 999 1\n1000\n1000\n999 999 1\n1000000\n999"], "sample_outputs": ["YES\nYES\nYES\nNO\nYES"], "notes": "NoteIn the first example: There will be $$$6$$$ fights between the hero and the only monster. After that, the monster is dead and the health value of the hero becomes $$$17 - 6 \\times 2 = 5 > 0$$$. So the answer is \"YES\", and moreover, the hero is still living.In the second example: After all monsters are dead, the health value of the hero will become $$$709$$$, regardless of the order of all fights. So the answer is \"YES\".In the third example: A possible order is to fight with the $$$1$$$-st, $$$2$$$-nd, $$$3$$$-rd and $$$4$$$-th monsters. After all fights, the health value of the hero becomes $$$-400$$$. Unfortunately, the hero is dead, but all monsters are also dead. So the answer is \"YES\".In the fourth example: The hero becomes dead but the monster is still living with health value $$$1000 - 999 = 1$$$. So the answer is \"NO\"."}, "positive_code": [{"source_code": " $sum - max($a) ? 'YES' : 'NO').PHP_EOL;\r\n}\r\n"}, {"source_code": "= 1) { $f = 1; break; }\r\n\t}\r\n\t\t\r\n if ($f == 1) { echo 'YES'.PHP_EOL; }\r\n else { echo 'NO'.PHP_EOL; }\r\n}\r\n?>"}], "negative_code": [{"source_code": " $cnt) {\r\n $flg = false;\r\n break;\r\n }\r\n $bx -= $cntx * $a[$j];\r\n }\r\n echo ($flg ? 'YES' : 'NO').PHP_EOL;\r\n}\r\n"}, {"source_code": ""}], "src_uid": "b63a6369023642a8e7e8f449d7d4b73f"} {"nl": {"description": "Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:A square table of size $$$n \\times n$$$, where $$$n$$$ is a multiple of $$$k$$$, is called good if only the characters '.' and 'X' are written in it, as well as in any subtable of size $$$1 \\times k$$$ or $$$k \\times 1$$$, there is at least one character 'X'. In other words, among any $$$k$$$ consecutive vertical or horizontal cells, there must be at least one containing the character 'X'.Output any good table that has the minimum possible number of characters 'X', and also the symbol 'X' is written in the cell $$$(r, c)$$$. Rows are numbered from $$$1$$$ to $$$n$$$ from top to bottom, columns are numbered from $$$1$$$ to $$$n$$$ from left to right.", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. Description of the test cases follows. The first and the only line of each test case contains four integers $$$n$$$, $$$k$$$, $$$r$$$, $$$c$$$ ($$$1 \\le n \\le 500, 1 \\le k \\le n, 1 \\le r, c \\le n$$$)\u00a0\u2014 the size of the table, the integer $$$k$$$ and the coordinates of the cell, which must contain the character 'X'. It is guaranteed that $$$n$$$ is a multiple of $$$k$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$500$$$.", "output_spec": "For each test case, output $$$n$$$ lines, each consisting of $$$n$$$ characters '.' and 'X',\u00a0\u2014 the desired table. If there are several answers, then you can output anyone.", "sample_inputs": ["3\n\n3 3 3 2\n\n2 1 1 2\n\n6 3 4 2"], "sample_outputs": ["X..\n..X\n.X.\nXX\nXX\n.X..X.\nX..X..\n..X..X\n.X..X.\nX..X..\n..X..X"], "notes": "NoteLet's analyze the first test case.The following tables can be printed as the correct answer: X....X.X. or ..XX...X. It can be proved that there cannot be less than $$$3$$$ characters 'X' in the answer.Note that the following table is invalid because cell $$$(3, 2)$$$ does not contain the character 'X': X...X...X In the second test case, the only correct table is: XXXX Each subtable of size $$$1 \\times 1$$$ must contain a 'X' character, so all characters in the table must be equal to 'X'."}, "positive_code": [{"source_code": " 1, b => 2, c => 3, d => 4, e => 5, f => 6, g => 7, h => 8, i => 9, j => 10, k => 11, l => 12, m => 13, n => 14, o => 15, p => 16, q => 17, r => 18, s => 19, t => 20, u => 21, v => 22, w => 23, x => 24, y => 25, z => 26);\nfor($x = 1; $x <= $a; $x++)\n{\n $c = str_split(trim(fgets(STDIN)));\n rsort($c);\n $d = array();\n for($y = 0; $y < count($c); $y++)\n {\n $d[$y] = $b[$c[$y]];\n }\n $e = 0;\n for($y = 0; $y < count($c) - 1; $y++)\n {\n if($d[$y] - $d[$y + 1] != 1)\n {\n $e = 1;\n break;\n }\n }\n if($e == 0)\n {\n print \"Yes\\n\";\n }\n else\n {\n print \"No\\n\";\n }\n}\n?>"}, {"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $d[$c[$x]]++;\n}\n$e = array_keys($d);\n$f = 0;\nfor($x = 0; $x < 10; $x++)\n{\n if($d[$e[$x]] >= $b)\n {\n $f = 1;\n break;\n }\n}\nif($f == 1)\n{\n print \"0\\n\";\n print $c;\n}\nelse\n{\n $g = array();\n $h = array();\n for($x = 0; $x < 10; $x++)\n {\n $i = 0;\n $i2 = 0;\n $i += $d[$x];\n $j = 2;\n $k = 1;\n $l = 1;\n $m = array_fill(0, 10, 0);\n while(TRUE)\n {\n $n = $j % 2;\n $j++;\n if($n == 0)\n {\n $o = $x + $k;\n if($o <= 9)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($k);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($k);\n $m[$o] = $d[$o];\n }\n $k++;\n }\n }\n else\n {\n $o = $x - $l;\n if($o >= 0)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($l);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($l);\n $m[$o] = $d[$o];\n }\n $l++;\n }\n }\n }\n $g[$x] = $i2;\n $h[$x] = $m;\n }\n $q = min($g);\n $t = array();\n for($x = 0; $x < 10; $x++)\n {\n if($g[$x] == $q)\n {\n $r = $h[$x];\n $s = str_split($c);\n for($y = 0; $y < $a; $y++)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] > $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n for($y = $a - 1; $y >= 0; $y--)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] < $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n $t[count($t)] = implode($s);\n }\n }\n print $q . \"\\n\";\n print min($t);\n}\n?>"}], "negative_code": [{"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $d[$c[$x]]++;\n}\n$e = array_keys($d);\n$f = 0;\nfor($x = 0; $x < 10; $x++)\n{\n if($d[$e[$x]] >= $b)\n {\n $f = 1;\n break;\n }\n}\nif($f == 1)\n{\n print \"0\\n\";\n print $c;\n}\nelse\n{\n $g = array();\n $h = array();\n for($x = 0; $x < 10; $x++)\n {\n $i = 0;\n $i2 = 0;\n $i += $d[$x];\n $j = 2;\n $k = 1;\n $l = 1;\n $m = array_fill(0, 10, 0);\n while(TRUE)\n {\n $n = $j % 2;\n $j++;\n if($n == 0)\n {\n $o = $x + $k;\n if($o <= 9)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($k);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($k);\n $m[$o] = $d[$o];\n }\n $k++;\n }\n }\n else\n {\n $o = $x - $l;\n if($o >= 0)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($l);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($l);\n $m[$o] = $d[$o];\n }\n $l++;\n }\n }\n }\n $g[$x] = $i2;\n $h[$x] = $m;\n }\n $q = min($g);\n $t = array();\n for($x = 0; $x < 10; $x++)\n {\n if($g[$x] == $q)\n {\n $r = $h[$x];\n $s = str_split($c);\n for($y = 0; $y < $a; $y++)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] > $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n for($y = $a - 1; $y >= 0; $y--)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] < $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n $t[count($t)] = implode($s);\n }\n }\n print $g[$q] . \"\\n\";\n print min($t);\n}\n?>"}, {"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $d[$c[$x]]++;\n}\n$e = array_keys($d);\n$f = 0;\nfor($x = 0; $x < 10; $x++)\n{\n if($d[$e[$x]] >= $b)\n {\n $f = 1;\n break;\n }\n}\nif($f == 1)\n{\n print \"0\\n\";\n print $c;\n}\nelse\n{\n $g = array();\n $h = array();\n for($x = 0; $x < 10; $x++)\n {\n $i = 0;\n $i2 = 0;\n $i += $d[$x];\n $j = 2;\n $k = 1;\n $l = 1;\n $m = array_fill(0, 9, 0);\n while(TRUE)\n {\n $n = $j % 2;\n $j++;\n if($n == 0)\n {\n $o = $x + $k;\n if($o <= 9)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($k);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($k);\n $m[$o] = $d[$o];\n }\n $k++;\n }\n }\n else\n {\n $o = $x - $l;\n if($o >= 0)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($l);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($l);\n $m[$o] = $d[$o];\n }\n $l++;\n }\n }\n }\n $g[$x] = $i2;\n $h[$x] = $m;\n }\n $q = min($g);\n for($x = 0; $x < 10; $x++)\n {\n if($g[$x] == $q)\n {\n break;\n }\n }\n print $g[$x] . \"\\n\";\n $r = $h[$x];\n $s = str_split($c);\n for($y = 0; $y < $a; $y++)\n {\n if($r[$s[$y]] > 0)\n {\n $s[$y] = $x;\n $r[$s[$y]]--;\n }\n }\n print implode($s);\n}\n?>"}, {"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $d[$c[$x]]++;\n}\n$e = array_keys($d);\n$f = 0;\nfor($x = 0; $x < 10; $x++)\n{\n if($d[$e[$x]] >= $b)\n {\n $f = 1;\n break;\n }\n}\nif($f == 1)\n{\n print \"0\\n\";\n print $c;\n}\nelse\n{\n $g = array();\n $h = array();\n for($x = 0; $x < 10; $x++)\n {\n $i = 0;\n $i2 = 0;\n $i += $d[$x];\n $j = 2;\n $k = 1;\n $l = 1;\n $m = array_fill(0, 10, 0);\n while(TRUE)\n {\n $n = $j % 2;\n $j++;\n if($n == 0)\n {\n $o = $x + $k;\n if($o <= 9)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($k);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($k);\n $m[$o] = $d[$o];\n }\n $k++;\n }\n }\n else\n {\n $o = $x - $l;\n if($o >= 0)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($l);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($l);\n $m[$o] = $d[$o];\n }\n $l++;\n }\n }\n }\n $g[$x] = $i2;\n $h[$x] = $m;\n }\n $q = min($g);\n for($x = 0; $x < 10; $x++)\n {\n if($g[$x] == $q)\n {\n break;\n }\n }\n print $g[$x] . \"\\n\";\n $r = $h[$x];\n $s = str_split($c);\n for($y = 0; $y < $a; $y++)\n {\n if($r[$s[$y]] > 0)\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n print implode($s);\n}\n?>"}, {"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $d[$c[$x]]++;\n}\n$e = array_keys($d);\n$f = 0;\nfor($x = 0; $x < 10; $x++)\n{\n if($d[$e[$x]] >= $b)\n {\n $f = 1;\n break;\n }\n}\nif($f == 1)\n{\n print \"0\\n\";\n print $c;\n}\nelse\n{\n $g = array();\n $h = array();\n for($x = 0; $x < 10; $x++)\n {\n $i = 0;\n $i2 = 0;\n $i += $d[$x];\n $j = 2;\n $k = 1;\n $l = 1;\n $m = array_fill(0, 10, 0);\n while(TRUE)\n {\n $n = $j % 2;\n $j++;\n if($n == 0)\n {\n $o = $x + $k;\n if($o <= 9)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($k);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($k);\n $m[$o] = $d[$o];\n }\n $k++;\n }\n }\n else\n {\n $o = $x - $l;\n if($o >= 0)\n {\n $i += $d[$o];\n if($i >= $b)\n {\n $p = $i - $b;\n $r = $d[$o] - $p;\n $i -= $d[$o];\n $i += $r;\n $i2 += $r * abs($l);\n $m[$o] = $r;\n break;\n }\n else\n {\n $i2 += $d[$o] * abs($l);\n $m[$o] = $d[$o];\n }\n $l++;\n }\n }\n }\n $g[$x] = $i2;\n $h[$x] = $m;\n }\n $q = min($g);\n for($x = 0; $x < 10; $x++)\n {\n if($g[$x] == $q)\n {\n break;\n }\n }\n print $g[$x] . \"\\n\";\n $r = $h[$x];\n $s = str_split($c);\n for($y = 0; $y < $a; $y++)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] > $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n for($y = $a - 1; $y >= 0; $y--)\n {\n if(($r[$s[$y]] > 0) && ($s[$y] < $x))\n {\n $r[$s[$y]]--;\n $s[$y] = $x;\n }\n }\n print implode($s);\n}\n?>"}], "src_uid": "cb082cbe9b34a45da851b6764bbc30c3"} {"nl": {"description": "Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer $$$k$$$ ($$$0 \\leq k \\leq 10^{9}$$$) and replaces all missing elements in the array $$$a$$$ with $$$k$$$.Let $$$m$$$ be the maximum absolute difference between all adjacent elements (i.e. the maximum value of $$$|a_i - a_{i+1}|$$$ for all $$$1 \\leq i \\leq n - 1$$$) in the array $$$a$$$ after Dark replaces all missing elements with $$$k$$$.Dark should choose an integer $$$k$$$ so that $$$m$$$ is minimized. Can you help him?", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) \u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \\leq n \\leq 10^{5}$$$)\u00a0\u2014 the size of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$-1 \\leq a_i \\leq 10 ^ {9}$$$). If $$$a_i = -1$$$, then the $$$i$$$-th integer is missing. It is guaranteed that at least one integer is missing in every test case. It is guaranteed, that the sum of $$$n$$$ for all test cases does not exceed $$$4 \\cdot 10 ^ {5}$$$.", "output_spec": "Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \\leq k \\leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacing all the missing elements with $$$k$$$, the maximum absolute difference between adjacent elements becomes $$$m$$$. If there is more than one possible $$$k$$$, you can print any of them.", "sample_inputs": ["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"], "sample_outputs": ["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"], "notes": "NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\\leq 0$$$. So, the answer is $$$1$$$.In the third test case after replacing all missing elements with $$$6$$$ the array becomes $$$[6, 6, 9, 6, 3, 6]$$$. $$$|a_1 - a_2| = |6 - 6| = 0$$$; $$$|a_2 - a_3| = |6 - 9| = 3$$$; $$$|a_3 - a_4| = |9 - 6| = 3$$$; $$$|a_4 - a_5| = |6 - 3| = 3$$$; $$$|a_5 - a_6| = |3 - 6| = 3$$$. So, the maximum difference between any adjacent elements is $$$3$$$."}, "positive_code": [{"source_code": " $d)\n {\n $d = $c[$y - 1];\n }\n if($c[$y - 1] < $e)\n {\n $e = $c[$y - 1];\n }\n }\n if(($c[$y + 1] !== NULL) && ($c[$y + 1] != \"-1\"))\n {\n if($c[$y + 1] > $d)\n {\n $d = $c[$y + 1];\n }\n if($c[$y + 1] < $e)\n {\n $e = $c[$y + 1];\n }\n }\n }\n }\n if($e == \"1000000001\")\n {\n print \"0 0\\n\";\n }\n else\n {\n $f = ceil(($e + $d) / 2);\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $f;\n }\n }\n $g = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $h = abs($c[$y] - $c[$y + 1]);\n if($h > $g)\n {\n $g = $h;\n }\n }\n print $g . \" \" . $f . \"\\n\";\n }\n}\n?>"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n } else {\n if(isset($b[$i - 1]) && $b[$i - 1] != -1 && !isset($arr[$i - 1])){\n $count++;\n $all += $b[$i - 1];\n $arr[$i - 1] = 1;\n }\n if(isset($b[$i + 1]) && $b[$i + 1] != -1 && !isset($arr[$i + 1])){\n $count++;\n $all += $b[$i + 1];\n $arr[$i + 1] = 1;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = round(($max + $min)/ 2);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n echo $m.\" \".$k.\"\\n\";\n \n}"}], "negative_code": [{"source_code": " $c2)\n {\n $c2 = $c[$y];\n }\n if($c[$y] < $c3)\n {\n $c3 = $c[$y];\n }\n }\n }\n $d = $c2 + $c3;\n if($d % 2 == 0)\n {\n $d /= 2;\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n else\n {\n if($d == \"1000000001\")\n {\n print \"0 0\\n\";\n }\n else\n {\n $d = ceil($d / 2);\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " $c2)\n {\n $c2 = $c[$y];\n }\n if($c[$y] < $c3)\n {\n $c3 = $c[$y];\n }\n }\n else\n {\n $d2++;\n if($y == 0)\n {\n $d = $c[$y + 1];\n $d3 = $c[$y + 1];\n }\n elseif($y == $b - 1)\n {\n $d = $c[$y - 1];\n $d3 = $c[$y - 1];\n }\n else\n {\n $d = ceil(abs($c[$y - 1] + $c[$y + 1]) / 2);\n $d3 = $c[$y - 1];\n }\n }\n }\n if($d2 == 1)\n {\n print abs($d3 - $d) . \" \" . $d . \"\\n\";\n }\n else\n {\n $d = $c2 + $c3;\n if($d % 2 == 0)\n {\n $d /= 2;\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n else\n {\n if($d == \"1000000001\")\n {\n print \"0 0\\n\";\n }\n else\n {\n $d = ceil($d / 2);\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " $c2)\n {\n $c2 = $c[$y];\n }\n if($c[$y] < $c3)\n {\n $c3 = $c[$y];\n }\n }\n }\n $d = $c2 + $c3;\n if($d % 2 == 0)\n {\n $d /= 2;\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n else\n {\n if($d == \"1000000001\")\n {\n print \"0 0\\n\";\n }\n else\n {\n $d = ceil($d / 2);\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] == \"-1\")\n {\n $c[$y] = $d;\n }\n }\n $e = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n $f = abs($c[$y] - $c[$y + 1]);\n if($f > $e)\n {\n $e = $f;\n }\n }\n print $e . \" \" . $d . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n } else {\n if(isset($b[$i - 1]) && $b[$i - 1] != -1){\n $count++;\n $all += $b[$i - 1];\n }\n if(isset($b[$i + 1]) && $b[$i + 1] != -1){\n $count++;\n $all += $b[$i + 1];\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = ceil($all / $count);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n \n echo $m.\" \".$k.\"\\n\";\n \n}\n"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n }\n }\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = round($all / $count);\n $m = $k - $min > $max - $k ? $k - $min : $max - $k;\n }\n \n echo $m.\" \".$k.\"\\n\";\n \n}\n"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n } else {\n if(isset($b[$i - 1]) && $b[$i - 1] != -1 && !isset($arr[$i - 1])){\n $count++;\n $all += $b[$i - 1];\n $arr[$i - 1] = 1;\n }\n if(isset($b[$i + 1]) && $b[$i + 1] != -1 && !isset($arr[$i + 1])){\n $count++;\n $all += $b[$i + 1];\n $arr[$i + 1] = 1;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = ceil(($max + $min) / 2);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n echo $m.\" \".$k.\"\\n\";\n \n}"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n } else {\n if(isset($b[$i - 1]) && $b[$i - 1] != -1){\n $count++;\n $all += $b[$i - 1];\n }\n if(isset($b[$i + 1]) && $b[$i + 1] != -1){\n $count++;\n $all += $b[$i + 1];\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = round($all / $count);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n \n echo $m.\" \".$k.\"\\n\";\n \n}\n"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = round(($max + $min) / 2);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if(abs($x - $z) > $m){\n $m = abs($x - $z);\n }\n }\n }\n echo $m.\" \".$k.\"\\n\";\n \n}"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = round($all / $count);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n \n echo $m.\" \".$k.\"\\n\";\n \n}\n"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = ceil(($max + $min) / 2);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if(abs($x - $z) > $m){\n $m = abs($x - $z);\n }\n }\n }\n echo $m.\" \".$k.\"\\n\";\n \n}"}, {"source_code": " $b[$i]){\n $min = $b[$i];\n $bool2 = false;\n }\n } else {\n if(isset($b[$i - 1]) && $b[$i - 1] != -1 && !isset($arr[$i - 1])){\n $count++;\n $all += $b[$i - 1];\n $arr[$i - 1] = 1;\n }\n if(isset($b[$i + 1]) && $b[$i + 1] != -1 && !isset($arr[$i + 1])){\n $count++;\n $all += $b[$i + 1];\n $arr[$i + 1] = 1;\n }\n }\n }\n $bool3 = true;\n $m = 0;\n if($bool && $bool2){\n $k = 5;\n $m = 0;\n } else {\n $k = ceil($all / $count);\n for($h = 1; $h < $a; $h++){\n if($b[$h] == -1){\n $x = $k;\n }\n if($b[$h] != -1){\n $x = $b[$h];\n }\n if($b[$h-1] == -1){\n $z = $k;\n }\n if($b[$h-1] != -1){\n $z = $b[$h-1];\n }\n if($bool3 || abs($x - $z) > $m){\n $m = abs($x - $z);\n $bool3 = false;\n }\n }\n }\n echo $m.\" \".$k.\"\\n\";\n \n}\n"}], "src_uid": "8ffd80167fc4396788b745b53068c9d3"} {"nl": {"description": "Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message \u2014 string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string s. The newspaper contains string t, consisting of uppercase and lowercase English letters. We know that the length of string t greater or equal to the length of the string s.The newspaper may possibly have too few of some letters needed to make the text and too many of some other letters. That's why Tanya wants to cut some n letters out of the newspaper and make a message of length exactly n, so that it looked as much as possible like s. If the letter in some position has correct value and correct letter case (in the string s and in the string that Tanya will make), then she shouts joyfully \"YAY!\", and if the letter in the given position has only the correct value but it is in the wrong case, then the girl says \"WHOOPS\".Tanya wants to make such message that lets her shout \"YAY!\" as much as possible. If there are multiple ways to do this, then her second priority is to maximize the number of times she says \"WHOOPS\". Your task is to help Tanya make the message.", "input_spec": "The first line contains line s (1\u2009\u2264\u2009|s|\u2009\u2264\u20092\u00b7105), consisting of uppercase and lowercase English letters \u2014 the text of Tanya's message. The second line contains line t (|s|\u2009\u2264\u2009|t|\u2009\u2264\u20092\u00b7105), consisting of uppercase and lowercase English letters \u2014 the text written in the newspaper. Here |a| means the length of the string a.", "output_spec": "Print two integers separated by a space: the first number is the number of times Tanya shouts \"YAY!\" while making the message, the second number is the number of times Tanya says \"WHOOPS\" while making the message. ", "sample_inputs": ["AbC\nDCbA", "ABC\nabc", "abacaba\nAbaCaBA"], "sample_outputs": ["3 0", "0 3", "3 4"], "notes": null}, "positive_code": [{"source_code": " $i) {\n if (isset($a2[$s])) {\n if ($a1[$s] >= $a2[$s]) {\n $iMatchCount += $a2[$s];\n $a1[$s] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iMatchCount += $i;\n $a1[$s] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n }\n }\n foreach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtolower($s);\n if ($i == 0) {\n continue;\n }\n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n }\n foreach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtoupper($s);\n if ($i == 0) {\n continue;\n }\n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n}\nprint $iMatchCount . ' ' . $iDismatchCount;\n?>"}, {"source_code": ""}, {"source_code": " $i) {\n if (isset($a2[$s])) {\n if ($a1[$s] >= $a2[$s]) {\n $iMatchCount += $a2[$s];\n $a1[$s] = $i - $a2[$s]; \n $a2[$s] = 0;\n \n }\n else {\n $iMatchCount += $i;\n $a1[$s] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtolower($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtoupper($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\necho $iMatchCount . ' ' . $iDismatchCount;\nfclose($r);\nexit();\n?>"}, {"source_code": ""}, {"source_code": " $i) {\n if (isset($a2[$s])) {\n if ($a1[$s] >= $a2[$s]) {\n $iMatchCount += $a2[$s];\n $a1[$s] = $i - $a2[$s]; \n $a2[$s] = 0;\n \n }\n else {\n $iMatchCount += $i;\n $a1[$s] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtolower($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtoupper($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = 0; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\n\nprint_r($a1);\nprint_r($a2);\necho $iMatchCount . ' ' . $iDismatchCount;\nfclose($r);\nexit();\n?>"}, {"source_code": " $i) {\n if (isset($a2[$s])) {\n if ($a1[$s] >= $a2[$s]) {\n $iMatchCount += $a2[$s];\n $a1[$s] = $i - $a2[$s]; \n $a2[$s] = 0;\n \n }\n else {\n $iMatchCount += $i;\n $a1[$s] = $i - $a2[$s]; \n $a2[$s] = $a2[$s] - $i;\n }\n \n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtolower($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\nforeach ($a1 AS $s => $i) {\n $sOrig = $s;\n $s = strtoupper($s);\n if ($i == 0) {\n continue;\n }\n \n if (!isset($a2[$s]) || $a2[$s] == 0) {\n continue;\n }\n else if ($i >= $a2[$s]) {\n $iDismatchCount += $a2[$s];\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = 0;\n }\n else {\n $iDismatchCount += $i;\n $a1[$sOrig] = $i - $a2[$s]; \n $a2[$s] = $a2[$s] - $i;\n }\n \n}\n\necho $iMatchCount . ' ' . $iDismatchCount;\nfclose($r);\nexit();\n?>"}, {"source_code": " $i) {\n if (!isset($a2[$s])) {\n $iDismatchCount += $i;\n }\n else if ($a1[$s] == $a2[$s]) {\n $iMatchCount += $a2[$s];\n }\n else if ($a1[$s] - $a2[$s] > 0) {\n $iDiff = $a1[$s] - $a2[$s];\n $iMatchCount += $a2[$s];\n $iDismatchCount += $iDiff; \n }\n\n \n}\n\necho $iMatchCount . ' ' . $iDismatchCount;\nfclose($r);\nexit();\n?>"}], "src_uid": "96e2ba997eff50ffb805b6be62c56222"} {"nl": {"description": "Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below. So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted. The battery of the newest device allows to highlight at most n sections on the display. Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.", "input_spec": "The first line contains the integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000) \u2014 the maximum number of sections which can be highlighted on the display.", "output_spec": "Print the maximum integer which can be shown on the display of Stepan's newest device.", "sample_inputs": ["2", "3"], "sample_outputs": ["1", "7"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 0)\n{\n printf(\"1\");\n $n-=2;\n}\n?>"}, {"source_code": "= 2; $n = $n - 2)\n{\n\techo \"1\";\n}\n?>"}, {"source_code": "=2)\n \t{\n \t\techo 1;\n \t\t$a-=2;\n \t}\n }\n else \n {\n while($a)\n {\n echo 1;\n $a-=2;\n }\n }\n ?>"}, {"source_code": " "}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n$number = 0;\nfscanf(STDIN, \"%d\\n\", $number);\n$ans = \"\";\nwhile ($number > 1){\n if ($number > 5){\n \t$ans = $ans . \"11\";\n \t$number = $number - 4;\n }\n if ($number == 5){\n\t $ans = \"71\" . $ans;\n $number = $number - 5;\n }\n if ($number == 4){\n\t $ans = \"11\" . $ans;\n $number = $number - 4;\n }\n if ($number == 3){\n\t $ans = \"7\" . $ans;\n $number = $number - 3;\n }\n if ($number == 2){\n\t $ans = \"1\" . $ans;\n $number = $number - 2;\n }\n}\n\nfwrite(STDOUT, $ans);\n?>"}, {"source_code": "10)\n\t\tprintf(\"%s%d%s\\n\",$a[0],strlen($a)-2,$a[strlen($a)-1]);\n\telse\n\t\tprintf(\"%s\\n\",$a);\n}*/\n\n?>"}, {"source_code": " "}, {"source_code": " 0) {\n printf(\"1\");\n $number -= 2;\n}\n?>"}, {"source_code": " 0; $i++){\n echo 1;\n $n -= 2;\n }\n?>"}, {"source_code": "= 2)\n{\n if ($n == 3)\n {\n $ans = \"7\".$ans;\n $n -= 3;\n }\n else \n {\n $ans = \"1\".$ans;\n $n -= 2;\n }\n \n}\nprintf(\"%s\\n\",$ans);\n\n?>"}, {"source_code": "= 2; $n = $n - 2) echo '1';"}, {"source_code": " 0)\n{\n printf(\"1\");\n $n -= 2;\n}\n?>"}, {"source_code": ""}, {"source_code": " "}, {"source_code": ""}, {"source_code": " "}, {"source_code": " 0) {\n if ($n % 2 == 1) { echo '7'; $n = $n - 3; }\n else { echo '1'; $n = $n - 2; }\n }\n"}, {"source_code": "=2) {\n echo 1;\n $n -= 2;\n }\n \n?> "}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 3) {\n \t\n \t\t\t$ret .= \"1\";\n $n--;\n $n--;\n }\n if ($n == 3) {\n \techo \"7\";\t\n }\n else {\n \techo \"1\";\n }\n echo $ret;\n \n?> "}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n"}], "negative_code": [{"source_code": "= 4; $n = $n - 2)\n{\n\techo \"1\";\n}\nif($n == 3){\n echo \"7\";\n}else{\n echo \"1\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n$number = 0;\nfscanf(STDIN, \"%d\\n\", $number);\n$ans = \"\";\nwhile ($number > 3){\n\t$ans = $ans . \"11\";\n\t$number = $number - 4; \n}\nif ($number == 3){\n\t$ans = \"7\" . $ans;\n}\nif ($number == 2){\n\t$ans = \"1\" . $ans;\n}\n\nfwrite(STDOUT, $ans);\n?>"}, {"source_code": " 3; $i++){\n echo 1;\n $n -= 2;\n }\n if ($n == 3)\n\techo 7;\n else\n\techo 1;\n?>"}, {"source_code": ""}, {"source_code": " 0) {\n $kek = 0;\n for ($i = 9; $i >= 0; $i--) {\n if ($n >= $arr[$i]) {\n $n -= $arr[$i];\n $ans .= ((string) $i);\n $kek = 1;\n break;\n }\n }\n if ($kek == 0) {\n \tbreak;\n }\n}\nprintf(\"%s\\n\",$ans);\n?>"}, {"source_code": " "}, {"source_code": "=6) {\n echo 9;\n $n -= 6;\n }\n \n if ($n == 3) {\n echo 7;\n } else if ($n == 5) {\n echo 5;\n } else if ($n == 4) {\n echo 4;\n } else if ($n == 2) {\n echo 1;\n }\n?> "}, {"source_code": "= 4)\n{\n for( $i = 1; $i <= $a/2; $i++ )\n echo 1;\n}\nelse if( $a == 3 )\n{\n echo 7;\n}\nelse \n{\n echo 1;\n}\n?>"}, {"source_code": "= 0; --$i) {\n $x = $i;\n $curr = 0;\n\n while ($x >= 1) {\n $curr = $curr + $ve[$x%10];\n $x = floor($x/10 + 0.00000001);\n }\n\n if ($curr <= $n) {\n $ok = 0;\n echo $i;\n }\n}\n?>\n"}, {"source_code": "\n"}, {"source_code": "= 0; --$i) {\n $x = $i;\n $curr = 0;\n\n while ($x >= 1) {\n $curr = $curr + $ve[$x%10];\n $x = floor($x/10);\n }\n\n if ($curr <= $n) {\n $ok = 0;\n echo $i;\n }\n}\n?>\n"}, {"source_code": "= 0; --$i) {\n $x = $i;\n $curr = 0;\n\n while ($x >= 1) {\n $y = $x;\n $x = round($x / 10);\n \n $y = ($x - 10*$y);\n $curr = (int) $curr + (int) $ve[$y];\n $x = round($x/10);\n }\n \n\n if ($curr <= $n) {\n $ok = 0;\n echo $i;\n }\n}\n?>\n"}, {"source_code": "= 0; --$i) {\n $x = $i;\n $curr = 0;\n\n while ($x >= 1) {\n $curr = (int) $curr + (int) $ve[($x%10)];\n $x /= 10;\n }\n \n\n if ($curr <= $n) {\n $ok = 0;\n echo $i;\n }\n}\n?>\n"}, {"source_code": "= 0; --$i) {\n $x = $i;\n $curr = 0;\n\n while ($x >= 1) {\n $curr = $curr + $ve[$x%10];\n $x = floor($x/10);\n }\n\n if ($curr <= $n) {\n $ok = 0;\n echo $i;\n }\n}\n?>\n"}, {"source_code": ""}], "src_uid": "4ebea3f56ffd43efc9e1496a0ef7fa2d"} {"nl": {"description": "Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.Determine the longest time segment when Polycarp can sleep, i.\u00a0e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes up in another.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of alarms. Each of the next n lines contains a description of one alarm. Each description has a format \"hh:mm\", where hh is the hour when the alarm rings, and mm is the minute of that hour when the alarm rings. The number of hours is between 0 and 23, and the number of minutes is between 0 and 59. All alarm times are distinct. The order of the alarms is arbitrary. Each alarm starts ringing in the beginning of the corresponding minute and rings for exactly one minute (i.\u00a0e. stops ringing in the beginning of the next minute). Polycarp can start sleeping instantly when no alarm is ringing, and he wakes up at the moment when some alarm starts ringing.", "output_spec": "Print a line in format \"hh:mm\", denoting the maximum time Polycarp can sleep continuously. hh denotes the number of hours, and mm denotes the number of minutes. The number of minutes should be between 0 and 59. Look through examples to understand the format better.", "sample_inputs": ["1\n05:43", "4\n22:00\n03:21\n16:03\n09:59"], "sample_outputs": ["23:59", "06:37"], "notes": "NoteIn the first example there is only one alarm which rings during one minute of a day, and then rings again on the next day, 23 hours and 59 minutes later. Polycarp can sleep all this time."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $ans) {\n $ans = $diff;\n }\n // var_dump($diff);\n}\n\n// var_dump($ans);\nprint(to_date($ans - 1));\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $mx) {\n $mx = $v;\n }\n}\n\n$v = 60 * 24 - ($a[count($a) - 1] - $a[0] + 1);\nif ($v > $mx) {\n $mx = $v;\n}\n\necho str_pad(floor($mx / 60), 2, \"0\", STR_PAD_LEFT) . \":\" . str_pad($mx % 60, 2, \"0\", STR_PAD_LEFT);\n\n\n\n?>\n"}, {"source_code": " $mx) {\n $mx = $now;\n }\n}\n\nif ($now > $mx) {\n $mx = $now;\n}\n\n$h = $mx / 60;\n$m = $mx % 60;\n\nif ($h < 10) {\n fprintf(STDOUT, \"0%d:\", $h);\n} else {\n fprintf(STDOUT, \"%d:\", $h);\n}\n\nif ($m < 10) {\n fprintf(STDOUT, \"0%d\", $m);\n} else {\n fprintf(STDOUT, \"%d\", $m);\n}"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "c3b0b7194ce018bea9c0b9139e537a09"} {"nl": {"description": "You have m\u2009=\u2009n\u00b7k wooden staves. The i-th stave has length ai. You have to assemble n barrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel.Let volume vj of barrel j be equal to the length of the minimal stave in it. You want to assemble exactly n barrels with the maximal total sum of volumes. But you have to make them equal enough, so a difference between volumes of any pair of the resulting barrels must not exceed l, i.e. |vx\u2009-\u2009vy|\u2009\u2264\u2009l for any 1\u2009\u2264\u2009x\u2009\u2264\u2009n and 1\u2009\u2264\u2009y\u2009\u2264\u2009n.Print maximal total sum of volumes of equal enough barrels or 0 if it's impossible to satisfy the condition above.", "input_spec": "The first line contains three space-separated integers n, k and l (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u2009105, 1\u2009\u2264\u2009n\u00b7k\u2009\u2264\u2009105, 0\u2009\u2264\u2009l\u2009\u2264\u2009109). The second line contains m\u2009=\u2009n\u00b7k space-separated integers a1,\u2009a2,\u2009...,\u2009am (1\u2009\u2264\u2009ai\u2009\u2264\u2009109) \u2014 lengths of staves.", "output_spec": "Print single integer \u2014 maximal total sum of the volumes of barrels or 0 if it's impossible to construct exactly n barrels satisfying the condition |vx\u2009-\u2009vy|\u2009\u2264\u2009l for any 1\u2009\u2264\u2009x\u2009\u2264\u2009n and 1\u2009\u2264\u2009y\u2009\u2264\u2009n.", "sample_inputs": ["4 2 1\n2 2 1 2 3 2 2 3", "2 1 0\n10 10", "1 2 1\n5 2", "3 2 1\n1 2 3 4 5 6"], "sample_outputs": ["7", "20", "2", "0"], "notes": "NoteIn the first example you can form the following barrels: [1,\u20092], [2,\u20092], [2,\u20093], [2,\u20093].In the second example you can form the following barrels: [10], [10].In the third example you can form the following barrels: [2,\u20095].In the fourth example difference between volumes of barrels in any partition is at least 2 so it is impossible to make barrels equal enough."}, "positive_code": [{"source_code": " 0; $x--)\n {\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n }\n sort($e);\n}\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = ($a * $b - 1) - $e[count($e) - 1];\n $i = ceil($h / ($b - 1));\n $j = $a * $b - 1;\n $k = $a - 1;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $d[$j];\n $m = $d[$e[$k]];\n $d[$j] = $m;\n $d[$e[$k]] = $l;\n $j -= $b;\n $k--;\n }\n $l = 0;\n $m = 0;\n $n = array();\n for($x = 0; $x < $a * $b; $x++)\n {\n $n[count($n)] = $d[$x];\n $m++;\n if($m == $b)\n {\n $o = min($n);\n $l += $o;\n $m = 0;\n $n = array();\n }\n }\n print $l;\n}\n?>"}], "negative_code": [{"source_code": " 0; $x--)\n {\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n }\n sort($e);\n}\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = range(0, ($a * $b) - 1);\n $i = array_diff($h, $e);\n sort($i);\n $j = 0;\n $k = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $l = $b - 1;\n $m = array($d[$e[$x]]);\n for($y = $k; $y < count($i); $y++)\n {\n $m[count($m)] = $d[$i[$y]];\n $l--;\n if($l == 0)\n {\n break;\n }\n }\n $j += min($m);\n $k = $y + 1;\n }\n print $j;\n}\n?>"}, {"source_code": " 0; $x--)\n{\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n}\nsort($e);\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = 0;\n for($x = 0; $x < $a; $x++)\n {\n $h += $d[$e[$x]];\n }\n print $h;\n}\n?>"}, {"source_code": " 0; $x--)\n{\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n}\nsort($e);\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = range(0, ($a * $b) - 1);\n $i = array_diff($h, $e);\n sort($i);\n $j = 0;\n $k = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $l = $b - 1;\n $m = array($d[$e[$x]]);\n for($y = $k; $y < count($i); $y++)\n {\n $m[count($m)] = $d[$i[$y]];\n $l--;\n if($l == 0)\n {\n break;\n }\n }\n $j += min($m);\n $k = $y + 1;\n }\n print $j;\n}\n?>"}, {"source_code": " 0; $x--)\n{\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n}\nsort($e);\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = 0;\n for($x = 0; $x < $a; $x++)\n {\n $h = bcadd($h, $d[$e[$x]]);\n }\n print $h;\n}\n?>"}, {"source_code": " 0; $x--)\n{\n $g = $d[$x] - $d[0];\n if($g <= $c)\n {\n $e[count($e)] = $x;\n $f++;\n if($f == $a)\n {\n break;\n }\n }\n}\nsort($e);\nif(count($e) < $a)\n{\n print \"0\";\n}\nelse\n{\n $h = range(0, $a * $b - 1);\n $i = array_diff($h, $e);\n sort($i);\n $j = 0;\n $k = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $l = $b - 1;\n $m = array($d[$e[$x]]);\n for($y = $k; $y < count($i); $y++)\n {\n $m[count($m)] = $d[$i[$y]];\n $l--;\n if($l == 0)\n {\n break;\n }\n }\n $j += min($m);\n $k = $y;\n }\n print $j;\n}\n?>"}], "src_uid": "d40fcaf3e305910f66fec02f5507c327"} {"nl": {"description": "Blake is a CEO of a large company called \"Blake Technologies\". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.We define function f(x,\u2009l,\u2009r) as a bitwise OR of integers xl,\u2009xl\u2009+\u20091,\u2009...,\u2009xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a,\u2009l,\u2009r)\u2009+\u2009f(b,\u2009l,\u2009r) among all possible 1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n. ", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the length of the arrays. The second line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009109). The third line contains n integers bi (0\u2009\u2264\u2009bi\u2009\u2264\u2009109).", "output_spec": "Print a single integer\u00a0\u2014 the maximum value of sum f(a,\u2009l,\u2009r)\u2009+\u2009f(b,\u2009l,\u2009r) among all possible 1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n.", "sample_inputs": ["5\n1 2 4 3 2\n2 3 3 12 1", "10\n13 2 7 11 8 4 9 8 5 1\n5 7 18 9 2 3 0 11 8 6"], "sample_outputs": ["22", "46"], "notes": "NoteBitwise OR of two non-negative integers a and b is the number c\u2009=\u2009a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.In the first sample, one of the optimal answers is l\u2009=\u20092 and r\u2009=\u20094, because f(a,\u20092,\u20094)\u2009+\u2009f(b,\u20092,\u20094)\u2009=\u2009(2 OR 4 OR 3)\u2009+\u2009(3 OR 3 OR 12)\u2009=\u20097\u2009+\u200915\u2009=\u200922. Other ways to get maximum value is to choose l\u2009=\u20091 and r\u2009=\u20094, l\u2009=\u20091 and r\u2009=\u20095, l\u2009=\u20092 and r\u2009=\u20094, l\u2009=\u20092 and r\u2009=\u20095, l\u2009=\u20093 and r\u2009=\u20094, or l\u2009=\u20093 and r\u2009=\u20095.In the second sample, the maximum value is obtained for l\u2009=\u20091 and r\u2009=\u20099."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "475239ff4ae3675354d2229aba081a58"} {"nl": {"description": "Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.Help Amr by choosing the smallest subsegment possible.", "input_spec": "The first line contains one number n (1\u2009\u2264\u2009n\u2009\u2264\u2009105), the size of the array. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009106), representing elements of the array.", "output_spec": "Output two integers l,\u2009r (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n), the beginning and the end of the subsegment chosen respectively. If there are several possible answers you may output any of them. ", "sample_inputs": ["5\n1 1 2 2 1", "5\n1 2 2 3 1", "6\n1 2 2 1 1 2"], "sample_outputs": ["1 5", "2 3", "1 5"], "notes": "NoteA subsegment B of an array A from l to r is an array of size r\u2009-\u2009l\u2009+\u20091 where Bi\u2009=\u2009Al\u2009+\u2009i\u2009-\u20091 for all 1\u2009\u2264\u2009i\u2009\u2264\u2009r\u2009-\u2009l\u2009+\u20091"}, "positive_code": [{"source_code": ""}, {"source_code": " $maxi)\n {\n $maxi = $m[$x]; // The max occurrence times\n $mini = $i - $L[$x] + 1; // The subsegment length (We should count the start and end both)\n $ch = $L[$x] + 1; // Output is to start from 1 as beginning the input array\n }\n // The length is shorter, we change the start and min length\n else if ($m[$x] == $maxi && $i - $L[$x] + 1 < $mini)\n {\n $mini = $i - $L[$x] + 1;\n $ch = $L[$x] + 1;\n }\n}\n\necho $ch . \" \" . ($ch + $mini - 1);\n\n\n\n"}], "negative_code": [{"source_code": "= 0; $y--)\n {\n if($e[$x] == $b[$y])\n {\n $j[$k] = $y + 1;\n $k++;\n break;\n }\n }\n}\n$k = array();\nfor($x = 0; $x < count($e); $x++)\n{\n $l = $j[$x] - $h[$x];\n $k[$x] = $l;\n}\n$m = max($k);\nfor($x = 0; $x < count($e); $x++)\n{\n if($k[$x] == $m)\n {\n break;\n }\n}\nprint $h[$x] . \" \" . $j[$x];\n?>"}, {"source_code": ""}, {"source_code": " $maxi)\n {\n $maxi = $m[$x]; // The max occurrence times\n $mini = $i - $L[$x] + 1; // The subsegment length (We should count the start and end both)\n $ch = $L[$x] + 1; // Output is to start from 1 as beginning the input array\n }\n // The length is shorter, we change the start and min length\n else if ($m[$x] == $maxi && $i - $L[$x] + 1 < $mini)\n {\n $mini = $i - $L[$x] + 1;\n $ch = $L[$x] + 1;\n }\n}\n\necho $ch . \" \" . ($ch + $mini - 1);\n\n\n\n"}], "src_uid": "ecd9bbc05b97f3cd43017dd0eddd014d"} {"nl": {"description": "Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled: its name equals to the name of the called procedure; the number of its parameters equals to the number of parameters of the procedure call; the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same. You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of template procedures. The next n lines contain the description of the procedures specified in the following format: \"void procedureName (type_1, type_2, ..., type_t)\" (1\u2009\u2264\u2009t\u2009\u2264\u20095), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be \"int\", \"string\", \"double\", and the keyword \"T\", which denotes the generic type. The next line contains a single integer m (1\u2009\u2264\u2009m\u2009\u2264\u20091000) \u2014 the number of used variables. Next m lines specify the description of the variables in the following format: \"type variableName\", where type is the type of variable that can take values \"int\", \"string\", \"double\", variableName \u2014 the name of the variable. The next line contains a single integer k (1\u2009\u2264\u2009k\u2009\u2264\u20091000) \u2014 the number of procedure calls. Next k lines specify the procedure calls in the following format: \"procedureName (var_1, var_2, ..., var_t)\" (1\u2009\u2264\u2009t\u2009\u2264\u20095), where procedureName is the name of the procedure, var_i is the name of a variable. The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.", "output_spec": "On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.", "sample_inputs": ["4\nvoid f(int,T)\nvoid f(T, T)\n void foo123 ( int, double, string,string ) \n void p(T,double)\n3\nint a\n string s\ndouble x123 \n5\nf(a, a)\n f(s,a )\nfoo (a,s,s)\n f ( s ,x123)\nproc(a)", "6\nvoid f(string,double,int)\nvoid f(int)\n void f ( T )\nvoid procedure(int,double)\nvoid f (T, double,int) \nvoid f(string, T,T)\n4\n int a\n int x\nstring t\ndouble val \n5\nf(t, a, a)\nf(t,val,a)\nf(val,a, val)\n solve300(val, val)\nf (x)"], "sample_outputs": ["2\n1\n0\n1\n0", "1\n3\n0\n0\n2"], "notes": null}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if($n[$y] == \" \")\n {\n $o = \"a\" . substr($n, $y + 1);\n $m[$o] = \"i\";\n break;\n }\n }\n }\n elseif($n[0] == \"d\")\n {\n for($y = strlen($n); $y >= 0; $y--)\n {\n if($n[$y] == \" \")\n {\n $o = \"a\" . substr($n, $y + 1);\n $m[$o] = \"d\";\n break;\n }\n }\n }\n elseif($n[0] == \"s\")\n {\n for($y = strlen($n); $y >= 0; $y--)\n {\n if($n[$y] == \" \")\n {\n $o = \"a\" . substr($n, $y + 1);\n $m[$o] = \"s\";\n break;\n }\n }\n }\n}\n$p = array();\nfor($x = 0; $x < $k; $x++)\n{\n $n = $i[$x];\n for($y = 0; $y < strlen($n); $y++)\n {\n if($n[$y] == \"(\")\n {\n $o = \"a\" . trim(substr($n, 0, $y));\n $s = $y;\n }\n if($n[$y] == \")\")\n {\n $r = trim(substr($n, $s + 1, $y - $s - 1));\n $t = explode(\",\", $r);\n for($z = 0; $z < count($t); $z++)\n {\n $t[$z] = $m[\"a\" . trim($t[$z])];\n } \n $u = implode($t); \n }\n }\n $v = $o . \"(\" . $u . \")\";\n $p[$x] = $v;\n}\n$n = array();\n$o = array(\"i\", \"d\", \"s\");\n$s = array();\nfor($x = 0; $x < count($o); $x++)\n{\n $r = $o[$x];\n $s[$x] = $r; \n}\n$n[1] = $s;\n$s = array();\n$t = 0;\nfor($x = 0; $x < count($o); $x++)\n{\n for($y = 0; $y < count($o); $y++)\n {\n $r = $o[$x] . $o[$y];\n $s[$t] = $r;\n $t++;\n }\n}\n$n[2] = $s;\n$s = array();\n$t = 0;\nfor($x = 0; $x < count($o); $x++)\n{\n for($y = 0; $y < count($o); $y++)\n {\n for($z = 0; $z < count($o); $z++)\n {\n $r = $o[$x] . $o[$y] . $o[$z];\n $s[$t] = $r;\n $t++;\n }\n }\n}\n$n[3] = $s;\n$s = array();\n$t = 0;\nfor($x = 0; $x < count($o); $x++)\n{\n for($y = 0; $y < count($o); $y++)\n {\n for($z = 0; $z < count($o); $z++)\n {\n for($z2 = 0; $z2 < count($o); $z2++)\n {\n $r = $o[$x] . $o[$y] . $o[$z] . $o[$z2];\n $s[$t] = $r;\n $t++;\n }\n }\n }\n}\n$n[4] = $s;\n$s = array();\n$t = 0;\nfor($x = 0; $x < count($o); $x++)\n{\n for($y = 0; $y < count($o); $y++)\n {\n for($z = 0; $z < count($o); $z++)\n {\n for($z2 = 0; $z2 < count($o); $z2++)\n {\n for($z3 = 0; $z3 < count($o); $z3++)\n {\n $r = $o[$x] . $o[$y] . $o[$z] . $o[$z2] . $o[$z3];\n $s[$t] = $r;\n $t++;\n }\n }\n }\n }\n}\n$n[5] = $s;\n$u = array();\n$e = 0;\nfor($x = 0; $x < $c; $x++)\n{\n $v = $a[$x];\n $n2 = trim(substr($v, 4));\n for($y = 0; $y < strlen($n2); $y++)\n {\n if($n2[$y] == \"(\")\n {\n $o = \"a\" . trim(substr($n2, 0, $y));\n $s = $y;\n }\n if($n2[$y] == \")\")\n {\n $r = trim(substr($n2, $s + 1, $y - $s - 1));\n $t = explode(\",\", $r);\n $b = array();\n $c2 = 0;\n for($z = 0; $z < count($t); $z++)\n {\n if(trim($t[$z]) == \"int\")\n {\n $t[$z] = \"i\";\n }\n elseif(trim($t[$z]) == \"double\")\n {\n $t[$z] = \"d\";\n }\n elseif(trim($t[$z]) == \"string\")\n {\n $t[$z] = \"s\";\n }\n elseif(trim($t[$z]) == \"T\")\n {\n $t[$z] = \"T\";\n $b[$c2] = $z;\n $c2++;\n }\n } \n }\n }\n if(count($b) != 0)\n {\n $d = $n[count($b)];\n for($y = 0; $y < count($d); $y++)\n {\n $f = $d[$y];\n for($z = 0; $z < strlen($f); $z++)\n {\n $t[$b[$z]] = $f[$z];\n }\n $g = $t;\n $u2 = implode($g); \n $v = $o . \"(\" . $u2 . \")\";\n $u[$e] = $v; \n $e++; \n }\n }\n else\n {\n $u2 = implode($t); \n $v = $o . \"(\" . $u2 . \")\";\n $u[$e] = $v; \n $e++; \n } \n}\n$b = array();\nfor($x = 0; $x < count($u); $x++)\n{\n $b[$u[$x]]++;\n}\nfor($x = 0; $x < count($p) - 1; $x++)\n{\n if($b[$p[$x]] == TRUE)\n {\n print $b[$p[$x]] . \"\\n\";\n }\n else\n {\n print \"0\\n\";\n }\n}\nif($b[$p[$x]] == TRUE)\n{\n print $b[$p[$x]];\n}\nelse\n{\n print \"0\";\n}\n?>"}], "negative_code": [], "src_uid": "d5e3136b236f0e84ed6b88e43acd4205"} {"nl": {"description": "Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most ai milliliters of water.It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does.Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends.", "input_spec": "The first line of the input contains two integers, n and w (1\u2009\u2264\u2009n\u2009\u2264\u2009105, 1\u2009\u2264\u2009w\u2009\u2264\u2009109)\u00a0\u2014 the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109, 1\u2009\u2264\u2009i\u2009\u2264\u20092n)\u00a0\u2014\u00a0the capacities of Pasha's tea cups in milliliters.", "output_spec": "Print a single real number \u2014 the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10\u2009-\u20096.", "sample_inputs": ["2 4\n1 1 1 1", "3 18\n4 4 4 2 2 2", "1 5\n2 3"], "sample_outputs": ["3", "18", "4.5"], "notes": "NotePasha also has candies that he is going to give to girls but that is another task..."}, "positive_code": [{"source_code": "= $i)\n{\n print $i;\n}\nelse\n{\n print $b;\n}\n?>"}], "negative_code": [{"source_code": "= $i)\n{\n print $i;\n}\nelse\n{\n for($x = 1; $x <= 100000; $x++)\n {\n $g -= 0.5;\n $h -= 1;\n $i = number_format(($a * $g) + ($a * $h), 6, \".\", \"\");\n if($b >= $i)\n {\n print $i;\n break;\n }\n }\n}\n?>"}], "src_uid": "b2031a328d72b464f965b4789fd35b93"} {"nl": {"description": "Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1,\u2009a2,\u2009...,\u2009an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and changed their order, so now the sequence of numbers written on the cubes became equal to b1,\u2009b2,\u2009...,\u2009bn. Stepan said that he swapped only cubes which where on the positions between l and r, inclusive, and did not remove or add any other cubes (i. e. he said that he reordered cubes between positions l and r, inclusive, in some way).Your task is to determine if it is possible that Stepan said the truth, or it is guaranteed that Stepan deceived his brother.", "input_spec": "The first line contains three integers n, l, r (1\u2009\u2264\u2009n\u2009\u2264\u2009105, 1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n) \u2014 the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n) \u2014 the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1,\u2009b2,\u2009...,\u2009bn (1\u2009\u2264\u2009bi\u2009\u2264\u2009n) \u2014 the sequence of integers written on cubes after Stepan rearranged their order. It is guaranteed that Stepan did not remove or add other cubes, he only rearranged Vasya's cubes.", "output_spec": "Print \"LIE\" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print \"TRUTH\" (without quotes).", "sample_inputs": ["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1"], "sample_outputs": ["TRUTH", "LIE", "TRUTH"], "notes": "NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3 and 4 (after that the sequence of integers on cubes became equal to [3, 2, 3, 4, 1]).In the second example it is not possible that Stepan said truth because he said that he swapped cubes only between positions 1 and 2, but we can see that it is guaranteed that he changed the position of the cube which was on the position 3 at first. So it is guaranteed that Stepan deceived his brother.In the third example for any values l and r there is a situation when Stepan said the truth."}, "positive_code": [{"source_code": "= $l-1 && $i <= $r-1) {\n $checka[] = (int)$arra[$i];\n //printf(\"%d \",(int)$arra[$i]);\n }\n}\nfor($i=0;$i<$n;++$i)\n{\n if ($i >= $l-1 && $i <= $r-1) {\n $checkb[] = (int)$arrb[$i];\n }\n else {\n if ($arra[$i] != $arrb[$i]) $flag = 1;\n }\n}\n\nsort ($checka);\nsort($checkb);\nfor($i=0;$i<$r-$l+1;++$i) {\n //printf(\"%d \",$checka[$i]);\n if ($checka[$i] != $checkb[$i]) $flag = 1;\n}\nif ($flag == 0) {\n printf(\"TRUTH\");\n}\nelse {\n printf(\"LIE\");\n}\n?>\n"}, {"source_code": " "}, {"source_code": " $r) {\n if ($a[$i] != $b[$i]) {\n $ok = false;\n break;\n }\n }\n}\n\nif ($ok) {\n echo \"TRUTH\";\n}\nelse {\n echo \"LIE\";\n}\n\n?>\n"}, {"source_code": " "}, {"source_code": "= $L && $i <= $R){\n $box1[ (int)$arr[0][$i] ]++;\n $box2[ (int)$arr[1][$i] ]++;\n }else if( $arr[0][$i] != $arr[1][$i] ){\n printf(\"LIE\\n\");\n return;\n }\n}\nif( count( $box1 ) != count( $box2 ) ){\n printf(\"LIE\\n\");\n return;\n}\n\nforeach( $box1 as $i => $v){\n //printf(\"(%d, %d) vs (%d, %d)\\n\", $i, $v, $i, $box1[$i]);\n if( $v != $box2[$i] ){\n printf(\"LIE\\n\");\n return;\n }\n}\nprintf(\"TRUTH\\n\");\n\n?>\n"}, {"source_code": ""}, {"source_code": " "}, {"source_code": " = $l && $x <= $r){\n $ar[$cur]++;\n }else{\n $a[] = $cur;\n }\n }\n\n for($x=1;$x<=$n;$x++){\n $cur = (int)$line3[$x - 1];\n \n if($x >= $l && $x <= $r){\n $ar[$cur]--;\n }else{\n $b[] = $cur;\n }\n }\n \n for ($i = 0 ; $i - 2 < $n ; ++$i) {\n if($ar[$i] != 0) $flag = 0;\n }\n for($i = 0 ; $i < count($a) ; ++$i){\n if($a[$i] != $b[$i]) $flag = 0;\n }\n\n $ans = \"LIE\";\n if($flag == 1){\n $ans = \"TRUTH\";\n }\n echo $ans;\n \n ?> "}, {"source_code": ""}, {"source_code": ""}, {"source_code": "=$r) {\n if((int)$a[$i]!=(int)$b[$i]) $ans = false;\n }\n }\n \n //print_r($a);\n //print_r(array($l, $r));\n \n if($ans) printf(\"TRUTH\");\n else printf(\"LIE\");\n?>"}, {"source_code": " $value) {\n$arr1[$key] = (int) $value;\n}\nforeach ($arr2 as $key => $value) {\n$arr2[$key] = (int) $value;\n}\n $a = array_slice($arr1, 0, $l-1);\n $b = array_slice($arr2, 0, $l-1);\n $a2 = array_slice($arr1, $r, count($arr1)-$r);\n $b2 = array_slice($arr2, $r, count($arr1)-$r);\n $a1 = array_slice($arr1, $l-1, $r-$l+1);\n $b1 = array_slice($arr2, $l-1, $r-$l+1);\n sort($a1);\n sort($b1);\n\n if ($a1 == $b1 and $a == $b and $a2 == $b2) {\n echo \"TRUTH\";\n } else {\n echo \"LIE\";\n }\n?> \n"}, {"source_code": ""}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\n$a = fgets($stdin);\n$t = explode(\" \", $a);\n$n = $t[0] + 0;\n$l = $t[1] - 1;\n$r = $t[2] - 1;\n\n$a = fgets($stdin);\n$a = explode(\" \", $a);\n\n$b = fgets($stdin);\n$b = explode(\" \", $b);\n\n\n$stdout = fopen('php://stdout', 'w');\n\n\nfor($i = 0; $i < $n; $i++){\n if($a[$i] != $b[$i]){\n if($i < $l || $i > $r){\n fwrite($stdout, \"LIE\");\n die();\n }\n }\n}\n\n\nfwrite($stdout, \"TRUTH\");\n\n\n\nfclose($stdout);"}, {"source_code": " \n"}, {"source_code": "= $l && $i <= $r) {\n\t\tif (!array_key_exists($x, $cnts)) {\n\t\t\t$cnts[$x] = 0;\n\t\t}\n\t\t$cnts[$x] += 1;\n\t}\n}\n\n$b = explode(\" \", trim(fgets($fl)));\nfor ($i = 1; $i <= $n; ++$i) {\n\t$x = intval($b[$i - 1]);\n\tif ($i >= $l && $i <= $r) {\n\t\tif (!array_key_exists($x, $cnts) || $cnts[$x] == 0) {\n\t\t\techo \"LIE\";\n\t\t\tdie();\n\t\t} else {\n\t\t\t$cnts[$x] -= 1;\n\t\t}\n\t} else {\n\t\tif ($x != intval($a[$i - 1])) {\n\t\t\techo \"LIE\";\n\t\t\tdie();\n\t\t}\n\t}\n}\n\necho \"TRUTH\";\n?>\n"}], "negative_code": [{"source_code": "= $l-1 && $i <= $r-1) {\n $checka[] = (int)$arra[$i];\n //printf(\"%d \",(int)$arra[$i]);\n }\n}\nfor($i=0;$i<$n;++$i)\n{\n if ($i >= $l-1 && $i <= $r-1) {\n $checkb[] = (int)$arrb[$i];\n }\n}\nsort ($checka);\nsort($checkb);\nfor($i=0;$i<$r-$l+1;++$i) {\n //printf(\"%d \",$checka[$i]);\n if ($checka[$i] != $checkb[$i]) $flag = 1;\n}\nif ($flag == 0) {\n printf(\"TRUTH\");\n}\nelse {\n printf(\"LIE\");\n}\n?>\n"}, {"source_code": "= l-1 && $i <= r-1) {\n $checka[$arra[$i]]++;\n }\n}\nfor($i=0;$i<$n;++$i)\n{\n if ($i >= l-1 && $i <= r-1) {\n $checkb[$arrb[$i]]++;\n }\n}\nfor($i=0;$i<100001;++$i) {\n if ($checka[$i] != $checkb[$i]) $flag = 1;\n}\nif (!$flag) {\n printf(\"TRUTH\");\n}\nelse {\n printf(\"LIE\");\n}\n?>\n"}, {"source_code": "= $L && $i <= $R){\n $box[0][ $arr[0][$i] ]++;\n $box[1][ $arr[1][$i] ]++;\n }else if( $arr[0][$i] != $arr[1][$i] ){\n printf(\"LIE\\n\");\n return;\n }\n}\nif( count( $box[0] ) != count( $box[1] ) ){\n printf(\"LIE\\n\");\n return;\n}\n\nforeach( $box[0] as $i => $v){\n //printf(\"(%d, %d) vs (%d, %d)\\n\", $i, $v, $i, $box[1][$i]);\n if( $v != $box[1][$i] ){\n printf(\"LIE\\n\");\n return;\n }\n}\nprintf(\"TRUTH\\n\");\n\n?>\n"}, {"source_code": " = $l && $x <= $r)\n $ar[$cur]++;\n }\n\n for($x=1;$x<=$n;$x++){\n $cur = (int)$line3[$x - 1];\n \n if($x >= $l && $x <= $r){\n $ar[$cur]--;\n }\n }\n \n for ($i = 0 ; $i - 2 < $n ; ++$i) {\n if($ar[$i] != 0) $flag = 0;\n }\n\n $ans = \"LIE\";\n if($flag == 1){\n $ans = \"TRUTH\";\n }\n echo $ans;\n \n ?> "}, {"source_code": " = $l && $x <= $r)\n $ar[$cur]++;\n }\n\n for($x=1;$x<=$n;$x++){\n $cur = (int)$line3[$x - 1];\n \n if($x >= $l && $x <= $r){\n $ar[$cur]--;\n }\n }\n \n foreach ($ar as $key => $value) {\n if($value != 0) $flag = 0;\n }\n\n $ans = \"LIE\";\n if($flag == 1){\n $ans = \"TRUTH\";\n }\n echo $ans;\n \n ?> "}, {"source_code": ""}, {"source_code": "= $l && $i <= $r) {\n\t\tif (!array_key_exists($x, $cnts)) {\n\t\t\t$cnts[$x] = 0;\n\t\t}\n\t\t$cnts[$x] += 1;\n\t}\n}\n\n$a = explode(\" \", trim(fgets($fl)));\nfor ($i = 1; $i <= $n; ++$i) {\n\t$x = intval($a[$i - 1]);\n\tif ($i >= $l && $i <= $r) {\n\t\tif (!array_key_exists($x, $cnts) || $cnts[$x] == 0) {\n\t\t\techo \"LIE\";\n\t\t\tdie();\n\t\t} else {\n\t\t\t$cnts[$x] -= 1;\n\t\t}\n\t}\n}\n\necho \"TRUTH\";\n?>\n"}], "src_uid": "1951bf085050c7e32fcf713132b30605"} {"nl": {"description": "There are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.We are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\u2009\u2264\u2009i\u2009\u2264\u2009n\u2009-\u20091), such that ai\u2009+\u20091\u2009>\u2009ai.", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the number of painting. The second line contains the sequence a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20091000), where ai means the beauty of the i-th painting.", "output_spec": "Print one integer\u00a0\u2014 the maximum possible number of neighbouring pairs, such that ai\u2009+\u20091\u2009>\u2009ai, after the optimal rearrangement.", "sample_inputs": ["5\n20 30 10 50 40", "4\n200 100 100 200"], "sample_outputs": ["4", "2"], "notes": "NoteIn the first sample, the optimal order is: 10,\u200920,\u200930,\u200940,\u200950.In the second sample, the optimal order is: 100,\u2009200,\u2009100,\u2009200."}, "positive_code": [{"source_code": ""}, {"source_code": " 0) {\n\t\n\t$b = array_unique($a);\n\tsort($b);\n\n\tfor ($i=0; $i < count($b); $i++) { \n\t\tunset($a[array_search($b[$i], $a)]);\n\t}\n\n\t$c = array_merge($c, $b);\n}\n\nfor ($i=1; $i < count($c); $i++) { \n\tif ($c[$i] > $c[$i-1]) $m++;\n}\n\nprint $m;\n?>"}], "negative_code": [], "src_uid": "30ad5bdc019fcd8a4e642c90decca58f"} {"nl": {"description": "Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer ai\u00a0\u2014 number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole minute. Vitalya will definitely wake up if during some m consecutive minutes at least k alarm clocks will begin ringing. Pay attention that Vitalya considers only alarm clocks which begin ringing during given period of time. He doesn't consider alarm clocks which started ringing before given period of time and continues ringing during given period of time.Vitalya is so tired that he wants to sleep all day long and not to wake up. Find out minimal number of alarm clocks Vitalya should turn off to sleep all next day. Now all alarm clocks are turned on. ", "input_spec": "First line contains three integers n, m and k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105, 1\u2009\u2264\u2009m\u2009\u2264\u2009106)\u00a0\u2014 number of alarm clocks, and conditions of Vitalya's waking up. Second line contains sequence of distinct integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009106) in which ai equals minute on which i-th alarm clock will ring. Numbers are given in arbitrary order. Vitalya lives in a Berland in which day lasts for 106 minutes. ", "output_spec": "Output minimal number of alarm clocks that Vitalya should turn off to sleep all next day long.", "sample_inputs": ["3 3 2\n3 5 1", "5 10 3\n12 8 18 25 1", "7 7 2\n7 3 4 1 6 5 2", "2 2 2\n1 3"], "sample_outputs": ["1", "0", "6", "0"], "notes": "NoteIn first example Vitalya should turn off first alarm clock which rings at minute 3.In second example Vitalya shouldn't turn off any alarm clock because there are no interval of 10 consequence minutes in which 3 alarm clocks will ring.In third example Vitalya should turn off any 6 alarm clocks."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "1241e23684a5cf95eca085a77f6483ad"} {"nl": {"description": "As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number fi, where 1\u2009\u2264\u2009fi\u2009\u2264\u2009n and fi\u2009\u2260\u2009i.We call a love triangle a situation in which plane A likes plane B, plane B likes plane C and plane C likes plane A. Find out if there is any love triangle on Earth.", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20095000)\u00a0\u2014 the number of planes. The second line contains n integers f1,\u2009f2,\u2009...,\u2009fn (1\u2009\u2264\u2009fi\u2009\u2264\u2009n, fi\u2009\u2260\u2009i), meaning that the i-th plane likes the fi-th.", "output_spec": "Output \u00abYES\u00bb if there is a love triangle consisting of planes on Earth. Otherwise, output \u00abNO\u00bb. You can output any letter in lower case or in upper case.", "sample_inputs": ["5\n2 4 5 1 3", "5\n5 5 5 5 1"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn first example plane 2 likes plane 4, plane 4 likes plane 1, plane 1 likes plane 2 and that is a love triangle.In second example there are no love triangles."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "a37c3f2828490c70301b5b5deeee0f88"} {"nl": {"description": "Stepan has a set of n strings. Also, he has a favorite string s. Stepan wants to do the following. He will take some strings of his set and write them down one after another. It is possible that he will take some strings more than once, and will not take some of them at all.Your task is to determine the minimum number of strings in the set which Stepan needs to take and write so that the string s appears as a subsequence in the resulting written down string. For example, in the string \"abcd\" strings \"ad\", \"acd\", \"abcd\" appear as subsequences, and strings \"ba\", \"abdc\" don't appear as subsequences. ", "input_spec": "The first line contains the integer n (1\u2009\u2264\u2009n\u2009\u2264\u200950) \u2014 the number of strings in Stepan's set. The next n lines contain n non-empty strings consisting of lowercase letters of the English alphabet. The length of each of these strings does not exceed 50 symbols. It is possible that some strings from Stepan's set are the same. The next line contains the non-empty string s, consisting of lowercase letters of the English alphabet \u2014 Stepan's favorite string. The length of this string doesn't exceed 2500 symbols.", "output_spec": "Print the minimum number of strings which Stepan should take from the set and write them down one after another so that the string s appears as a subsequence in the resulting written down string. Each string from the set should be counted as many times as Stepan takes it from the set. If the answer doesn't exsist, print -1.", "sample_inputs": ["3\na\naa\na\naaa", "4\nab\naab\naa\nbb\nbaaab", "2\naaa\nbbb\naaacbbb"], "sample_outputs": ["2", "3", "-1"], "notes": "NoteIn the first test, Stepan can take, for example, the third and the second strings from the set, write them down, and get exactly his favorite string.In the second example Stepan can take, for example, the second, the third and again the second strings from the set and write them down. Then he will get a string \"aabaaaab\", in which his favorite string \"baaab\" is a subsequence.In the third test Stepan can not get his favorite string, because it contains the letter \"c\", which is not presented in any of the strings in the set."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "e01057d9128ff0843cee577673016039"} {"nl": {"description": "Gerald plays the following game. He has a checkered field of size n\u2009\u00d7\u2009n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n\u2009-\u20091 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original edge to the opposite edge. Gerald loses in this game in each of the three cases: At least one of the chips at least once fell to the banned cell. At least once two chips were on the same cell. At least once two chips swapped in a minute (for example, if you stand two chips on two opposite border cells of a row with even length, this situation happens in the middle of the row). In that case he loses and earns 0 points. When nothing like that happened, he wins and earns the number of points equal to the number of chips he managed to put on the board. Help Gerald earn the most points.", "input_spec": "The first line contains two space-separated integers n and m (2\u2009\u2264\u2009n\u2009\u2264\u20091000, 0\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009n) \u2014 the coordinates of the i-th banned cell. All given cells are distinct. Consider the field rows numbered from top to bottom from 1 to n, and the columns \u2014 from left to right from 1 to n.", "output_spec": "Print a single integer \u2014 the maximum points Gerald can earn in this game.", "sample_inputs": ["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"], "sample_outputs": ["0", "1", "1"], "notes": "NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4)."}, "positive_code": [{"source_code": " $f)\n {\n $o = $g - $f;\n if($d[$f] == FALSE)\n {\n $d[$f] = $g;\n $d2[$f] = $o;\n }\n else\n {\n if($o < $d2[$f])\n {\n $d[$f] = $g;\n $d2[$f] = $o;\n }\n }\n }\n}\nksort($c);\nfor($x = 1; $x <= $a; $x++)\n{\n if($c[$x] == TRUE)\n {\n $c2 = $c[$x];\n sort($c2);\n $c[$x] = $c2;\n }\n}\nksort($d);\n$p = array();\nfor($x = 1; $x <= 1; $x++)\n{\n $h = 0;\n $i = 1;\n $j = $x;\n $m = 0;\n while(TRUE)\n {\n if($i == $a + 1)\n {\n break;\n }\n else\n {\n if($j == $a + 1)\n {\n $j = 1;\n }\n if($c[$j] == TRUE)\n {\n if($d[$j] < $j)\n {\n $n = $a - $j + $d[$j];\n }\n elseif($d[$j] > $j)\n {\n $n = $d[$j] - $j;\n }\n $k = ((count($c[$j]) - 1) * $a) + $n + $m;\n $p[$j] = ((count($c[$j]) - 1) * $a) + $n;\n if($k > $h)\n {\n $h = $k;\n }\n }\n $m++;\n }\n $i++;\n $j++;\n }\n $e .= $h . \" \";\n}\nfor($x = 2; $x <= $a; $x++)\n{\n $h--;\n if($p[$x - 1] == TRUE)\n {\n if($d[$x - 1] < $x - 1)\n {\n $t = $a - ($x - 1) + $d[$x - 1];\n }\n elseif($d[$x - 1] > $x - 1)\n {\n $t = $d[$x - 1] - ($x - 1);\n }\n $s = ($a - 1) + ((count($c[$x - 1]) - 1) * $a) + $t;\n if($s > $h)\n {\n $h = $s;\n }\n }\n $e .= $h . \" \";\n}\nprint $e;\n?>"}], "negative_code": [], "src_uid": "ecda736a0caa924ebd5f8f133586d542"} {"nl": {"description": "This problem is same as the next one, but has smaller constraints.Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.For each of the $$$n$$$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $$$i$$$-th day has a ribbon with color $$$u_i$$$. Shiro wants to know the largest number $$$x$$$, such that if we consider the streak of the first $$$x$$$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $$$x - 1$$$ will have the same number of occurrences.For example, consider the following sequence of $$$u_i$$$: $$$[2, 2, 1, 1, 5, 4, 4, 5]$$$. Then $$$x = 7$$$ makes a streak, since if we remove the leftmost $$$u_i = 5$$$, each ribbon color will appear exactly twice in the prefix of $$$x - 1$$$ days. Note that $$$x = 8$$$ doesn't form a streak, since you must remove exactly one day. Since Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the total number of days. The second line contains $$$n$$$ integers $$$u_1, u_2, \\ldots, u_n$$$ ($$$1 \\leq u_i \\leq 10$$$)\u00a0\u2014 the colors of the ribbons the cats wear. ", "output_spec": "Print a single integer $$$x$$$\u00a0\u2014 the largest possible streak of days.", "sample_inputs": ["13\n1 1 1 2 2 2 3 3 3 4 4 4 5", "5\n10 2 5 4 1", "1\n10", "7\n3 2 1 1 4 5 1", "6\n1 1 1 2 2 2"], "sample_outputs": ["13", "5", "1", "6", "5"], "notes": "NoteIn the first example, we can choose the longest streak of $$$13$$$ days, since upon removing the last day out of the streak, all of the remaining colors $$$1$$$, $$$2$$$, $$$3$$$, and $$$4$$$ will have the same number of occurrences of $$$3$$$. Note that the streak can also be $$$10$$$ days (by removing the $$$10$$$-th day from this streak) but we are interested in the longest streak.In the fourth example, if we take the streak of the first $$$6$$$ days, we can remove the third day from this streak then all of the remaining colors $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$ and $$$5$$$ will occur exactly once."}, "positive_code": [{"source_code": ""}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? ($n == 1 ? 1 : $ans+1) : $ans+1);\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": "= 0; $x--)\n {\n if(max($c) - min($c) == 0)\n {\n print $x + 2;\n break;\n }\n elseif(max($c) - min($c) == 1)\n {\n print $x + 1;\n break;\n }\n $c[$b[$x]]--;\n if($c[$b[$x]] == 0)\n {\n unset($c[$b[$x]]);\n }\n }\n }\n }\n elseif(max($c) - min($c) == 1)\n {\n print $a;\n }\n else\n {\n for($x = $a - 1; $x >= 0; $x--)\n {\n if(max($c) - min($c) == 0)\n {\n print $x + 2;\n break;\n }\n elseif(max($c) - min($c) == 1)\n {\n print $x + 1;\n break;\n }\n $c[$b[$x]]--;\n if($c[$b[$x]] == 0)\n {\n unset($c[$b[$x]]);\n }\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $d[$c[$b[$x]] - 1]--;\n if($d[$c[$b[$x]] - 1] == 0)\n {\n unset($d[$c[$b[$x]] - 1]);\n }\n }\n if(count($d) == 1)\n {\n $e = reset($d);\n $f = key($d);\n if($e == 2)\n {\n $i = $e * $f - $e + 1;\n }\n else\n {\n $i = $e * $f - $f + 1;\n }\n }\n elseif(count($d) == 2)\n {\n $e = reset($d);\n $f = key($d);\n $g = next($d);\n $h = key($d);\n if($h == 1)\n {\n $i = $e * $f + 1;\n }\n elseif(abs($f - $h) == 1)\n {\n $i = $e * $f + $g * $h;\n }\n }\n}\nprint $i;\n?>"}, {"source_code": " 1)\n {\n $d[$c[$b[$x]] - 1]--;\n if($d[$c[$b[$x]] - 1] == 0)\n {\n unset($d[$c[$b[$x]] - 1]);\n }\n }\n if(count($d) == 1)\n {\n $e = reset($d);\n $f = key($d);\n if($e == 2)\n {\n $i = $e * $f - $e + 1;\n }\n else\n {\n $i = $e * $f - $f + 1;\n }\n }\n elseif(count($d) == 2)\n {\n $e = reset($d);\n $f = key($d);\n $g = next($d);\n $h = key($d);\n if(abs($f - $h) == 1)\n {\n $i = $e * $f + $g * $h;\n }\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n {\n if(max($c) - min($c) == 0)\n {\n print $x + 2;\n break;\n }\n elseif(max($c) - min($c) == 1)\n {\n print $x + 1;\n break;\n }\n $c[$b[$x]]--;\n if($c[$b[$x]] == 0)\n {\n unset($c[$b[$x]]);\n }\n }\n }\n}\nelseif(max($c) - min($c) == 1)\n{\n print $a;\n}\nelse\n{\n for($x = $a - 1; $x >= 0; $x--)\n {\n if(max($c) - min($c) == 0)\n {\n print $x + 2;\n break;\n }\n elseif(max($c) - min($c) == 1)\n {\n print $x + 1;\n break;\n }\n $c[$b[$x]]--;\n if($c[$b[$x]] == 0)\n {\n unset($c[$b[$x]]);\n }\n }\n}\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? ($n == 1 ? 1 : $ans) : $ans+1);\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? ($n == 1 ? 1 : $ans) : $ans+1);\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo $ans+1;\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? ($n == 1 ? 1 : $ans) : $ans+1);\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? ($n == 1 ? 1 : $ans) : $ans+1);\n?>"}, {"source_code": "= $ans && $t){\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\t//print_r($cur);\n\techo (count($cur) == 1 ? $ans : $ans+1);\n?>"}], "src_uid": "2d020e6c3000836e8b903a12ae39dd9b"} {"nl": {"description": "Currently Tiny is learning Computational Geometry. When trying to solve a problem called \"The Closest Pair Of Points In The Plane\", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.The problem is the follows. Given n points in the plane, find a pair of points between which the distance is minimized. Distance between (x1,\u2009y1) and (x2,\u2009y2) is .The pseudo code of the unexpected code is as follows:input nfor i from 1 to n input the i-th point's coordinates into p[i]sort array p[] by increasing of x coordinate first and increasing of y coordinate secondd=INF //here INF is a number big enoughtot=0for i from 1 to n for j from (i+1) to n ++tot if (p[j].x-p[i].x>=d) then break //notice that \"break\" is only to be //out of the loop \"for j\" d=min(d,distance(p[i],p[j]))output dHere, tot can be regarded as the running time of the code. Due to the fact that a computer can only run a limited number of operations per second, tot should not be more than k in order not to get Time Limit Exceeded.You are a great hacker. Would you please help Tiny generate a test data and let the code get Time Limit Exceeded?", "input_spec": "A single line which contains two space-separated integers n and k (2\u2009\u2264\u2009n\u2009\u2264\u20092000, 1\u2009\u2264\u2009k\u2009\u2264\u2009109).", "output_spec": "If there doesn't exist such a data which let the given code get TLE, print \"no solution\" (without quotes); else print n lines, and the i-th line contains two integers xi,\u2009yi (|xi|,\u2009|yi|\u2009\u2264\u2009109) representing the coordinates of the i-th point. The conditions below must be held: All the points must be distinct. |xi|,\u2009|yi|\u2009\u2264\u2009109. After running the given code, the value of tot should be larger than k. ", "sample_inputs": ["4 3", "2 100"], "sample_outputs": ["0 0\n0 1\n1 0\n1 1", "no solution"], "notes": null}, "positive_code": [{"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$x]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "$v)\n{\n if($check==0)\n {\n $last=$v;\n $check=1;\n }else\n {\n $map[$k]+=$last;\n $last=$map[$k];\n }\n}$mapt=[];\nforeach ($map as $k=>$v)\n{\n $mapt[]=$k;\n}\nfor ($i=0;$i<$t[1];$i++)\n{\n $check=0;\n $left = 0;\n $right = sizeof($mapt) - 1;\n\n $count = 0;\n while ($left <= $right) {\n $mid =(int) (($right + $left) / 2);\n\n if ($mapt[$mid] <= $b[$i]) {\n $count = $mid + 1;\n $left = $mid + 1;\n }\n else\n $right = $mid - 1;\n }\n if($count==0)\n {\n echo '0'.\" \";\n }else\n {\n echo $map[$mapt[$count-1]].\" \";\n }\n}"}], "negative_code": [{"source_code": "= $c[$j]) && ($j == $a - 1))\n {\n $i++;\n $j++;\n $g[$f[$h]] = $i;\n break;\n }\n elseif($d[$h] >= $c[$j])\n {\n $i++;\n $j++;\n }\n else\n {\n $g[$f[$h]] = $i;\n $h++;\n }\n if($h == $b)\n {\n break;\n }\n}\nksort($g);\nif($a == 107329)\n{\n $k = array_slice($g, 4900, 50);\n print implode(\" \", $k);\n}\nelse\n{\n print implode(\" \", $g);\n}\n?>"}, {"source_code": "= $c[$j]) && ($j == $a - 1))\n {\n $i++;\n $j++;\n $g[$f[$h]] = $i;\n break;\n }\n elseif($d[$h] >= $c[$j])\n {\n $i++;\n $j++;\n }\n else\n {\n $g[$f[$h]] = $i;\n $h++;\n }\n if($h == $b)\n {\n break;\n }\n}\nksort($g);\nprint implode(\" \", $g);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nif($a == 107329)\n{\n $k = array_slice($g, 4900, 50);\n print implode(\" \", $k);\n}\nelse\n{\n print implode(\" \", $f);\n}\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$j]) && ($j == $a - 1))\n {\n $i++;\n $j++;\n $g[$f[$h]] = $i;\n break;\n }\n elseif($d[$h] >= $c[$j])\n {\n $i++;\n $j++;\n }\n else\n {\n $g[$f[$h]] = $i;\n $h++;\n }\n if($h == $b)\n {\n break;\n }\n}\nksort($g);\nif($a == 10739)\n{\n $k = array_slice($g, 4900, 50);\n print implode(\" \", $k);\n}\nelse\n{\n print implode(\" \", $g);\n}\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nif($a == 107329)\n{\n $j = array_slice($f, 4900, 50);\n print implode(\" \", $k);\n}\nelse\n{\n print implode(\" \", $f);\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n if($a != 10739)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nif($a == 10739)\n{\n $j = array_slice($f, 4900, 50);\n print_r($j);\n}\nelse\n{\n print implode(\" \", $f);\n}\n?>"}, {"source_code": "= $c[$j]) && ($j == $a - 1))\n {\n $i++;\n $j++;\n $g[$f[$h]] = $i;\n break;\n }\n elseif($d[$h] >= $c[$j])\n {\n $i++;\n $j++;\n }\n else\n {\n $g[$f[$h]] = $i;\n $h++;\n }\n if($h == $b)\n {\n break;\n }\n}\nksort($g);\nif($a == 10739)\n{\n print count($g);\n}\nelse\n{\n print implode(\" \", $g);\n}\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n if($a != 10739)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nprint implode(\" \", $f);\n?>"}, {"source_code": "= $c[$h])\n {\n $g++;\n $h++;\n if($h == $a)\n {\n for($x = $i; $x < $b; $x++)\n {\n $f[$e[$i]] = $g;\n }\n break;\n }\n }\n else\n {\n $f[$e[$i]] = $g;\n $i++;\n if($i == $b)\n {\n break;\n }\n }\n}\nksort($f);\nif($a == 107329)\n{\n $j = array_slice($f, 4900, 50);\n print_r($j);\n}\nelse\n{\n print implode(\" \", $f);\n}\n?>"}, {"source_code": "$v)\n{\n if($check==0)\n {\n $last=$v;\n $check=1;\n }else\n {\n $map[$k]+=$last;\n $last=$map[$k];\n }\n}\nkrsort($map);\nfor ($i=0;$i<$t[1];$i++)\n{\n foreach ($map as $k=>$m)\n {\n if($k<=$b[$i])\n {\n echo $m.\" \";\n break;\n }\n }\n}"}, {"source_code": "$v)\n{\n if($check==0)\n {\n $last=$v;\n $check=1;\n }else\n {\n $map[$k]+=$last;\n $last=$map[$k];\n }\n}\nkrsort($map);\nfor ($i=0;$i<$t[1];$i++)\n{\n $check=0;\n foreach ($map as $k=>$m)\n {\n if($k<=$b[$i])\n {\n echo $m.\" \";\n $check=1;\n break;\n }\n }\n if($check==0)\n {\n echo '0'.\" \";\n }\n}"}, {"source_code": "$v)\n{\n if($check==0)\n {\n $last=$v;\n $check=1;\n }else\n {\n $map[$k]+=$last;\n $last=$map[$k];\n }\n}\nkrsort($map);\nvar_dump($map);\nfor ($i=0;$i<$t[1];$i++)\n{\n $check=0;\n foreach ($map as $k=>$m)\n {\n if($k<=$b[$i])\n {\n echo $m.\" \";\n $check=1;\n break;\n }\n }\n if($check==0)\n {\n echo '0'.\" \";\n }\n}"}], "src_uid": "e9a519be33f25c828bae787330c18dd4"} {"nl": {"description": "Vasya has a string $$$s$$$ of length $$$n$$$. He decides to make the following modification to the string: Pick an integer $$$k$$$, ($$$1 \\leq k \\leq n$$$). For $$$i$$$ from $$$1$$$ to $$$n-k+1$$$, reverse the substring $$$s[i:i+k-1]$$$ of $$$s$$$. For example, if string $$$s$$$ is qwer and $$$k = 2$$$, below is the series of transformations the string goes through: qwer (original string) wqer (after reversing the first substring of length $$$2$$$) weqr (after reversing the second substring of length $$$2$$$) werq (after reversing the last substring of length $$$2$$$) Hence, the resulting string after modifying $$$s$$$ with $$$k = 2$$$ is werq. Vasya wants to choose a $$$k$$$ such that the string obtained after the above-mentioned modification is lexicographically smallest possible among all choices of $$$k$$$. Among all such $$$k$$$, he wants to choose the smallest one. Since he is busy attending Felicity 2020, he asks for your help.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if and only if one of the following holds: $$$a$$$ is a prefix of $$$b$$$, but $$$a \\ne b$$$; in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$b$$$. ", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 5000$$$). The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 5000$$$)\u00a0\u2014 the length of the string $$$s$$$. The second line of each test case contains the string $$$s$$$ of $$$n$$$ lowercase latin letters. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$.", "output_spec": "For each testcase output two lines: In the first line output the lexicographically smallest string $$$s'$$$ achievable after the above-mentioned modification. In the second line output the appropriate value of $$$k$$$ ($$$1 \\leq k \\leq n$$$) that you chose for performing the modification. If there are multiple values of $$$k$$$ that give the lexicographically smallest string, output the smallest value of $$$k$$$ among them.", "sample_inputs": ["6\n4\nabab\n6\nqwerty\n5\naaaaa\n6\nalaska\n9\nlfpbavjsm\n1\np"], "sample_outputs": ["abab\n1\nertyqw\n3\naaaaa\n1\naksala\n6\navjsmbpfl\n5\np\n1"], "notes": "NoteIn the first testcase of the first sample, the string modification results for the sample abab are as follows : for $$$k = 1$$$ : abab for $$$k = 2$$$ : baba for $$$k = 3$$$ : abab for $$$k = 4$$$ : babaThe lexicographically smallest string achievable through modification is abab for $$$k = 1$$$ and $$$3$$$. Smallest value of $$$k$$$ needed to achieve is hence $$$1$$$. "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "f501e17271a220f3bcd69377c01721a1"} {"nl": {"description": "Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!To compose a story, Stephen wrote out $$$n$$$ words consisting of the first $$$5$$$ lowercase letters of the Latin alphabet. He wants to select the maximum number of words to make an interesting story.Let a story be a sequence of words that are not necessarily different. A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.For example, the story consisting of three words \"bac\", \"aaada\", \"e\" is interesting (the letter 'a' occurs $$$5$$$ times, all other letters occur $$$4$$$ times in total). But the story consisting of two words \"aba\", \"abcde\" is not (no such letter that it occurs more than all other letters in total).You are given a sequence of $$$n$$$ words consisting of letters 'a', 'b', 'c', 'd' and 'e'. Your task is to choose the maximum number of them to make an interesting story. If there's no way to make a non-empty story, output $$$0$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 5000$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of the words in the sequence. Then $$$n$$$ lines follow, each of them contains a word \u2014 a non-empty string consisting of lowercase letters of the Latin alphabet. The words in the sequence may be non-distinct (i.\u2009e. duplicates are allowed). Only the letters 'a', 'b', 'c', 'd' and 'e' may occur in the words. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \\cdot 10^5$$$; the sum of the lengths of all words over all test cases doesn't exceed $$$4 \\cdot 10^5$$$.", "output_spec": "For each test case, output the maximum number of words that compose an interesting story. Print 0 if there's no way to make a non-empty interesting story.", "sample_inputs": ["6\n3\nbac\naaada\ne\n3\naba\nabcde\naba\n2\nbaba\nbaba\n4\nab\nab\nc\nbc\n5\ncbdca\nd\na\nd\ne\n3\nb\nc\nca"], "sample_outputs": ["3\n2\n0\n2\n3\n2"], "notes": "NoteIn the first test case of the example, all $$$3$$$ words can be used to make an interesting story. The interesting story is \"bac aaada e\".In the second test case of the example, the $$$1$$$-st and the $$$3$$$-rd words can be used to make an interesting story. The interesting story is \"aba aba\". Stephen can't use all three words at the same time.In the third test case of the example, Stephen can't make a non-empty interesting story. So the answer is $$$0$$$.In the fourth test case of the example, Stephen can use the $$$3$$$-rd and the $$$4$$$-th words to make an interesting story. The interesting story is \"c bc\"."}, "positive_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $m = [];\r\n $counter = 0;\r\n while($n > 0) {\r\n $n--;\r\n $a[$counter] = ['all' => 0];\r\n foreach (str_split(IO::str()) as $v) {\r\n if (isset($m[$v])) {\r\n $m[$v] += 1;\r\n } else {\r\n $m[$v] = 1;\r\n }\r\n if (isset($a[$counter][$v])) {\r\n $a[$counter][$v] += 1;\r\n } else {\r\n $a[$counter][$v] = 1;\r\n }\r\n $a[$counter]['all'] += 1;\r\n }\r\n $counter++;\r\n }\r\n\r\n $result = [];\r\n foreach ($m as $key => $valll) {\r\n $tt = [];\r\n foreach ($a as $word) {\r\n $tf = 0;\r\n if (isset($word[$key])) {\r\n $tf = $word[$key];\r\n }\r\n $tt[] = $tf - ($word['all'] - $tf);\r\n }\r\n rsort($tt);\r\n $res = 0;\r\n $value = 0;\r\n foreach ($tt as $vv) {\r\n $value += $vv;\r\n if ($value > 0) {\r\n $res++;\r\n } else {\r\n break;\r\n }\r\n }\r\n $result[] = $res;\r\n }\r\n\r\n IO::line(max($result));\r\n\r\n\r\n}\r\n\r\n\r\n?>"}], "negative_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $m = [];\r\n $counter = 0;\r\n while($n > 0) {\r\n $n--;\r\n $a[$counter] = ['all' => 0];\r\n foreach (str_split(IO::str()) as $v) {\r\n if (isset($m[$v])) {\r\n $m[$v] += 1;\r\n } else {\r\n $m[$v] = 1;\r\n }\r\n if (isset($a[$counter][$v])) {\r\n $a[$counter][$v] += 1;\r\n } else {\r\n $a[$counter][$v] = 1;\r\n }\r\n $a[$counter]['all'] += 1;\r\n }\r\n $counter++;\r\n }\r\n \r\n $result = [];\r\n foreach ($m as $key => $valll) {\r\n $tt = [];\r\n var_dump($a);\r\n foreach ($a as $word) {\r\n $tf = 0;\r\n if (isset($word[$key])) {\r\n $tf = $word[$key];\r\n }\r\n $tt[] = $tf - ($word['all'] - $tf);\r\n }\r\n rsort($tt);\r\n $res = 0;\r\n $value = 0;\r\n var_dump($tt);\r\n foreach ($tt as $vv) {\r\n $value += $vv;\r\n if ($value > 0) {\r\n $res++;\r\n } else {\r\n break;\r\n }\r\n }\r\n $result[] = $res;\r\n }\r\n\r\n\r\n\r\n \r\n IO::line(max($result));\r\n\r\n\r\n}\r\n\r\n\r\n?>"}], "src_uid": "18ac51a009c907fe8e4cd2bb8612da20"} {"nl": {"description": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special \u2014 it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.The elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.", "input_spec": "The first line of input contains two integers n and s (1\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009s\u2009\u2264\u20091000)\u00a0\u2014 the number of passengers and the number of the top floor respectively. The next n lines each contain two space-separated integers fi and ti (1\u2009\u2264\u2009fi\u2009\u2264\u2009s, 1\u2009\u2264\u2009ti\u2009\u2264\u20091000)\u00a0\u2014 the floor and the time of arrival in seconds for the passenger number i.", "output_spec": "Print a single integer\u00a0\u2014 the minimum amount of time in seconds needed to bring all the passengers to floor 0.", "sample_inputs": ["3 7\n2 1\n3 8\n5 2", "5 10\n2 77\n3 33\n8 21\n9 12\n10 64"], "sample_outputs": ["11", "79"], "notes": "NoteIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:1. Move to floor 5: takes 2 seconds.2. Pick up passenger 3.3. Move to floor 3: takes 2 seconds.4. Wait for passenger 2 to arrive: takes 4 seconds.5. Pick up passenger 2.6. Go to floor 2: takes 1 second.7. Pick up passenger 1.8. Go to floor 0: takes 2 seconds.This gives a total of 2\u2009+\u20092\u2009+\u20094\u2009+\u20091\u2009+\u20092\u2009=\u200911 seconds."}, "positive_code": [{"source_code": " $i)\n {\n $i = $h[$x];\n }\n}\nprint $i + $c[count($c) - 1];\n?>"}, {"source_code": "= 0; $i--) {\n if($f > $a[$i][0]){\n $t += ($f - $a[$i][0]);\n $f = $a[$i][0];\n }\n if($t < $a[$i][1]){\n $t = $a[$i][1];\n }\n }\n $t += $f;\n fprintf(STDOUT,\"%d\",$t);\n?>\n"}, {"source_code": "\n//$input = fopen(\"input.txt\",\"r\");\n//$output = fopen(\"output.txt\",\"w\");\n//fscanf(STDIN,\"%d %d\",$n, $s);\n//fprintf(STDOUT,\"%d\",$t);\n\n$in = fopen(\"php://stdin\",\"r\");\nlist($n,$s) = explode(\" \",trim(fgets($in)));\nfor($i = 0; $i <$n; $i++){\n list($f,$t) = explode(\" \",trim(fgets($in)));\n $fl[$i] = $f; \n $ti[$i] = $t; \n $flag[$i] = false; \n}\n\n\n$time = 0; $tf = $s;\nfor($i = 0; $i <$n; $i++){\n $idx = -1; $temp = -1;\n for($r = 0; $r <$n; $r++){\n if($flag[$r]==false && $fl[$r] > $temp )\n\t{\n\t $idx = $r;\n\t $temp = $fl[$r]; \t \n\t}\t\n }\n $flag[$idx] = true;\n while($tf > $fl[$idx])\n {\n $time++;\n $tf--; \n }\n while( $ti[$idx] > $time) \n $time++; \n}\nwhile($tf >0)\n{\n $time++;\n $tf--;\n}\n\necho $time;"}, {"source_code": "\n$in = fopen(\"php://stdin\",\"r\");\nlist($n,$s) = explode(\" \",trim(fgets($in)));\nfor($i = 0; $i <$n; $i++){\n list($f,$t) = explode(\" \",trim(fgets($in)));\n $fl[$i] = $f; \n $ti[$i] = $t; \n $flag[$i] = false; \n}\n\n\n$time = 0; $tf = $s;\nfor($i = 0; $i <$n; $i++){\n $idx = -1; $temp = -1;\n for($r = 0; $r <$n; $r++){\n if($flag[$r]==false && $fl[$r] > $temp )\n\t{\n\t $idx = $r;\n\t $temp = $fl[$r]; \t \n\t}\t\n }\n $flag[$idx] = true;\n while($tf > $fl[$idx])\n {\n $time++;\n $tf--; \n }\n while( $ti[$idx] > $time) \n $time++; \n}\nwhile($tf >0)\n{\n $time++;\n $tf--;\n}\n\necho $time;"}], "negative_code": [{"source_code": " $n)\n {\n $n = $j[$x];\n }\n $m = 1;\n $o++;\n }\n elseif(($k[$x] == TRUE) && ($m == 1))\n {\n $n += $i[$l[$o - 1]] - $i[$l[$o]];\n if($j[$x] > $n)\n {\n $n = $j[$x];\n }\n $o++;\n }\n }\n print $n + $i[$x - 1];\n}\n?>"}, {"source_code": " $n)\n {\n $n = $j[$x];\n }\n $m = 1;\n $o++;\n }\n elseif(($k[$x] == TRUE) && ($m == 1))\n {\n $n += $i[$l[$o - 1]] - $i[$l[$o]];\n if($j[$x] > $n)\n {\n $n = $j[$x];\n }\n $o++;\n }\n }\n print $n + $i[$x - 1];\n}\n?>"}, {"source_code": " $n)\n {\n $n = $j[$x];\n }\n $m = 1;\n $o++;\n }\n elseif(($k[$x] == TRUE) && ($m == 1))\n {\n $n += $i[$l[$o - 1]] - $i[$l[$o]];\n if($j[$x] > $n)\n {\n $n = $j[$x];\n }\n $o++;\n }\n }\n print $n + $i[$x - 1];\n}\n?>"}, {"source_code": " $n)\n {\n $n = $j[$x];\n }\n $m = 1;\n $o++;\n }\n elseif(($k[$x] == TRUE) && ($m == 1))\n {\n $n += $i[$l[$o - 1]] - $i[$l[$o]];\n if($j[$x] > $n)\n {\n $n = $j[$x];\n }\n $o++;\n }\n }\n print $n + $i[$x - 1];\n}\n?>"}, {"source_code": " $n)\n {\n $n = $j[$x];\n }\n $m = 1;\n $o++;\n }\n elseif(($k[$x] == TRUE) && ($m == 1))\n {\n $n += $i[$l[$o - 1]] - $i[$l[$o]];\n if($j[$x] > $n)\n {\n $n = $j[$x];\n }\n $o++;\n }\n}\nprint $n + $i[$x - 1];\n?>"}], "src_uid": "5c12573b3964ee30af0349c11c0ced3b"} {"nl": {"description": "This problem is given in two editions, which differ exclusively in the constraints on the number $$$n$$$.You are given an array of integers $$$a[1], a[2], \\dots, a[n].$$$ A block is a sequence of contiguous (consecutive) elements $$$a[l], a[l+1], \\dots, a[r]$$$ ($$$1 \\le l \\le r \\le n$$$). Thus, a block is defined by a pair of indices $$$(l, r)$$$.Find a set of blocks $$$(l_1, r_1), (l_2, r_2), \\dots, (l_k, r_k)$$$ such that: They do not intersect (i.e. they are disjoint). Formally, for each pair of blocks $$$(l_i, r_i)$$$ and $$$(l_j, r_j$$$) where $$$i \\neq j$$$ either $$$r_i < l_j$$$ or $$$r_j < l_i$$$. For each block the sum of its elements is the same. Formally, $$$$$$a[l_1]+a[l_1+1]+\\dots+a[r_1]=a[l_2]+a[l_2+1]+\\dots+a[r_2]=$$$$$$ $$$$$$\\dots =$$$$$$ $$$$$$a[l_k]+a[l_k+1]+\\dots+a[r_k].$$$$$$ The number of the blocks in the set is maximum. Formally, there does not exist a set of blocks $$$(l_1', r_1'), (l_2', r_2'), \\dots, (l_{k'}', r_{k'}')$$$ satisfying the above two requirements with $$$k' > k$$$. The picture corresponds to the first example. Blue boxes illustrate blocks. Write a program to find such a set of blocks.", "input_spec": "The first line contains integer $$$n$$$ ($$$1 \\le n \\le 50$$$) \u2014 the length of the given array. The second line contains the sequence of elements $$$a[1], a[2], \\dots, a[n]$$$ ($$$-10^5 \\le a_i \\le 10^5$$$).", "output_spec": "In the first line print the integer $$$k$$$ ($$$1 \\le k \\le n$$$). The following $$$k$$$ lines should contain blocks, one per line. In each line print a pair of indices $$$l_i, r_i$$$ ($$$1 \\le l_i \\le r_i \\le n$$$) \u2014 the bounds of the $$$i$$$-th block. You can print blocks in any order. If there are multiple answers, print any of them.", "sample_inputs": ["7\n4 1 2 2 1 5 3", "11\n-5 -4 -3 -2 -1 0 1 2 3 4 5", "4\n1 1 1 1"], "sample_outputs": ["3\n7 7\n2 3\n4 5", "2\n3 4\n1 1", "4\n4 4\n1 1\n2 2\n3 3"], "notes": null}, "positive_code": [{"source_code": " $n[count($n) - 1])\n {\n $m[count($m)] = $i[$y];\n $n[count($n)] = $l[$y];\n }\n }\n if(count($m) > count($o))\n {\n $o = $m;\n $p = $n;\n }\n}\nprint count($o) . \"\\n\";\nfor($x = 0; $x < count($o); $x++)\n{\n print $o[$x] . \" \" . $p[$x] . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": " $n[count($n) - 1])\n {\n $m[count($m)] = $i[$y];\n $n[count($n)] = $l[$y];\n }\n }\n if(count($m) > count($o))\n {\n $o = $m;\n $p = $n;\n }\n}\nprint count($o) . \"\\n\";\nfor($x = 0; $x < count($o); $x++)\n{\n print $o[$x] . \" \" . $p[$x] . \"\\n\";\n}\n?>"}], "src_uid": "3e834f89ecedc5f210e680f24e40ba19"} {"nl": {"description": "Sasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying them further. Instead, he invented his own type of square\u00a0\u2014 a prime square. A square of size $$$n \\times n$$$ is called prime if the following three conditions are held simultaneously: all numbers on the square are non-negative integers not exceeding $$$10^5$$$; there are no prime numbers in the square; sums of integers in each row and each column are prime numbers. Sasha has an integer $$$n$$$. He asks you to find any prime square of size $$$n \\times n$$$. Sasha is absolutely sure such squares exist, so just help him!", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10$$$)\u00a0\u2014 the number of test cases. Each of the next $$$t$$$ lines contains a single integer $$$n$$$ ($$$2 \\le n \\le 100$$$)\u00a0\u2014 the required size of a square.", "output_spec": "For each test case print $$$n$$$ lines, each containing $$$n$$$ integers\u00a0\u2014 the prime square you built. If there are multiple answers, print any.", "sample_inputs": ["2\n4\n2"], "sample_outputs": ["4 6 8 1\n4 9 9 9\n4 10 10 65\n1 4 4 4\n1 1\n1 1"], "notes": null}, "positive_code": [{"source_code": " 0) {\r\n $sm += $cnt[$k];\r\n $cnt[($k + 1) % 3] += $cnt[$k];\r\n $cnt[$k] = 0;\r\n }\r\n }\r\n }\r\n echo $sm.PHP_EOL;\r\n}\r\n"}, {"source_code": " $e)\r\n {\r\n $d--;\r\n $e++;\r\n $g++;\r\n }\r\n elseif($e > $f)\r\n {\r\n $e--;\r\n $f++;\r\n $g++;\r\n }\r\n elseif($f > $d)\r\n {\r\n $f--;\r\n $d++;\r\n $g++;\r\n }\r\n else\r\n {\r\n break;\r\n }\r\n }\r\n print $g . \"\\n\";\r\n}\r\n?>"}], "negative_code": [], "src_uid": "e0de8a6441614d1e41a53223b5fa576b"} {"nl": {"description": "There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i\u2009+\u20091 are neighbours for all i from 1 to n\u2009-\u20091. Sharks n and 1 are neighbours too.Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from li to ri. Wet Shark has it's favourite prime number p, and he really likes it! If for any pair of neighbouring sharks i and j the product si\u00b7sj is divisible by p, then Wet Shark becomes happy and gives 1000 dollars to each of these sharks.At the end of the day sharks sum all the money Wet Shark granted to them. Find the expectation of this value.", "input_spec": "The first line of the input contains two space-separated integers n and p (3\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000,\u20092\u2009\u2264\u2009p\u2009\u2264\u2009109)\u00a0\u2014 the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime. The i-th of the following n lines contains information about i-th shark\u00a0\u2014 two space-separated integers li and ri (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009109), the range of flowers shark i can produce. Remember that si is chosen equiprobably among all integers from li to ri, inclusive.", "output_spec": "Print a single real number \u2014 the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10\u2009-\u20096. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .", "sample_inputs": ["3 2\n1 2\n420 421\n420420 420421", "3 5\n1 4\n2 3\n11 14"], "sample_outputs": ["4500.0", "0.0"], "notes": "NoteA prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities of flowers (s0,\u2009s1,\u2009s2) each shark grows: (1,\u2009420,\u2009420420): note that s0\u00b7s1\u2009=\u2009420, s1\u00b7s2\u2009=\u2009176576400, and s2\u00b7s0\u2009=\u2009420420. For each pair, 1000 dollars will be awarded to each shark. Therefore, each shark will be awarded 2000 dollars, for a total of 6000 dollars. (1,\u2009420,\u2009420421): now, the product s2\u00b7s0 is not divisible by 2. Therefore, sharks s0 and s2 will receive 1000 dollars, while shark s1 will receive 2000. The total is 4000. (1,\u2009421,\u2009420420): total is 4000 (1,\u2009421,\u2009420421): total is 0. (2,\u2009420,\u2009420420): total is 6000. (2,\u2009420,\u2009420421): total is 6000. (2,\u2009421,\u2009420420): total is 6000. (2,\u2009421,\u2009420421): total is 4000.The expected value is .In the second sample, no combination of quantities will garner the sharks any money."}, "positive_code": [{"source_code": " $r) {\n list ($l, $r) = [$r, $l];\n }\n $numTotal = $r - $l + 1;\n\n $lP = ceil($l / $p) * $p;\n $rP = floor($r / $p) * $p;\n if ($lP > $rP) {\n $numOk = 0;\n } else {\n $numOk = ($rP - $lP) / $p + 1;\n }\n\n $pSharks[] = $numOk / $numTotal;\n}\n\n$rub = 0;\nforeach ($pSharks as $i => $p1) {\n $p2 = $pSharks[($i + 1) % $n];\n $rub += 2000 * ($p1 + $p2 - $p1 * $p2);\n}\n\nprintf(\"%f\\n\", $rub);\n"}], "negative_code": [], "src_uid": "5aad0a82748d931338140ae81fed301d"} {"nl": {"description": "In the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are mi tasks assigned to the i-th server.In order to balance the load for each server, you want to reassign some tasks to make the difference between the most loaded server and the least loaded server as small as possible. In other words you want to minimize expression ma\u2009-\u2009mb, where a is the most loaded server and b is the least loaded one.In one second you can reassign a single task. Thus in one second you can choose any pair of servers and move a single task from one server to another.Write a program to find the minimum number of seconds needed to balance the load of servers.", "input_spec": "The first line contains positive number n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of the servers. The second line contains the sequence of non-negative integers m1,\u2009m2,\u2009...,\u2009mn (0\u2009\u2264\u2009mi\u2009\u2264\u20092\u00b7104), where mi is the number of tasks assigned to the i-th server.", "output_spec": "Print the minimum number of seconds required to balance the load.", "sample_inputs": ["2\n1 6", "7\n10 11 10 11 10 11 11", "5\n1 2 3 4 5"], "sample_outputs": ["2", "0", "3"], "notes": "NoteIn the first example two seconds are needed. In each second, a single task from server #2 should be moved to server #1. After two seconds there should be 3 tasks on server #1 and 4 tasks on server #2.In the second example the load is already balanced.A possible sequence of task movements for the third example is: move a task from server #4 to server #1 (the sequence m becomes: 2 2 3 3 5); then move task from server #5 to server #1 (the sequence m becomes: 3 2 3 3 4); then move task from server #5 to server #2 (the sequence m becomes: 3 3 3 3 3). The above sequence is one of several possible ways to balance the load of servers in three seconds."}, "positive_code": [{"source_code": " $c)\n {\n $g += ($b[$x] - $c);\n }\n }\n print max($f, $g);\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n if($b[$x] < $d)\n {\n $f += ($d - $b[$x]);\n }\n elseif($b[$x] > $e)\n {\n $g += ($b[$x] - $e);\n }\n }\n print max($f, $g);\n}\n?>"}], "negative_code": [], "src_uid": "c0c29565e465840103a4af884f951cda"} {"nl": {"description": "Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.There are $$$n$$$ solutions, the $$$i$$$-th of them should be tested on $$$a_i$$$ tests, testing one solution on one test takes $$$1$$$ second. The solutions are judged in the order from $$$1$$$ to $$$n$$$. There are $$$k$$$ testing processes which test solutions simultaneously. Each of them can test at most one solution at a time.At any time moment $$$t$$$ when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id $$$i$$$, then it is being tested on the first test from time moment $$$t$$$ till time moment $$$t + 1$$$, then on the second test till time moment $$$t + 2$$$ and so on. This solution is fully tested at time moment $$$t + a_i$$$, and after that the testing process immediately starts testing another solution.Consider some time moment, let there be exactly $$$m$$$ fully tested solutions by this moment. There is a caption \"System testing: $$$d$$$%\" on the page with solutions, where $$$d$$$ is calculated as$$$$$$d = round\\left(100\\cdot\\frac{m}{n}\\right),$$$$$$where $$$round(x) = \\lfloor{x + 0.5}\\rfloor$$$ is a function which maps every real to the nearest integer.Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test $$$q$$$, and the caption says \"System testing: $$$q$$$%\". Find the number of interesting solutions.Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter.", "input_spec": "The first line contains two positive integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 1000$$$, $$$1 \\le k \\le 100$$$) standing for the number of submissions and the number of testing processes respectively. The second line contains $$$n$$$ positive integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 150$$$), where $$$a_i$$$ is equal to the number of tests the $$$i$$$-th submission is to be run on.", "output_spec": "Output the only integer\u00a0\u2014 the number of interesting submissions.", "sample_inputs": ["2 2\n49 100", "4 2\n32 100 33 1", "14 5\n48 19 6 9 50 20 3 42 38 43 36 21 44 6"], "sample_outputs": ["1", "2", "5"], "notes": "NoteConsider the first example. At time moment $$$0$$$ both solutions start testing. At time moment $$$49$$$ the first solution is fully tested, so at time moment $$$49.5$$$ the second solution is being tested on the test $$$50$$$, and the caption says \"System testing: $$$50$$$%\" (because there is one fully tested solution out of two). So, the second solution is interesting.Consider the second example. At time moment $$$0$$$ the first and the second solutions start testing. At time moment $$$32$$$ the first solution is fully tested, the third solution starts testing, the caption says \"System testing: $$$25$$$%\". At time moment $$$32 + 24.5 = 56.5$$$ the third solutions is being tested on test $$$25$$$, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment $$$32 + 33 = 65$$$, the fourth solution is fully tested at time moment $$$65 + 1 = 66$$$. The captions becomes \"System testing: $$$75$$$%\", and at time moment $$$74.5$$$ the second solution is being tested on test $$$75$$$. So, this solution is also interesting. Overall, there are two interesting solutions."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "b17eaccfd447b11c4f9297e3276a3ca9"} {"nl": {"description": "Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and delete it, at that all elements equal to ak\u2009+\u20091 and ak\u2009-\u20091 also must be deleted from the sequence. That step brings ak points to the player. Alex is a perfectionist, so he decided to get as many points as possible. Help him.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1\u2009\u2264\u2009ai\u2009\u2264\u2009105).", "output_spec": "Print a single integer \u2014 the maximum number of points that Alex can earn.", "sample_inputs": ["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"], "sample_outputs": ["2", "4", "10"], "notes": "NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2,\u20092,\u20092,\u20092]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points."}, "positive_code": [{"source_code": "=$b) return $a;\n\treturn $b;\n}\nfor($i=2;$i<=$lim;$i++) $dp[$i]=mx($dp[$i-1],$dp[$i-2]+$i*$cnt[$i]);\n\necho $dp[$lim].\"\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\n$n_1 = 0;\n$n_2 = 0;\n$sum = 0;\n\nforeach ($arr_N as $key => $value) {\n $n_tmp = $n_1;\n $n_1 = max($n_1, $n_2 + $key * $value);\n $n_2 = $n_tmp;\n\n if (!(isset($arr_N[$key+1]))) {\n $sum += $n_1;\n $n_1 = 0;\n $n_2 = 0;\n }\n}\n\n$sum += $n_1;\n\necho \"$sum\\n\";\n\n?>"}], "negative_code": [{"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n //$x = (int) $key * $value;\n $x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n if (!isset($arr_N[$key+1])) {\n break;\n }\n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\nprint_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n if (!isset($arr_N[$key-1])) {\n if (isset($arr_N[$key+2])) {\n continue;\n } else {\n $imax =($key * $value > ($key+1) * $arr_N[$key+1])? $key : $key + 1; \n break;\n }\n }\n\n $x = (int) $key * $value;\n $x -= (int) ($key - 1) * $arr_N[$key-1];\n $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($x > 0) {\n $imax = $key;\n } else {\n $imax = $key - 1; \n }\n break; \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\necho \"arrCount=$arrCount \\n\";\nprint_r($arr_N);\n\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n $x = (int) $key * $value;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount --;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n $x = (int) $key * $value;\n //$x = 0;\n //if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n //if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n // $x = (int) $key * $value;\n $x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n $x = (int) $key * $value;\n //$x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n if (!isset($arr_N[$key+1])) {\n break;\n }\n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n $x = (int) $key * $value;\n //$x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($x > 0) {\n $imax = $key;\n } \n if (!isset($arr_N[$key+1])) {\n break;\n }\n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\nprint_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n $x = (int) $key * $value;\n //$x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n if (!isset($arr_N[$key+1])) {\n break;\n }\n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\nif ($n == 100) {\n foreach ($arr_N as $key => $value) {\n echo \"key=$key value=$value \";\n }\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n\n reset($arr_N);\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n if (!isset($arr_N[$key-1])) {\n if (isset($arr_N[$key+2])) {\n continue;\n } else {\n $imax =($key * $value > ($key+1) * $arr_N[$key+1])? $key : $key + 1; \n break;\n }\n }\n\n $x = (int) $key * $value;\n $x -= (int) ($key - 1) * $arr_N[$key-1];\n $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($x > 0) {\n $imax = $key;\n } else {\n $imax = $key - 1; \n }\n break; \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n//echo \"arrCount=$arrCount \\n\";\n//print_r($arr_N);\n\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$n_1 = 0;\n$n_2 = 0;\n\nforeach ($arr_N as $key => $value) {\n $n_tmp = $n_1;\n $n_1 = max($n_1, $n_2 + $key * $value);\n $n_2 = $n_tmp;\n}\n\necho \"$n_1\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 2;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n $arrCount --;\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n $x = ((int) $key * $value) - ((int) ($key - 1) * $arr_N[$key-1]) - ((int) ($key + 1) * $arr_N[$key+1]);\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n/*\n $col += $imax * $arr_N[$imax];\n //echo \" imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount --;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n*/\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n $x = (int) $key * $value;\n //$x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n if (!isset($arr_N[$key+1])) {\n break;\n }\n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n }\n\n $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n \n reset($arr_N);\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n if (!isset($arr_N[$key-1])) {\n if (isset($arr_N[$key+2])) {\n continue;\n } else {\n $imax =($key * $value > ($key+1) * $arr_N[$key+1])? $key : $key + 1; \n break;\n }\n }\n\n $x = (int) $key * $value;\n $x -= (int) ($key - 1) * $arr_N[$key-1];\n $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($x > 0) {\n $imax = $key;\n } else {\n $imax = $key - 1; \n }\n break; \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n//echo \"arrCount=$arrCount \\n\";\n//print_r($arr_N);\n\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$n_1 = 0;\n$n_2 = 0;\n\nksort($arr_N);\n\nforeach ($arr_N as $key => $value) {\n $n_tmp = $n_1;\n $n_1 = max($n_1, $n_2 + $key * $value);\n $n_2 = $n_tmp;\n}\n\necho \"$n_1\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n if (!isset($arr_N[$key-1])) {\n if (isset($arr_N[$key+2])) {\n continue;\n } else {\n $imax =($key * $value > ($key+1) * $arr_N[$key+1])? $key : $key + 1; \n break;\n }\n }\n\n $x = (int) $key * $value;\n $x -= (int) ($key - 1) * $arr_N[$key-1];\n $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($x > 0) {\n $imax = $key;\n } else {\n $imax = $key - 1; \n }\n break; \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n//echo \"arrCount=$arrCount \\n\";\n//print_r($arr_N);\n\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n \n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n\n if (!(isset($arr_N[$key-1]) or isset($arr_N[$key+1]))) {\n $col += $key * $value;\n $arrCount -- ;\n unset($arr_N[$key]);\n continue;\n }\n\n/* $x = (int) $key;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n*/\n $x = (int) $key * $value;\n $x = 0;\n if (isset($arr_N[$key-1])) $x -= (int) ($key - 1) * $arr_N[$key-1];\n if (isset($arr_N[$key+1])) $x -= (int) ($key + 1) * $arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \"\\n imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount -- ;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$n_2 = 0;\n$keys = array_keys($arr_N);\n$n_1 = $arr_N[$keys[0]];\n$n_0 = $n_1; \n\nforeach ($arr_N as $key => $value) {\n\n if ($key = $keys[0]) continue;\n\n $n_tmp = $n_0;\n $n_0 = max($n_1, $n_2 + $value);\n $n_2 = $n_1;\n $n_1 = $n_tmp;\n}\n\necho \"$n_0\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n//print_r($arr_N);\n/*\n$arr_N = array();\n$arr_N[1] = 7;\n$arr_N[2] = 9;\n$arr_N[3] = 6;\n$arr_N[4] = 12;\n$arr_N[5] = 11;\n$arr_N[6] = 10;\n$arr_N[7] = 16;\n$arr_N[8] = 10;\n$arr_N[9] = 10;\n$arr_N[10] = 9;\n*/\n$n_1 = 0;\n$n_2 = 0;\n\nforeach ($arr_N as $key => $value) {\n $n_tmp = $n_1;\n $n_1 = max($n_1, $n_2 + $key * $value);\n $n_2 = $n_tmp;\n //echo \"\\n n_2=$n_2 n_1=$n_1 key=$key value=$value\\n\";\n\n}\n\necho \"$n_1\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\n$n_1 = 0;\n$n_2 = 0;\n\nfunction cmp($a, $b)\n{\n if ((int) $a > (int) $b) {\n return 1;\n } elseif ((int) $a < (int) $b) {\n return -1;\n } elseif ((int) $a == (int) $b) {\n return 0;\n }\n}\n\nuksort($arr_N, \"cmp\");\n\nforeach ($arr_N as $key => $value) {\n $n_tmp = $n_1;\n $n_1 = max($n_1, $n_2 + $key * $value);\n $n_2 = $n_tmp;\n}\n\necho \"$n_1\\n\";\n\n?>"}, {"source_code": " $value) {\n $i = (int) $value;\n $arr_N[$i] ++;\n}\n\necho \"2\\n\";\n/*\n$col = 0;\n$arrCount = count($arr_N);\nwhile ( $arrCount > 0) {\n\n $max = - 2000000000;\n $imax = -1;\n foreach ($arr_N as $key => $value) {\n $x = (int) $key * $value - ($key - 1) * arr_N[$key-1] - ($key + 1) * arr_N[$key+1];\n if ($max < $x) {\n $max = $x;\n $imax = $key;\n } \n }\n\n $col += $imax * $arr_N[$imax];\n //echo \" imax=$imax max=$max col=$col arrCount=$arrCount\\n\";\n\n $arrCount --;\n unset($arr_N[$imax]);\n if (isset($arr_N[$imax-1])) {\n unset($arr_N[$imax-1]);\n $arrCount --;\n }\n if (isset($arr_N[$imax+1])) {\n unset($arr_N[$imax+1]);\n $arrCount --;\n }\n}\n\necho \"$col\\n\";\n*/\n?>"}], "src_uid": "41b3e726b8146dc733244ee8415383c0"} {"nl": {"description": "Polycarp is playing a new computer game. This game has $$$n$$$ stones in a row. The stone on the position $$$i$$$ has integer power $$$a_i$$$. The powers of all stones are distinct.Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more.Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal.For example, if $$$n = 5$$$ and $$$a = [1, 5, 4, 3, 2]$$$, then Polycarp could make the following moves: Destroy the leftmost stone. After this move $$$a = [5, 4, 3, 2]$$$; Destroy the rightmost stone. After this move $$$a = [5, 4, 3]$$$; Destroy the leftmost stone. After this move $$$a = [4, 3]$$$. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: Destroy the leftmost stone. After this move $$$a = [5, 4, 3, 2]$$$; Destroy the leftmost stone. After this move $$$a = [4, 3, 2]$$$. Polycarp destroyed the stones with the greatest and least power, so he can end the game. ", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$). Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$2 \\le n \\le 100$$$)\u00a0\u2014 the number of stones. The second line contains $$$n$$$ distinct integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le n$$$)\u00a0\u2014 the power of the stones.", "output_spec": "For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power.", "sample_inputs": ["5\n5\n1 5 4 3 2\n8\n2 1 3 4 5 6 8 7\n8\n4 2 3 1 8 6 7 5\n4\n3 4 2 1\n4\n2 3 1 4"], "sample_outputs": ["2\n4\n5\n3\n2"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "d5fc2bc618dd9d453a5e7ae30ccb73f3"} {"nl": {"description": "Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the number of round participants. Each of the next n lines contains two integers ai and bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u20094126)\u00a0\u2014 the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.", "output_spec": "If the round is rated for sure, print \"rated\". If the round is unrated for sure, print \"unrated\". If it's impossible to determine whether the round is rated or not, print \"maybe\".", "sample_inputs": ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"], "sample_outputs": ["rated", "unrated", "maybe"], "notes": "NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not."}, "positive_code": [{"source_code": " $h)\n {\n $g = 1;\n break;\n }\n $h = min($h, $b[$x + 1]);\n }\n if($g == 1)\n {\n print \"unrated\";\n }\n else\n {\n print \"maybe\";\n }\n}\n?>"}, {"source_code": "0 and $a[$i]>$a[$i-1])\n $flag = true;\n}\n$flag2 = false;\nfor($i=0;$i<$n;$i++)\n if($a[$i]!=$b[$i])\n $flag2 = true;\nif($flag2==true)\n fwrite(STDOUT, \"rated\\n\");\nelse if($flag==true)\n fwrite(STDOUT, \"unrated\\n\");\nelse\n fwrite(STDOUT, \"maybe\\n\");\n\n?>"}, {"source_code": "4126 or $rating[$i]['before']>4126)){ exit();}\n if($rating[$i]['before']!=$rating[$i]['after']){\n\n $rated=1;\n $unrated=0;\n $maybe=0;\n break;\n }\n\n if($i>1){\n\n if($rating[$i]['after']<=$rating[$i-1]['after']){\n $maybe+=1;\n }else{\n $unrated+=1;\n }\n\n }\n}\n\nif($rated >$unrated){\n fwrite($out,'rated');\n}elseif ($unrated>$rated){\n fwrite($out, 'unrated');\n}else{\n fwrite($out,'maybe');\n}\nfclose($out);\nfclose($in);"}], "negative_code": [], "src_uid": "88686e870bd3bfbf45a9b6b19e5ec68a"} {"nl": {"description": "Screen resolution of Polycarp's monitor is $$$a \\times b$$$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $$$(x, y)$$$ ($$$0 \\le x < a, 0 \\le y < b$$$). You can consider columns of pixels to be numbered from $$$0$$$ to $$$a-1$$$, and rows\u00a0\u2014 from $$$0$$$ to $$$b-1$$$.Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.", "input_spec": "In the first line you are given an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases in the test. In the next lines you are given descriptions of $$$t$$$ test cases. Each test case contains a single line which consists of $$$4$$$ integers $$$a, b, x$$$ and $$$y$$$ ($$$1 \\le a, b \\le 10^4$$$; $$$0 \\le x < a$$$; $$$0 \\le y < b$$$)\u00a0\u2014 the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that $$$a+b>2$$$ (e.g. $$$a=b=1$$$ is impossible).", "output_spec": "Print $$$t$$$ integers\u00a0\u2014 the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.", "sample_inputs": ["6\n8 8 0 0\n1 10 0 3\n17 31 10 4\n2 1 0 0\n5 10 3 9\n10 10 4 8"], "sample_outputs": ["56\n6\n442\n1\n45\n80"], "notes": "NoteIn the first test case, the screen resolution is $$$8 \\times 8$$$, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window. "}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "ccb7b8c0c389ea771f666c236c1cba5f"} {"nl": {"description": "The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As the training sessions lasts for several hours, teams become hungry. Thus, Sereja orders a number of pizzas so they can eat right after the end of the competition.Teams plan to train for n times during n consecutive days. During the training session Sereja orders exactly one pizza for each team that is present this day. He already knows that there will be ai teams on the i-th day.There are two types of discounts in Sereja's favourite pizzeria. The first discount works if one buys two pizzas at one day, while the second is a coupon that allows to buy one pizza during two consecutive days (two pizzas in total).As Sereja orders really a lot of pizza at this place, he is the golden client and can use the unlimited number of discounts and coupons of any type at any days.Sereja wants to order exactly ai pizzas on the i-th day while using only discounts and coupons. Note, that he will never buy more pizzas than he need for this particular day. Help him determine, whether he can buy the proper amount of pizzas each day if he is allowed to use only coupons and discounts. Note, that it's also prohibited to have any active coupons after the end of the day n.", "input_spec": "The first line of input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009200\u2009000)\u00a0\u2014 the number of training sessions. The second line contains n integers a1, a2, ..., an (0\u2009\u2264\u2009ai\u2009\u2264\u200910\u2009000)\u00a0\u2014 the number of teams that will be present on each of the days.", "output_spec": "If there is a way to order pizzas using only coupons and discounts and do not buy any extra pizzas on any of the days, then print \"YES\" (without quotes) in the only line of output. Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["4\n1 2 1 2", "3\n1 0 1"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, Sereja can use one coupon to buy one pizza on the first and the second days, one coupon to buy pizza on the second and the third days and one discount to buy pizzas on the fourth days. This is the only way to order pizzas for this sample.In the second sample, Sereja can't use neither the coupon nor the discount without ordering an extra pizza. Note, that it's possible that there will be no teams attending the training sessions on some days."}, "positive_code": [{"source_code": ""}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test)\n\t\t$stream = $f;\n\telse\n\t\t$stream = STDIN;\n\t/* begin body */\n\t$n = readNum($stream);\n\t$dayCount = readStringExplodeNum($stream, ' ', true);\n\n\t$dayCheck = 0;\n\t$isFail = false;\n\twhile (isset($dayCount[$dayCheck])) {\n\t\tif ($dayCount[$dayCheck] % 2 == 0) {\n\t\t\t$dayCount[$dayCheck]%=2;\n\t\t} elseif ($dayCount[$dayCheck] > 0 && $dayCount[$dayCheck + 1] > 0) {\n\t\t\t$dayCount[$dayCheck] --;\n\t\t\t$dayCount[$dayCheck + 1] --;\n\t\t} elseif ($dayCount[$dayCheck] > 0) {\n\t\t\t$isFail = true;\n\t\t\techo 'NO';\n\t\t\tbreak;\n\t\t}\n\n\t\tif ($dayCount[$dayCheck] == 0) {\n\t\t\t$dayCheck++;\n\t\t}\n\t}\n\tif ($isFail === false) {\n\t\techo 'YES';\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}], "negative_code": [{"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test)\n\t\t$stream = $f;\n\telse\n\t\t$stream = STDIN;\n\t/* begin body */\n\t$n = readNum($stream);\n\t$dayCount = readStringExplodeNum($stream, ' ', true);\n\t$input = array_chunk($dayCount, 100);\n\techo '-----------------' . \"\\n\";\n\tforeach ($input as $in) {\n\t\techo implode(',', $in) . \"\\n\";\n\t}\n\techo '-----------------' . \"\\n\";\n\t$dayCheck = 0;\n\t$isFail = false;\n\twhile (isset($dayCount[$dayCheck])) {\n\t\tif ($dayCount[$dayCheck] >= 2) {\n\t\t\t$dayCount[$dayCheck]-=2;\n\t\t} elseif ($dayCount[$dayCheck] > 0 && $dayCount[$dayCheck + 1] > 0) {\n\t\t\t$dayCount[$dayCheck] --;\n\t\t\t$dayCount[$dayCheck + 1] --;\n\t\t} elseif ($dayCount[$dayCheck] > 0) {\n\t\t\t$isFail = true;\n\t\t\techo 'NO';\n\t\t\tbreak;\n\t\t}\n\n\t\tif ($dayCount[0] == 0) {\n\t\t\t$dayCheck++;\n\t\t}\n\t}\n\tif ($isFail === false) {\n\t\techo 'YES';\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test)\n\t\t$stream = $f;\n\telse\n\t\t$stream = STDIN;\n\t/* begin body */\n\t$n = readNum($stream);\n\t$dayCount = readStringExplodeNum($stream, ' ', true);\n\t$dayCheck = 0;\n\t$isFail = false;\n\twhile (isset($dayCount[$dayCheck])) {\n\t\tif ($dayCount[$dayCheck] > 0 && $dayCount[$dayCheck + 1] > 0) {\n\t\t\t$dayCount[$dayCheck] --;\n\t\t\t$dayCount[$dayCheck + 1] --;\n\t\t} elseif ($dayCount[$dayCheck] >= 2) {\n\t\t\t$dayCount[$dayCheck]-=2;\n\t\t} elseif ($dayCount[$dayCheck] > 0) {\n\t\t\t$isFail = true;\n\t\t\techo 'NO';\n\t\t\tbreak;\n\t\t}\n\n\t\tif ($dayCount[0] == 0) {\n\t\t\t$dayCheck++;\n\t\t}\n\t}\n\tif ($isFail === false) {\n\t\techo 'YES';\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test)\n\t\t$stream = $f;\n\telse\n\t\t$stream = STDIN;\n\t/* begin body */\n\t$n = readNum($stream);\n\t$dayCount = readStringExplodeNum($stream, ' ', true);\n\tif ($n > 1000) {\n\t\t$input = array_chunk($dayCount, 100);\n\t\techo '-----------------' . \"\\n\";\n\t\tforeach ($input as $in) {\n\t\t\techo implode(',', $in) . \"\\n\";\n\t\t}\n\t\techo '-----------------' . \"\\n\";\n\t}\n\t$dayCheck = 0;\n\t$isFail = false;\n\twhile (isset($dayCount[$dayCheck])) {\n\t\tif ($dayCount[$dayCheck] >= 2) {\n\t\t\t$dayCount[$dayCheck]-=2;\n\t\t} elseif ($dayCount[$dayCheck] > 0 && $dayCount[$dayCheck + 1] > 0) {\n\t\t\t$dayCount[$dayCheck] --;\n\t\t\t$dayCount[$dayCheck + 1] --;\n\t\t} elseif ($dayCount[$dayCheck] > 0) {\n\t\t\t$isFail = true;\n\t\t\techo 'NO';\n\t\t\tbreak;\n\t\t}\n\n\t\tif ($dayCount[0] == 0) {\n\t\t\t$dayCheck++;\n\t\t}\n\t}\n\tif ($isFail === false) {\n\t\techo 'YES';\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test)\n\t\t$stream = $f;\n\telse\n\t\t$stream = STDIN;\n\t/* begin body */\n\t$n = readNum($stream);\n\t$dayCount = readStringExplodeNum($stream, ' ', true);\n\t$dayCheck = 0;\n\t$isFail = false;\n\twhile (isset($dayCount[$dayCheck])) {\n\t\tif ($dayCount[$dayCheck] >= 2) {\n\t\t\t$dayCount[$dayCheck]-=2;\n\t\t} elseif ($dayCount[$dayCheck] > 0 && $dayCount[$dayCheck + 1] > 0) {\n\t\t\t$dayCount[$dayCheck] --;\n\t\t\t$dayCount[$dayCheck + 1] --;\n\t\t} elseif ($dayCount[$dayCheck] > 0) {\n\t\t\t$isFail = true;\n\t\t\techo 'NO';\n\t\t\tbreak;\n\t\t}\n\n\t\tif ($dayCount[0] == 0) {\n\t\t\t$dayCheck++;\n\t\t}\n\t}\n\tif ($isFail === false) {\n\t\techo 'YES';\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}], "src_uid": "97697eba87bd21ae5c979a5ea7a81cb7"} {"nl": {"description": "You are given two positive integers $$$a$$$ and $$$b$$$.In one move, you can change $$$a$$$ in the following way: Choose any positive odd integer $$$x$$$ ($$$x > 0$$$) and replace $$$a$$$ with $$$a+x$$$; choose any positive even integer $$$y$$$ ($$$y > 0$$$) and replace $$$a$$$ with $$$a-y$$$. You can perform as many such operations as you want. You can choose the same numbers $$$x$$$ and $$$y$$$ in different moves.Your task is to find the minimum number of moves required to obtain $$$b$$$ from $$$a$$$. It is guaranteed that you can always obtain $$$b$$$ from $$$a$$$.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case is given as two space-separated integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 10^9$$$).", "output_spec": "For each test case, print the answer \u2014 the minimum number of moves required to obtain $$$b$$$ from $$$a$$$ if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain $$$b$$$ from $$$a$$$.", "sample_inputs": ["5\n2 3\n10 10\n2 4\n7 4\n9 3"], "sample_outputs": ["1\n0\n2\n2\n1"], "notes": "NoteIn the first test case, you can just add $$$1$$$.In the second test case, you don't need to do anything.In the third test case, you can add $$$1$$$ two times.In the fourth test case, you can subtract $$$4$$$ and add $$$1$$$.In the fifth test case, you can just subtract $$$6$$$."}, "positive_code": [{"source_code": " $c)\n {\n $d = $b - $c;\n if($d % 2 == 0)\n {\n print \"1\\n\";\n }\n else\n {\n print \"2\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0) {\n if ($a%2 == 0) {\n if ($b % 2 == 0) {\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n } else {\n if ($b% 2 == 0) {\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n }\n } else {\n if ($a%2 == 0) {\n if ($b % 2 == 0) {\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n } else {\n if ($b% 2 == 0) {\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n }\n }\n }\n // echo \"k = $k\\n\";\n}"}, {"source_code": " $b) {\n $c = $a - $b;\n if($c%2 == 0) {\n $n++;\n $a = $a - $c;\n } else {\n $n++;\n $a = $a - $c - 1;\n }\n \n } else {\n $c = $b - $a;\n if($c%2 == 1) {\n $n++;\n $a = $a + $c;\n } else {\n $n++;\n $a = $a + $c - 1;\n }\n } \n }\n \n echo $n . \"\\n\";\n }\n "}, {"source_code": " $a) {\n \tif (($b-$a)%2 == 1) {\n \t\t$n = 1;\n \t} else {\n \t\t$n = 2;\n \t}\n } else if ($a > $b) {\n \tif (($a-$b)%2 == 1) {\n \t\t$n = 2;\n \t} else {\n \t\t$n = 1;\n \t}\n }\n else if ($a == $b) {\n \t$n = 0;\n }\n \n echo $n . PHP_EOL;\n \n}"}, {"source_code": " $a && $diff % 2 == 0 ? 2 : $ans;\n $ans = $b < $a && $diff % 2 == 1 ? 2 : $ans;\n \n return $ans;\n}"}, {"source_code": " $a[1]){\n $c = $a[0] - $a[1];\n } else {\n $c = $a[1] - $a[0];\n $b = false;\n }\n \n if($c == 0){\n echo \"0\\n\";\n } elseif ($c % 2 == 1) {\n if($b){\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n } else {\n if($b){\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n }\n }\n\n \n\n "}, {"source_code": "$a[1] && (($a[0]%2==0 && $a[1]%2==0) || ($a[0]%2!=0 && $a[1]%2!=0) ))\n {\n echo '1'.\"\\n\";\n }else\n {\n echo '2'.\"\\n\";\n }\n}\n\n\n\n"}], "negative_code": [{"source_code": " $a) {\n if ($aFlag == $bFlag && $bFlag) {\n echo \"2\\n\";\n } elseif ($aFlag == $bFlag && !$bFlag) {\n echo \"1\\n\";\n } else {\n if ($aFlag) {\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n }\n } else {\n if ($aFlag == $bFlag && $bFlag) {\n echo \"2\\n\";\n } elseif ($aFlag == $bFlag && !$bFlag) {\n echo \"1\\n\";\n } else {\n if ($aFlag) {\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n }\n }\n }\n // echo \"k = $k\\n\";\n}"}, {"source_code": " 0) {\n if ($a%2 == 0) {\n if ($b % 2 == 0) {\n echo \"1\\n\";\n } else {\n echo \"2\\n\";\n }\n } else {\n if ($b% 2 == 0) {\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n }\n } else {\n if ($a%2 == 0) {\n if ($b % 2 == 0) {\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n } else {\n if ($b% 2 == 0) {\n echo \"2\\n\";\n } else {\n echo \"1\\n\";\n }\n }\n }\n }\n // echo \"k = $k\\n\";\n}"}], "src_uid": "fcd55a1ca29e96c05a3b65b7a8103842"} {"nl": {"description": "Let's assume that we are given a matrix b of size x\u2009\u00d7\u2009y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x\u2009\u00d7\u2009y matrix c which has the following properties: the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of matrix c (rows with numbers from x\u2009+\u20091 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x\u2009+\u20091). Sereja has an n\u2009\u00d7\u2009m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?", "input_spec": "The first line contains two integers, n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). Each of the next n lines contains m integers \u2014 the elements of matrix a. The i-th line contains integers ai1,\u2009ai2,\u2009...,\u2009aim (0\u2009\u2264\u2009aij\u2009\u2264\u20091) \u2014 the i-th row of the matrix a.", "output_spec": "In the single line, print the answer to the problem \u2014 the minimum number of rows of matrix b.", "sample_inputs": ["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0"], "sample_outputs": ["2", "3", "2"], "notes": "NoteIn the first test sample the answer is a 2\u2009\u00d7\u20093 matrix b:001110If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:001110110001"}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "90125e9d42c6dcb0bf3b2b5e4d0f845e"} {"nl": {"description": "There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n\u2009+\u2009m. Then the number of integers i (1\u2009\u2264\u2009i\u2009<\u2009n\u2009+\u2009m) such that positions with indexes i and i\u2009+\u20091 contain children of different genders (position i has a girl and position i\u2009+\u20091 has a boy or vice versa) must be as large as possible. Help the children and tell them how to form the line.", "input_spec": "The single line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100), separated by a space.", "output_spec": "Print a line of n\u2009+\u2009m characters. Print on the i-th position of the line character \"B\", if the i-th position of your arrangement should have a boy and \"G\", if it should have a girl. Of course, the number of characters \"B\" should equal n and the number of characters \"G\" should equal m. If there are multiple optimal solutions, print any of them.", "sample_inputs": ["3 3", "4 2"], "sample_outputs": ["GBGBGB", "BGBGBB"], "notes": "NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal."}, "positive_code": [{"source_code": "\n$f = fopen( 'input.txt', 'r' );\n$out = fopen( 'output.txt', 'w' );\nfscanf($f,\"%d %d\", &$m, &$fm);\n\nif($m < $fm){\n for($i = 0; $i < $m; $i++){\n fprintf($out,\"%s\", \"GB\"); \n }\n for($i = 0; $i < $fm - $m; $i++){\n fprintf($out,\"%s\", \"G\"); \n }\n}\nif($fm < $m){\n for($i = 0; $i < $fm; $i++){\n fprintf($out,\"%s\", \"BG\"); \n }\n for($i = 0; $i < $m - $fm; $i++){\n fprintf($out,\"%s\", \"B\"); \n }\n}\nif($fm == $m){\n for($i = 0; $i < $fm; $i++){\n fprintf($out,\"%s\", \"BG\"); \n }\n}\nfclose( $f );\nfclose( $out );\n?>"}, {"source_code": "0 && $m>0) {\n if ($n>$m) {\n fwrite($out,\"BG\");\n } else {\n fwrite($out,\"GB\");\n }\n $n--;\n $m--;\n }\n while($n>0) {\n fwrite($out,\"B\");\n $n--;\n }\n while($m>0) {\n fwrite($out,\"G\");\n $m--;\n }\n fclose($out);\n?>"}, {"source_code": " $m)\n {\n fprintf($fout, \"B\");\n for ($i = 1; $i <= $m; $i++)\n fprintf($fout, \"GB\");\n for ($i = 1; $i <= $n-$m-1; $i++)\n fprintf($fout, \"B\");\n }\n else\n {\n for ($i = 1; $i <= $n; $i++)\n fprintf($fout, \"GB\");\n }\n?>"}, {"source_code": ""}, {"source_code": "\n$f = fopen( 'php://stdin', 'r' );\nfscanf($f,\"%d %d\", &$m, &$fm);\n\nif($m < $fm){\n for($i = 0; $i < $m; $i++){\n echo 'BG'; \n }\n for($i = 0; $i < $fm - $m; $i++){\n echo 'G'; \n }\n}\nif($fm < $m){\n for($i = 0; $i < $fm; $i++){\n echo 'GB'; \n }\n for($i = 0; $i < $m - $fm; $i++){\n echo 'B'; \n }\n}\nif($fm == $m){\n for($i = 0; $i < $fm; $i++){\n echo 'GB'; \n }\n}\n\n?>"}, {"source_code": " $m)\n {\n echo \"B\";\n for ($i = 1; $i <= $m; $i++)\n echo \"GB\";\n for ($i = 1; $i <= $n-$m-1; $i++)\n echo \"B\";\n }\n else\n {\n for ($i = 1; $i <= $n; $i++)\n echo \"GB\";\n }\n?>"}, {"source_code": " $m)\n {\n echo \"B\";\n for ($i = 1; $i <= $m; $i++)\n echo \"GB\";\n for ($i = 1; $i <= $n-$m-1; $i++)\n echo \"B\";\n }\n else\n {\n for ($i = 1; $i <= $n; $i++)\n echo \"GB\";\n }\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $m)\n {\n echo \"B\";\n for ($i = 1; $i <= $m; $i++)\n echo \"GB\";\n for ($i = 1; $i <= $n-$m-1; $i++)\n echo \"B\";\n }\n else\n {\n for ($i = 1; $i <= $n; $i++)\n echo \"GB\";\n }\n?>"}, {"source_code": " $m)\n {\n echo \"B\";\n for ($i = 1; $i <= $m; $i++)\n echo \"GB\";\n for ($i = 1; $i <= $n-$m-1; $i++)\n echo \"B\";\n }\n else\n {\n for ($i = 1; $i <= $n; $i++)\n echo \"GB\";\n }\n?>"}], "src_uid": "5392996bd06bf52b48fe30b64493f8f5"} {"nl": {"description": "The grasshopper is located on the numeric axis at the point with coordinate $$$x_0$$$.Having nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate $$$x$$$ with a distance $$$d$$$ to the left moves the grasshopper to a point with a coordinate $$$x - d$$$, while jumping to the right moves him to a point with a coordinate $$$x + d$$$.The grasshopper is very fond of positive integers, so for each integer $$$i$$$ starting with $$$1$$$ the following holds: exactly $$$i$$$ minutes after the start he makes a jump with a distance of exactly $$$i$$$. So, in the first minutes he jumps by $$$1$$$, then by $$$2$$$, and so on.The direction of a jump is determined as follows: if the point where the grasshopper was before the jump has an even coordinate, the grasshopper jumps to the left, otherwise he jumps to the right.For example, if after $$$18$$$ consecutive jumps he arrives at the point with a coordinate $$$7$$$, he will jump by a distance of $$$19$$$ to the right, since $$$7$$$ is an odd number, and will end up at a point $$$7 + 19 = 26$$$. Since $$$26$$$ is an even number, the next jump the grasshopper will make to the left by a distance of $$$20$$$, and it will move him to the point $$$26 - 20 = 6$$$.Find exactly which point the grasshopper will be at after exactly $$$n$$$ jumps.", "input_spec": "The first line of input contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. Each of the following $$$t$$$ lines contains two integers $$$x_0$$$ ($$$-10^{14} \\leq x_0 \\leq 10^{14}$$$) and $$$n$$$ ($$$0 \\leq n \\leq 10^{14}$$$)\u00a0\u2014 the coordinate of the grasshopper's initial position and the number of jumps.", "output_spec": "Print exactly $$$t$$$ lines. On the $$$i$$$-th line print one integer\u00a0\u2014 the answer to the $$$i$$$-th test case\u00a0\u2014 the coordinate of the point the grasshopper will be at after making $$$n$$$ jumps from the point $$$x_0$$$.", "sample_inputs": ["9\n0 1\n0 2\n10 10\n10 99\n177 13\n10000000000 987654321\n-433494437 87178291199\n1 0\n-1 1"], "sample_outputs": ["-1\n1\n11\n110\n190\n9012345679\n-87611785637\n1\n0"], "notes": "NoteThe first two test cases in the example correspond to the first two jumps from the point $$$x_0 = 0$$$. Since $$$0$$$ is an even number, the first jump of length $$$1$$$ is made to the left, and the grasshopper ends up at the point $$$0 - 1 = -1$$$.Then, since $$$-1$$$ is an odd number, a jump of length $$$2$$$ is made to the right, bringing the grasshopper to the point with coordinate $$$-1 + 2 = 1$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "dbe12a665c374ce3745e20b4a8262eac"} {"nl": {"description": "And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All n participants who have made it to the finals found themselves in a huge m-floored 108-star hotel. Of course the first thought to come in a place like this is \"How about checking out the elevator?\".The hotel's elevator moves between floors according to one never changing scheme. Initially (at the moment of time 0) the elevator is located on the 1-st floor, then it moves to the 2-nd floor, then \u2014 to the 3-rd floor and so on until it reaches the m-th floor. After that the elevator moves to floor m\u2009-\u20091, then to floor m\u2009-\u20092, and so on until it reaches the first floor. This process is repeated infinitely. We know that the elevator has infinite capacity; we also know that on every floor people get on the elevator immediately. Moving between the floors takes a unit of time.For each of the n participant you are given si, which represents the floor where the i-th participant starts, fi, which represents the floor the i-th participant wants to reach, and ti, which represents the time when the i-th participant starts on the floor si.For each participant print the minimum time of his/her arrival to the floor fi. If the elevator stops on the floor si at the time ti, then the i-th participant can enter the elevator immediately. If the participant starts on the floor si and that's the floor he wanted to reach initially (si\u2009=\u2009fi), then the time of arrival to the floor fi for this participant is considered equal to ti.", "input_spec": "The first line contains two space-separated integers n and m (1\u2009\u2264\u2009n\u2009\u2264\u2009105,\u20092\u2009\u2264\u2009m\u2009\u2264\u2009108). Next n lines contain information about the participants in the form of three space-separated integers si fi ti (1\u2009\u2264\u2009si,\u2009fi\u2009\u2264\u2009m,\u20090\u2009\u2264\u2009ti\u2009\u2264\u2009108), described in the problem statement.", "output_spec": "Print n lines each containing one integer \u2014 the time of the arrival for each participant to the required floor.", "sample_inputs": ["7 4\n2 4 3\n1 2 0\n2 2 0\n1 2 1\n4 3 5\n1 2 2\n4 2 0", "5 5\n1 5 4\n1 3 1\n1 3 4\n3 1 5\n4 2 5"], "sample_outputs": ["9\n1\n0\n7\n10\n7\n5", "12\n10\n10\n8\n7"], "notes": "NoteLet's consider the first sample. The first participant starts at floor s\u2009=\u20092 by the time equal to t\u2009=\u20093. To get to the floor f\u2009=\u20094, he has to wait until the time equals 7, that's the time when the elevator will go upwards for the second time. Then the first participant should get on the elevator and go two floors up. In this case the first participant gets to the floor f at time equal to 9. The second participant starts at the time t\u2009=\u20090 on the floor s\u2009=\u20091, enters the elevator immediately, and arrives to the floor f\u2009=\u20092. The third participant doesn't wait for the elevator, because he needs to arrive to the same floor where he starts."}, "positive_code": [{"source_code": "$ufin) { // \u0432\u043d\u0438\u0437 \u0436\u0434\u0435\u043c\n $j= (($utime - 2*$m +$ust+1)/(2*$m-2));\n $j = (j<0)?0:ceil($j);\n $check2 = 2*$m-$ust-1+$j*(2*$m-2);\n \n echo ($check2+($ust-$ufin)).\"\\n\";\n \n } elseif ($ust<$ufin){ //\u0432\u0432\u0435\u0440\u0445 \u0436\u0434\u0435\u043c\n $j = ceil(($utime - $ust+1)/(2*$m-2));\n $check1 = $ust-1+$j*(2*$m-2);\n echo ($check1+($ufin-$ust)).\"\\n\";\n }\n}\n?>"}, {"source_code": "$ufin) { // \u0432\u043d\u0438\u0437 \u0436\u0434\u0435\u043c\n $j= (($utime - 2*$m +$ust+1)/(2*$m-2));\n $j = (j<0)?0:ceil($j);\n $check2 = 2*$m-$ust-1+$j*(2*$m-2);\n echo ($check2+($ust-$ufin)).\"\\n\";\n } elseif ($ust<$ufin){ //\u0432\u0432\u0435\u0440\u0445 \u0436\u0434\u0435\u043c\n $j = ceil(($utime - $ust+1)/(2*$m-2));\n $check1 = $ust-1+$j*(2*$m-2);\n echo ($check1+($ufin-$ust)).\"\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": "=$utime)\n if ($i==$ust)\n $startcount = true;\n \n if (($startcount)&&($i==$ufin)){ \n echo $time.\"\\n\";\n break;\n } \n \n \n $i += $step;\n if ($i==$m)\n $step = -1;\n elseif ($i==1)\n $step = 1;\n \n $time++;\n }\n }\n}\n?>"}, {"source_code": "(2*$m-1)){\n $time = floor($utime/(2*$m-1))*(2*$m-1);\n } else{\n $time = 0;\n }\n \n $i = 1;\n $step = 1;\n $elapsed = 0;\n $startcount = false;\n \n \n if ($ufin==$ust){\n echo $utime.\"\\n\"; \n } else {\n \n while (true){\n \n if ($time>=$utime)\n if ($i==$ust)\n $startcount = true;\n \n if (($startcount)&&($i==$ufin)){ \n echo $time.\"\\n\";\n break;\n } \n \n \n $i += $step;\n if ($i==$m)\n $step = -1;\n elseif ($i==1)\n $step = 1;\n \n $time++;\n }\n }\n}\n?>"}, {"source_code": "$ufin) { // \u0432\u043d\u0438\u0437 \u0436\u0434\u0435\u043c\n $j= (($utime - 2*$m +$ust+1)/(2*$m-2));\n $j = (j<0)?0:ceil($j);\n $check2 = 2*$m-$ust-1+$j*(2*$m-2);\n \n echo ($check2+($ust-$ufin)).\"\\n\";\n \n } elseif ($ust<$ufin){ //\u0432\u0432\u0435\u0440\u0445 \u0436\u0434\u0435\u043c\n $j = ceil(($utime - $ust+1)/(2*$m-2));\n $check1 = $ust-1+$j*(2*$m-2);\n echo ($check1+($ufin-$ust)).\"\\n\";\n }\n}\n?>"}, {"source_code": "(2*$m-1)){\n $time = floor($utime/(2*$m-1))*(2*$m-1);\n } else{\n $time = 0;\n }\n \n $i = 1;\n $step = 1;\n $elapsed = 0;\n $startcount = false;\n \n \n if ($ufin==$ust){\n echo $utime.\"\\n\"; \n } else {\n \n while (true){\n \n if ($time>=$utime)\n if ($i==$ust)\n $startcount = true;\n \n if (($startcount)&&($i==$ufin)){ \n echo $time.\"\\n\";\n break;\n } \n \n \n $i += $step;\n if ($i==$m)\n $step = -1;\n elseif ($i==1)\n $step = 1;\n \n $time++;\n }\n }\n}\n?>"}], "src_uid": "b8321b0a3fc8c295182a4c2c8d2e9d01"} {"nl": {"description": "According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should be at the bottom of the tower, while small snacks should be at the top.Years passed, and once different snacks started to fall onto the city, and the residents began to build the Snacktower. However, they faced some troubles. Each day exactly one snack fell onto the city, but their order was strange. So, at some days the residents weren't able to put the new stack on the top of the Snacktower: they had to wait until all the bigger snacks fell. Of course, in order to not to anger miss Fortune again, the residents placed each snack on the top of the tower immediately as they could do it.Write a program that models the behavior of Ankh-Morpork residents.", "input_spec": "The first line contains single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the total number of snacks. The second line contains n integers, the i-th of them equals the size of the snack which fell on the i-th day. Sizes are distinct integers from 1 to n. ", "output_spec": "Print n lines. On the i-th of them print the sizes of the snacks which the residents placed on the top of the Snacktower on the i-th day in the order they will do that. If no snack is placed on some day, leave the corresponding line empty.", "sample_inputs": ["3\n3 1 2", "5\n4 5 1 2 3"], "sample_outputs": ["3\n\u00a0\n2 1", "5 4\n\u00a0\n\u00a0\n3 2 1"], "notes": "NoteIn the example a snack of size 3 fell on the first day, and the residents immediately placed it. On the second day a snack of size 1 fell, and the residents weren't able to place it because they were missing the snack of size 2. On the third day a snack of size 2 fell, and the residents immediately placed it. Right after that they placed the snack of size 1 which had fallen before."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "3d648acee2abbf834f865b582aa9b7bc"} {"nl": {"description": "You are given a sequence of $$$n$$$ digits $$$d_1d_2 \\dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digits painted in the color $$$2$$$, then the resulting sequence of $$$n$$$ digits will be non-decreasing (that is, each next digit will be greater than or equal to the previous digit). For example, for the sequence $$$d=914$$$ the only valid coloring is $$$211$$$ (paint in the color $$$1$$$ two last digits, paint in the color $$$2$$$ the first digit). But $$$122$$$ is not a valid coloring ($$$9$$$ concatenated with $$$14$$$ is not a non-decreasing sequence).It is allowed that either of the two colors is not used at all. Digits painted in the same color are not required to have consecutive positions.Find any of the valid ways to paint the given sequence of digits or determine that it is impossible to do.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10000$$$) \u2014 the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \\le n \\le 2\\cdot10^5$$$) \u2014 the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \\dots d_{n}$$$ ($$$0 \\le d_i \\le 9$$$). The digits are written in a row without spaces or any other separators. The sequence can start with 0. It is guaranteed that the sum of the values \u200b\u200bof $$$n$$$ for all test cases in the input does not exceed $$$2\\cdot10^5$$$.", "output_spec": "Print $$$t$$$ lines \u2014 the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \\dots t_n$$$ ($$$1 \\le t_i \\le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digit is painted in. If there are several feasible solutions, print any of them. If there is no solution, then the corresponding output line should contain a single character '-' (the minus sign).", "sample_inputs": ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"], "sample_outputs": ["121212211211\n1\n222222222\n21\n-"], "notes": "NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits."}, "positive_code": [{"source_code": " 0; $y--)\n {\n if($c[$y] < $c[$y - 1])\n {\n $d = 1;\n $f = $c[$y];\n $f2 = $c[$y - 1];\n break;\n }\n else\n {\n $e[$y - 1] = \"1\";\n }\n }\n if($d == 0)\n {\n print implode(array_fill(0, $b, 1)) . \"\\n\";\n }\n else\n {\n for($z = $y; $z >= 0; $z--)\n {\n if($c[$z] <= $f)\n {\n $e[$z] = \"1\";\n if($c[$z] < $f)\n {\n $f = $c[$z];\n }\n }\n }\n for($z = $b - 1; $z >= 0; $z--)\n {\n if($c[$z] >= $f2)\n {\n $e[$z] = \"2\";\n }\n else\n {\n break;\n }\n }\n $g = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"2\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n $h = $g;\n sort($h);\n if($h == $g)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}], "negative_code": [{"source_code": "= $c[$y])\n {\n $f = $c[$y + 1];\n }\n }\n else\n {\n $e = 1;\n break;\n }\n }\n if($e == 0)\n {\n for($y = 0; $y < $d; $y++)\n {\n if($c[$y] > $c[$d])\n {\n $g[$y] = \"2\";\n }\n else\n {\n $g[$y] = \"1\";\n }\n }\n for($y = $d; $y < $b; $y++)\n {\n if($c[$y] < $f)\n {\n $g[$y] = \"1\";\n }\n else\n {\n $g[$y] = \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $f)\n {\n $g[$y] = \"1\";\n }\n elseif($c[$y] < $f)\n {\n break;\n }\n }\n $h = \"\";\n $i = \"\";\n for($y = 0; $y < $b; $y++)\n {\n if($g[$y] == \"1\")\n {\n $h .= $c[$y];\n }\n else\n {\n $i .= $c[$y];\n }\n }\n $j = 0;\n $k = $h . $i;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($k[$y] > $k[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($g) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": "= $c[$y])\n {\n $f = $c[$y + 1];\n }\n }\n else\n {\n $e = 1;\n break;\n }\n }\n if($e == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] < $f)\n {\n $g[$y] = \"1\";\n }\n else\n {\n $g[$y] = \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $f)\n {\n $g[$y] = \"1\";\n }\n elseif($c[$y] < $f)\n {\n break;\n }\n }\n $h = \"\";\n $i = \"\";\n for($y = 0; $y < $b; $y++)\n {\n if($g[$y] == \"1\")\n {\n $h .= $c[$y];\n }\n else\n {\n $i .= $c[$y];\n }\n }\n $j = 0;\n $k = $h . $i;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($k[$y] > $k[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($g) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $d[count($d)] = $c[$y];\n $e[count($e)] = $c[$y + 1];\n }\n }\n $f = 0;\n for($y = 0; $y < count($d) - 1; $y++)\n {\n if($d[$y] > $d[$y + 1])\n {\n $f = 1;\n break;\n }\n }\n for($y = 0; $y < count($e) - 1; $y++)\n {\n if($e[$y] > $e[$y + 1])\n {\n $f = 1;\n break;\n }\n }\n if($e[count($e) - 1] > $d[count($d) - 1])\n {\n $f = 1;\n }\n if($f == 0)\n {\n $g = \"\";\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] < $d[0])\n {\n $g .= \"1\";\n }\n else\n {\n $g .= \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $d[0])\n {\n $g[$y] = \"1\";\n }\n elseif($c[$y] < $d[0])\n {\n break;\n }\n }\n print $g . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $g = $c[$y];\n break;\n }\n }\n if($g == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($d[$y] >= $f)\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n if(($d[$y] >= $f) && ($c[$d[$y]] < $g))\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $g)\n {\n $e[$y] = \"1\";\n }\n elseif($c[$y] < $g)\n {\n break;\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0; $y--)\n {\n if($c[$y] < $c[$y - 1])\n {\n $d = 1;\n $f = $c[$y];\n break;\n }\n else\n {\n $e[$y - 1] = \"1\";\n }\n }\n if($d == 0)\n {\n print implode(array_fill(0, $b, 1)) . \"\\n\";\n }\n else\n {\n for($z = $y; $z >= 0; $z--)\n {\n if($c[$z] <= $f)\n {\n $e[$z] = \"1\";\n if($c[$z] < $f)\n {\n $f = $c[$z];\n }\n }\n }\n $g = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"2\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n $h = $g;\n sort($h);\n if($h == $g)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": "= $c[$y])\n {\n $f = $c[$y + 1];\n }\n }\n else\n {\n $e = 1;\n break;\n }\n }\n if($e == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] < $f)\n {\n $g[$y] = \"1\";\n }\n else\n {\n $g[$y] = \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $f)\n {\n $g[$y] = \"1\";\n }\n elseif($c[$y] < $f)\n {\n break;\n }\n }\n print implode(\" \", $g);\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": " 0; $y--)\n {\n if($c[$y] < $c[$y - 1])\n {\n $d = 1;\n $f = $c[$y];\n $f2 = $c[$y - 1];\n break;\n }\n else\n {\n $e[$y - 1] = \"1\";\n }\n }\n if($d == 0)\n {\n print implode(array_fill(0, $b, 1)) . \"\\n\";\n }\n else\n {\n for($z = $y; $z >= 0; $z--)\n {\n if($c[$z] <= $f)\n {\n $e[$z] = \"1\";\n if($c[$z] < $f)\n {\n $f = $c[$z];\n }\n }\n }\n for($z = $b - 1; $z >= 0; $z--)\n {\n if($c[$z] > $f2)\n {\n $e[$z] = \"2\";\n }\n else\n {\n break;\n }\n }\n $g = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"2\")\n {\n $g[count($g)] = $c[$y];\n }\n }\n $h = $g;\n sort($h);\n if($h == $g)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $g = $c[$y];\n break;\n }\n }\n if($g == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($d[$y] >= $f)\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n if(($d[$y] >= $f) && ($c[$d[$y]] < $g))\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $k = $c[0];\n for($y = 1; $y < $b; $y++)\n {\n if($e[$y] == \"2\")\n {\n if($c[$y] < $k)\n {\n $k = $c[$y];\n }\n }\n else\n {\n break;\n }\n }\n $e2 = $e;\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $g)\n {\n $e[$y] = \"1\";\n }\n elseif($c[$y] < $g)\n {\n if($k > $c[$y])\n {\n $e = $e2;\n }\n break;\n }\n }\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $d = 1;\n $e = $c[$y];\n break;\n }\n }\n if($d == 0)\n {\n $f = array_fill(0, $b, \"1\");\n print implode($f) . \"\\n\";\n }\n else\n {\n $f = \"\";\n $f2 = \"\";\n $f3 = \"\";\n $g = 0;\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] > $e)\n {\n $g = 1;\n }\n if(($c[$y] < $e) && ($g == 0))\n {\n $f .= $c[$y];\n $f3 .= \"1\";\n }\n elseif(($c[$y] <= $e) && ($g == 1))\n {\n $f .= $c[$y];\n $f3 .= \"1\";\n }\n else\n {\n $f2 .= $c[$y];\n $f3 .= \"2\";\n }\n }\n $h = 0;\n for($y = 0; $y < strlen($f) - 1; $y++)\n {\n if($f[$y] > $f[$y + 1])\n {\n $h = 1;\n break;\n }\n }\n for($y = 0; $y < strlen($f2) - 1; $y++)\n {\n if($f2[$y] > $f2[$y + 1])\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print $f3 . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $d[count($d)] = $c[$y];\n $e[count($e)] = $c[$y + 1];\n }\n }\n $f = 0;\n for($y = 0; $y < count($d) - 1; $y++)\n {\n if($d[$y] > $d[$y + 1])\n {\n $f = 1;\n break;\n }\n }\n for($y = 0; $y < count($e) - 1; $y++)\n {\n if($e[$y] > $e[$y + 1])\n {\n $f = 1;\n break;\n }\n }\n if($e[count($e) - 1] > $d[count($d) - 1])\n {\n $f = 1;\n }\n if($f == 0)\n {\n $g = \"\";\n for($y = 0; $y < $b; $y++)\n {\n if($c[$y] < $d[0])\n {\n $g .= \"1\";\n }\n else\n {\n $g .= \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $d[0])\n {\n $g[$y] = \"1\";\n }\n else\n {\n break;\n }\n }\n print $g . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $d2[count($d2)] = $c[$y];\n $e2[count($e2)] = $c[$y + 1];\n }\n }\n $f2 = 0;\n for($y = 0; $y < count($d2) - 1; $y++)\n {\n if($d2[$y] > $d2[$y + 1])\n {\n $f2 = 1;\n break;\n }\n }\n for($y = 0; $y < count($e2) - 1; $y++)\n {\n if($e2[$y] > $e2[$y + 1])\n {\n $f2 = 1;\n break;\n }\n }\n if($e2[count($e2) - 1] > $d2[count($d2) - 1])\n {\n $f2 = 1;\n }\n if($f2 == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($d[$y] >= $f)\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $g = $c[$y];\n break;\n }\n }\n if($g == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($d[$y] >= $f)\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n if(($d[$y] >= $f) && ($c[$d[$y]] < $g))\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $g)\n {\n $e[$y] = \"1\";\n }\n elseif(($c[$y] < $g) || ($c[$y] > $g))\n {\n break;\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}, {"source_code": " $c[$y + 1])\n {\n $g = $c[$y];\n break;\n }\n if($g2 > $c[$y + 1])\n {\n $g2 = $c[$y + 1];\n }\n }\n if($g == 0)\n {\n for($y = 0; $y < $b; $y++)\n {\n if($d[$y] >= $f)\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n else\n {\n for($y = 0; $y < $b; $y++)\n {\n if(($d[$y] >= $f) && ($c[$d[$y]] < $g2))\n {\n $e[$d[$y]] = \"1\";\n $f = $d[$y];\n }\n else\n {\n $e[$d[$y]] = \"2\";\n }\n }\n ksort($e);\n $k = $c[0];\n for($y = 1; $y < $b; $y++)\n {\n if($e[$y] == \"2\")\n {\n if($c[$y] < $k)\n {\n $k = $c[$y];\n }\n }\n else\n {\n break;\n }\n }\n $e2 = $e;\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($c[$y] == $g)\n {\n $e[$y] = \"1\";\n }\n elseif($c[$y] < $g)\n {\n if($k > $c[$y])\n {\n $e = $e2;\n }\n break;\n }\n }\n $h = array();\n $i = array();\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"1\")\n {\n $h[count($h)] = $c[$y];\n }\n else\n {\n $i[count($i)] = $c[$y];\n }\n }\n $j = 0;\n for($y = 0; $y < count($h) - 1; $y++)\n {\n if($h[$y] > $h[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if($i[$y] > $i[$y + 1])\n {\n $j = 1;\n break;\n }\n }\n if($j == 0)\n {\n print implode($e) . \"\\n\";\n }\n else\n {\n print \"-\\n\";\n }\n }\n}\n?>"}], "src_uid": "886f773e75fa3c770fb70133ff1b595b"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by $$$2$$$) or determine that there is no such subset.Both the given array and required subset may contain equal values.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$), number of test cases to solve. Descriptions of $$$t$$$ test cases follow. A description of each test case consists of two lines. The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$), length of array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 100$$$), elements of $$$a$$$. The given array $$$a$$$ can contain equal values (duplicates).", "output_spec": "For each test case output $$$-1$$$ if there is no such subset of elements. Otherwise output positive integer $$$k$$$, number of elements in the required subset. Then output $$$k$$$ distinct integers ($$$1 \\leq p_i \\leq n$$$), indexes of the chosen elements. If there are multiple solutions output any of them.", "sample_inputs": ["3\n3\n1 4 3\n1\n15\n2\n3 5"], "sample_outputs": ["1\n2\n-1\n2\n1 2"], "notes": "NoteThere are three test cases in the example.In the first test case, you can choose the subset consisting of only the second element. Its sum is $$$4$$$ and it is even.In the second test case, there is only one non-empty subset of elements consisting of the first element, however sum in it is odd, so there is no solution.In the third test case, the subset consisting of all array's elements has even sum."}, "positive_code": [{"source_code": ""}, {"source_code": "count($A))\n return false;\n \n $sum=0;\n for($i=0;$i<$len;$i++)\n { \n $val = $A[$i+$pos];\n $sum += (int)$val;\n }\n return $sum % 2 == 0;\n}\n\n?>\n"}, {"source_code": " $v) {\n if ($sum > 0 && $sum % 2 === 0) {\n break;\n } elseif ($v % 2 === 0) {\n echo 1 . \"\\n\";\n echo (($k + 1) . \"\\n\");\n break;\n } else {\n $sum += $v;\n ++$f;\n $p .= (($k + 1) . ' ');\n }\n }\n if ($l == 1 && $sum % 2 != 0)\n echo -1 . \"\\n\";\n if ($sum > 0 && $sum % 2 === 0) {\n echo $f . \"\\n\";\n echo $p . \"\\n\";\n }\n}\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "count($A))\n return false;\n \n $sum=0;\n for($i=0;$i<$len;$i++)\n { \n $val = $A[$i+$pos];\n $sum += (int)$val;\n }\n return $sum % 2 == 0;\n}\n\n?>\n"}, {"source_code": " $v) {\n if ($sum > 0 && $sum % 2 === 0) {\n echo $f . \"\\n\";\n echo $p . \"\\n\";\n break;\n } elseif ($v % 2 === 0) {\n echo 1 . \"\\n\";\n echo (($k + 1) . \"\\n\");\n break;\n } else {\n $sum += $v;\n ++$f;\n $p .= (($k + 1) . ' ');\n }\n }\n if ($l == 1 && $sum % 2 != 0)\n echo -1 . \"\\n\";\n if ($sum > 0 && $sum % 2 === 0) {\n echo $f . \"\\n\";\n echo $p . \"\\n\";\n }\n}\n"}], "src_uid": "3fe51d644621962fe41c32a2d90c7f94"} {"nl": {"description": "Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones); take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones). She wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has $$$0$$$ stones. Can you help her?", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$) \u00a0\u2014 the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \\leq a,b,c \\leq 100$$$)\u00a0\u2014 the number of stones in the first, the second and the third heap, respectively. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.", "output_spec": "Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer \u00a0\u2014 the maximum possible number of stones that Alice can take after making some operations. ", "sample_inputs": ["3\n3 4 5\n1 0 5\n5 3 2"], "sample_outputs": ["9\n0\n6"], "notes": "NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones, that Alice will take is $$$9$$$. It is impossible to make some operations to take more than $$$9$$$ stones, so the answer is $$$9$$$."}, "positive_code": [{"source_code": " 0)\n {\n $e += 3;\n $b--;\n $c -= 2;\n }\n else\n {\n $e += 3;\n $c--;\n $d -= 2;\n }\n }\n elseif($c > $d)\n {\n if($b > 0)\n {\n $e += 3;\n $b--;\n $c -= 2;\n }\n elseif($d >= 2)\n {\n $e += 3;\n $c--;\n $d -= 2;\n }\n else\n {\n break;\n }\n }\n }\n print $e . \"\\n\";\n}\n?>"}, {"source_code": "=2 && $v[1]>=1){\n $k+=3;\n $v[2]-=2;\n $v[1]-=1;\n goto again;\n }\n \n again_1:\n if($v[1]>=2 && $v[0]>=1){\n $k+=3;\n $v[1]-=2;\n $v[0]-=1;\n goto again_1;\n }\n \n echo $k;\n if($i!=$arr[0]-1) echo \"\\n\";\n \n}\n\n?>"}, {"source_code": "$a[1])\n {\n $new=0;\n $sum=$sum+$a[1];\n }\n else\n {\n $sum=$sum+$ans;\n $new=$a[1]-$ans;\n }\n\n $ans1=(int)($new/2);\n if($ans1>$a[0])\n {\n $new1=0;\n $sum=$sum+$a[0];\n }else\n {\n $sum=$sum+$ans1;\n }\n echo $sum*3;\n echo \"\\n\";\n }\n}\n\nsolve();\n?>"}], "negative_code": [{"source_code": "$a[1])\n {\n $new=0;\n $sum=$sum+$a[1];\n }else\n {\n $sum=$sum+$ans;\n $new=$a[1]-$ans;\n }\n $ans1=(int)($new/2);\n if($ans1>$a[0])\n {\n $new1=0;\n $sum=$sum+$ans1;\n }else\n {\n $sum=$sum+$ans1;\n }\n echo $sum*3;\n echo \"\\n\";\n }\n}\n\nsolve();\n?>"}], "src_uid": "14fccd50d5dfb557dd53f2896ed844c3"} {"nl": {"description": "George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b1,\u2009b2,\u2009...,\u2009b|b| (record |b| denotes the current length of the array). Then one change is a sequence of actions: Choose two distinct indexes i and j (1\u2009\u2264\u2009i,\u2009j\u2009\u2264\u2009|b|;\u00a0i\u2009\u2260\u2009j), such that bi\u2009\u2265\u2009bj. Get number v\u2009=\u2009concat(bi,\u2009bj), where concat(x,\u2009y) is a number obtained by adding number y to the end of the decimal record of number x. For example, concat(500,\u200910)\u2009=\u200950010, concat(2,\u20092)\u2009=\u200922. Add number v to the end of the array. The length of the array will increase by one. Remove from the array numbers with indexes i and j. The length of the array will decrease by two, and elements of the array will become re-numbered from 1 to current length of the array. George played for a long time with his array b and received from array b an array consisting of exactly one number p. Now George wants to know: what is the maximum number of elements array b could contain originally? Help him find this number. Note that originally the array could contain only positive integers.", "input_spec": "The first line of the input contains a single integer p (1\u2009\u2264\u2009p\u2009<\u200910100000). It is guaranteed that number p doesn't contain any leading zeroes.", "output_spec": "Print an integer \u2014 the maximum number of elements array b could contain originally.", "sample_inputs": ["9555", "10000000005", "800101", "45", "1000000000000001223300003342220044555", "19992000", "310200"], "sample_outputs": ["4", "2", "3", "1", "17", "1", "2"], "notes": "NoteLet's consider the test examples: Originally array b can be equal to {5,\u20099,\u20095,\u20095}. The sequence of George's changes could have been: {5,\u20099,\u20095,\u20095}\u2009\u2192\u2009{5,\u20095,\u200995}\u2009\u2192\u2009{95,\u200955}\u2009\u2192\u2009{9555}. Originally array b could be equal to {1000000000,\u20095}. Please note that the array b cannot contain zeros. Originally array b could be equal to {800,\u200910,\u20091}. Originally array b could be equal to {45}. It cannot be equal to {4,\u20095}, because George can get only array {54} from this array in one operation. Note that the numbers can be very large."}, "positive_code": [{"source_code": " 0; $x--)\n {\n if(($b[$x - 1] >= $b[$x]) && ($b[$x] == 0) && ($x == 1))\n {\n $f = $c - $e + 1;\n $d += $f;\n $c = 0;\n $e = 0;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 2;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c != 0))\n {\n $f = $c - $e + 1;\n $d += $f;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c == 0))\n {\n $c = 0;\n $e = 0;\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h >= $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c == 0))\n {\n $g = $b[$x];\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h >= $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($e == 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h >= $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h >= $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h >= $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\"; \n }\n else\n {\n $g = $b[$x] . $g;\n $c++;\n if($b[$x] == 0)\n {\n $e++;\n }\n }\n }\n print $d;\n}\n?>"}, {"source_code": " $l/2) return true; \n\n\tif ($j > 1 and $s[$j+1] != 0) return true;\n\n\tif ($j == 1 and $s[$j+1] != 0) return ($s[0] >= $s[1]); \n\n\t$k = $j+1; \n\twhile ($s[$k] == '0') { $k++; if ($k >= $l) break; }\n\t$zero = $k-$j-1; \n\n\tif ($j <= $zero) return false;\n\n\tif ($j > $zero+1) return true; \n\n\treturn ($s[0] >= $s[$j]);\n}\n"}], "negative_code": [{"source_code": " 0; $x--)\n {\n if(($b[$x - 1] >= $b[$x]) && ($b[$x] == 0) && ($x == 1))\n {\n $f = $c - $e + 1;\n $d += $f;\n $c = 0;\n $e = 0;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 2;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c != 0))\n {\n $f = $c - $e + 1;\n $d += $f;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c == 0))\n {\n $c = 0;\n $e = 0;\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c == 0))\n {\n $g = $b[$x];\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($e == 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\"; \n }\n else\n {\n $g = $b[$x] . $g;\n $c++;\n if($b[$x] == 0)\n {\n $e++;\n }\n }\n }\n print $d;\n}\n?>"}, {"source_code": " 0; $x--)\n{\n if(($b[$x - 1] >= $b[$x]) && ($b[$x] == 0) && ($x == 1))\n {\n $f = $c - $e + 1;\n $d += $f;\n $c = 0;\n $e = 0;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 2;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c == 0))\n {\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($x == 1) && ($c != 0))\n {\n $f = $c - $e + 1;\n $d += $f;\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c == 0))\n {\n $c = 0;\n $e = 0;\n $d += 1;\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] != 0) && ($c == 0))\n {\n $g = $b[$x];\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($e == 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] < $b[$x]) && ($b[$x] != 0) && ($b[$x - 1] == 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\";\n }\n elseif(($b[$x - 1] >= $b[$x]) && ($b[$x] != 0) && ($c != 0))\n {\n $g = $b[$x] . $g;\n $h = substr($a, 0, $x);\n if(strlen($h) > strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif(strlen($h) < strlen($g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n }\n elseif((strlen($h) == strlen($g)) && ($h > $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n }\n elseif((strlen($h) == strlen($g)) && ($h < $g))\n {\n $d += 1;\n $c = 0;\n $e = 0;\n break;\n } \n $g = \"\";\n $h = \"\"; \n }\n else\n {\n $g = $b[$x] . $g;\n $c++;\n if($b[$x] == 0)\n {\n $e++;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": " $l/2) return true; \n\n\tif ($j > 1 and $s[$j+1] != 0) return true;\n\n\tif ($j == 1 and $s[$j+1] != 0) return ($s[0] > $s[1]); \n\n\t$k = $j+1; \n\twhile ($s[$k] == '0') { $k++; if ($k >= $l) break; }\n\t$zero = $k-$j-1; \n\n\tif ($j <= $zero) return false;\n\n\tif ($j > $zero+1) return true; \n\n\treturn ($s[0] >= $s[$j]);\n}\n"}, {"source_code": " $l/2) return true; \n\n\tif ($j > 1 and $s[$j+1] != 0) return true;\n\n\tif ($j == 1 and $s[$j+1] != 0) return ($s[0] > $s[1]);\n\n\t$k = $j+1; \n\twhile ($s[$k] == '0') { $k++; if ($k >= $l) break; }\n\t$zero = $k-$j-1; \n\n\tif ($j <= $zero) return false; \n\n\tif ($j > $zero+1) return true; \n\n\treturn ($s[0] > $s[$j]);\n}\n"}, {"source_code": " $l/2) return true; \n\n\tif ($j > 1 and $s[$j+1] != 0) return true;\n\n\tif ($j == 1 and $s[$j+1] != 0) return ($s[0] > $s[1]);\n\n\t$k = $j+1;\n\twhile ($s[$k] == '0') { $k++; if ($k+1 >= $l) break; }\n\t$zero = $k-$j;\n\n\tif ($j <= $zero) return false;\n\n\tif ($j > $zero+1) return true;\n\n\treturn ($s[0] > $s[$j]);\n}\n"}], "src_uid": "4e00fe693a636316d478978abf21d976"} {"nl": {"description": "Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj,\u2009bj) can close marker (xi,\u2009yi) only if their diameters match, that is, bj\u2009=\u2009yi. Besides, a marker is considered to be beautifully closed, if the cap color and the marker color match, that is, aj\u2009=\u2009xi.Find the way to close the maximum number of markers. If there are several such ways, then choose the one that has the maximum number of beautifully closed markers.", "input_spec": "The first input line contains two space-separated integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105) \u2014 the number of markers and the number of caps, correspondingly. Next n lines describe the markers. The i-th line contains two space-separated integers xi, yi (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u20091000) \u2014 the i-th marker's color and diameter, correspondingly. Next m lines describe the caps. The j-th line contains two space-separated integers aj, bj (1\u2009\u2264\u2009aj,\u2009bj\u2009\u2264\u20091000) \u2014 the color and diameter of the j-th cap, correspondingly.", "output_spec": "Print two space-separated integers u,\u2009v, where u is the number of closed markers and v is the number of beautifully closed markers in the sought optimal way. Remember that you have to find the way to close the maximum number of markers, and if there are several such ways, you should choose the one where the number of beautifully closed markers is maximum.", "sample_inputs": ["3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2", "2 2\n1 2\n2 1\n3 4\n5 1"], "sample_outputs": ["3 2", "1 0"], "notes": "NoteIn the first test sample the first marker should be closed by the fourth cap, the second marker should be closed by the first cap and the third marker should be closed by the second cap. Thus, three markers will be closed, and two of them will be beautifully closed \u2014 the first and the third markers."}, "positive_code": [{"source_code": ""}, {"source_code": " $val)\n{\n if(isset($kolp[$k]['cnt']))\n {\n $u += min($val['cnt'],$kolp[$k]['cnt']);\n foreach($val['color'] as $k1 => $v1)\n if(isset($kolp[$k]['color'][$k1]))\n $v += min($v1,$kolp[$k]['color'][$k1]); \n }\n}\nfputs(STDOUT, $u.\" \".$v); \n?>\n"}, {"source_code": "= 1 ) {\n\t\t$flomasters[ $cap[1] ][ $cap[0] ] --;\n\t\t$v++;\n\t\t$flomastersAll[ $cap[1] ]--;\n\t} else {\n\t\t$nonFormat[ $cap[1] ]++;\n\t}\n}\n\n$u = $v;\nforeach( $nonFormat as $key => $value ){\n\t$u += min( $flomastersAll[ $key ], $value);\n}\necho $u . \" \" . $v;\n\nfclose($fp);\n?>"}, {"source_code": " 0) {\n\t\t--$pens[$diameter][$color];\n\t\t--$penCount[$diameter];\n\t\t++$nice;\n\t}\n}\n\n$total = $nice;\nforeach($penCount as $diameter => $count) {\n\tif (isset($fail[$diameter])) {\n\t\t$total += ($count > $fail[$diameter]) ? $fail[$diameter] : $count;\n\t}\n}\n\n\necho \"$total $nice\\n\";\n?>"}, {"source_code": " 0) {\n $beautiful++;\n $closed++;\n $markers[$size][$color]--;\n $markers[$size][\"closed\"]--;\n unset($caps[$i]);\n }\n\n}\n\nforeach($caps as $cap) {\n if( $markers[$cap[1]][\"closed\"] > 0 ) {\n $closed++;\n $markers[$cap[1]][\"closed\"]--;\n }\n}\n\necho $closed. \" \".$beautiful;\n\n\n\n\n\n\n\n?>"}, {"source_code": " 0){\n $curr[$exp[1]][$exp[0]]--;\n $CountColor[$exp[1]]--; \n $CountMarker[0]++;\n $CountMarker[1]++;\n } else{\n if(isset($StackBad[$exp[1]]))\n $StackBad[$exp[1]]++;\n else\n $StackBad[$exp[1]] = 1; \n }\n}\nforeach($StackBad AS $key => $value){\n if($CountColor[$key] >= $value)\n $CountMarker[0]+= $value;\n else\n $CountMarker[0]+= $CountColor[$key];\n}\necho $CountMarker[0]. ' '. $CountMarker[1] . \"\\n\";"}, {"source_code": " $aMarkerColors) {\n\tforeach ($aMarkerColors as $iMarkerColor => $iTheMarkers) {\n\t\t\n\t\tif (isset($aCaps[$iMarkerDiameter][$iMarkerColor]) && $aCaps[$iMarkerDiameter][$iMarkerColor] > 0) {\n\t\t\t$iTheCaps = $aCaps[$iMarkerDiameter][$iMarkerColor];\n\t\t\t$iCapped = min($iTheCaps, $iTheMarkers);\n\t\t\t\n\t\t\t$iBeautifulCappedMarkers += $iCapped;\n\t\t}\n\t}\n}\n\nforeach ($aUnbeautifulMarkers as $iMarkerDiameter => $iTheMarkers) {\n\tif (isset($aUnbeautifulCaps[$iMarkerDiameter]) && $aUnbeautifulCaps[$iMarkerDiameter] > 0) {\n\t\t$iTheCaps = $aUnbeautifulCaps[$iMarkerDiameter];\n\t\t\n\t\t$iCapped = min($iTheCaps, $iTheMarkers);\n\t\t\n\t\t$iCappedMarkers += $iCapped;\n\t}\n}\n\necho $iCappedMarkers . ' ' . $iBeautifulCappedMarkers;"}, {"source_code": " $value) {\n if (isset($capdiameters[$key])) {\n $tmp = array();\n $tmp[] = $capdiameters[$key];\n $tmp[] = $markerdiameters[$key];\n $capped += min($tmp);\n }\n}\n\n$mhashcount = array_count_values($markerhash);\n$chashcount = array_count_values($caphash);\n\nforeach ($mhashcount as $key => $value) {\n if (isset($chashcount[$key])) {\n $tmp = array();\n $tmp[] = $chashcount[$key];\n $tmp[] = $mhashcount[$key];\n $beautifully += min($tmp);\n }\n}\n\necho $capped.\" \".$beautifully;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0) {\n $beautiful++;\n $closed++;\n $markers[ $caps[$i][1] ][ $caps[$i][0] ]--;\n $markers[ $caps[$i][1] ][\"closed\"]--;\n }\n elseif( $markers[ $caps[$i][1] ][\"closed\"] > 0 ) {\n $closed++;\n $markers[ $caps[$i][1] ][ $caps[$i][0] ]--;\n $markers[ $caps[$i][1] ][\"closed\"]--;\n }\n}\n\n\n\necho $closed. \" \".$beautiful;\n\n\n\n\n/*\n5 5\n1 5\n2 4\n1 5\n3 4\n1 6\n3 4\n2 4\n6 4\n8 5\n1 6\n\n5: [1]\n4: [2,3]\n6: [1]\n*/\n\n/*\n\n5 5\n1 2\n1 3\n1 2\n1 3\n1 3\n1 2\n1 2\n1 3\n1 2\n1 2\n\n*/\n\n\n?>"}], "src_uid": "3c9fb72577838f54b1670e84b4b60c61"} {"nl": {"description": "The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding\u00a0\u2014 an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slogan. They decided to start with the name.For this purpose the corporation has consecutively hired m designers. Once a company hires the i-th designer, he immediately contributes to the creation of a new corporation name as follows: he takes the newest version of the name and replaces all the letters xi by yi, and all the letters yi by xi. This results in the new version. It is possible that some of these letters do no occur in the string. It may also happen that xi coincides with yi. The version of the name received after the work of the last designer becomes the new name of the corporation.Manager Arkady has recently got a job in this company, but is already soaked in the spirit of teamwork and is very worried about the success of the rebranding. Naturally, he can't wait to find out what is the new name the Corporation will receive.Satisfy Arkady's curiosity and tell him the final version of the name.", "input_spec": "The first line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009200\u2009000)\u00a0\u2014 the length of the initial name and the number of designers hired, respectively. The second line consists of n lowercase English letters and represents the original name of the corporation. Next m lines contain the descriptions of the designers' actions: the i-th of them contains two space-separated lowercase English letters xi and yi.", "output_spec": "Print the new name of the corporation.", "sample_inputs": ["6 1\npolice\np m", "11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b"], "sample_outputs": ["molice", "cdcbcdcfcdc"], "notes": "NoteIn the second sample the name of the corporation consecutively changes as follows: "}, "positive_code": [{"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\nfor($x = 0; $x < $b; $x++)\n{\n list($e, $f) = explode(\" \", trim(fgets(STDIN)));\n $g = $d[$e];\n $h = $d[$f];\n $d[$e] = $h;\n $d[$f] = $g;\n}\n$i = array_flip($d);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$x] = $i[$c[$x]];\n}\nprint $c;\n?>"}, {"source_code": " $pArray) {\n if (count($pArray)==0) {\n continue;\n }\n foreach ($pArray as $p) {\n $o[$p] = chr($c);\n }\n}\nfor ($i = 0; $i < $n; $i++) {\n echo $o[$i];\n}"}], "negative_code": [{"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$e = array(\"a\" => \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$j = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n array_push($j, $f);\n array_push($j, $g);\n array_push($j, \" \");\n $h = $d[$e[$f]];\n $i = $d[$e[$g]];\n $d[$e[$f]] = $i;\n $d[$e[$g]] = $h;\n $e[$f] = $g;\n $e[$g] = $f;\n}\nif($b == 100)\n{\n print implode(\" \", $j);\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n $c[$x] = $d[$c[$x]];\n }\n print $c;\n}\n?>"}, {"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$e = array(\"a\" => \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$j = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n array_push($j, $f);\n array_push($j, $g);\n array_push($j, \" \");\n $h = $d[$e[$f]];\n $i = $d[$e[$g]];\n $d[$e[$f]] = $i;\n $d[$e[$g]] = $h;\n $e[$f] = $g;\n $e[$g] = $f;\n}\nprint implode(\" \", $j);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$x] = $d[$c[$x]];\n}\nprint $c;\n?>"}, {"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$e = array(\"a\" => \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$j = array();\nfor($x = 0; $x < $b; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n array_push($j, $f);\n array_push($j, $g);\n $h = $d[$e[$f]];\n $i = $d[$e[$g]];\n $d[$e[$f]] = $i;\n $d[$e[$g]] = $h;\n $e[$f] = $g;\n $e[$g] = $f;\n}\nif($b == 100)\n{\n print implode(\" \", $j);\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n $c[$x] = $d[$c[$x]];\n }\n print $c;\n}\n?>"}, {"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$e = array(\"a\" => \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\nfor($x = 0; $x < $b; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n $h = $d[$e[$f]];\n $i = $d[$e[$g]];\n $d[$e[$f]] = $i;\n $d[$e[$g]] = $h;\n $e[$f] = $g;\n $e[$g] = $f;\n}\nfor($x = 0; $x < $a; $x++)\n{\n $c[$x] = $d[$c[$x]];\n}\nprint $c;\n?>"}, {"source_code": " \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\n$e = array(\"a\" => \"a\", \"b\" => \"b\", \"c\" => \"c\", \"d\" => \"d\", \"e\" => \"e\", \"f\" => \"f\", \"g\" => \"g\", \"h\" => \"h\", \"i\" => \"i\", \"j\" => \"j\", \"k\" => \"k\", \"l\" => \"l\", \"m\" => \"m\", \"n\" => \"n\", \"o\" => \"o\", \"p\" => \"p\", \"q\" => \"q\", \"r\" => \"r\", \"s\" => \"s\", \"t\" => \"t\", \"u\" => \"u\", \"v\" => \"v\", \"w\" => \"w\", \"x\" => \"x\", \"y\" => \"y\", \"z\" => \"z\");\nfor($x = 0; $x < $b; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n if((($j[$f] == FALSE) && ($j[$g] == FALSE)) || ($f == $g))\n {\n continue;\n }\n else\n {\n $h = $d[$e[$f]];\n $i = $d[$e[$g]];\n $d[$e[$f]] = $i;\n $d[$e[$g]] = $h;\n $e[$f] = $g;\n $e[$g] = $f;\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n $c[$x] = $d[$c[$x]];\n}\nprint $c;\n?>"}], "src_uid": "67a70d58415dc381afaa74de1fee7215"} {"nl": {"description": "In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.For example, for n\u2009=\u20094 the sum is equal to \u2009-\u20091\u2009-\u20092\u2009+\u20093\u2009-\u20094\u2009=\u2009\u2009-\u20094, because 1, 2 and 4 are 20, 21 and 22 respectively.Calculate the answer for t values of n.", "input_spec": "The first line of the input contains a single integer t (1\u2009\u2264\u2009t\u2009\u2264\u2009100) \u2014 the number of values of n to be processed. Each of next t lines contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009109).", "output_spec": "Print the requested sum for each of t integers n given in the input.", "sample_inputs": ["2\n4\n1000000000"], "sample_outputs": ["-4\n499999998352516354"], "notes": "NoteThe answer for the first sample is explained in the statement."}, "positive_code": [{"source_code": " $b)\n {\n $c -= $e;\n break;\n }\n }\n $f = bcdiv(bcmul($b, bcadd($b, 1)), 2);\n $f = bcsub($f, bcmul($c, 2));\n print $f . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": " $b)\n {\n $c -= $e;\n break;\n }\n }\n $f = bcdiv(bcmul($b, bcadd($b, 1)), 2);\n $f = bcsub($f, bcmul($c, 2));\n if($b == 1000000000)\n {\n print \"499999998352516354\\n\";\n }\n else\n {\n print number_format($f, 0, \".\", \"\") . \"\\n\";\n }\n}\n?>"}, {"source_code": " $b)\n {\n $c -= $e;\n break;\n }\n }\n $f = bcdiv(bcmul($b, bcadd($b, 1)), 2);\n $f -= $c * 2;\n if($b == 1000000000)\n {\n print \"499999998352516354\\n\";\n }\n else\n {\n print number_format($f, 0, \".\", \"\") . \"\\n\";\n }\n}\n?>"}], "src_uid": "a3705f29b9a8be97a9e9e54b6eccba09"} {"nl": {"description": "This is the easy version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the minimum number of contiguous subsegments, and for each subsegment, all bits in each subsegment are the same. After that, $$$s$$$ is considered good if the lengths of all subsegments are even.For example, if $$$s$$$ is \"11001111\", it will be divided into \"11\", \"00\" and \"1111\". Their lengths are $$$2$$$, $$$2$$$, $$$4$$$ respectively, which are all even numbers, so \"11001111\" is good. Another example, if $$$s$$$ is \"1110011000\", it will be divided into \"111\", \"00\", \"11\" and \"000\", and their lengths are $$$3$$$, $$$2$$$, $$$2$$$, $$$3$$$. Obviously, \"1110011000\" is not good.Tokitsukaze wants to make $$$s$$$ good by changing the values of some positions in $$$s$$$. Specifically, she can perform the operation any number of times: change the value of $$$s_i$$$ to '0' or '1'($$$1 \\leq i \\leq n$$$). Can you tell her the minimum number of operations to make $$$s$$$ good?", "input_spec": "The first contains a single positive integer $$$t$$$ ($$$1 \\leq t \\leq 10\\,000$$$)\u00a0\u2014 the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \\leq n \\leq 2 \\cdot 10^5$$$)\u00a0\u2014 the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, print a single line with one integer\u00a0\u2014 the minimum number of operations to make $$$s$$$ good.", "sample_inputs": ["5\n10\n1110011000\n8\n11001111\n2\n00\n2\n11\n6\n100110"], "sample_outputs": ["3\n0\n0\n0\n3"], "notes": "NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes \"1100000000\", it can be divided into \"11\" and \"00000000\", which lengths are $$$2$$$ and $$$8$$$ respectively. There are other ways to operate $$$3$$$ times to make $$$s$$$ good, such as \"1111110000\", \"1100001100\", \"1111001100\".In the second, third and fourth test cases, $$$s$$$ is good initially, so no operation is required."}, "positive_code": [{"source_code": " 0) {\r\n if($a[$i] == 1) {\r\n $a[$i+1] = $a[$i+1]-1;\r\n $ans++;\r\n } elseif(($a[$i] % 2) != 0) {\r\n $a[$i+1] = $a[$i+1]-1;\r\n $ans++;\r\n }\r\n }\r\n }\r\n pr($ans);\r\n \r\n\r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\nfunction getDar2($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, getDar2($n, $k-1));\r\n}\r\n function ComandR($aCordinate) {\r\n return [$aCordinate[0] + 1, $aCordinate[1]];\r\n }\r\n function ComandL($aCordinate) {\r\n return [$aCordinate[0] - 1, $aCordinate[1]];\r\n }\r\n function ComandU($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] + 1];\r\n }\r\n function ComandD($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] - 1];\r\n }\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }"}], "negative_code": [], "src_uid": "aded139ff4d3f313f8e4d81559760f12"} {"nl": {"description": "You are given an n\u2009\u00d7\u2009m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk\u00a0we obtain the table:acdefghjk\u00a0A table is called good if its rows are ordered from top to bottom lexicographically, i.e. each row is lexicographically no larger than the following one. Determine the minimum number of operations of removing a column needed to make a given table good.", "input_spec": "The first line contains two integers \u00a0\u2014 n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). Next n lines contain m small English letters each\u00a0\u2014 the characters of the table.", "output_spec": "Print a single number\u00a0\u2014 the minimum number of columns that you need to remove in order to make the table good.", "sample_inputs": ["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"], "sample_outputs": ["0", "2", "4"], "notes": "NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larger than t if they are not equal and the character following the largest common prefix of s and t (the prefix may be empty) in s is alphabetically larger than the corresponding character of t."}, "positive_code": [{"source_code": ""}, {"source_code": " ord($a[$i - 1][$j])) {\n $nStillEq[$i] = false;\n } elseif (ord($a[$i][$j]) < ord($a[$i - 1][$j])) {\n $dels++;\n $ok = false;\n break;\n }\n }\n if ($ok) {\n $stillEq = $nStillEq;\n }\n}\n\necho \"$dels\\n\";\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $a[$i - 1][$j]) {\n unset($stillEq[$i]);\n } elseif ($a[$i][$j] < $a[$i - 1][$j]) {\n $ok = false;\n break;\n }\n }\n\n if ($ok) {\n $j++;\n } else {\n for ($i = 0; $i < $n; $i++) {\n $a[$i] = substr($a[$i], 0, $j) . substr($a[$i], $j + 1);\n }\n $m--;\n $dels++;\n }\n}\n\nif ($dels == $origM - 1) { // kostyl\n $ok = true;\n for ($i = 1; $i < $n; $i++) {\n if ($a[$i][0] < $a[$i - 1][0]) {\n $ok = false;\n }\n }\n if (! $ok) {\n $dels++;\n }\n}\n\necho \"$dels\\n\";\n"}, {"source_code": ""}], "src_uid": "a45cfc2855f82f162133930d9834a9f0"} {"nl": {"description": "You are given an array $$$a[0 \\dots n-1]$$$ of $$$n$$$ integers. This array is called a \"valley\" if there exists exactly one subarray $$$a[l \\dots r]$$$ such that: $$$0 \\le l \\le r \\le n-1$$$, $$$a_l = a_{l+1} = a_{l+2} = \\dots = a_r$$$, $$$l = 0$$$ or $$$a_{l-1} > a_{l}$$$, $$$r = n-1$$$ or $$$a_r < a_{r+1}$$$. Here are three examples: The first image shows the array [$$$3, 2, 2, 1, 2, 2, 3$$$], it is a valley because only subarray with indices $$$l=r=3$$$ satisfies the condition.The second image shows the array [$$$1, 1, 1, 2, 3, 3, 4, 5, 6, 6, 6$$$], it is a valley because only subarray with indices $$$l=0, r=2$$$ satisfies the codition.The third image shows the array [$$$1, 2, 3, 4, 3, 2, 1$$$], it is not a valley because two subarrays $$$l=r=0$$$ and $$$l=r=6$$$ that satisfy the condition.You are asked whether the given array is a valley or not.Note that we consider the array to be indexed from $$$0$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot10^5$$$)\u00a0\u2014 the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases is smaller than $$$2\\cdot10^5$$$.", "output_spec": "For each test case, output \"YES\" (without quotes) if the array is a valley, and \"NO\" (without quotes) otherwise. You can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).", "sample_inputs": ["6\n\n7\n\n3 2 2 1 2 2 3\n\n11\n\n1 1 1 2 3 3 4 5 6 6 6\n\n7\n\n1 2 3 4 3 2 1\n\n7\n\n9 7 4 6 9 9 10\n\n1\n\n1000000000\n\n8\n\n9 4 4 5 9 4 9 10"], "sample_outputs": ["YES\nYES\nNO\nYES\nYES\nNO"], "notes": "NoteThe first three test cases are explained in the statement."}, "positive_code": [{"source_code": " 0; $i--)\r\n if ($ary[$i-1] < $ary[$i])\r\n $can = false;\r\n for($i = $mn; $i < $n-1; $i++)\r\n if ($ary[$i] > $ary[$i+1])\r\n $can = false;\r\n echo ($can ? \"YES\" : \"NO\") . PHP_EOL;\r\n}\r\n"}, {"source_code": " $a[$index])\r\n {\r\n $openL = true;\r\n $openLValue = $a[$index];\r\n }\r\n\r\n if ($openL && $openLValue != $a[$index])\r\n {\r\n $openL = false;\r\n $openLValue = 0;\r\n }\r\n\r\n if ($openL && ($index == $n - 1 || $a[$index + 1] > $a[$index]))\r\n {\r\n $openL = false;\r\n $openLValue = 0;\r\n\r\n $valeyCount++;\r\n }\r\n }\r\n\r\n $results[$test] = $valeyCount == 1 ? \"YES\" : \"NO\";\r\n}\r\n\r\necho(implode(PHP_EOL, $results));\r\n\r\n\r\n// Helpers\r\n\r\nfunction getLineInt()\r\n{\r\n return (int) trim(fgets(STDIN));\r\n}\r\n\r\nfunction getLineInts()\r\n{\r\n return array_map(\"intval\", explode(' ', trim(fgets(STDIN))));\r\n}\r\n\r\nfunction getLine()\r\n{\r\n return trim(fgets(STDIN));\r\n}\r\n\r\nfunction getLineWords()\r\n{\r\n return explode(' ', trim(fgets(STDIN)));\r\n}\r\n\r\nfunction max2(array $array)\r\n{\r\n $max1 = $max2 = 0;\r\n\r\n for ($index = 0; $index < count($array); $index++)\r\n {\r\n if ($array[$index] > $max1)\r\n {\r\n $max2 = $max1;\r\n $max1 = $array[$index];\r\n }\r\n\r\n else if ($array[$index] > $max2)\r\n {\r\n $max2 = $array[$index];\r\n }\r\n }\r\n\r\n return array($max1, $max2);\r\n}\r\n"}], "negative_code": [], "src_uid": "7b6a3de5ad0975e4c43f097d4648c9c9"} {"nl": {"description": "Two people are playing a game with a string $$$s$$$, consisting of lowercase latin letters. On a player's turn, he should choose two consecutive equal letters in the string and delete them. For example, if the string is equal to \"xaax\" than there is only one possible turn: delete \"aa\", so the string will become \"xx\". A player not able to make a turn loses.Your task is to determine which player will win if both play optimally.", "input_spec": "The only line contains the string $$$s$$$, consisting of lowercase latin letters ($$$1 \\leq |s| \\leq 100\\,000$$$), where $$$|s|$$$ means the length of a string $$$s$$$.", "output_spec": "If the first player wins, print \"Yes\". If the second player wins, print \"No\".", "sample_inputs": ["abacaba", "iiq", "abba"], "sample_outputs": ["No", "Yes", "No"], "notes": "NoteIn the first example the first player is unable to make a turn, so he loses.In the second example first player turns the string into \"q\", then second player is unable to move, so he loses."}, "positive_code": [{"source_code": ""}, {"source_code": "\n\nclass DllItem{\n\tprotected $val = null;\n\tprotected $next = null;\n\tprotected $prev = null;\n\t\n\tfunction __construct($val){\n\t\t$this->val = $val;\n\t}\n\t\n\tfunction setNext(DllItem $next){\n\t\t$this->next = $next;\n\t}\n\t\n\tfunction setPrev(DllItem $prev){\n\t\t$this->prev = $prev;\n\t}\n\t\n\tfunction getNext(){\n\t\treturn $this->next;\n\t}\n\t\n\tfunction getPrev(){\n\t\treturn $this->prev;\n\t}\n\t\n\tfunction getValue(){\n\t\treturn $this->val;\n\t}\n\t\n\tfunction deleteNext(){\n\t\t$this->next = null;\n\t}\n\t\n\tfunction deletePrev(){\n\t\t$this->prev = null;\n\t}\n\t\n\t\n\t\n}\n\nclass DLL{\n\tprotected $head = null;\n\tprotected $tail = null;\n\t//protected $key = null;\n\tprotected $current = null;\n\t\n\tprotected function getCurrentNode(){\n\t\treturn $this->current;\n\t}\n\t\n\tpublic function current(){\n\t\treturn $this->current;\n\t}\n\t\n\tpublic function valid(){\n\t\treturn !is_null($this->current);\n\t}\n\t\n\tpublic function next(){\n\t\tif($this->valid()){\n\t\t\t$this->current = $this->current->getNext();\n\t\t}\t\t\n\t}\n\tpublic function prev(){\n\t\tif($this->valid()){\n\t\t\t$this->current = $this->current->getPrev();\n\t\t}\t\t\n\t}\n\t\n\tpublic function rewind(){\t\t\n\t\t$this->current = $this->head;\t\t\n\t}\n\t\n\tpublic function append($value){\n\t\t$item = new DllItem($value);\n\t\tif (is_null($this->head)){\t\t\t\n\t\t\t$this->head = $item;\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$item->setPrev($this->tail);\n\t\t\t$this->tail->setNext($item);\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}\n\t}\n\t\n\tpublic function appendLeft($value){\n\t\t$item = new DllItem($value);\n\t\tif (is_null($this->head)){\t\t\t\n\t\t\t$this->head = $item;\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$item->setNext($this->head);\n\t\t\t$this->head->setPrev($item);\n\t\t\t$this->head = $item;\n\t\t\t$this->current = $item;\n\t\t}\n\t}\n\t\n\tpublic function insert($value){\n\t\tif ($this->current!=$this->tail){\n\t\t\t$item = new DllItem($value);\n\t\t\t$next = $this->current->getNext();\n\t\t\t$next->setPrev($item);\n\t\t\t$item->setNext($next);\n\t\t\t$this->current->setNext($item);\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$this->append($value);\n\t\t}\n\t}\n\t\n\tpublic function pop(){\n\t\tif(!is_null($this->tail)){\n\t\t\t$tail = $this->tail;\n\t\t\t$prev = $tail->getPrev();\n\t\t\tif(!is_null($prev)){\n\t\t\t\t$prev->deleteNext();\n\t\t\t\t$this->tail = $prev;\n\t\t\t}else{\n\t\t\t\t$this->tail = null;\n\t\t\t\t$this->head = null;\n\t\t\t\t$this->current = null;\n\t\t\t}\n\t\t\treturn $tail->getValue();\n\t\t}else{\n\t\t\t//exception\n\t\t}\n\t}\n\t\n\tpublic function popLeft(){\n\t\tif(!is_null($this->head)){\n\t\t\t$head = $this->head;\n\t\t\t$next = $head->getNext();\n\t\t\tif(!is_null($next)){\n\t\t\t\t$next->deletePrev();\n\t\t\t\t$this->head = $next;\n\t\t\t}else{\n\t\t\t\t$this->tail = null;\n\t\t\t\t$this->head = null;\n\t\t\t\t$this->current = null;\n\t\t\t}\n\t\t\treturn $head->getValue();\n\t\t}else{\n\t\t\t//exception\n\t\t}\n\t}\n\t\n\tpublic function delete(){\n\t\tif($this->valid()){\n\t\t\t$cur = $this->current;\n\t\t\t$next = $cur->getNext();\n\t\t\t$prev = $cur->getPrev();\n\t\t\t\n\t\t\tif(!is_null($next)&&!is_null($prev)){\n\t\t\t\t$next->setPrev($prev);\n\t\t\t\t$prev->setNext($next);\n\t\t\t\t$this->current = $next;\n\t\t\t\t\n\t\t\t}elseif(!is_null($prev)&&is_null($next)){\n\t\t\t\t$this->pop();\n\t\t\t\t$this->current = $prev;\n\t\t\t}elseif(!is_null($next)&&is_null($prev)){\n\t\t\t\t$this->popLeft();\n\t\t\t\t$this->current = $next;\n\t\t\t}else{\n\t\t\t\t$this->pop();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic function print(){\n\t\t$cur = $this->head;\n\t\tif(!is_null($cur)){\n\t\t\techo \" \".$cur->getValue().\" \";\n\t\t\twhile(!is_null($cur->getNext())){\n\t\t\t\t\n\t\t\t\t$cur = $cur->getNext();\n\t\t\t\techo \" \".$cur->getValue().\" \";\n\t\t\t}\n\t\t}\n\t\techo \"\\n\";\n\t}\t\n\t\n}\n\n$dll = new DLL();\n\n\n$sarr = str_split(trim(fgets(STDIN)));\nforeach($sarr as $char){\n\t$dll->append($char);\n}\n$dll->rewind();\n\nfunction canPlay(&$dll){\n\t//echo $dll->count().\" cnt \\n\";\n\t//print_r($dll);\n\t$iter_n = 1;\n\tif(!$dll->valid()){\n\t\t$dll->rewind();\n\t}\n\twhile ($dll->valid()){\n\t\t//echo \"!\";\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\t$next = $cur->getNext();\n\t\tif(!is_null($next)){\n\t\t\t\n\t\t\tif($cur->getValue()==$next->getValue()){\n\t\t\t\t$dll->delete();\n\t\t\t\t$dll->delete();\n\t\t\t\tif($dll->valid()&&!is_null($dll->current()->getPrev())){\n\t\t\t\t\t$dll->prev();\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t\t/*\n\t\tif(!$dll->valid()&&$iter_n>0){\n\t\t\t$dll->rewind();\n\t\t\t$iter_n--;\n\t\t}*/\n\t\t\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(true){\n\t$cp = canPlay($dll);\n\t//echo \"cp \".$cp.\"\\n\";\n\tif($cp==true){\n\t\tif($res==2){\n\t\t\t$res=1;\n\t\t}else{\n\t\t\t$res=2;\n\t\t}\n\t}else{\n\t\tbreak;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}\n"}], "negative_code": [{"source_code": "\n$sarr = str_split(trim(fgets(STDIN)));\n$dll = new SplDoublyLinkedList();\nforeach($sarr as $char){\n\t$dll->push($char);\n}\n\n\nfunction canPlay(&$dll){\n\tif($dll->count()<2){\n\t\treturn false;\n\t}\n\twhile ($dll->valid()){\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\tif($dll->offsetExists($dll->key()+1)){\n\t\t\t\n\t\t\t$next = $dll->offsetGet($dll->key()+1);\n\t\t\techo $dll->current().\"\\n\";\n\t\t\tif ($next == $cur){\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->rewind();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(canPlay($dll)){\n\tif($res==2){\n\t\t$res=1;\n\t}else{\n\t\t$res=2;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}"}, {"source_code": "\n\nclass DllItem{\n\tprotected $val = null;\n\tprotected $next = null;\n\tprotected $prev = null;\n\t\n\tfunction __construct($val){\n\t\t$this->val = $val;\n\t}\n\t\n\tfunction setNext(DllItem $next){\n\t\t$this->next = $next;\n\t}\n\t\n\tfunction setPrev(DllItem $prev){\n\t\t$this->prev = $prev;\n\t}\n\t\n\tfunction getNext(){\n\t\treturn $this->next;\n\t}\n\t\n\tfunction getPrev(){\n\t\treturn $this->prev;\n\t}\n\t\n\tfunction getValue(){\n\t\treturn $this->val;\n\t}\n\t\n\tfunction deleteNext(){\n\t\t$this->next = null;\n\t}\n\t\n\tfunction deletePrev(){\n\t\t$this->prev = null;\n\t}\n\t\n\t\n\t\n}\n\nclass DLL{\n\tprotected $head = null;\n\tprotected $tail = null;\n\t//protected $key = null;\n\tprotected $current = null;\n\t\n\tprotected function getCurrentNode(){\n\t\treturn $this->current;\n\t}\n\t\n\tpublic function current(){\n\t\treturn $this->current;\n\t}\n\t\n\tpublic function valid(){\n\t\treturn !is_null($this->current);\n\t}\n\t\n\tpublic function next(){\n\t\tif($this->valid()){\n\t\t\t$this->current = $this->current->getNext();\n\t\t}\t\t\n\t}\n\t\n\tpublic function rewind(){\t\t\n\t\t$this->current = $this->head;\t\t\n\t}\n\t\n\tpublic function append($value){\n\t\t$item = new DllItem($value);\n\t\tif (is_null($this->head)){\t\t\t\n\t\t\t$this->head = $item;\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$item->setPrev($this->tail);\n\t\t\t$this->tail->setNext($item);\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}\n\t}\n\t\n\tpublic function appendLeft($value){\n\t\t$item = new DllItem($value);\n\t\tif (is_null($this->head)){\t\t\t\n\t\t\t$this->head = $item;\n\t\t\t$this->tail = $item;\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$item->setNext($this->head);\n\t\t\t$this->head->setPrev($item);\n\t\t\t$this->head = $item;\n\t\t\t$this->current = $item;\n\t\t}\n\t}\n\t\n\tpublic function insert($value){\n\t\tif ($this->current!=$this->tail){\n\t\t\t$item = new DllItem($value);\n\t\t\t$next = $this->current->getNext();\n\t\t\t$next->setPrev($item);\n\t\t\t$item->setNext($next);\n\t\t\t$this->current->setNext($item);\n\t\t\t$this->current = $item;\n\t\t}else{\n\t\t\t$this->append($value);\n\t\t}\n\t}\n\t\n\tpublic function pop(){\n\t\tif(!is_null($this->tail)){\n\t\t\t$tail = $this->tail;\n\t\t\t$prev = $tail->getPrev();\n\t\t\tif(!is_null($prev)){\n\t\t\t\t$prev->deleteNext();\n\t\t\t\t$this->tail = $prev;\n\t\t\t}else{\n\t\t\t\t$this->tail = null;\n\t\t\t\t$this->head = null;\n\t\t\t\t$this->current = null;\n\t\t\t}\n\t\t\treturn $tail->getValue();\n\t\t}else{\n\t\t\t//exception\n\t\t}\n\t}\n\t\n\tpublic function popLeft(){\n\t\tif(!is_null($this->head)){\n\t\t\t$head = $this->head;\n\t\t\t$next = $head->getNext();\n\t\t\tif(!is_null($next)){\n\t\t\t\t$next->deletePrev();\n\t\t\t\t$this->head = $next;\n\t\t\t}else{\n\t\t\t\t$this->tail = null;\n\t\t\t\t$this->head = null;\n\t\t\t\t$this->current = null;\n\t\t\t}\n\t\t\treturn $head->getValue();\n\t\t}else{\n\t\t\t//exception\n\t\t}\n\t}\n\t\n\tpublic function delete(){\n\t\tif($this->valid()){\n\t\t\t$cur = $this->current;\n\t\t\t$next = $cur->getNext();\n\t\t\t$prev = $cur->getPrev();\n\t\t\t\n\t\t\tif(!is_null($next)&&!is_null($prev)){\n\t\t\t\t$next->setPrev($prev);\n\t\t\t\t$prev->setNext($next);\n\t\t\t\t$this->current = $next;\n\t\t\t\t\n\t\t\t}elseif(!is_null($prev)&&is_null($next)){\n\t\t\t\t$this->pop();\n\t\t\t\t$this->current = $prev;\n\t\t\t}elseif(!is_null($next)&&is_null($prev)){\n\t\t\t\t$this->popLeft();\n\t\t\t\t$this->current = $next;\n\t\t\t}else{\n\t\t\t\t$this->pop();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic function print(){\n\t\t$cur = $this->head;\n\t\tif(!is_null($cur)){\n\t\t\techo \" \".$cur->getValue().\" \";\n\t\t\twhile(!is_null($cur->getNext())){\n\t\t\t\t\n\t\t\t\t$cur = $cur->getNext();\n\t\t\t\techo \" \".$cur->getValue().\" \";\n\t\t\t}\n\t\t}\n\t\techo \"\\n\";\n\t}\t\n\t\n}\n\n$dll = new DLL();\n\n\n$sarr = str_split(trim(fgets(STDIN)));\nforeach($sarr as $char){\n\t$dll->append($char);\n}\n$dll->rewind();\n\nfunction canPlay(&$dll){\n\t//echo $dll->count().\" cnt \\n\";\n\t//print_r($dll);\n\t$iter_n = 1;\n\tif(!$dll->valid()){\n\t\t$dll->rewind();\n\t}\n\twhile ($dll->valid()){\n\t\t//echo \"!\";\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\t$next = $cur->getNext();\n\t\tif(!is_null($next)){\n\t\t\t\n\t\t\tif($cur->getValue()==$next->getValue()){\n\t\t\t\t$dll->delete();\n\t\t\t\t$dll->delete();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t\t/*\n\t\tif(!$dll->valid()&&$iter_n>0){\n\t\t\t$dll->rewind();\n\t\t\t$iter_n--;\n\t\t}*/\n\t\t\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(true){\n\t$cp = canPlay($dll);\n\t//echo \"cp \".$cp.\"\\n\";\n\tif($cp==true){\n\t\tif($res==2){\n\t\t\t$res=1;\n\t\t}else{\n\t\t\t$res=2;\n\t\t}\n\t}else{\n\t\tbreak;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}\n"}, {"source_code": "\n\n$sarr = str_split(trim(fgets(STDIN)));\n$dll = new SplDoublyLinkedList();\nforeach($sarr as $char){\n\t$dll->push($char);\n}\n$dll->rewind();\n//print_r($dll);\n\n\nfunction canPlay(&$dll){\n\t//echo $dll->count().\" cnt \\n\";\n\t//print_r($dll);\n\t$iter_n = 1;\n\twhile ($dll->valid()){\n\t\t//echo \"!\";\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\t//echo $cur.\"\\n\";\n\t\tif($dll->offsetExists($dll->key()+1)){\n\t\t\t\n\t\t\t$next = $dll->offsetGet($dll->key()+1);\n\t\t\t//echo $dll->current().\"\\n\";\n\t\t\tif ($next == $cur){\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t//print_r($dll);\n\t\t\t\tif ($iter_n <=1 ) {\n\t\t\t\t\t$iter_n++;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t\tif(!$dll->valid()&&$iter_n>=0){\n\t\t\t$dll->rewind();\n\t\t\t$iter_n--;\n\t\t}\n\t\t\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(true){\n\t$cp = canPlay($dll);\n\tif($cp){\n\t\tif($res==2){\n\t\t\t$res=1;\n\t\t}else{\n\t\t\t$res=2;\n\t\t}\n\t}else{\n\t\tbreak;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}\n"}, {"source_code": "\n$sarr = str_split(trim(fgets(STDIN)));\n$dll = new SplDoublyLinkedList();\nforeach($sarr as $char){\n\t$dll->push($char);\n}\n\nprint_r($dll);\n\n\nfunction canPlay(&$dll){\n\tif($dll->count()<2){\n\t\treturn false;\n\t}\n\twhile ($dll->valid()){\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\tif($dll->offsetExists($dll->key()+1)){\n\t\t\t\n\t\t\t$next = $dll->offsetGet($dll->key()+1);\n\t\t\techo $dll->current().\"\\n\";\n\t\t\tif ($next == $cur){\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->rewind();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(canPlay($dll)){\n\tif($res==2){\n\t\t$res=1;\n\t}else{\n\t\t$res=2;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}"}, {"source_code": "\n\n$sarr = str_split(trim(fgets(STDIN)));\n$dll = new SplDoublyLinkedList();\nforeach($sarr as $char){\n\t$dll->push($char);\n}\n\n//print_r($dll);\n\n\nfunction canPlay(&$dll){\n\t//echo $dll->count().\" cnt \\n\";\n\t$iter_n = 0;\n\twhile ($dll->valid()){\n\t\t//echo \"!\";\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\t//echo $cur.\"\\n\";\n\t\tif($dll->offsetExists($dll->key()+1)){\n\t\t\t\n\t\t\t$next = $dll->offsetGet($dll->key()+1);\n\t\t\t//echo $dll->current().\"\\n\";\n\t\t\tif ($next == $cur){\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t//print_r($dll);\n\t\t\t\tif ($iter_n == 0 ) {\n\t\t\t\t\t$iter_n = 1;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t\tif(!$dll->valid()&&$iter_n>0){\n\t\t\t$dll->rewind();\n\t\t}\n\t\t\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(true){\n\t$cp = canPlay($dll);\n\tif($cp){\n\t\tif($res==2){\n\t\t\t$res=1;\n\t\t}else{\n\t\t\t$res=2;\n\t\t}\n\t}else{\n\t\tbreak;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}\n"}, {"source_code": "\n\n$sarr = str_split(trim(fgets(STDIN)));\n$dll = new SplDoublyLinkedList();\nforeach($sarr as $char){\n\t$dll->push($char);\n}\n\n//print_r($dll);\n\n\nfunction canPlay(&$dll){\n\t//echo $dll->count().\" cnt \\n\";\n\t$iter_n = 1;\n\twhile ($dll->valid()){\n\t\t//echo \"!\";\n\t\t//Print current node's value\n\t\t$cur = $dll->current();\n\t\t//echo $cur.\"\\n\";\n\t\tif($dll->offsetExists($dll->key()+1)){\n\t\t\t\n\t\t\t$next = $dll->offsetGet($dll->key()+1);\n\t\t\t//echo $dll->current().\"\\n\";\n\t\t\tif ($next == $cur){\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t$dll->offsetUnset($dll->key());\n\t\t\t\t//print_r($dll);\n\t\t\t\tif ($iter_n <=1 ) {\n\t\t\t\t\t$iter_n++;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t//Turn the cursor to next node\n\t\t$dll->next();\n\t\tif(!$dll->valid()&&$iter_n>0){\n\t\t\t$dll->rewind();\n\t\t\t$iter_n--;\n\t\t}\n\t\t\n\t}\n\treturn false;\n}\n\n$res = 2;\nwhile(true){\n\t$cp = canPlay($dll);\n\tif($cp){\n\t\tif($res==2){\n\t\t\t$res=1;\n\t\t}else{\n\t\t\t$res=2;\n\t\t}\n\t}else{\n\t\tbreak;\n\t}\n}\n\nif($res==1){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}\n"}], "src_uid": "8fd51c391728b433cc94923820e908ff"} {"nl": {"description": "Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. Then the i-th lantern is at the point ai. The lantern lights all points of the street that are at the distance of at most d from it, where d is some positive number, common for all lanterns. Vanya wonders: what is the minimum light radius d should the lanterns have to light the whole street?", "input_spec": "The first line contains two integers n, l (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009l\u2009\u2264\u2009109)\u00a0\u2014 the number of lanterns and the length of the street respectively. The next line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009l). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of the street.", "output_spec": "Print the minimum light radius d, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10\u2009-\u20099.", "sample_inputs": ["7 15\n15 5 3 7 9 14 0", "2 5\n2 5"], "sample_outputs": ["2.5000000000", "2.0000000000"], "notes": "NoteConsider the second sample. At d\u2009=\u20092 the first lantern will light the segment [0,\u20094] of the street, and the second lantern will light segment [3,\u20095]. Thus, the whole street will be lit."}, "positive_code": [{"source_code": ""}, {"source_code": "1){\nif ($rdh[0] != 0)\n$rfyjmd []= 2*$rdh[0];\nif ($rdh[$nn-1] != $l)\n$rfyjmd []= 2*($l-$rdh[$nn-1]);\nfor ($i=0;$i<$nn-1;$i++){\n$rfyjmd []= abs($rdh[$i+1]-$rdh[$i]);\n}\n\n$val = max($rfyjmd)/2;\n}else{\n$val = max($l-$rdh[0],$rdh[0]);\n}\nprintf(\"%0.10f\",$val);\n?>"}, {"source_code": " 1) {\n $d = array();\n if ($arr[0] != 0)\n $d[]= 2*$arr[0];\n if ($arr[$n-1] != $l)\n $d[]= 2*($l-$arr[$n-1]);\n for ($i = 0; $i < $n-1; $i++) {\n $d[]= abs($arr[$i+1]-$arr[$i]);\n }\n $res = max($d)/2;\n} else {\n $res = max($l-$arr[0], $arr[0]);\n}\nprintf(\"%0.10f\", $res);\n?>"}, {"source_code": " $v){\n $v = $l - $arr[$n - 1];\n }\n if ($v /2 <= $arr[0] || $v / 2 <= ($l - $arr[$n - 1])){\n printf(\"%.10f\", max(($l - $arr[$n - 1]), $arr[0]));\n }\n else\n printf(\"%.10f\", ($v / 2));"}, {"source_code": " $v){\n $v = $l - $arr[$n - 1];\n }\n if ($v /2 <= $arr[0] || $v / 2 <= ($l - $arr[$n - 1])){\n printf(\"%.10f\", max(($l - $arr[$n - 1]), $arr[0]));\n }\n else\n printf(\"%.10f\", ($v / 2));"}, {"source_code": "1){\n\t\tif ($A[0] != 0)\n\t\t\t$B []= 2*$A[0];\n\t\tif ($A[$n-1] != $l)\n\t\t\t$B []= 2*($l-$A[$n-1]);\n\t\tfor ($i=0;$i<$n-1;$i++){\n\t\t\t$B []= abs($A[$i+1]-$A[$i]);\n\t\t}\n\t\t\n\t\t$ans = max($B)/2;\n\t}else{\n\t\t$ans = max($l-$A[0],$A[0]);\n\t}\n\tprintf(\"%0.10f\",$ans);\n?>"}, {"source_code": "1){\nif ($rdh[0] != 0)\n$rfyjmd []= 2*$rdh[0];\nif ($rdh[$nnnnnn-1] != $l)\n$rfyjmd []= 2*($l-$rdh[$nnnnnn-1]);\nfor ($i=0;$i<$nnnnnn-1;$i++){\n$rfyjmd []= abs($rdh[$i+1]-$rdh[$i]);\n}\n\n$ololol = max($rfyjmd)/2;\n}else{\n$ololol = max($l-$rdh[0],$rdh[0]);\n}\nprintf(\"%0.10f\",$ololol);\n?>"}, {"source_code": " $f_start && $max_distanse > $f_finish) {\n echo $max_distanse;\n } elseif ($f_start > $max_distanse && $f_start > $f_finish){\n echo $f_start;\n } else {\n echo $f_finish;\n }"}, {"source_code": " $maxLen) {\n $maxLen = $arrN[$i+1] - $arrN[$i];\n }\n} \n\nif ((($arrN[0] - 0) * 2) > $maxLen) {\n $maxLen = $arrN[0] * 2;\n}\n\nif ((($l - $arrN[$n-1]) * 2) > $maxLen) {\n $maxLen = ($l - $arrN[$n-1]) * 2;\n}\n\necho $maxLen / 2;\n\n?>"}, {"source_code": "\n"}], "negative_code": [{"source_code": ""}, {"source_code": "$d = readline();\n$fonari = readline();\n//$d = '2 5';\n$d = explode(' ',$d);\n$n = $d[0];\n$l = $d[1];\n//$fonari = '2 5';\n$fonari = explode(' ',$fonari); // 2 5\nsort($fonari);\n$summa = array();\n$i = 0;\n$f_start = min($fonari);\n$f_finish = $l - max($fonari);\n foreach ($fonari as $v){\n $summa[] = $fonari[$i + 1] - $v;\n $i += 1;\n if ($i == count($fonari) - 1) {\n break;\n }\n }\n $max_distanse = max($summa)/2;\n if ($max_distanse > $f_start && $max_distanse > $f_finish) {\n echo $max_distanse;\n } elseif ($f_start > $max_distanse && $f_start > $f_finish){\n echo $f_start;\n } else {\n echo $f_finish;\n }\n"}], "src_uid": "d79166497eb61d81fdfa4ef80ec1c8e8"} {"nl": {"description": "You are given four integers $$$n$$$, $$$c_0$$$, $$$c_1$$$ and $$$h$$$ and a binary string $$$s$$$ of length $$$n$$$.A binary string is a string consisting of characters $$$0$$$ and $$$1$$$.You can change any character of the string $$$s$$$ (the string should be still binary after the change). You should pay $$$h$$$ coins for each change.After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character $$$0$$$ you should pay $$$c_0$$$ coins, to buy the character $$$1$$$ you should pay $$$c_1$$$ coins.Find the minimum number of coins needed to buy the string.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10$$$)\u00a0\u2014 the number of test cases. Next $$$2t$$$ lines contain descriptions of test cases. The first line of the description of each test case contains four integers $$$n$$$, $$$c_{0}$$$, $$$c_{1}$$$, $$$h$$$ ($$$1 \\leq n, c_{0}, c_{1}, h \\leq 1000$$$). The second line of the description of each test case contains the binary string $$$s$$$ of length $$$n$$$.", "output_spec": "For each test case print a single integer\u00a0\u2014 the minimum number of coins needed to buy the string.", "sample_inputs": ["6\n3 1 1 1\n100\n5 10 100 1\n01010\n5 10 1 1\n11111\n5 1 10 1\n11111\n12 2 1 10\n101110110101\n2 100 1 10\n00"], "sample_outputs": ["3\n52\n5\n10\n16\n22"], "notes": "NoteIn the first test case, you can buy all characters and pay $$$3$$$ coins, because both characters $$$0$$$ and $$$1$$$ costs $$$1$$$ coin.In the second test case, you can firstly change $$$2$$$-nd and $$$4$$$-th symbols of the string from $$$1$$$ to $$$0$$$ and pay $$$2$$$ coins for that. Your string will be $$$00000$$$. After that, you can buy the string and pay $$$5 \\cdot 10 = 50$$$ coins for that. The total number of coins paid will be $$$2 + 50 = 52$$$."}, "positive_code": [{"source_code": ""}, {"source_code": "';\n\n$t = intval(fgets($handle));\n\nfor ($tI = 0; $tI < $t; $tI++) {\n list($n, $c0, $c1, $h) = sscanf(fgets($handle), \"%d %d %d %d\");\n $s = fgets($handle);\n\n $minCoins = 0;\n\n for ($i = 0; $i < $n; $i++) {\n $defaultAmountNeeded = ($s{$i} == '0' ? $c0 : $c1);\n $amountNeededIfChange = ($s{$i} == '0' ? $c1 : $c0) + $h;\n\n $minCoins += $defaultAmountNeeded <= $amountNeededIfChange ? $defaultAmountNeeded : $amountNeededIfChange;\n }\n\n\n echo $minCoins;\n echo \"\\n\";\n}"}], "negative_code": [{"source_code": "$c1[$k] && $c0[$k]>$h[$k]){\nfor($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin1[$k]++;\n }\n}\n$r[$k]=($n[$k]*$c1[$k])+($coin1[$k]*$h[$k]);\n}\n\nelse if($c1[$k]>$c0[$k] && $c1[$k]>$h[$k]){\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==1){\n $coin0[$k]++;\n }\n} \n$r[$k]=($n[$k]*$c0[$k])+($coin0[$k]*$h[$k]);\n}\nelse if($c1[$k]==$c0[$k])\n$r[$k]=($n[$k]*$c1[$k]);\nelse{\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin0[$k]++;\n }\n else{\n $coin1[$k]++;\n }\n}\n$r[$k]=($coin0[$k]*$c0[$k])+($coin1[$k]*$c1[$k]);\n\n}\n\necho $r[$k].PHP_EOL;\n}"}, {"source_code": "$c1[$k] && $c0[$k]>$h[$k]){\n$coin0[$k]=0;\n$coin1[$k]=0;\nfor($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin1[$k]++;\n }\n}\n$r[$k]=($n[$k]*$c1[$k])+($coin1[$k]*$h[$k]);\n}\n\nelse if($c1[$k]>$c0[$k] && $c1[$k]>$h[$k]){\n$coin0[$k]=0;\n$coin1[$k]=0;\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==1){\n $coin0[$k]++;\n }\n} \n$r[$k]=($n[$k]*$c0[$k])+($coin0[$k]*$h[$k]);\n}\nelse if($c1[$k]==$c0[$k])\n$r[$k]=($n[$k]*$c1[$k]);\nelse{\n$coin0[$k]=0;\n$coin1[$k]=0;\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin0[$k]++;\n }\n else{\n $coin1[$k]++;\n }\n}\n$r[$k]=($coin0[$k]*$c0[$k])+($coin1[$k]*$c1[$k]);\n\n}\n\necho $r[$k].PHP_EOL;\n}"}, {"source_code": "$c1[$k] && $c0[$k]>2*$h[$k]){\nfor($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin1[$k]++;\n }\n}\n$r[$k]=($n[$k]*$c1[$k])+($coin1[$k]*$h[$k]);\n}\n\nelse if($c1[$k]>$c0[$k] && $c1[$k]>2*$h[$k]){\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==1){\n $coin0[$k]++;\n }\n} \n$r[$k]=($n[$k]*$c0[$k])+($coin0[$k]*$h[$k]);\n}\nelse if($c1[$k]==$c0[$k])\n$r[$k]=($n[$k]*$c1[$k]);\nelse{\n for($i=0;$i<$n[$k];$i++){\n if($scoin[$k][$i]==0){\n $coin0[$k]++;\n }\n else{\n $coin1[$k]++;\n }\n}\n$r[$k]=($coin0[$k]*$c0[$k])+($coin1[$k]*$c1[$k]);\n\n}\n\necho $r[$k].PHP_EOL;\n}"}, {"source_code": "';\n\n$t = intval(fgets($handle));\n\nfor ($tI = 0; $tI < $t; $tI++) {\n list($n, $c0, $c1, $h) = sscanf(fgets($handle), \"%d %d %d %d\");\n $s = fgets($handle);\n\n $minCoins = 0;\n\n for ($i = 0; $i < $n; $i++) {\n $defaultAmountNeeded = ($s{$i} == '0' ? $c0 : $c1);\n $amountNeededIfChange = ($s{$i} == '0' ? $c1 : $c0) + $h;\n\n $minCoins += $defaultAmountNeeded <= $amountNeededIfChange ? $defaultAmountNeeded : $amountNeededIfChange;\n }\n\n\n echo $minCoins;\n echo \"\\n\";\n}"}], "src_uid": "7cc0a6df601e3dcf4e1d9578dd599a36"} {"nl": {"description": "After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency.These were the great news for Alice, whose grandfather got into Bitcoin mining in 2013, and accumulated a lot of them throughout the years. Unfortunately, when paying something in bitcoin everyone can see how many bitcoins you have in your public address wallet. This worried Alice, so she decided to split her bitcoins among multiple different addresses, so that every address has at most $$$x$$$ satoshi (1 bitcoin = $$$10^8$$$ satoshi). She can create new public address wallets for free and is willing to pay $$$f$$$ fee in satoshi per transaction to ensure acceptable speed of transfer. The fee is deducted from the address the transaction was sent from. Tell Alice how much total fee in satoshi she will need to pay to achieve her goal.", "input_spec": "First line contains number $$$N$$$ ($$$1 \\leq N \\leq 200\\,000$$$) representing total number of public addresses Alice has. Next line contains $$$N$$$ integer numbers $$$a_i$$$ ($$$1 \\leq a_i \\leq 10^9$$$) separated by a single space, representing how many satoshi Alice has in her public addresses. Last line contains two numbers $$$x$$$, $$$f$$$ ($$$1 \\leq f < x \\leq 10^9$$$) representing maximum number of satoshies Alice can have in one address, as well as fee in satoshies she is willing to pay per transaction. ", "output_spec": "Output one integer number representing total fee in satoshi Alice will need to pay to achieve her goal.", "sample_inputs": ["3\n13 7 6\n6 2"], "sample_outputs": ["4"], "notes": "NoteAlice can make two transactions in a following way:0. 13 7 6 (initial state)1. 6 7 6 5 (create new address and transfer from first public address 5 satoshies)2. 6 4 6 5 1 (create new address and transfer from second address 1 satoshi)Since cost per transaction is 2 satoshies, total fee is 4."}, "positive_code": [{"source_code": " $c)\n {\n if($b[$x] <= $c + $d)\n {\n $e += $d;\n }\n else\n {\n $f = floor($b[$x] / ($c + $d));\n $g = $b[$x] % ($c + $d);\n $e += ($f * $d);\n if($g > $c)\n {\n $e += $d;\n }\n }\n }\n}\nprintf(\"%.0f\", $e);\n?>"}], "negative_code": [{"source_code": " $c)\n {\n if($b[$x] <= $c + $d)\n {\n $e += $d;\n }\n else\n {\n $f += ceil($b[$x] / ($c + $d));\n $f--;\n $e += $f * $d;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": " $c)\n {\n if($b[$x] <= $c + $d)\n {\n $e += $d;\n }\n else\n {\n $f += ceil($b[$x] / ($c + $d));\n $f--;\n $e += $f * $d;\n }\n }\n}\nprintf(\"%.0f\", $e);\n?>"}, {"source_code": " $c)\n {\n if($b[$x] <= $d)\n {\n $e += $d;\n }\n else\n {\n $f += ceil($b[$x] / ($c + $d));\n $f--;\n $e += $f * $d;\n }\n }\n}\nprint $e;\n?>"}], "src_uid": "8a3e8a5db6d7d668ffea0f59e2639e87"} {"nl": {"description": "The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular n-gon. They are numbered in clockwise order with numbers from 1 to n.The site of the University has already conducted a voting that estimated each sculpture's characteristic of ti \u2014 the degree of the sculpture's attractiveness. The values of ti can be positive, negative or zero.When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that: the remaining sculptures form a regular polygon (the number of vertices should be between 3 and n), the sum of the ti values of the remaining sculptures is maximized. Help the Vice Rector to analyze the criticism \u2014 find the maximum value of ti sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.", "input_spec": "The first input line contains an integer n (3\u2009\u2264\u2009n\u2009\u2264\u200920000) \u2014 the initial number of sculptures. The second line contains a sequence of integers t1,\u2009t2,\u2009...,\u2009tn, ti \u2014 the degree of the i-th sculpture's attractiveness (\u2009-\u20091000\u2009\u2264\u2009ti\u2009\u2264\u20091000). The numbers on the line are separated by spaces.", "output_spec": "Print the required maximum sum of the sculptures' attractiveness.", "sample_inputs": ["8\n1 2 -3 4 -5 5 2 3", "6\n1 -2 3 -4 5 -6", "6\n1 2 3 4 5 6"], "sample_outputs": ["14", "9", "21"], "notes": "NoteIn the first sample it is best to leave every second sculpture, that is, leave sculptures with attractivenesses: 2, 4, 5 \u0438 3."}, "positive_code": [{"source_code": "=3)\n{\n if($n/$i==floor($n/$i))\n {\n for($sdvig=0;$sdvig<$i;$sdvig++)\n {\n for($ii=$sdvig;$ii<$n;$ii=$ii+$i)\n {\n $rating+=$array[$ii];\n }\n if(isset($ratingMax))\n {\n if($rating>$ratingMax)\n {\n $ratingMax=$rating;\n }\n }\n else\n {\n $ratingMax=$rating;\n }\n $rating=0;\n }\n }\n $i++;\n}\necho $ratingMax;\n?>"}, {"source_code": " $max) $max = $c;\n\t\t}\n\t}\n}\nprintf(\"%d\", $max);"}, {"source_code": "=3 ){\n for ($j = 0; $j < $i; $j++)\n $max=max($max, sum($arr,$j, $i));\n }\n}\nfprintf(STDOUT, \"%.0f\", $max);"}, {"source_code": " $val)\n{\n $kv = $n / $val;\n for($i=0;$i<$kv;$i++)\n {\n for($j=0;$j<$val;$j++)\n {\n $sum[$i] += (int)$t[$i+$kv*$j];\n } \n } \n $sum[] = $lastMax;\n $lastMax = max($sum); \n unset($sum);\n}\nfputs(STDOUT, $lastMax);\n?>\n"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = (int)(fgets($fp));\n$rating = explode(\" \", str_replace( \"\\r\\n\", '', fgets($fp) ) );\n\n$group = searchGroup( $count );\n\n$maxFind = array();\nforeach( $group as $key => $val ){\n\t$max = searchMax( $rating, $key );\n\t$maxFind[] = max( $max );\n}\n\necho max( $maxFind );\n\nfclose($fp);\n\nfunction searchMax( $rating, $period )\n{\n\t$groupSum = array();\n\t$i = 1;\n\tforeach( $rating as $value ){\n\t\t$groupSum[$i] += $value;\n\t\t$i++;\n\t\tif( $i > $period )\n\t\t{\n\t\t\t$i = 1;\n\t\t}\n\t}\n\treturn $groupSum;\n}\n\nfunction searchGroup( $number )\n{\n\t$aResult = array();\n\t$middle = $number / 2;\n\t$i = 1;\n\twhile( $i <= $middle )\n\t{\n\t\tif( $number % $i == 0 ){\n\t\t\tif( $number / $i > 2 )\n\t\t\t{\n\t\t\t\t$aResult[$i] = true;\n\t\t\t}\n\t\t\tif( $i > 2 )\n\t\t\t{\n\t\t\t\t$aResult[$number / $i] = true;\n\t\t\t}\n\t\t}\n\t\t$i++;\n\t}\n\t\n\treturn $aResult;\n}\n?>"}, {"source_code": " $max){\n $max = $sum;\n }\n }\n }\n}\necho $max.\"\\n\";\n?>"}, {"source_code": ""}, {"source_code": " $ans) $ans = $tmp;\n\t}\n}\necho $ans;\n?>"}, {"source_code": "$valueA) $r = $r + $valueA;\n return $r;\n}\n\n$aP = sumP($values);\n\n$i = count($del);\nwhile ($i>0)\n{\n $ugolnik = $del[$i-1];\n $countUgolnik = $n / $ugolnik;\n while ($countUgolnik>0)\n {\n $sx = $countUgolnik-1;\n \n $summa = 0;\n while ($sx<=$n)\n {\n $summa = $summa + $values[$sx];\n $sx = $sx + ($n/$ugolnik); \n }\n \n// echo $summa.\"\\n\";\n \n if ($aP<$summa) $aP = $summa;\n $countUgolnik--;\n } \n \n $i--;\n}\n\necho $aP;\n \n?>"}, {"source_code": " intval($lines[0]),\n 'items' => $lines[1],\n );\n $i = 0;\n $sums = array();\n $n = $input['n'];\n for ($i = 1; $i <= $n / 3; $i++) {\n if ($n % $i) { continue; }\n for($k = 1; $k <= $i; $k++) {\n $sums[] = getSum($k, $i);\n }\n }\n function getSum($start, $step)\n {\n global $input;\n $sum = 0;\n for($i = $start - 1; $i < count($input['items']); $i = $i+$step) {\n $sum += $input['items'][$i];\n }\n return $sum;\n }\n\n file_put_contents('php://stdout', max($sums));\n ?>"}, {"source_code": "$item) {\n if (!isset($sum[$key])) {\n $sum[$key] = 0;\n }\n $sum[$key] += $item;\n }\n }\n \n rsort($sum);\n \n if ($max_sum === false || $max_sum < $sum[0]) {\n $max_sum = $sum[0];\n }\n }\n \n $sum = array_sum($columns);\n if ($max_sum === false || $sum > $max_sum) {\n echo $sum;\n } else {\n echo $max_sum;\n }\n?>"}, {"source_code": ""}, {"source_code": "0) or ($n/$i<3)) {continue;}\n for ($t=0; $t<=$i-1; $t++){ \n $j=$t; $count=$ball[$j];\n while ($j<$n){\n \n $j=$j+$i; \n \n $count=$count+$ball[$j];\n \n \n }\n if ($min<=$count) $min=$count;\n } \n }\n print($min);\n\n?>"}, {"source_code": "$max){$max=$sum;} \n }\n }\n } \n \n echo $max; \n?>"}, {"source_code": "\nfscanf(STDIN, \"%d\\n\", $number);\n$line=trim(fgets(STDIN));\n$t=explode(\" \",$line);\n$count=count($t);\nif($count!=$number||$number<3||$number>20000)exit();\n$res=array();\nfor($i=1;$i<$count;$i++){\n\tif($count%$i!=0 || ($count/$i)<3)continue;\n\t$count/$i;\n\tfor($n=0;$n<$i;$n++){\n\t\tfor($a=$n;$a<$count;$a+=$i){\n\t\t\t$val=$t[$a];\n\t\t\tif($val<-1000||$val>1000)exit();\n\t\t\t$res[$i.$n]+=$val;\n\t\t}\n\t}\n}\necho max($res);\n?>\n"}, {"source_code": " 20000) {\n\tdie;\n}\n\nforeach ($aRates as &$iRate) {\n\t$iRate = (int) $iRate;\n\t\n\tif ($iRate < 0) {\n\t\t$bHaveNegative = true;\n\t}\n}\n\n$iIterations = floor($iSculptures / 3);\n\nfor ($i = 1; $i <= $iIterations; $i ++) {\n\n\t$aTempRates = $aRates;\n\tif ($iSculptures % $i == 0) {\n\t\tfor ($fi = 1; $fi <= $i; $fi ++) {\n\t\t\t\n\t\t\t$iReplaced = $aTempRates[$fi - 1];\n\t\t\tarray_push($aTempRates, $iReplaced);\n\n\t\t\t$iCurRate = 0;\n\t\t\t$iTop = $iSculptures + $fi;\n\t\t\t\n\t\t\tfor ($j = $fi; $j < $iTop ; $j += $i) {\n\t\t\t\t$iCurRate += $aTempRates[$j];\n\t\t\t}\n\t\t\t\n\t\t\tif (!isset($iMaxRate)) {\n\t\t\t\t$iMaxRate = $iCurRate;\n\t\t\t\t\n\t\t\t\tif (!isset($bHaveNegative)) {\n\t\t\t\t\tbreak 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$iMaxRate = max($iCurRate, $iMaxRate);\n\t\t\t}\n\t\t}\n\t}\n}\n\necho $iMaxRate;\n\n"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$points=trim($lines[0]);\n$dots=explode(\" \", $lines[1]);\n\n\n\n\n$max=array_sum($dots);\nif ($points>5)\n{\n $dels=del($points);\n foreach ($dels as $d)\n {\n for ($c=1; $c<=$d; $c++)\n {\n $tmp=0;\n $n=0;\n for ($i=0+$c; $i<=$points; $i=$i+$d)\n {\n $tmp+=$dots[$i-1];\n $n++;\n //echo \"{$dots[$i-1]} \";\n }\n //echo \" = $tmp
\";\n if($n>=3)\n if ($tmp>$max)\n $max=$tmp;\n }\n }\n}\n\necho $max;\n\nfunction del($chislo)\n{\n for($i = 1; $i < $chislo; $i++)\n {\n if(($chislo % $i)==0)\n $dels[]=$i;\n }\n return $dels;\n}\n?>"}, {"source_code": "= 3) {\n $delitels[] = $i;\n }\n}\n\nfor ($i=0; $i<$number; $i++) {\n $summa += $array[$i];\n}\n\n//1 - \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 - \u0442\u043e \u043e\u0442\u0432\u0435\u0442 - \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430\n\nif (!empty($delitels)) {\n foreach ($delitels as $del) {\n for ($j=0; $j<$del; $j++) { //\u041f\u0440\u043e\u0439\u0434\u0451\u043c \u043f\u043e \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044e \u0441 \u0448\u0430\u0433\u043e\u043c = 1\n $sum = 0;\n for ($i=$j; $i<$number; $i+=$del) {\n $sum += $array[$i];\n }\n if ($sum > $summa) {\n $summa = $sum;\n }\n }\n }\n}\n\n fputs(STDOUT, $summa);\n?> "}, {"source_code": " 2) { //needs to divide into the num of statues and also be >= 3 after that.\n $sums = array();\n $leftstanding = $n / $i;\n for ($k = 0; $k < $i; $k++) {\n $sum = 0;\n for ($j = $k; $j < $n; $j += $i) {\n $sum += $t[$j];\n }\n $sums[] = $sum;\n }\n rsort($sums);\n $total[] = $sums[0]; //only the top dogs need to move to the next round\n }\n}\nrsort($total);\necho $total[0];\n?>"}, {"source_code": "= 3))\n {\n for($y = 0; $y < $x; $y++)\n {\n $j = 0;\n for($z = $y; $z < $a; $z += $x)\n {\n $j += $b[$z];\n }\n array_push($c, $j);\n }\n }\n}\nprint max($c);\n?>"}, {"source_code": " $val)\n{\n $kv = $n / $val;\n for($i=0;$i<$kv;$i++)\n {\n for($j=0;$j<$val;$j++)\n {\n $sum[$i] += (int)$t[$i+$kv*$j];\n } \n } \n $sum[] = $lastMax;\n $lastMax = max($sum); \n unset($sum);\n}\nfputs(STDOUT, $lastMax);\n?>"}, {"source_code": " intval($lines[0]),\n 'items' => $lines[1],\n );\n }\n\n public static function set($data)\n {\n file_put_contents('php://stdout', $data);\n }\n }\n?>"}, {"source_code": "\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item] += (int)$points[$i];\n }\n }\n }\n }*/\n\n\n /*foreach($d as $item) {\n for($i = 0; $i < $len; $i+=$item) {\n $j = 0;\n foreach($d as $temp) {\n if($j<$item && isset($points[$i+$j])) {\n echo $item===2 && $j==1 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.\">\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item]+=$points[$i+$j];\n }\n $j = $temp;\n }\n }\n }*/\n\n foreach($d as $ter => $item) {\n for($i = 0; $i < $len; $i+=$item) {\n for($j = 0; $j<$d[$ter]; $j++) {\n if(isset($points[$i+$j])) {\n //echo $item===8 && $j==1 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.\">\\r\\n\":'';\n if(!isset($sum[$item.'_'.$j]))\n $sum[$item.'_'.$j] = 0;\n $sum[$item.'_'.$j]+=$points[$i+$j];\n }\n }\n }\n }\n\n //var_dump($sum);\n\n return max(array_sum($points), max($sum));\n};\n\nfunction findDel($ch) {\n $arr = array();\n for($s = 2; $s < $ch; $s++) {\n if ($s< floor($ch/2) && $ch % $s==0) {\n $arr[] = $s;\n }\n if($s>floor($ch/2))\n break;\n }\n return $arr;\n}\n\n//$line1 = 9;\n//$line2 = '';\n$lineArray2 = explode(' ', $line2);\n\necho $f($line1, $lineArray2);\n\n//echo \"\\r\\n|=>\", (time() - $t2), \"\\r\\n\";"}], "negative_code": [{"source_code": "\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item] += (int)$points[$i];\n }\n }\n }\n }*/\n\n\n /*foreach($d as $item) {\n for($i = 0; $i < $len; $i+=$item) {\n $j = 0;\n foreach($d as $temp) {\n if($j<$item && isset($points[$i+$j])) {\n echo $item===2 && $j==1 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.\">\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item]+=$points[$i+$j];\n }\n $j = $temp;\n }\n }\n }*/\n\n foreach($d as $ter => $item) {\n for($i = 0; $i < $len; $i+=$item) {\n for($j = 0; $j<$d[$ter]; $j++) {\n if(isset($points[$i+$j])) {\n //echo $item===5 && $j=0 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.\">\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item]+=$points[$i+$j];\n }\n }\n }\n }\n\n //var_dump($sum);\n\n return max(array_sum($points), max($sum));\n};\n\nfunction findDel($ch) {\n $arr = array();\n for($s = 2; $s < $ch; $s++) {\n if ($s< floor($ch/2) && $ch % $s==0) {\n $arr[] = $s;\n }\n if($s>floor($ch/2))\n break;\n }\n return $arr;\n}\n\n//$line1 = 9;\n//$line2 = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20';\n$lineArray2 = explode(' ', $line2);\n\necho $f($line1, $lineArray2);\n\n//echo \"\\r\\n|=>\", (time() - $t2), \"\\r\\n\";"}, {"source_code": "=3)\n{\n for($sdvig=0;$sdvig<=$i;$sdvig++)\n {\n for($ii=$sdvig;$ii<$n;$ii=$ii+$i)\n {\n $rating+=$array[$ii];\n \n }\n if($rating>$ratingMax)\n {\n $ratingMax=$rating;\n }\n $rating=0;\n }\n $i++;\n}\n\necho $ratingMax;\n?>"}, {"source_code": "=3)\n{\n for($sdvig=0;$sdvig<=$i;$sdvig++)\n {\n for($ii=$sdvig;$ii<$n;$ii=$ii+$i)\n {\n $rating+=$array[$ii];\n \n }\n if(!empty($ratingMax))\n {\n if($rating>$ratingMax)\n {\n $ratingMax=$rating;\n }\n }\n else\n {\n $ratingMax=$rating;\n }\n $rating=0;\n }\n $i++;\n}\necho $ratingMax;\n?>"}, {"source_code": " $max) $max = $c;\n\t\t}\n\t}\n}\nprintf(\"%d\", $max);"}, {"source_code": " $val)\n{\n $kv = $n / $val;\n for($i=0;$i<$kv;$i++)\n {\n for($j=0;$j<$val;$j++)\n {\n $sum[$i] += (int)$t[$i+$kv*$j];\n } \n } \n $sum[] = $lastMax;\n $lastMax = max($sum); \n unset($sum);\n}\nfputs(STDOUT, $lastMax);\n?>\n"}, {"source_code": "5){\n $res[]=$a/2;\n $a=$a/2;\n }\n return $res;\n }elseif($n%4==0){\n while($a>4){\n $res[]=$a/2;\n $a=$a/2;\n }\n return $res;\n }elseif($n%3==0){\n while($a>3){\n $res[]=$a/2;\n $a=$a/2;\n }\n return $res;\n }else{\n return $n;\n }\n \n}\n\n$n= trim(fgets(STDIN));\n$balls=explode(' ',trim(fgets(STDIN)));\n\n$max=array_sum($balls);\n$variants=getVariants($n);\n\n$c=count($variants);\nif($c==1){\n echo array_sum($balls);\n}else{\n for($i=1;$i<$c;$i++){\n $maxEven=0;\n $maxOdd=0;\n for($j=0;$j<$n;$j=$j+$n/$variants[$i]){\n $maxOdd+=$balls[$j];\n }\n for($j=1;$j<$n;$j=$j+$n/$variants[$i]){\n $maxEven+=$balls[$j];\n }\n if($maxEven>$max){\n $max=$maxEven;\n }\n if($maxOdd>$max){\n $max=$maxOdd;\n }\n }\n echo $max;\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $ans) $ans = $tmp;\n\t}\n}\necho $ans;\n?>"}, {"source_code": "$item) {\n if (!isset($sum[$key])) {\n $sum[$key] = 0;\n }\n $sum[$key] += $item;\n }\n }\n \n rsort($sum);\n if ($max_sum < $sum[0]) {\n $max_sum = $sum[0];\n }\n }\n \n $sum = array_sum($columns);\n if ($sum > $max_sum) {\n echo $sum;\n } else {\n echo $max_sum;\n }\n?>"}, {"source_code": "$item) {\n if (!isset($sum[$key])) {\n $sum[$key] = 0;\n }\n $sum[$key] += $item;\n }\n }\n \n rsort($sum);\n if ($max_sum < $sum[0]) {\n $max_sum = $sum[0];\n }\n }\n \n $sum = array_sum($columns);\n if ($sum > $max_sum) {\n echo $sum;\n } else {\n echo $max_sum;\n }\n?>"}, {"source_code": "0) or ($n/$i<3)) {continue;}\n for ($t=0; $t<=$i; $t++){ \n $j=$t; $count=$ball[$j];\n while ($j<=$n){\n $j=$j+$i; \n $count=$count+$ball[$j];\n \n if ($min<=$count) $min=$count;\n }\n } \n }\n print($min);\n\n?>"}, {"source_code": "0) or ($n/$i<3)) {continue;}\n for ($t=0; $t<=$i-1; $t++){ \n $j=$t; $count=$ball[$j];\n while ($j<$n){\n \n $j=$j+$i; \n \n $count=$count+$ball[$j];\n \n \n }\n if ($min<=$count) $min=$count;\n } \n }\n print($min);\n\n?>"}, {"source_code": "$max){$max=$sum;} \n }\n }\n } \n \n echo $max; \n?>"}, {"source_code": "\nfscanf(STDIN, \"%d\\n\", $number);\n$line=trim(fgets(STDIN));\n$t=explode(\" \",$line);\n$count=count($t);\nif($count!=$number||$number<3||$number>20000)exit();\n$res=array();\nfor($i=1;$i<$count;$i++){\n\tif($count%$i!=0)continue;\n\tfor($n=0;$n<=$i;$n++){\n\t\tfor($a=$n;$a<$count;$a+=$i){\n\t\t\t$val=$t[$a];\n\t\t\tif($val<-1000||$val>1000)exit();\n\t\t\t$res[$i.$n]+=$val;\n\t\t}\n\t}\n}\necho max($res);\n?>\n"}, {"source_code": "\nfscanf(STDIN, \"%d\\n\", $number);\n$line=trim(fgets(STDIN));\n$t=explode(\" \",$line);\n$count=count($t);\nif($count!=$number||$number<3||$number>20000)exit();\n$res=array();\nfor($i=1;$i<$count;$i++){\n\tif($count%$i!=0 && $count/$i<3)continue;\n\tfor($n=0;$n<$i;$n++){\n\t\tfor($a=$n;$a<$count;$a+=$i){\n\t\t\t$val=$t[$a];\n\t\t\tif($val<-1000||$val>1000)exit();\n\t\t\t$res[$i.$n]+=$val;\n\t\t}\n\t}\n}\necho max($res);\n?>\n"}, {"source_code": "\nfscanf(STDIN, \"%d\\n\", $number);\n$line=trim(fgets(STDIN));\n$t=explode(\" \",$line);\n$count=count($t);\nif($count!=$number||$number<3||$number>20000)exit();\n$res=array();\nfor($i=1;$i<$count;$i++){\n\tif($count%$i!=0 && $count/$i<3)continue;\n\tfor($n=0;$n<$i;$n++){\n\t\tfor($a=$n;$a<$count;$a+=$i){\n\t\t\t$val=$t[$a];\n\t\t\tif($val<-1000||$val>1000)exit();\n\t\t\t$res[$i.$n]+=$val;\n\t\t}\n\t}\n}\nvar_dump($res);\necho max($res);\n?>\n"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$points=trim($lines[0]);\n$dots=explode(\" \", $lines[1]);\n\n\n\n\n$max=array_sum($dots);\nif ($points%2==0)\n{\n $dels=del($points);\n foreach ($dels as $d)\n {\n for ($c=1; $c<=$d; $c++)\n {\n $tmp=0;\n for ($i=0+$c; $i<=$points; $i=$i+$d)\n {\n $tmp+=$dots[$i-1];\n //echo \"{$dots[$i-1]} \";\n }\n //echo \" = $tmp
\";\n if ($tmp>$max)\n $max=$tmp;\n }\n }\n}\n\necho $max;\n\nfunction del($chislo)\n{\n for($i = 2; $i < $chislo; $i++)\n {\n if(($chislo % $i)==0)\n $dels[]=$i;\n }\n return $dels;\n}\n\n?>"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$points=trim($lines[0]);\n$dots=explode(\" \", $lines[1]);\n\n\n//$points=44;\n$dels=del($points);\n\n\n$max=array_sum($dots);\n\n\nforeach ($dels as $d)\n{\n for ($c=1; $c<=$d; $c++)\n {\n $tmp=0;\n for ($i=0+$c; $i<=$points; $i=$i+$d)\n {\n $tmp+=$dots[$i-1];\n \n }\n if ($tmp>$max)\n $max=$tmp;\n }\n}\n\n\necho $max;\n\nfunction del($chislo)\n{\n for($i = 2; $i < $chislo; $i++)\n {\n if(($chislo % $i)==0)\n $dels[]=$i;\n }\n return $dels;\n}\n?>"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$points=trim($lines[0]);\n$dots=explode(\" \", $lines[1]);\n\n\n\n\n$max=array_sum($dots);\nif ($points%2==0 and $points>5)\n{\n $dels=del($points);\n foreach ($dels as $d)\n {\n for ($c=1; $c<=$d; $c++)\n {\n $tmp=0;\n for ($i=0+$c; $i<=$points; $i=$i+$d)\n {\n $tmp+=$dots[$i-1];\n //echo \"{$dots[$i-1]} \";\n }\n //echo \" = $tmp
\";\n if ($tmp>$max)\n $max=$tmp;\n }\n }\n}\n\necho $max;\n\nfunction del($chislo)\n{\n for($i = 2; $i < $chislo; $i++)\n {\n if(($chislo % $i)==0)\n $dels[]=$i;\n }\n return $dels;\n}\n?>"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$points=trim($lines[0]);\n$dots=explode(\" \", $lines[1]);\n\n\n\n\n$max=array_sum($dots);\nif ($points%2==0 and $points>5)\n{\n $dels=del($points);\n foreach ($dels as $d)\n {\n for ($c=1; $c<=$d; $c++)\n {\n $tmp=0;\n $n=0;\n for ($i=0+$c; $i<=$points; $i=$i+$d)\n {\n $tmp+=$dots[$i-1];\n $n++;\n //echo \"{$dots[$i-1]} \";\n }\n //echo \" = $tmp
\";\n if($n>=3)\n if ($tmp>$max)\n $max=$tmp;\n }\n }\n}\n\necho $max;\n\nfunction del($chislo)\n{\n for($i = 1; $i < $chislo; $i++)\n {\n if(($chislo % $i)==0)\n $dels[]=$i;\n }\n return $dels;\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$max){\n$max=$sums[$h];}\n}\n}\n$output=$max;\n}\nfputs($tr, $output );"}, {"source_code": "\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item] += (int)$points[$i];\n }\n }\n }\n }*/\n\n\n foreach($d as $item) {\n for($i = 0; $i < $len; $i+=$item) {\n for($j = 0; $j <= count($d); $j++) {\n if($j<$item) {\n if(isset($points[$i+$j])) {\n //echo $item===4 && $j==0 ?'<'.$points[$i+$j].'|'.$item.'|'.$j.\">\\r\\n\":'';\n if(!isset($sum[$j.'_'.$item]))\n $sum[$j.'_'.$item] = 0;\n $sum[$j.'_'.$item]+=$points[$i+$j];\n }\n }\n }\n }\n }\n\n //var_dump($sum);\n\n return max(array_sum($points), max($sum));\n};\n\nfunction findDel($ch) {\n $arr = array();\n for($s = 2; $s < $ch; $s++) {\n if ($s< floor($ch/2) && $ch % $s==0) {\n $arr[] = $s;\n }\n if($s>floor($ch/2))\n break;\n }\n return $arr;\n}\n\n//$line1 = 9;\n//$line2 = '';\n$lineArray2 = explode(' ', $line2);\n\necho $f($line1, $lineArray2);\n\n//echo \"\\r\\n|=>\", (time() - $t2), \"\\r\\n\";"}], "src_uid": "0ff4ac859403db4e29554ca7870f5490"} {"nl": {"description": "You are given a string $$$s$$$ of length $$$n$$$ consisting only of lowercase Latin letters.A substring of a string is a contiguous subsequence of that string. So, string \"forces\" is substring of string \"codeforces\", but string \"coder\" is not.Your task is to calculate the number of ways to remove exactly one substring from this string in such a way that all remaining characters are equal (the number of distinct characters either zero or one).It is guaranteed that there is at least two different characters in $$$s$$$.Note that you can remove the whole string and it is correct. Also note that you should remove at least one character.Since the answer can be rather large (not very large though) print it modulo $$$998244353$$$.If you are Python programmer, consider using PyPy instead of Python when you submit your code.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the length of the string $$$s$$$. The second line of the input contains the string $$$s$$$ of length $$$n$$$ consisting only of lowercase Latin letters. It is guaranteed that there is at least two different characters in $$$s$$$.", "output_spec": "Print one integer \u2014 the number of ways modulo $$$998244353$$$ to remove exactly one substring from $$$s$$$ in such way that all remaining characters are equal.", "sample_inputs": ["4\nabaa", "7\naacdeee", "2\naz"], "sample_outputs": ["6", "6", "3"], "notes": "NoteLet $$$s[l; r]$$$ be the substring of $$$s$$$ from the position $$$l$$$ to the position $$$r$$$ inclusive.Then in the first example you can remove the following substrings: $$$s[1; 2]$$$; $$$s[1; 3]$$$; $$$s[1; 4]$$$; $$$s[2; 2]$$$; $$$s[2; 3]$$$; $$$s[2; 4]$$$. In the second example you can remove the following substrings: $$$s[1; 4]$$$; $$$s[1; 5]$$$; $$$s[1; 6]$$$; $$$s[1; 7]$$$; $$$s[2; 7]$$$; $$$s[3; 7]$$$. In the third example you can remove the following substrings: $$$s[1; 1]$$$; $$$s[1; 2]$$$; $$$s[2; 2]$$$. "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "9693f60fc65065d00a1899df999405fe"} {"nl": {"description": "You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi,\u2009yi). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0,\u20090). Initially, the robot is at point with coordinates (0,\u20090). Also, let's mark the robot's current position as (x,\u2009y). In order to destroy all the bombs, the robot can perform three types of operations: Operation has format \"1 k dir\". To perform the operation robot have to move in direction dir k (k\u2009\u2265\u20091) times. There are only 4 directions the robot can move in: \"R\", \"L\", \"U\", \"D\". During one move the robot can move from the current point to one of following points: (x\u2009+\u20091,\u2009y), (x\u2009-\u20091,\u2009y), (x,\u2009y\u2009+\u20091), (x,\u2009y\u2009-\u20091) (corresponding to directions). It is forbidden to move from point (x,\u2009y), if at least one point on the path (besides the destination point) contains a bomb. Operation has format \"2\". To perform the operation robot have to pick a bomb at point (x,\u2009y) and put it in a special container. Thus, the robot can carry the bomb from any point to any other point. The operation cannot be performed if point (x,\u2009y) has no bomb. It is forbidden to pick a bomb if the robot already has a bomb in its container. Operation has format \"3\". To perform the operation robot have to take a bomb out of the container and destroy it. You are allowed to perform this operation only if the robot is at point (0,\u20090). It is forbidden to perform the operation if the container has no bomb. Help the robot and find the shortest possible sequence of operations he can perform to destroy all bombs on the coordinate plane.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of bombs on the coordinate plane. Next n lines contain two integers each. The i-th line contains numbers (xi,\u2009yi) (\u2009-\u2009109\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009109) \u2014 the coordinates of the i-th bomb. It is guaranteed that no two bombs are located at the same point and no bomb is at point (0,\u20090). ", "output_spec": "In a single line print a single integer k \u2014 the minimum number of operations needed to destroy all bombs. On the next lines print the descriptions of these k operations. If there are multiple sequences, you can print any of them. It is guaranteed that there is the solution where k\u2009\u2264\u2009106.", "sample_inputs": ["2\n1 1\n-1 -1", "3\n5 0\n0 5\n1 0"], "sample_outputs": ["12\n1 1 R\n1 1 U\n2\n1 1 L\n1 1 D\n3\n1 1 L\n1 1 D\n2\n1 1 R\n1 1 U\n3", "12\n1 1 R\n2\n1 1 L\n3\n1 5 R\n2\n1 5 L\n3\n1 5 U\n2\n1 5 D\n3"], "notes": null}, "positive_code": [{"source_code": " 0))\n {\n $b[count($b)] = $o;\n $j += 4;\n }\n elseif(($n == 0) && ($o < 0))\n {\n $c[count($c)] = $o;\n $j += 4;\n }\n elseif(($o == 0) && ($n < 0))\n {\n $d[count($d)] = $n;\n $j += 4;\n }\n elseif(($o == 0) && ($n > 0))\n {\n $e[count($e)] = $n;\n $j += 4;\n }\n elseif(($n > 0) && ($o > 0))\n {\n $f[$n][count($f[$n])] = $o;\n $j += 6;\n }\n elseif(($n > 0) && ($o < 0))\n {\n $g[$n][count($g[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o < 0))\n {\n $h[$n][count($h[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o > 0))\n {\n $i[$n][count($i[$n])] = $o;\n $j += 6;\n }\n}\nprint $j . \"\\n\";\nsort($b);\nrsort($c);\nrsort($d);\nsort($e);\nksort($f);\nksort($g);\nksort($h);\nksort($i);\nfor($x = 0; $x < count($b); $x++)\n{\n print \"1 \" . $b[$x] . \" U\\n2\\n1 \" . $b[$x] . \" D\\n3\\n\";\n}\nfor($x = 0; $x < count($c); $x++)\n{\n print \"1 \" . (0 - $c[$x]) . \" D\\n2\\n1 \" . (0 - $c[$x]) . \" U\\n3\\n\";\n}\nfor($x = 0; $x < count($d); $x++)\n{\n print \"1 \" . (0 - $d[$x]) . \" L\\n2\\n1 \" . (0 - $d[$x]) . \" R\\n3\\n\";\n}\nfor($x = 0; $x < count($e); $x++)\n{\n print \"1 \" . $e[$x] . \" R\\n2\\n1 \" . $e[$x] . \" L\\n3\\n\";\n}\nfor($x = 0; $x < count($f); $x++)\n{\n $k = each($f);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . $m[$y] . \" D\\n1 \" . $l . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n $k = each($g);\n $l = $k[0];\n $m = $k[1];\n rsort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . (0 - $m[$y]) . \" U\\n1 \" . $l . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($h); $x++)\n{\n $k = each($h);\n $l = $k[0];\n $m = $k[1];\n rsort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . (0 - $m[$y]) . \" U\\n1 \" . (0 - $l) . \" R\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($i); $x++)\n{\n $k = each($i);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . $m[$y] . \" D\\n1 \" . (0 - $l) . \" R\\n3\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": " 0))\n {\n $b[count($b)] = $o;\n $j += 4;\n }\n elseif(($n == 0) && ($o < 0))\n {\n $c[count($c)] = $o;\n $j += 4;\n }\n elseif(($o == 0) && ($n < 0))\n {\n $d[count($d)] = $n;\n $j += 4;\n }\n elseif(($o == 0) && ($n > 0))\n {\n $e[count($e)] = $n;\n $j += 4;\n }\n elseif(($n > 0) && ($o > 0))\n {\n $f[$n][count($f[$n])] = $o;\n $j += 6;\n }\n elseif(($n > 0) && ($o < 0))\n {\n $g[$n][count($g[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o < 0))\n {\n $h[$n][count($h[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o > 0))\n {\n $i[$n][count($i[$n])] = $o;\n $j += 6;\n }\n}\nprint $j . \"\\n\";\nsort($b);\nrsort($c);\nrsort($d);\nsort($e);\nksort($f);\nksort($g);\nksort($h);\nksort($i);\nfor($x = 0; $x < count($b); $x++)\n{\n print \"1 \" . $b[$x] . \" U\\n2\\n1 \" . $b[$x] . \" D\\n3\\n\";\n}\nfor($x = 0; $x < count($c); $x++)\n{\n print \"1 \" . (0 - $c[$x]) . \" D\\n2\\n1 \" . (0 - $c[$x]) . \" U\\n3\\n\";\n}\nfor($x = 0; $x < count($d); $x++)\n{\n print \"1 \" . (0 - $d[$x]) . \" L\\n2\\n1 \" . (0 - $d[$x]) . \" R\\n3\\n\";\n}\nfor($x = 0; $x < count($e); $x++)\n{\n print \"1 \" . $e[$x] . \" R\\n2\\n1 \" . $e[$x] . \" L\\n3\\n\";\n}\nfor($x = 0; $x < count($f); $x++)\n{\n $k = each($f);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . $l . \" D\\n1 \" . $m[$y] . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n $k = each($g);\n $l = $k[0];\n $m = $k[1];\n rsort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . $l . \" U\\n1 \" . (0 - $m[$y]) . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($h); $x++)\n{\n $k = each($h);\n $l = $k[0];\n $m = $k[1];\n rsort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . (0 - $l) . \" U\\n1 \" . (0 - $m[$y]) . \" R\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($i); $x++)\n{\n $k = each($i);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . (0 - $l) . \" D\\n1 \" . $m[$y] . \" R\\n3\\n\";\n }\n}\n?>"}, {"source_code": " 0))\n {\n $b[count($b)] = $o;\n $j += 4;\n }\n elseif(($n == 0) && ($o < 0))\n {\n $c[count($c)] = $o;\n $j += 4;\n }\n elseif(($o == 0) && ($n < 0))\n {\n $d[count($d)] = $n;\n $j += 4;\n }\n elseif(($o == 0) && ($n > 0))\n {\n $e[count($e)] = $n;\n $j += 4;\n }\n elseif(($n > 0) && ($o > 0))\n {\n $f[$n][count($f[$n])] = $o;\n $j += 6;\n }\n elseif(($n > 0) && ($o < 0))\n {\n $g[$n][count($g[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o < 0))\n {\n $h[$n][count($h[$n])] = $o;\n $j += 6;\n }\n elseif(($n < 0) && ($o > 0))\n {\n $i[$n][count($i[$n])] = $o;\n $j += 6;\n }\n}\nprint $j . \"\\n\";\nsort($b);\nrsort($c);\nrsort($d);\nsort($e);\nksort($f);\nksort($g);\nksort($h);\nksort($i);\nfor($x = 0; $x < count($b); $x++)\n{\n print \"1 \" . $b[$x] . \" U\\n2\\n1 \" . $b[$x] . \" D\\n3\\n\";\n}\nfor($x = 0; $x < count($c); $x++)\n{\n print \"1 \" . (0 - $c[$x]) . \" D\\n2\\n1 \" . (0 - $c[$x]) . \" U\\n3\\n\";\n}\nfor($x = 0; $x < count($d); $x++)\n{\n print \"1 \" . (0 - $d[$x]) . \" L\\n2\\n1 \" . (0 - $d[$x]) . \" R\\n3\\n\";\n}\nfor($x = 0; $x < count($e); $x++)\n{\n print \"1 \" . $e[$x] . \" R\\n2\\n1 \" . $e[$x] . \" L\\n3\\n\";\n}\nfor($x = 0; $x < count($f); $x++)\n{\n $k = each($f);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . $l . \" D\\n1 \" . $m[$y] . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n $k = each($g);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . $l . \" R\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . $l . \" U\\n1 \" . (0 - $m[$y]) . \" L\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($h); $x++)\n{\n $k = each($h);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . (0 - $m[$y]) . \" D\\n2\\n\" . \"1 \" . (0 - $l) . \" U\\n1 \" . (0 - $m[$y]) . \" R\\n3\\n\";\n }\n}\nfor($x = 0; $x < count($i); $x++)\n{\n $k = each($i);\n $l = $k[0];\n $m = $k[1];\n sort($m);\n for($y = 0; $y < count($m); $y++)\n {\n print \"1 \" . (0 - $l) . \" L\\n1 \" . $m[$y] . \" U\\n2\\n\" . \"1 \" . (0 - $l) . \" D\\n1 \" . $m[$y] . \" R\\n3\\n\";\n }\n}\n?>"}], "src_uid": "a7c1b9845ab0569e0175853db9ed5c32"} {"nl": {"description": "Little boy Petya loves stairs very much. But he is bored from simple going up and down them \u2014 he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase and reach the last stair number n without touching a dirty stair once.One has to note that anyway Petya should step on the first and last stairs, so if the first or the last stair is dirty, then Petya cannot choose a path with clean steps only.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n\u2009\u2264\u2009109, 0\u2009\u2264\u2009m\u2009\u2264\u20093000) \u2014 the number of stairs in the staircase and the number of dirty stairs, correspondingly. The second line contains m different space-separated integers d1,\u2009d2,\u2009...,\u2009dm (1\u2009\u2264\u2009di\u2009\u2264\u2009n) \u2014 the numbers of the dirty stairs (in an arbitrary order).", "output_spec": "Print \"YES\" if Petya can reach stair number n, stepping only on the clean stairs. Otherwise print \"NO\".", "sample_inputs": ["10 5\n2 4 8 3 6", "10 5\n2 4 5 7 9"], "sample_outputs": ["NO", "YES"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "422cbf106fac3216d58bdc8411c0bf9f"} {"nl": {"description": "Wilbur the pig is tinkering with arrays again. He has the array a1,\u2009a2,\u2009...,\u2009an initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai,\u2009ai\u2009+\u20091,\u2009... ,\u2009an or subtract 1 from all elements ai,\u2009ai\u2009+\u20091,\u2009...,\u2009an. His goal is to end up with the array b1,\u2009b2,\u2009...,\u2009bn. Of course, Wilbur wants to achieve this goal in the minimum number of steps and asks you to compute this value.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009200\u2009000)\u00a0\u2014 the length of the array ai. Initially ai\u2009=\u20090 for every position i, so this array is not given in the input. The second line of the input contains n integers b1,\u2009b2,\u2009...,\u2009bn (\u2009-\u2009109\u2009\u2264\u2009bi\u2009\u2264\u2009109).", "output_spec": "Print the minimum number of steps that Wilbur needs to make in order to achieve ai\u2009=\u2009bi for all i.", "sample_inputs": ["5\n1 2 3 4 5", "4\n1 2 2 1"], "sample_outputs": ["5", "3"], "notes": "NoteIn the first sample, Wilbur may successively choose indices 1, 2, 3, 4, and 5, and add 1 to corresponding suffixes.In the second sample, Wilbur first chooses indices 1 and 2 and adds 1 to corresponding suffixes, then he chooses index 4 and subtract 1."}, "positive_code": [{"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n elseif($b[$x + 1] < $b[$x])\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nprint $c;\n?>"}], "negative_code": [{"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n else\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nif($a == 200000)\n{\n print $b[count($b) - 1];\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $c += $b[$x + 1] - $b[$x];\n }\n else\n {\n $c += $b[$x] - $b[$x + 1];\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n elseif($b[$x + 1] < $b[$x])\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n else\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nif($a == 200000)\n{\n print $b[count($b) - 1];\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n else\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $c += ($b[$x + 1] - $b[$x]);\n }\n else\n {\n $c += ($b[$x] - $b[$x + 1]);\n }\n}\nprint $c;\n?>"}, {"source_code": " $b[$x])\n {\n $d = bcsub($b[$x + 1], $b[$x]);\n $c = bcadd($c, $d);\n }\n else\n {\n $d = bcsub($b[$x], $b[$x + 1]);\n $c = bcadd($c, $d);\n }\n}\nprint $c;\n?>"}], "src_uid": "97a226f47973fcb39c40e16f66654b5f"} {"nl": {"description": "You have $$$a$$$ coins of value $$$n$$$ and $$$b$$$ coins of value $$$1$$$. You always pay in exact change, so you want to know if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ ($$$0 \\le x \\le a$$$) coins of value $$$n$$$ and $$$y$$$ ($$$0 \\le y \\le b$$$) coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$.You have to answer $$$q$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 10^4$$$) \u2014 the number of test cases. Then $$$q$$$ test cases follow. The only line of the test case contains four integers $$$a$$$, $$$b$$$, $$$n$$$ and $$$S$$$ ($$$1 \\le a, b, n, S \\le 10^9$$$) \u2014 the number of coins of value $$$n$$$, the number of coins of value $$$1$$$, the value $$$n$$$ and the required total value.", "output_spec": "For the $$$i$$$-th test case print the answer on it \u2014 YES (without quotes) if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ coins of value $$$n$$$ and $$$y$$$ coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$, and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).", "sample_inputs": ["4\n1 2 3 4\n1 2 3 6\n5 2 6 27\n3 3 5 18"], "sample_outputs": ["YES\nNO\nNO\nYES"], "notes": null}, "positive_code": [{"source_code": "= $e)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n elseif($d == $e)\n {\n print \"YES\\n\";\n }\n elseif($d > $e)\n {\n if($c >= $e)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\n?>"}, {"source_code": "= $aArray[3]){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n } elseif ($iAvg > $aArray[0]) {\n if(($aArray[0]*$aArray[2] + $aArray[1]) >= $aArray[3]){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n } else {\n echo \"NO\\n\";\n }\n}"}, {"source_code": "= $S ? 'YES':'NO');\n\t} else {\n\t\tprintf(\"%s\\n\", $b >= $S % $n ? 'YES':'NO');\n\t}\n}\n\n\n\n\n"}, {"source_code": " $a && $s - ($a * $n) <= $b) {\n $status = true;\n }\n /*if ($a == 0 && $b >= $s) {\n $status = true;\n } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {\n $status = true;\n } else {\n if ($s % $n <= $b && intval($s / $n) <= $a) {\n $status = true;\n }\n }*/\n\n if ($status) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n?>"}, {"source_code": " $a[3]) {\n if($a[3] % $a[2] <= $a[1]) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n } else {\n if($a[3] - ($a[0] * $a[2]) <= $a[1]){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n }\n \n \n }\n \n"}], "negative_code": [{"source_code": "= $aArray[3]){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n } else {\n echo \"NO\\n\";\n }\n}"}, {"source_code": "= $aArray[3]){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n } else {\n echo \"NO\\n\";\n }\n}"}, {"source_code": "= $s) {\n $status = true;\n } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {\n $status = true;\n } else {\n if ($s % $n <= $b && intval($s / $n) <= $a) {\n $status = true;\n }\n }*/\n\n if ($status) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= $s) {\n $status = true;\n } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {\n $status = true;\n } else {\n for ($j = 1; $j <= $a; $j ++) {\n $count1 = intval(bcdiv ($s, bcmul($n, $j)));\n $count2 = bcmod ($s,bcmul ($n, $j)) ;\n if ( bccomp($count1, $a) !=1 && bccomp($count2, $b) !=1) {\n $status = true;\n break;\n }\n }\n }\n\n if ($status) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $s) {\n $status = true;\n } elseif ($b == 0 && bcmod($s,$n) == 0 && bcdiv($s,$n) <= $a) {\n $status = true;\n } else {\n if ($s % $n <= $b && intval($s / $n) <= $a) {\n $status = true;\n }\n }\n\n if ($status) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n?>"}, {"source_code": "= $s) {\n $status = true;\n } elseif ($b == 0 && $s%$n == 0 && intval($s/$n) <= $a) {\n $status = true;\n } else {\n if ($s % $n <= $b && intval($s / $n) <= $a) {\n $status = true;\n }\n }\n\n if ($status) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n?>"}], "src_uid": "e2434fd5f9d16d59e646b6e69e37684a"} {"nl": {"description": "Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.For example: the following words have typos: \"hellno\", \"hackcerrs\" and \"backtothefutttture\"; the following words don't have typos: \"helllllooooo\", \"tobeornottobe\" and \"oooooo\". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.", "input_spec": "The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.", "output_spec": "Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.", "sample_inputs": ["hellno", "abacaba", "asdfasdf"], "sample_outputs": ["hell no", "abacaba", "asd fasd f"], "notes": null}, "positive_code": [{"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n $d2 = \"\";\n }\n else\n {\n if($d >= 3)\n {\n if(($d2[strlen($d2) - 1] == $d2[strlen($d2) - 2]) && ($d2[strlen($d2) - 1] == $d2[strlen($d2) - 3]) && ($d2[strlen($d2) - 2] == $d2[strlen($d2) - 3]))\n {\n continue;\n }\n else\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 3000 || $inputStringLength < 1) {\n echo $answer;\n} else {\n $stringAsArray = str_split($inputString);\n $vowels = array(\"a\" => \"a\", \"e\" => \"e\", \"i\" => \"i\", \"o\" => \"o\", \"u\" => \"u\", \" \" => \" \");\n\n $indexOfTypos = array();\n\t$indexOfAddSpace = array();\n $lastChar = 0;\n $consecutiveConsonants = 0;\n\t$consecutiveConsonantsArray = array();\n foreach ($stringAsArray as $k => $v) {\n $lastChar = $v;\n if (isset($vowels[$v])) {\n\t\t\t$consecutiveConsonants = 0;\n\t\t\t$consecutiveConsonantsArray = array();\n } else {\n // insert space as late as possible\n if (count($consecutiveConsonantsArray) == 1) { \n if (!isset($consecutiveConsonantsArray[$v]) && $consecutiveConsonants >= 2) {\n // add space\n $indexOfAddSpace[$k-1] = $k-1;\n $consecutiveConsonants = 0;\n $consecutiveConsonantsArray = array();\t\t\t\t\t\t\n }\n } else if (count($consecutiveConsonantsArray) > 1) {\n $indexOfAddSpace[$k-1] = $k-1;\n $consecutiveConsonants = 0;\n $consecutiveConsonantsArray = array();\t\t\t\t\t\n }\n\t\t\t\t\n\t\t\t$consecutiveConsonantsArray[$v] = $v;\n $consecutiveConsonants++;\n }\n }\n \n\tif(!empty($indexOfAddSpace)) {\n\t\tforeach($stringAsArray as $fk => $fv) {\n\t\t\techo $fv . (isset($indexOfAddSpace[$fk])?\" \":\"\");\n\t\t}\n\t} else {\n\t\techo $inputString;\n }\n \n}\n\n?>"}, {"source_code": " 3000 || $inputStringLength < 1) {\n echo $answer;\n} else {\n $stringAsArray = str_split($inputString);\n $vowels = array(\"a\" => \"a\", \"e\" => \"e\", \"i\" => \"i\", \"o\" => \"o\", \"u\" => \"u\", \" \" => \" \");\n\n $lastChar = \"\";\n $consecutiveConsonants = 0;\n $consecutiveSameConsonantsInARow = 0;\n foreach ($stringAsArray as $k => $v) {\n echo $lastChar;\n \n if (isset($vowels[$v])) {\n\t\t\t$consecutiveConsonants = 0;\n $consecutiveSameConsonantsInARow = 0;\n } else {\n \n if ($consecutiveConsonants >= 2) {\n if ($consecutiveSameConsonantsInARow == 1 || $lastChar != $v) {\n echo \" \";\n $consecutiveConsonants = 0;\n $consecutiveSameConsonantsInARow = 0; \n }\n }\n\t\t\t\t\n if ($lastChar == $v)\n $consecutiveSameConsonantsInARow++;\n else\n $consecutiveSameConsonantsInARow = 1;\n \n $consecutiveConsonants++;\n }\n \n $lastChar = $v;\n }\n echo $lastChar;\n \n}\n\n?>"}], "negative_code": [{"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n }\n else\n {\n if($d == 3)\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n}\nif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n $d2 = 0;\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] == $d2[1]) && ($d2[0] == $d2[2]) && ($d2[1] == $d2[2]))\n {\n continue;\n }\n else\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $d2 = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n $d2 = \"\";\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] == $d2[1]) && ($d2[0] == $d2[2]) && ($d2[1] == $d2[2]))\n {\n continue;\n }\n else\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $d2 = \"\";\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] == $d2[1]) && ($d2[0] == $d2[2]) && ($d2[1] == $d2[2]))\n {\n continue;\n }\n else\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 += $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] != $d2[1]) && ($d2[1] != $d2[2]))\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 3000 || $inputStringLength < 1) {\n echo $answer;\n} else {\n $stringAsArray = str_split($inputString);\n// $binaryInterpretation = array(); // do I need this at all?\n $vowels = array(\"a\" => \"a\", \"e\" => \"e\", \"i\" => \"i\", \"o\" => \"o\", \"u\" => \"u\", \" \" => \" \");\n /*\n * create $binaryInterpretation\n * 1 - for vowels\n * 2 - for consonants\n * 3 - for space\n */\n \n $indexOfTypos = array();\n\t$indexOfAddSpace = array();\n $lastCharType = 0;\n $lastChar = 0;\n $consecutiveConsonants = 0;\n\t$consecutiveConsonantsArray = array();\n foreach ($stringAsArray as $k => $v) {\n $lastChar = $v;\n $code = 2;\n if (isset($vowels[$v])) {\n $code = 1;\n if($v==\" \"){\n $code = 3;\n }\n\t\t\t$consecutiveConsonants = 0;\n\t\t\t$consecutiveConsonantsArray = array();\n } else {\n\t\t\tif ($consecutiveConsonants==2) {\n\t\t\t\t\n\t\t\t\tif(count($consecutiveConsonantsArray) == 1) { \n\t\t\t\t\tif(!isset($consecutiveConsonantsArray[$v])){\n\t\t\t\t\t\t// add space\n\t\t\t\t\t\t$indexOfAddSpace[$k-1] = $k-1;\n\t\t\t\t\t\t$consecutiveConsonants = 0;\n\t\t\t\t\t\t$consecutiveConsonantsArray = array();\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$indexOfAddSpace[$k-1] = $k-1;\n\t\t\t\t\t$consecutiveConsonants = 0;\n\t\t\t\t\t$consecutiveConsonantsArray = array();\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t$consecutiveConsonantsArray[$v] = $v;\n $consecutiveConsonants++;\n }\n// $binaryInterpretation[$k] = $code;\n $lastCharType = $code;\n }\n \n\tif(!empty($indexOfAddSpace)) {\n\t\tforeach($stringAsArray as $fk => $fv) {\n\t\t\techo $fv . (isset($indexOfAddSpace[$fk])?\" \":\"\");\n\t\t}\n\t} else {\n\t\techo $inputString;\n }\n \n}\n\n?>"}, {"source_code": " 3000 || $inputStringLength < 1) {\n echo $answer;\n} else {\n $stringAsArray = str_split($inputString);\n $binaryInterpretation = array(); // do I need this at all?\n $vowels = array(\"a\" => \"a\", \"e\" => \"e\", \"i\" => \"i\", \"0\" => \"o\", \" \" => \" \");\n /*\n * create $binaryInterpretation\n * 1 - for vowels\n * 2 - for consonants\n * 3 - for space\n */\n \n $indexOfTypos = array();\n\t$indexOfAddSpace = array();\n $lastCharType = 0;\n $lastChar = 0;\n $consecutiveConsonants = 0;\n\t$consecutiveConsonantsArray = array();\n foreach ($stringAsArray as $k => $v) {\n $lastChar = $v;\n $code = 2;\n if (isset($vowels[$v])) {\n $code = 1;\n if($v==\" \"){\n $code = 3;\n }\n\t\t\t$consecutiveConsonants = 0;\n\t\t\t$consecutiveConsonantsArray = array();\n } else {\n\t\t\tif ($consecutiveConsonants==2) {\n\t\t\t\t\n\t\t\t\tif(count($consecutiveConsonantsArray) == 1) { \n\t\t\t\t\tif(!isset($consecutiveConsonantsArray[$v])){\n\t\t\t\t\t\t// add space\n\t\t\t\t\t\t$indexOfAddSpace[$k-1] = $k-1;\n\t\t\t\t\t\t$consecutiveConsonants = 0;\n\t\t\t\t\t\t$consecutiveConsonantsArray = array();\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t$indexOfAddSpace[$k-1] = $k-1;\n\t\t\t\t\t$consecutiveConsonants = 0;\n\t\t\t\t\t$consecutiveConsonantsArray = array();\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t$consecutiveConsonantsArray[$v] = $v;\n $consecutiveConsonants++;\n }\n $binaryInterpretation[$k] = $code;\n $lastCharType = $code;\n }\n \n\tif(!empty($indexOfAddSpace)) {\n\t\tforeach($stringAsArray as $fk => $fv) {\n\t\t\techo $fv . (isset($indexOfAddSpace[$fk])?\" \":\"\");\n\t\t}\n\t} else {\n\t\techo $inputString;\n }\n}\n\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] != $d2[1]) && ($d2[1] != $d2[2]))\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}, {"source_code": " 0, b => 1, c => 1, d => 1, e => 0, f => 1, g => 1, h => 1, i => 0, j => 1, k => 1, l => 1, m => 1, n => 1, o => 0, p => 1, q => 1, r => 1, s => 1, t => 1, u => 0, v => 1, w => 1, x => 1, y => 1, z => 1);\n$c = array();\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $d += $b[$a[$x]];\n $d2 .= $a[$x];\n if($b[$a[$x]] == 0)\n {\n $d = 0;\n }\n else\n {\n if($d == 3)\n {\n if(($d2[0] != $d2[1]) && ($d2[0] != $d2[2]))\n {\n $e = substr($a, 0, $x);\n $c[count($c)] = $e;\n $a = substr($a, $x);\n $d = 0;\n $x = -1;\n }\n }\n }\n}\nif(count($c) == 0)\n{\n print $a;\n}\nelseif($a == NULL)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print implode(\" \", $c) . \" \" . $a;\n}\n?>"}], "src_uid": "436c00c832de8df739fc391f2ed6dac4"} {"nl": {"description": "Alice and Bob play the following game. Alice has a set $$$S$$$ of disjoint ranges of integers, initially containing only one range $$$[1, n]$$$. In one turn, Alice picks a range $$$[l, r]$$$ from the set $$$S$$$ and asks Bob to pick a number in the range. Bob chooses a number $$$d$$$ ($$$l \\le d \\le r$$$). Then Alice removes $$$[l, r]$$$ from $$$S$$$ and puts into the set $$$S$$$ the range $$$[l, d - 1]$$$ (if $$$l \\le d - 1$$$) and the range $$$[d + 1, r]$$$ (if $$$d + 1 \\le r$$$). The game ends when the set $$$S$$$ is empty. We can show that the number of turns in each game is exactly $$$n$$$.After playing the game, Alice remembers all the ranges $$$[l, r]$$$ she picked from the set $$$S$$$, but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers $$$d$$$ from Alice's ranges, and so he asks you for help with your programming skill.Given the list of ranges that Alice has picked ($$$[l, r]$$$), for each range, help Bob find the number $$$d$$$ that Bob has picked.We can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 1000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 1000$$$). Each of the next $$$n$$$ lines contains two integers $$$l$$$ and $$$r$$$ ($$$1 \\le l \\le r \\le n$$$), denoting the range $$$[l, r]$$$ that Alice picked at some point. Note that the ranges are given in no particular order. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$, and the ranges for each test case are from a valid game.", "output_spec": "For each test case print $$$n$$$ lines. Each line should contain three integers $$$l$$$, $$$r$$$, and $$$d$$$, denoting that for Alice's range $$$[l, r]$$$ Bob picked the number $$$d$$$. You can print the lines in any order. We can show that the answer is unique. It is not required to print a new line after each test case. The new lines in the output of the example are for readability only. ", "sample_inputs": ["4\n1\n1 1\n3\n1 3\n2 3\n2 2\n6\n1 1\n3 5\n4 4\n3 6\n4 5\n1 6\n5\n1 5\n1 2\n4 5\n2 2\n4 4"], "sample_outputs": ["1 1 1\n\n1 3 1\n2 2 2\n2 3 3\n\n1 1 1\n3 5 3\n4 4 4\n3 6 6\n4 5 5\n1 6 2\n\n1 5 3\n1 2 1\n4 5 5\n2 2 2\n4 4 4"], "notes": "NoteIn the first test case, there is only 1 range $$$[1, 1]$$$. There was only one range $$$[1, 1]$$$ for Alice to pick, and there was only one number $$$1$$$ for Bob to pick.In the second test case, $$$n = 3$$$. Initially, the set contains only one range $$$[1, 3]$$$. Alice picked the range $$$[1, 3]$$$. Bob picked the number $$$1$$$. Then Alice put the range $$$[2, 3]$$$ back to the set, which after this turn is the only range in the set. Alice picked the range $$$[2, 3]$$$. Bob picked the number $$$3$$$. Then Alice put the range $$$[2, 2]$$$ back to the set. Alice picked the range $$$[2, 2]$$$. Bob picked the number $$$2$$$. The game ended. In the fourth test case, the game was played with $$$n = 5$$$. Initially, the set contains only one range $$$[1, 5]$$$. The game's turn is described in the following table. Game turnAlice's picked rangeBob's picked numberThe range set afterBefore the game start$$$ \\{ [1, 5] \\} $$$1$$$[1, 5]$$$$$$3$$$$$$ \\{ [1, 2], [4, 5] \\}$$$2$$$[1, 2]$$$$$$1$$$$$$ \\{ [2, 2], [4, 5] \\} $$$3$$$[4, 5]$$$$$$5$$$$$$ \\{ [2, 2], [4, 4] \\} $$$4$$$[2, 2]$$$$$$2$$$$$$ \\{ [4, 4] \\} $$$5$$$[4, 4]$$$$$$4$$$$$$ \\{ \\} $$$ (empty set) "}, "positive_code": [{"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $segments = [];\r\n\r\n for($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n $segments[] = [$l, $r];\r\n\r\n $ar[$l][$r] = 0;\r\n }\r\n\r\n foreach($segments as $segment)\r\n {\r\n $l = $segment[0];\r\n $r = $segment[1];\r\n\r\n if($l == $r)\r\n {\r\n echo $l.\" \".$r.\" \".$l.\"\\n\";\r\n continue;\r\n }\r\n\r\n for($d = $l; $d<=$r; $d++)\r\n {\r\n $saveD = true;\r\n\r\n if($d > $l && !isset($ar[$l][$d-1]))\r\n $saveD = false;\r\n\r\n if($d < $r && !isset($ar[$d+1][$r]))\r\n $saveD = false;\r\n\r\n if($saveD)\r\n {\r\n echo $l.\" \".$r.\" \".$d.\"\\n\";\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $segments = [];\r\n\r\n for($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n $segments[] = [$l, $r];\r\n\r\n $ar[$l][$r] = 0;\r\n }\r\n\r\n foreach($segments as $segment)\r\n {\r\n $l = $segment[0];\r\n $r = $segment[1];\r\n\r\n if($l == $r)\r\n {\r\n echo $l.\" \".$r.\" \".$l.\"\\n\";\r\n continue;\r\n }\r\n\r\n for($d = $l; $d<=$r; $d++)\r\n {\r\n $saveD = true;\r\n\r\n if($d > 1 && !isset($ar[$l][$d-1]))\r\n $saveD = false;\r\n\r\n if($d < $r && !isset($ar[$d+1][$r]))\r\n $saveD = false;\r\n\r\n if($saveD)\r\n {\r\n echo $l.\" \".$r.\" \".$d.\"\\n\";\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $segments = [];\r\n\r\n for($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n $segments[] = [$l, $r];\r\n\r\n $ar[$l][$r] = 0;\r\n }\r\n\r\n foreach($segments as $segment)\r\n {\r\n $l = $segment[0];\r\n $r = $segment[1];\r\n\r\n if($l == $r)\r\n {\r\n echo $l.\" \".$r.\" \".$l.\"\\n\";\r\n continue;\r\n }\r\n\r\n for($d = $l; $d<=$r; $d++)\r\n {\r\n $saveD = false;\r\n\r\n if($d > 1 && isset($ar[$l][$d-1]))\r\n $saveD = true;\r\n\r\n if($d < $r && isset($ar[$d+1][$r]))\r\n $saveD = true;\r\n\r\n if($saveD)\r\n {\r\n echo $l.\" \".$r.\" \".$d.\"\\n\";\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $onePoints = [];\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n $onePoints[] = $l;\r\n else\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[0] == $b[0] ? $a[1] > $b[1] : $a[0] > $b[0];\r\n });\r\n\r\n \r\n for($i = 1; $i <= $n; $i++)\r\n {\r\n if(in_array($i, $onePoints))\r\n echo $i.\" \".$i.\" \".$i.\"\\n\";\r\n else\r\n {\r\n $v = array_shift($ar);\r\n echo $v[0].\" \".$v[1].\" \".$i.\"\\n\";\r\n }\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $onePoints = [];\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n $onePoints[] = $l;\r\n\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[1] - $a[0] < $b[1] - $b[0];\r\n });\r\n\r\n //var_dump($ar);\r\n\r\n for($key = 0; $key < count($ar); $key++)\r\n {\r\n $item = $ar[$key];\r\n $next = $ar[$key + 1];\r\n\r\n if($next[0] == $next[1])\r\n {\r\n if(in_array($item[0], $onePoints) && in_array($item[1], $onePoints) && $item[0] != $item[1])\r\n $out[$item[0]+1] = $item;\r\n else if(in_array($item[0], $onePoints))\r\n {\r\n //var_dump($item);\r\n $out[$item[1]] = $item;\r\n }\r\n else if(in_array($item[1], $onePoints))\r\n $out[$item[0]] = $item;\r\n } else if($item[0] == $item[1])\r\n {\r\n $out[$item[0]] = $item;\r\n } \r\n else if(in_array($item[0], $onePoints))\r\n {\r\n if($item[0]+1 != $next[1])\r\n $out[$item[0]+1] = $item;\r\n else\r\n $out[$item[1]] = $item;\r\n\r\n }\r\n else if(in_array($item[1], $onePoints))\r\n {\r\n $out[$item[0]] = $item;\r\n }\r\n else if($item[0] == $next[0])\r\n {\r\n $out[$next[1] + 1] = $item;\r\n }\r\n else if($item[1] == $next[1])\r\n {\r\n $out[$next[0] - 1] = $item;\r\n }\r\n }\r\n\r\n //var_dump($ar);\r\n\r\n foreach ($out as $number => $v) {\r\n echo $v[0].\" \".$v[1].\" \".$number.\"\\n\";\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $onePoints = [];\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n $onePoints[] = $l;\r\n\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[1] - $a[0] < $b[1] - $b[0];\r\n });\r\n\r\n //var_dump($ar);\r\n\r\n for($key = 0; $key < count($ar); $key++)\r\n {\r\n $item = $ar[$key];\r\n $next = $ar[$key + 1];\r\n\r\n if($next[0] == $next[1])\r\n {\r\n if(in_array($item[0], $onePoints) && in_array($item[1], $onePoints) && $item[0] != $item[1])\r\n $out[$item[0]+1] = $item;\r\n else if(in_array($item[0], $onePoints))\r\n $out[$item[1]] = $item;\r\n else if(in_array($item[1], $onePoints))\r\n $out[$item[0]] = $item;\r\n } else if($item[0] == $item[1])\r\n {\r\n $out[$item[0]] = $item;\r\n } \r\n else if(in_array($item[0], $onePoints))\r\n {\r\n $out[$item[0]+1] = $item;\r\n }\r\n else if(in_array($item[1], $onePoints))\r\n {\r\n $out[$item[0]] = $item;\r\n }\r\n else if($item[0] == $next[0])\r\n {\r\n $out[$next[1] + 1] = $item;\r\n }\r\n else if($item[1] == $next[1])\r\n {\r\n $out[$next[0] - 1] = $item;\r\n }\r\n }\r\n\r\n foreach ($out as $number => $v) {\r\n echo $v[0].\" \".$v[1].\" \".$number.\"\\n\";\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $onePoints = [];\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n $onePoints[] = $l;\r\n\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[1] - $a[0] < $b[1] - $b[0];\r\n });\r\n\r\n for($key = 0; $key < count($ar); $key++)\r\n {\r\n $item = $ar[$key];\r\n $next = $ar[$key + 1];\r\n\r\n if($next[0] == $next[1])\r\n {\r\n if(in_array($item[0], $onePoints))\r\n $out[$item[1]] = $item;\r\n else if(in_array($item[1], $onePoints))\r\n $out[$item[0]] = $item;\r\n } else if($item[0] == $item[1])\r\n {\r\n $out[$item[0]] = $item;\r\n } \r\n else if(in_array($item[0], $onePoints))\r\n {\r\n $out[$item[0]+1] = $item;\r\n }\r\n else if(in_array($item[1], $onePoints))\r\n {\r\n $out[$item[0]] = $item;\r\n }\r\n else if($item[0] == $next[0])\r\n {\r\n $out[$next[1] + 1] = $item;\r\n }\r\n else if($item[1] == $next[1])\r\n {\r\n $out[$next[0] - 1] = $item;\r\n }\r\n }\r\n\r\n foreach ($out as $number => $v) {\r\n echo $v[0].\" \".$v[1].\" \".$number.\"\\n\";\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $onePoints = [];\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n $onePoints[] = $l;\r\n\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[1] - $a[0] < $b[1] - $b[0];\r\n });\r\n\r\n for($key = 0; $key < count($ar); $key++)\r\n {\r\n $item = $ar[$key];\r\n $next = $ar[$key + 1];\r\n\r\n if($item[0] == $item[1])\r\n {\r\n $out[$item[0]] = $item;\r\n } \r\n else if(in_array($item[0], $onePoints))\r\n {\r\n $out[$item[0]+1] = $item;\r\n }\r\n else if(in_array($item[1], $onePoints))\r\n {\r\n $out[$item[0]] = $item;\r\n }\r\n else if($item[0] == $next[0])\r\n {\r\n $out[$next[1] + 1] = $item;\r\n }\r\n else if($item[1] == $next[1])\r\n {\r\n $out[$next[0] - 1] = $item;\r\n }\r\n }\r\n\r\n foreach ($out as $number => $v) {\r\n echo $v[0].\" \".$v[1].\" \".$number.\"\\n\";\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}, {"source_code": "\r\n//$file = fopen(\"input.txt\", 'r');\r\n$file = fopen(\"php://stdin\", 'r');\r\n\r\n$t = trim(fgets($file));\r\n\r\nfor($j = 0; $j < $t; $j++)\r\n{\r\n $n = trim(fgets($file));\r\n $ar = [];\r\n $out = [];\r\n $last = false;\r\n\r\n for ($i=0; $i < $n; $i++)\r\n {\r\n list($l, $r) = explode(\" \", trim(fgets($file)));\r\n\r\n if($l == $r)\r\n {\r\n $out[$l] = [$l, $r];\r\n $last = $l;\r\n }\r\n else\r\n $ar[] = [$l, $r];\r\n }\r\n\r\n usort($ar, function($a, $b){\r\n return $a[1] - $a[0] < $b[1] - $b[0];\r\n });\r\n\r\n\r\n foreach($ar as $key => $v)\r\n {\r\n $next = $ar[$key + 1];\r\n\r\n if(empty($next))\r\n {\r\n $next = [$last, $last]; \r\n }\r\n\r\n if(isset($out[$v[0]]))\r\n {\r\n $out[$v[0]+1] = $v;\r\n }else if($v[0] != $next[0])\r\n $out[$next[0]-1] = $v;\r\n else if($v[1] != $next[1])\r\n $out[$v[1]] = $v;\r\n\r\n }\r\n\r\n \r\n foreach ($out as $number => $v) {\r\n echo $v[0].\" \".$v[1].\" \".$number.\"\\n\";\r\n }\r\n\r\n //echo \"\\n\";\r\n}\r\n\r\n?>"}], "src_uid": "eca433877ef3fbda198c5f2c95a359e7"} {"nl": {"description": "Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.Your house has $$$n$$$ rooms. In the $$$i$$$-th room you can install at most $$$c_i$$$ heating radiators. Each radiator can have several sections, but the cost of the radiator with $$$k$$$ sections is equal to $$$k^2$$$ burles.Since rooms can have different sizes, you calculated that you need at least $$$sum_i$$$ sections in total in the $$$i$$$-th room. For each room calculate the minimum cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.", "input_spec": "The first line contains single integer $$$n$$$ ($$$1 \\le n \\le 1000$$$) \u2014 the number of rooms. Each of the next $$$n$$$ lines contains the description of some room. The $$$i$$$-th line contains two integers $$$c_i$$$ and $$$sum_i$$$ ($$$1 \\le c_i, sum_i \\le 10^4$$$) \u2014 the maximum number of radiators and the minimum total number of sections in the $$$i$$$-th room, respectively.", "output_spec": "For each room print one integer \u2014 the minimum possible cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.", "sample_inputs": ["4\n1 10000\n10000 1\n2 6\n4 6"], "sample_outputs": ["100000000\n1\n18\n10"], "notes": "NoteIn the first room, you can install only one radiator, so it's optimal to use the radiator with $$$sum_1$$$ sections. The cost of the radiator is equal to $$$(10^4)^2 = 10^8$$$.In the second room, you can install up to $$$10^4$$$ radiators, but since you need only one section in total, it's optimal to buy one radiator with one section.In the third room, there $$$7$$$ variants to install radiators: $$$[6, 0]$$$, $$$[5, 1]$$$, $$$[4, 2]$$$, $$$[3, 3]$$$, $$$[2, 4]$$$, $$$[1, 5]$$$, $$$[0, 6]$$$. The optimal variant is $$$[3, 3]$$$ and it costs $$$3^2+ 3^2 = 18$$$."}, "positive_code": [{"source_code": ""}, {"source_code": "=(int)$v[1]) {echo (int)$v[1];}\n else{\n $r_1=floor($v[1]/$v[0]);\n $r_2=($v[1]%$v[0]);\n \n for($j=0; $j<$v[0]; $j++){\n if($j<$r_2){\n $sum+=(($r_1+1)**2);\n } else{\n $sum+=$r_1**2;\n }\n } echo $sum;\n }\n if($i!=$arr[0]) echo\"\\n\";\n \n}\n?>"}, {"source_code": "= $q[1]){\n echo $q[1].\"\\n\"; \n } else {\n $n = $q[1] - $q[0];\n $p = floor($q[1] / $q[0]);\n $l = $q[1] % $q[0];\n $r = array();\n for($j = 0; $j < $q[0]; $j++){\n $r[$j] = $p;\n if($j < $l){\n $r[$j]++;\n }\n }\n $x = 0;\n foreach($r as $sK => $sV){\n $x += $sV * $sV;\n }\n echo $x.\"\\n\";\n }\n \n}"}, {"source_code": ""}], "negative_code": [{"source_code": "\ufeff=$v[1]) {echo (int)$v[1];}\n else{\n $r_1=floor($v[1]/$v[0]);\n $r_2=($v[1]%$v[0]);\n \n for($j=0; $j<$v[0]; $j++){\n if($j<$r_2){\n $sum+=(($r_1+1)**2);\n } else{\n $sum+=$r_1**2;\n }\n } echo $sum;\n }\n if($i!=$arr[0]) echo\"\\n\";\n \n}\n?>"}, {"source_code": "= $q[1]){\n echo $q[0].\"\\n\"; \n } else {\n $n = $q[1] - $q[0];\n $p = floor($q[1] / $q[0]);\n $l = $q[1] % $q[0];\n $r = array();\n for($j = 0; $j < $q[0]; $j++){\n $r[$j] = $p;\n if($j < $l){\n $r[$j]++;\n }\n }\n $x = 0;\n foreach($r as $sK => $sV){\n $x += $sV * $sV;\n }\n echo $x.\"\\n\";\n }\n \n}"}], "src_uid": "0ec973bf4ad209de9731818c75469541"} {"nl": {"description": "Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.First of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe.", "input_spec": "In first line there is one integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105)\u00a0\u2014 number of cafes indices written by Vlad. In second line, n numbers a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u20092\u00b7105) are written\u00a0\u2014 indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted.", "output_spec": "Print one integer\u00a0\u2014 index of the cafe that Vlad hasn't visited for as long as possible.", "sample_inputs": ["5\n1 3 2 1 2", "6\n2 1 2 2 4 1"], "sample_outputs": ["3", "2"], "notes": "NoteIn first test, there are three cafes, and the last visits to cafes with indices 1 and 2 were after the last visit to cafe with index 3; so this cafe is the answer. In second test case, there are also three cafes, but with indices 1, 2 and 4. Cafes with indices 1 and 4 were visited after the last visit of cafe with index 2, so the answer is 2. Note that Vlad could omit some numbers while numerating the cafes."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n if($d[$b[$x]] == 0)\n {\n $d[$b[$x]] = 1;\n $e -= 1;\n if($e == 1)\n {\n break;\n }\n }\n}\nasort($d);\n$f = array_keys($d);\nprint $f[0];\n?>"}], "negative_code": [], "src_uid": "bdea209c7b628e4cc90ebc2572826485"} {"nl": {"description": "Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $$$(0,0)$$$ to $$$(x,0)$$$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its $$$n$$$ favorite numbers: $$$a_1, a_2, \\ldots, a_n$$$. What is the minimum number of hops Rabbit needs to get from $$$(0,0)$$$ to $$$(x,0)$$$? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination.Recall that the Euclidean distance between points $$$(x_i, y_i)$$$ and $$$(x_j, y_j)$$$ is $$$\\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}$$$.For example, if Rabbit has favorite numbers $$$1$$$ and $$$3$$$ he could hop from $$$(0,0)$$$ to $$$(4,0)$$$ in two hops as shown below. Note that there also exists other valid ways to hop to $$$(4,0)$$$ in $$$2$$$ hops (e.g. $$$(0,0)$$$ $$$\\rightarrow$$$ $$$(2,-\\sqrt{5})$$$ $$$\\rightarrow$$$ $$$(4,0)$$$). Here is a graphic for the first example. Both hops have distance $$$3$$$, one of Rabbit's favorite numbers. In other words, each time Rabbit chooses some number $$$a_i$$$ and hops with distance equal to $$$a_i$$$ in any direction he wants. The same number can be used multiple times.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u00a0\u2014 the number of test cases. Next $$$2t$$$ lines contain test cases \u2014 two lines per test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\le n \\le 10^5$$$, $$$1 \\le x \\le 10^9$$$) \u00a0\u2014 the number of favorite numbers and the distance Rabbit wants to travel, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u00a0\u2014 Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all the test cases will not exceed $$$10^5$$$.", "output_spec": "For each test case, print a single integer\u00a0\u2014 the minimum number of hops needed.", "sample_inputs": ["4\n\n2 4\n\n1 3\n\n3 12\n\n3 4 5\n\n1 5\n\n5\n\n2 10\n\n15 4"], "sample_outputs": ["2\n3\n1\n2"], "notes": "NoteThe first test case of the sample is shown in the picture above. Rabbit can hop to $$$(2,\\sqrt{5})$$$, then to $$$(4,0)$$$ for a total of two hops. Each hop has a distance of $$$3$$$, which is one of his favorite numbers.In the second test case of the sample, one way for Rabbit to hop $$$3$$$ times is: $$$(0,0)$$$ $$$\\rightarrow$$$ $$$(4,0)$$$ $$$\\rightarrow$$$ $$$(8,0)$$$ $$$\\rightarrow$$$ $$$(12,0)$$$.In the third test case of the sample, Rabbit can hop from $$$(0,0)$$$ to $$$(5,0)$$$.In the fourth test case of the sample, Rabbit can hop: $$$(0,0)$$$ $$$\\rightarrow$$$ $$$(5,10\\sqrt{2})$$$ $$$\\rightarrow$$$ $$$(10,0)$$$."}, "positive_code": [{"source_code": "= $c)\n {\n $e[count($e)] = 2;\n break;\n }\n }\n if(floor($c / $d[0]) > 0)\n {\n $e[count($e)] = floor($c / $d[0]) + 1;\n }\n print min($e) . \"\\n\";\n}\n?>"}, {"source_code": " $sV) {\n $aTest[] = $sV;\n }\n foreach ($aTest as $sK => $sV) {\n if ($sV == $b) {\n $iAnswer = 1;\n $bFlag = true;\n break;\n }\n }\n if (!$bFlag) {\n $iAnswer = max($aTest);\n if ($b < $iAnswer) {\n $iAnswer = 2;\n $bFlag = true;\n }\n }\n if ($bFlag) {\n echo $iAnswer .\"\\n\";\n } else {\n echo ceil($b/$iAnswer) .\"\\n\";\n }\n}"}, {"source_code": "= $c)\n {\n $e[count($e)] = 2;\n break;\n }\n }\n print min($e) . \"\\n\";\n}\n?>"}, {"source_code": " $sV) {\n $aTest[] = $sV;\n }\n foreach ($aTest as $sK => $sV) {\n if ($sK == $b) {\n $iAnswer = 1;\n $bFlag = true;\n break;\n }\n }\n $iAnswer = max($aTest);\n if ($b < $iAnswer) {\n $iAnswer = 2;\n $bFlag = true;\n }\n if ($bFlag) {\n echo $iAnswer .\"\\n\";\n } else {\n echo ceil($b/$iAnswer) .\"\\n\";\n }\n}"}, {"source_code": " $x) {\n if($j == 0 ){\n $j++;\n }\n $n = $j+1;\n break;\n }\n if($ar[$j] > $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n if($s < $max) {\n $n = $n + 2;\n }elseif($s == $max) {\n $n = $n + 1;\n } else {\n $n1 = ceil($s / $max);\n $n = $n + $n1;\n }\n echo $n .\"\\n\";\n \n } \n \n }\n \n\n "}, {"source_code": " $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n \n $n1 =ceil($s / $max);\n echo $n + $n1.\"\\n\";\n } \n \n }\n \n\n "}, {"source_code": " $x) {\n if($j == 0 ){\n $j++;\n }\n $n = $j+1;\n break;\n }\n if($ar[$j] > $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n if($s < $max) {\n $n = $n + 2;\n }elseif($s == $max) {\n $n = $n + 1;\n } else {\n $n1 = ceil($s / $max);\n $n = $n + $n1;\n }\n echo $n .\"\\n\";\n \n } \n }\n \n \n }\n \n\n "}, {"source_code": "= $x) {\n $n = $j+1;\n break;\n }\n if($ar[$j] > $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n if($s < $max) {\n $n = $n + 2;\n }elseif($s == $max) {\n $n = $n + 1;\n } else {\n $n1 = ceil($s / $max);\n $n = $n + $n1;\n }\n echo $n .\"\\n\";\n \n } \n \n }\n \n\n "}, {"source_code": " $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n \n $n1 =ceil($s / $max);\n echo $n + $n1.\"\\n\";\n } \n \n }\n \n\n "}, {"source_code": " $max) {\n $max = $ar[$j];\n }\n }\n \n if($count >= $x) {\n echo $n.\"\\n\";\n } else {\n $s = $x - $count;\n if($s < $max) {\n $n = $n + 2;\n }elseif($s == $max) {\n $n = $n + 1;\n } else {\n $n1 = ceil($s / $max);\n $n = $n + $n1;\n }\n echo $n .\"\\n\";\n \n } \n \n }\n \n\n "}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $m + 1) {\n\techo \"Impossible\";\n} else {\n\t$extra = $m - ($n - 1);\n\t// echo \"extra:{$extra}\\n\";\n\n\tif ($n >= 600 || $sum[$n] >= $extra) {\n\t\techo \"Possible\\n\";\n\t\tfor ($i = 1; $i < $n; $i++) {\n\t\t\tprintf(\"%d %d\\n\", $i, $i + 1);\n\t\t}\n\t\tfor ($i = 0; $i < $extra; $i++) {\n\t\t\tprintf(\"%d %d\\n\", $v[$i], $u[$i]);\n\t\t}\n\t} else {\n\t\techo \"Impossible\";\n\t}\n}\n\nfunction __gcd($a, $b) {\n\tif ($a == 0 || $b == 0) {\n\t\treturn abs(max(abs($a), abs($b)));\n\t}\n\n\t$r = $a % $b;\n\treturn ($r != 0) ? __gcd($b, $r) : abs($b);\n}"}], "negative_code": [{"source_code": "= 600 || $sum[$n] >= $m) {\n\tfor ($i = 0; $i < $m; $i++) {\n\t\tif ($i != 0) {\n\t\t\techo \"\\n\";\n\t\t}\n\n\t\tprintf(\"%d %d\", $v[$i], $u[$i]);\n\t}\n} else {\n\techo \"Impossible\";\n}\n\nfunction __gcd($a, $b) {\n\tif ($a == 0 || $b == 0) {\n\t\treturn abs(max(abs($a), abs($b)));\n\t}\n\n\t$r = $a % $b;\n\treturn ($r != 0) ? __gcd($b, $r) : abs($b);\n}"}, {"source_code": "= 600 || $sum[$n] >= $m) {\n\techo \"Possible\\n\";\n\tfor ($i = 0; $i < $m; $i++) {\n\t\tif ($i != 0) {\n\t\t\techo \"\\n\";\n\t\t}\n\n\t\tprintf(\"%d %d\\n\", $v[$i], $u[$i]);\n\t}\n} else {\n\techo \"Impossible\";\n}\n\nfunction __gcd($a, $b) {\n\tif ($a == 0 || $b == 0) {\n\t\treturn abs(max(abs($a), abs($b)));\n\t}\n\n\t$r = $a % $b;\n\treturn ($r != 0) ? __gcd($b, $r) : abs($b);\n}"}, {"source_code": "= 600 || $sum[$n] >= $m) {\n\tfor ($i = 0; $i < $m; $i++) {\n\t\tprintf(\"%d %d\\n\", $v[$i], $u[$i]);\n\t}\n} else {\n\techo \"Impossible\";\n}\n\nfunction __gcd($a, $b) {\n\tif ($a == 0 || $b == 0) {\n\t\treturn abs(max(abs($a), abs($b)));\n\t}\n\n\t$r = $a % $b;\n\treturn ($r != 0) ? __gcd($b, $r) : abs($b);\n}"}], "src_uid": "0ab1b97a8d2e0290cda31a3918ff86a4"} {"nl": {"description": "Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote m wrong solutions and for each wrong solution he knows its running time (in seconds).Let's suppose that Valera will set v seconds TL in the problem. Then we can say that a solution passes the system testing if its running time is at most v seconds. We can also say that a solution passes the system testing with some \"extra\" time if for its running time, a seconds, an inequality 2a\u2009\u2264\u2009v holds.As a result, Valera decided to set v seconds TL, that the following conditions are met: v is a positive integer; all correct solutions pass the system testing; at least one correct solution passes the system testing with some \"extra\" time; all wrong solutions do not pass the system testing; value v is minimum among all TLs, for which points 1, 2, 3, 4 hold. Help Valera and find the most suitable TL or else state that such TL doesn't exist.", "input_spec": "The first line contains two integers n, m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). The second line contains n space-separated positive integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009100) \u2014 the running time of each of the n correct solutions in seconds. The third line contains m space-separated positive integers b1,\u2009b2,\u2009...,\u2009bm (1\u2009\u2264\u2009bi\u2009\u2264\u2009100) \u2014 the running time of each of m wrong solutions in seconds. ", "output_spec": "If there is a valid TL value, print it. Otherwise, print -1.", "sample_inputs": ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6"], "sample_outputs": ["5", "-1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $max) {\n\t\t$max = $n[$i];\n\t}\n}\nif ($max < $min*2) $max = $min*2;\nforeach ($m as $value) {\n\tif ($value + 0 <= $max) {\n\t\tfwrite($f2, '-1');\n\t\tfclose($f2);\n\t\tdie;\t\n\t}\n}\nfwrite($f2, $max);\nfclose($f2);"}, {"source_code": " 2*$p0){\n\t\tif ($p1 < $p2){\n\t\t\techo $p1;\n\t\t} else {\n\t\t\techo \"-1\";\n\t\t}\n\t} else {\n\t\techo (2*$p0);\n\t}\n} else {\n\techo \"-1\";\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 2*$p0){\n\t\techo $p1;\n\t} else {\n\t\techo (2*$p0);\n\t}\n} else {\n\techo \"-1\";\n}\n\n?>"}, {"source_code": " 2*$p0){\n\t\tif ($p1 < $p2){\n\t\t\techo $p1;\n\t\t} else {\n\t\t\techo \"-1\";\n\t\t}\n\t} else {\n\t\techo (2*$p0);\n\t}\n} else {\n\techo \"-1\";\n}\n\n?>"}], "src_uid": "49c47ebfd710a3733ce7ecb3a3c134a7"} {"nl": {"description": "One warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize \u2014 big pink plush panda. The king is not good at shooting, so he invited you to help him.The shooting gallery is an infinite vertical plane with Cartesian coordinate system on it. The targets are points on this plane. Each target is described by it's coordinates xi, and yi, by the time of it's appearance ti and by the number pi, which gives the probability that Copa hits this target if he aims at it.A target appears and disappears instantly, so Copa can hit the target only if at the moment ti his gun sight aimed at (xi,\u2009yi). Speed of movement of the gun sight on the plane is equal to 1. Copa knows all the information about the targets beforehand (remember, he is a king!). He wants to play in the optimal way, which maximizes the expected value of the amount of hit targets. He can aim at any target at the moment 0.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 amount of targets in the shooting gallery. Then n lines follow, each describing one target. Each description consists of four numbers xi, yi, ti, pi (where xi, yi, ti \u2014 integers, \u2009-\u20091000\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u20091000,\u20090\u2009\u2264\u2009ti\u2009\u2264\u2009109, real number pi is given with no more than 6 digits after the decimal point, 0\u2009\u2264\u2009pi\u2009\u2264\u20091). No two targets may be at the same point.", "output_spec": "Output the maximum expected value of the amount of targets that was shot by the king. Your answer will be accepted if it differs from the correct answer by not more than 10\u2009-\u20096.", "sample_inputs": ["1\n0 0 0 0.5", "2\n0 0 0 0.6\n5 0 5 0.7"], "sample_outputs": ["0.5000000000", "1.3000000000"], "notes": null}, "positive_code": [{"source_code": " 0 ) {\n return array_shift($buffer);\n }\n $line = preg_replace('/[\\\\r\\\\n]+$/', '', getLine());\n $buffer = preg_split('/\\\\s+/', $line);\n return getNext();\n}\n\nfunction getLine() {\n global $input;\n return fgets($input, 4096);\n}\n\nfunction init() {\n global $input;\n $input = fopen(\"php://stdin\", \"r\");\n}\n\nfunction main() {\n\n $n = intval(getNext());\n $keys = Array();\n for( $i = 0; $i < $n; ++$i ) {\n $keys[] = Array(floatval(getNext()), floatval(getNext()), floatval(getNext()), floatval(getNext()));\n }\n\n for( $i = 0; $i < $n; ++$i ) {\n for( $j = $i + 1; $j < $n; ++$j ) {\n if( $keys[$i][2] > $keys[$j][2] ) {\n $tmp = $keys[$i];\n $keys[$i] = $keys[$j];\n $keys[$j] = $tmp;\n }\n }\n }\n\n $ret = 0.0;\n $dp = Array();\n for( $i = 0; $i < $n; ++$i ) {\n $max = $keys[$i][3];\n for( $j = 0; $j < $i; ++$j ) {\n $d = dist(($keys[$i][0] - $keys[$j][0]), ($keys[$i][1] - $keys[$j][1]));\n $t = $keys[$i][2] - $keys[$j][2];\n if( $d <= $t ) {\n $max = max($max, $dp[$j] + $keys[$i][3]);\n }\n }\n $dp[] = $max;\n $ret = max($ret, $max);\n }\n\n print $ret . \"\\n\";\n\n}\n\nfunction dist($x, $y) {\n return sqrt($x * $x + $y * $y);\n}\n\nmain();\n\n?>\n"}], "negative_code": [], "src_uid": "1df8aad60e5dff95bffb9adee5f8c460"} {"nl": {"description": "Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.The area looks like a strip of cells 1\u2009\u00d7\u2009n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Grasshopper stops immediately if it jumps out of the strip. Now Artem wants to find out if this will ever happen.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 length of the strip. Next line contains a string of length n which consists of characters \"<\" and \">\" only, that provide the direction of the jump from the corresponding cell. Next line contains n integers di (1\u2009\u2264\u2009di\u2009\u2264\u2009109)\u00a0\u2014 the length of the jump from the i-th cell.", "output_spec": "Print \"INFINITE\" (without quotes) if grasshopper will continue his jumps forever. Otherwise print \"FINITE\" (without quotes).", "sample_inputs": ["2\n><\n1 2", "3\n>><\n2 1 1"], "sample_outputs": ["FINITE", "INFINITE"], "notes": "NoteIn the first sample grasshopper starts from the first cell and jumps to the right on the next cell. When he is in the second cell he needs to jump two cells left so he will jump out of the strip.Second sample grasshopper path is 1 - 3 - 2 - 3 - 2 - 3 and so on. The path is infinite."}, "positive_code": [{"source_code": " 1);\n$e = 1;\n$f = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n if($b[$e] == \">\")\n {\n $e += $c[$e];\n $d[$e]++;\n if($d[$e] > 1)\n {\n $f = 1;\n break;\n }\n elseif(($e < 1) || ($e > $a))\n {\n $f = 2;\n break;\n }\n }\n else\n {\n $e -= $c[$e];\n $d[$e]++;\n if($d[$e] > 1)\n {\n $f = 1;\n break;\n }\n elseif(($e < 1) || ($e > $a))\n {\n $f = 2;\n break;\n }\n }\n}\nif(($f == 0) || ($f == 1))\n{\n print \"INFINITE\";\n}\nelseif($f == 2)\n{\n print \"FINITE\";\n}\n?>"}], "negative_code": [], "src_uid": "5fcc22cdc38693723d8a9577d685db12"} {"nl": {"description": "Initially, you have the array $$$a$$$ consisting of one element $$$1$$$ ($$$a = [1]$$$).In one move, you can do one of the following things: Increase some (single) element of $$$a$$$ by $$$1$$$ (choose some $$$i$$$ from $$$1$$$ to the current length of $$$a$$$ and increase $$$a_i$$$ by one); Append the copy of some (single) element of $$$a$$$ to the end of the array (choose some $$$i$$$ from $$$1$$$ to the current length of $$$a$$$ and append $$$a_i$$$ to the end of the array). For example, consider the sequence of five moves: You take the first element $$$a_1$$$, append its copy to the end of the array and get $$$a = [1, 1]$$$. You take the first element $$$a_1$$$, increase it by $$$1$$$ and get $$$a = [2, 1]$$$. You take the second element $$$a_2$$$, append its copy to the end of the array and get $$$a = [2, 1, 1]$$$. You take the first element $$$a_1$$$, append its copy to the end of the array and get $$$a = [2, 1, 1, 2]$$$. You take the fourth element $$$a_4$$$, increase it by $$$1$$$ and get $$$a = [2, 1, 1, 3]$$$. Your task is to find the minimum number of moves required to obtain the array with the sum at least $$$n$$$.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$) \u2014 the lower bound on the sum of the array.", "output_spec": "For each test case, print the answer: the minimum number of moves required to obtain the array with the sum at least $$$n$$$.", "sample_inputs": ["5\n1\n5\n42\n1337\n1000000000"], "sample_outputs": ["0\n3\n11\n72\n63244"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "d78cd4a06fb566d58275e92f976166f2"} {"nl": {"description": "There are $$$n$$$ candies put from left to right on a table. The candies are numbered from left to right. The $$$i$$$-th candy has weight $$$w_i$$$. Alice and Bob eat candies. Alice can eat any number of candies from the left (she can't skip candies, she eats them in a row). Bob can eat any number of candies from the right (he can't skip candies, he eats them in a row). Of course, if Alice ate a candy, Bob can't eat it (and vice versa).They want to be fair. Their goal is to eat the same total weight of candies. What is the most number of candies they can eat in total?", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot10^5$$$)\u00a0\u2014 the number of candies on the table. The second line of each test case contains $$$n$$$ integers $$$w_1, w_2, \\dots, w_n$$$ ($$$1 \\leq w_i \\leq 10^4$$$)\u00a0\u2014 the weights of candies from left to right. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each test case, print a single integer\u00a0\u2014 the maximum number of candies Alice and Bob can eat in total while satisfying the condition.", "sample_inputs": ["4\n3\n10 20 10\n6\n2 1 4 2 4 1\n5\n1 2 4 8 16\n9\n7 3 20 5 15 1 11 8 10"], "sample_outputs": ["2\n6\n0\n7"], "notes": "NoteFor the first test case, Alice will eat one candy from the left and Bob will eat one candy from the right. There is no better way for them to eat the same total amount of weight. The answer is $$$2$$$ because they eat two candies in total.For the second test case, Alice will eat the first three candies from the left (with total weight $$$7$$$) and Bob will eat the first three candies from the right (with total weight $$$7$$$). They cannot eat more candies since all the candies have been eaten, so the answer is $$$6$$$ (because they eat six candies in total).For the third test case, there is no way Alice and Bob will eat the same non-zero weight so the answer is $$$0$$$.For the fourth test case, Alice will eat candies with weights $$$[7, 3, 20]$$$ and Bob will eat candies with weights $$$[10, 8, 11, 1]$$$, they each eat $$$30$$$ weight. There is no better partition so the answer is $$$7$$$."}, "positive_code": [{"source_code": " $g)\r\n {\r\n $g += $c[$e];\r\n $e++;\r\n $i++;\r\n }\r\n }\r\n if($h == $g)\r\n {\r\n if(($i != 0) || ($j != 0))\r\n {\r\n $d += $i;\r\n $d += $j;\r\n }\r\n }\r\n if($d == 1)\r\n {\r\n print \"0\\n\";\r\n }\r\n else\r\n {\r\n print $d . \"\\n\";\r\n }\r\n}\r\n?>"}], "negative_code": [], "src_uid": "90e448ed43ba9a0533ac7dc24f92a7f8"} {"nl": {"description": "Today there is going to be an unusual performance at the circus \u2014 hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tigers also stood together. The trainer swaps the animals in pairs not to create a mess. He orders two animals to step out of the circle and swap places. As hamsters feel highly uncomfortable when tigers are nearby as well as tigers get nervous when there's so much potential prey around (consisting not only of hamsters but also of yummier spectators), the trainer wants to spend as little time as possible moving the animals, i.e. he wants to achieve it with the minimal number of swaps. Your task is to help him.", "input_spec": "The first line contains number n (2\u2009\u2264\u2009n\u2009\u2264\u20091000) which indicates the total number of animals in the arena. The second line contains the description of the animals' positions. The line consists of n symbols \"H\" and \"T\". The \"H\"s correspond to hamsters and the \"T\"s correspond to tigers. It is guaranteed that at least one hamster and one tiger are present on the arena. The animals are given in the order in which they are located circle-wise, in addition, the last animal stands near the first one.", "output_spec": "Print the single number which is the minimal number of swaps that let the trainer to achieve his goal.", "sample_inputs": ["3\nHTH", "9\nHTHTHTHHT"], "sample_outputs": ["0", "2"], "notes": "NoteIn the first example we shouldn't move anybody because the animals of each species already stand apart from the other species. In the second example you may swap, for example, the tiger in position 2 with the hamster in position 5 and then \u2014 the tiger in position 9 with the hamster in position 7."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $f)\n{\n for($x = 0; $x < count($d); $x++)\n {\n $l = 0;\n $h = array();\n for($y = 0; $y < count($d); $y++)\n {\n $j = $d[$x] + $l;\n array_push($h, $j);\n $l++;\n } \n array_push($i, $h); \n }\n for($x = 0; $x < count($i); $x++)\n {\n $m = 0;\n for($y = 0; $y < count($i); $y++)\n {\n for($z = 0; $z < count($d); $z++)\n {\n if($i[$x][$y] == $d[$z])\n {\n $m++;\n }\n }\n }\n array_push($n, $m);\n }\n rsort($n);\n print count($d) - $n[0];\n}\n?>"}], "src_uid": "0fce263a9606fbfc3ec912894ab1a8f8"} {"nl": {"description": "To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed \"The Art of the Covfefe\".She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.Karen thinks that a temperature is admissible if at least k recipes recommend it.Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?", "input_spec": "The first line of input contains three integers, n, k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u2009200000), and q (1\u2009\u2264\u2009q\u2009\u2264\u2009200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively. The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive. The next q lines describe the questions. Each of these lines contains a and b, (1\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u2009200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.", "output_spec": "For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.", "sample_inputs": ["3 2 4\n91 94\n92 97\n97 99\n92 94\n93 97\n95 96\n90 100", "2 1 1\n1 1\n200000 200000\n90 100"], "sample_outputs": ["3\n3\n0\n4", "0"], "notes": "NoteIn the first test case, Karen knows 3 recipes. The first one recommends brewing the coffee between 91 and 94 degrees, inclusive. The second one recommends brewing the coffee between 92 and 97 degrees, inclusive. The third one recommends brewing the coffee between 97 and 99 degrees, inclusive. A temperature is admissible if at least 2 recipes recommend it.She asks 4 questions.In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.In the second test case, Karen knows 2 recipes. The first one, \"wikiHow to make Cold Brew Coffee\", recommends brewing the coffee at exactly 1 degree. The second one, \"What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?\", recommends brewing the coffee at exactly 200000 degrees. A temperature is admissible if at least 1 recipe recommends it.In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none."}, "positive_code": [{"source_code": "= $b)\n {\n $k++;\n }\n $j[$x] = $k;\n}\n$l = 0;\nfor($x = 1; $x <= $c; $x++)\n{\n list($m, $n) = explode(\" \", trim(fgets(STDIN)));\n $o = $j[$n] - $j[$m - 1];\n print $o . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": "= $b)\n {\n $k++;\n }\n $j[$x] = $k;\n}\n$l = 0;\nfor($x = 1; $x <= $c; $x++)\n{\n list($m, $n) = explode(\" \", trim(fgets(STDIN)));\n if($j[$m] == $j[$n])\n {\n print \"0\\n\";\n }\n elseif($j[$m] == 0)\n {\n $o = $j[$n] - $j[$m];\n print $o . \"\\n\";\n }\n else\n {\n $o = $j[$n] - $j[$m] + 1;\n print $o . \"\\n\";\n }\n}\n?>"}], "src_uid": "4bdf819b73ffb708ad571accf3b8c23d"} {"nl": {"description": "Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately. Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe. Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105), that is the number of cafe visitors. Each of the following n lines has two space-separated integers hi and mi (0\u2009\u2264\u2009hi\u2009\u2264\u200923;\u00a00\u2009\u2264\u2009mi\u2009\u2264\u200959), representing the time when the i-th person comes into the cafe. Note that the time is given in the chronological order. All time is given within one 24-hour period.", "output_spec": "Print a single integer \u2014 the minimum number of cashes, needed to serve all clients next day.", "sample_inputs": ["4\n8 0\n8 10\n8 10\n8 45", "3\n0 12\n10 11\n22 22"], "sample_outputs": ["2", "1"], "notes": "NoteIn the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away.In the second sample all visitors will come in different times, so it will be enough one cash."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0){\n \n $minimum_cash = max($cash);\n }\n if($minimum_cash==0)\n return 1;\n else \n return $minimum_cash;\n}\n \n\n\n\n\n$visitors = trim(fgets(STDIN));\n$visiting_time = array();\nfor($i=0;$i<$visitors;$i++){\n $time = trim(fgets(STDIN));\n $visiting_time[] = explode(\" \",$time);\n}\n\necho FindMinimumCash($visitors, $visiting_time);"}, {"source_code": "\n\nerror_reporting(false);\n//error_reporting(E_ALL);\n\n$handle = fopen('php://stdin', 'r');\n\nif (file_exists(\"in.txt\")) {\n $handle = fopen('in.txt', 'r');\n set_time_limit(2);\n};\n\n$nums = trim(fgets($handle));\n$min = 0;\n\n\nfor($i=0; $i<$nums; $i++) {\n list($h, $m) = explode(\" \", trim(fgets($handle)));\n $a[$h.\"_\".$m]++;\n}\n\necho max($a);\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$l){\n\t\t\t$l++;\n\t\t}\n\t}else{\n\t\t$k = 0;\n\t}\n\t$p = $j;\n}\necho $l+1;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $max) $max = $time[$h][$m];\n}\n\necho $max;\n"}, {"source_code": ""}, {"source_code": " $max) \n $max = $k;\n $k = 1; }\n \n}\necho $max;"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0){\n $common_cash = array_count_values($cash);\n $minimum_cash = max($common_cash);\n }\n if($minimum_cash==0)\n return 1;\n else \n return $minimum_cash;\n}\n \n\n\n\n\n$visitors = trim(fgets(STDIN));\n$visiting_time = array();\nfor($i=0;$i<$visitors;$i++){\n $time = trim(fgets(STDIN));\n $visiting_time[] = explode(\" \",$time);\n}\n\necho FindMinimumCash($visitors, $visiting_time);"}, {"source_code": "0){\n $common_cash = array_count_values($cash);\n $minimum_cash = max($common_cash);\n }\n if($minimum_cash==0)\n return 1;\n else \n return $minimum_cash;\n}\n \n\n\n\n\n$visitors = trim(fgets(STDIN));\n$visiting_time = array();\nfor($i=0;$i<$visitors;$i++){\n $time = trim(fgets(STDIN));\n $visiting_time[] = explode(\" \",$time);\n}\n\necho FindMinimumCash($visitors, $visiting_time);"}, {"source_code": "0){\n $common_cash = array_count_values($cash);\n $minimum_cash = max($common_cash);\n }\n if($minimum_cash==0)\n return 1;\n else \n return $minimum_cash;\n}\n \n\n\n\n\n$visitors = trim(fgets(STDIN));\n$visiting_time = array();\nfor($i=0;$i<$visitors;$i++){\n $time = trim(fgets(STDIN));\n $visiting_time[] = explode(\" \",$time);\n}\n\necho FindMinimumCash($visitors, $visiting_time);"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0)\n{\n for($i=0; $i<$a; ++$i)\n {\n $b = trim(fgets(STDIN));\n $e = explode(\" \", $b);\n $c[$i] = $e[0]*60+$e[1];\n }\n for($i=0; $i<$a; ++$i)\n {\n if($c[$i] == $c[$i+1])\n {\n $d += 1;\n if($d >= 2)\n {\n $f += 1;\n $d = 0;\n }\n }\n \n }\n}else{$f=0;}\necho $f;\n?>"}, {"source_code": "= 1)\n {\n $f += 1;\n $d = 0;\n }\n }\n \n}\necho $f;\n?>"}, {"source_code": " $max )$max = $k;\n $k = 0;\n}\necho $max;"}, {"source_code": "= $max ){$max = $k;}\n $k = 0;\n}\necho $max;"}], "src_uid": "cfad2cb472e662e037f3415a84daca57"} {"nl": {"description": "Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1\u2009\u2264\u2009a1\u2009\u2264\u2009a2\u2009\u2264\u2009...\u2009\u2264\u2009an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each box vertically down on the first wi stairs of the staircase, that is, the box covers stairs with numbers 1,\u20092,\u2009...,\u2009wi. Each thrown box flies vertically down until at least one of the two following events happen: the bottom of the box touches the top of a stair; the bottom of the box touches the top of a box, thrown earlier. We only consider touching of the horizontal sides of stairs and boxes, at that touching with the corners isn't taken into consideration. Specifically, that implies that a box with width wi cannot touch the stair number wi\u2009+\u20091.You are given the description of the staircase and the sequence in which Dima threw the boxes at it. For each box, determine how high the bottom of the box after landing will be. Consider a box to fall after the previous one lands.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109;\u00a0ai\u2009\u2264\u2009ai\u2009+\u20091). The next line contains integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the number of boxes. Each of the following m lines contains a pair of integers wi,\u2009hi (1\u2009\u2264\u2009wi\u2009\u2264\u2009n;\u00a01\u2009\u2264\u2009hi\u2009\u2264\u2009109) \u2014 the size of the i-th thrown box. The numbers in the lines are separated by spaces.", "output_spec": "Print m integers \u2014 for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.", "sample_inputs": ["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"], "sample_outputs": ["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"], "notes": "NoteThe first sample are shown on the picture. "}, "positive_code": [{"source_code": "= $c[$e])\n {\n printf(\"%.0f\", $c[1]);\n print \"\\n\";\n $c[1] += $f;\n }\n else\n {\n \n printf(\"%.0f\", $c[$e]);\n print \"\\n\";\n $c[1] = $c[$e] + $f;\n }\n}\n?>"}, {"source_code": " $max_h)\n $max_h = $arr[$j];\n }\n $max_w = $size[0];\n }\n echo $max_h.\"\\n\";\n $max_h += $size[1];\n $arr[0] = $max_h;\n }\n?>\n"}, {"source_code": ""}], "negative_code": [{"source_code": " $max_h)\n $max_h = $arr[$j];\n }\n echo $max_h.\"\\n\";\n $max_h += $size[1];\n $arr[$j] = $max_h;\n }\n?>\n"}], "src_uid": "fb0e6a573daa0ee7c20d20b0d2b83756"} {"nl": {"description": "Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:We will define the distance between two strings s and t of the same length consisting of digits zero and one as the number of positions i, such that si isn't equal to ti. As besides everything else Susie loves symmetry, she wants to find for two strings s and t of length n such string p of length n, that the distance from p to s was equal to the distance from p to t.It's time for Susie to go to bed, help her find such string p or state that it is impossible.", "input_spec": "The first line contains string s of length n. The second line contains string t of length n. The length of string n is within range from 1 to 105. It is guaranteed that both strings contain only digits zero and one.", "output_spec": "Print a string of length n, consisting of digits zero and one, that meets the problem statement. If no such string exist, print on a single line \"impossible\" (without the quotes). If there are multiple possible answers, print any of them.", "sample_inputs": ["0001\n1011", "000\n111"], "sample_outputs": ["0011", "impossible"], "notes": "NoteIn the first sample different answers are possible, namely \u2014 0010, 0011, 0110, 0111, 1000, 1001, 1100, 1101."}, "positive_code": [{"source_code": " $b[$x])\n {\n $d++;\n }\n}\n$e = max($c, $d) - min($c, $d);\n$f = $e % 2;\n$g = $e / 2;\nif($f != 0)\n{\n print \"impossible\";\n}\nelse\n{\n if($c == $d)\n {\n $h = \"\";\n for($x = 0; $x < strlen($a); $x++)\n {\n $h .= 1;\n }\n print $h;\n }\n elseif($c < $d)\n {\n $h = \"\";\n $i = 0;\n for($x = 0; $x < strlen($a); $x++)\n {\n if(($a[$x] > $b[$x]) && ($i == 0))\n {\n $h .= 1;\n $g--;\n if($g == 0)\n {\n $i = 1;\n }\n }\n else\n {\n $h .= 0;\n }\n }\n print $h;\n }\n elseif($c > $d)\n {\n $h = \"\";\n $i = 0;\n for($x = 0; $x < strlen($a); $x++)\n {\n if(($a[$x] < $b[$x]) && ($i == 0))\n {\n $h .= 0;\n $g--;\n if($g == 0)\n {\n $i = 1;\n }\n }\n else\n {\n $h .= 1;\n }\n }\n print $h;\n }\n}\n?>"}], "negative_code": [{"source_code": " $b[$x])\n {\n $d++;\n }\n}\n$e = max($c, $d) - min($c, $d);\n$f = $e % 2;\n$g = $e / 2;\nif($f != 0)\n{\n print \"impossible\";\n}\nelse\n{\n if($c == $d)\n {\n $h = \"\";\n for($x = 1; $x <= strlen($a); $x++)\n {\n $h .= 1;\n }\n print $h;\n }\n elseif($c < $d)\n {\n $h = \"\";\n $i = 0;\n for($x = 1; $x <= strlen($a); $x++)\n {\n if(($a[$x] < $a[$b]) && ($i = 1))\n {\n $h .= 1;\n $g--;\n if($g == 0)\n {\n $i = 1;\n }\n }\n else\n {\n $h .= 0;\n }\n }\n print $h;\n }\n elseif($c > $d)\n {\n $h = \"\";\n $i = 0;\n for($x = 1; $x <= strlen($a); $x++)\n {\n if(($a[$x] > $a[$b]) && ($i == 0))\n {\n $h .= 0;\n $g--;\n if($g == 0)\n {\n $i = 1;\n }\n }\n else\n {\n $h .= 1;\n }\n }\n print $h;\n }\n}\n?>"}], "src_uid": "2df181f2d1f4063a22fd2fa2d47eef92"} {"nl": {"description": "You are given n switches and m lamps. The i-th switch turns on some subset of the lamps. This information is given as the matrix a consisting of n rows and m columns where ai,\u2009j\u2009=\u20091 if the i-th switch turns on the j-th lamp and ai,\u2009j\u2009=\u20090 if the i-th switch is not connected to the j-th lamp.Initially all m lamps are turned off.Switches change state only from \"off\" to \"on\". It means that if you press two or more switches connected to the same lamp then the lamp will be turned on after any of this switches is pressed and will remain its state even if any switch connected to this lamp is pressed afterwards.It is guaranteed that if you push all n switches then all m lamps will be turned on.Your think that you have too many switches and you would like to ignore one of them. Your task is to say if there exists such a switch that if you will ignore (not use) it but press all the other n\u2009-\u20091 switches then all the m lamps will be turned on.", "input_spec": "The first line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20092000) \u2014 the number of the switches and the number of the lamps. The following n lines contain m characters each. The character ai,\u2009j is equal to '1' if the i-th switch turns on the j-th lamp and '0' otherwise. It is guaranteed that if you press all n switches all m lamps will be turned on.", "output_spec": "Print \"YES\" if there is a switch that if you will ignore it and press all the other n\u2009-\u20091 switches then all m lamps will be turned on. Print \"NO\" if there is no such switch.", "sample_inputs": ["4 5\n10101\n01000\n00111\n10000", "4 5\n10100\n01000\n00110\n00101"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "5ce39a83d27253f039f0e26045249d99"} {"nl": {"description": "Happy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.One of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 through n and is asked to convert the first one to the second. In one move he can remove the last number from the permutation of numbers and inserts it back in an arbitrary position. He can either insert last number between any two consecutive numbers, or he can place it at the beginning of the permutation.Happy PMP has an algorithm that solves the problem. But it is not fast enough. He wants to know the minimum number of moves to convert the first permutation to the second. ", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105) \u2014 the quantity of the numbers in the both given permutations. Next line contains n space-separated integers \u2014 the first permutation. Each number between 1 to n will appear in the permutation exactly once. Next line describe the second permutation in the same format.", "output_spec": "Print a single integer denoting the minimum number of moves required to convert the first permutation to the second.", "sample_inputs": ["3\n3 2 1\n1 2 3", "5\n1 2 3 4 5\n1 5 2 3 4", "5\n1 5 2 3 4\n1 2 3 4 5"], "sample_outputs": ["2", "1", "3"], "notes": "NoteIn the first sample, he removes number 1 from end of the list and places it at the beginning. After that he takes number 2 and places it between 1 and 3.In the second sample, he removes number 5 and inserts it after 1.In the third sample, the sequence of changes are like this: 1 5 2 3 4 1 4 5 2 3 1 3 4 5 2 1 2 3 4 5 So he needs three moves."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "a26e048eb9b18f87f1703d42e172f318"} {"nl": {"description": "Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the examiner will be...To prepare for the exam, one has to study proofs of n theorems. It is known that there will be k examination cards on the exam and each card contains distinct theorems. Besides, no theorem is mentioned in more than one card (that is, theorems won't be mentioned in any card). During the exam several students may get the same card.We do not know the exact way theorems are distributed by cards, however the students that took the exam before Vasya told him what theorems their cards contained. Vasya evaluates his level of proficiency in the i-th theorem by some number ai. The level of proficiency in some card is the average of the levels of proficiency in the theorems that are included in the card. Now Vasya wants to know the minimally and maximally possible levels of his proficiency in the card he gets on the exam. Vasya wants to determine it by the data he has collected from other students. Unfortunately, Vasya has no time left to do the math and he asked you to help him.", "input_spec": "The first line contains two integers n and k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of theorems and the number of cards correspondingly. The second line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009100), the i-th number (1\u2009\u2264\u2009i\u2009\u2264\u2009n) corresponds to Vasya's proficiency in the i-th theorem. The third line contains number q (0\u2009\u2264\u2009q\u2009\u2264\u2009100) \u2014 the number of people that have taken the exam before Vasya. Each of the following q lines contains the description of a student's card: integers from 1 to n inclusive. They are the numbers of theorems included in the card in the order in which they are enumerated in the input data. The numbers are given in an arbitrary order. It is guaranteed that the given cards are valid (that is, that all theorems in one card are different and that different people get cards that either don't contain the same theorems or coincide up to the theorems' permutation).", "output_spec": "Print two real numbers, representing Vasya's minimum and maximum proficiency in the card he will get on the exam. The absolute or relative error should not exceed 10\u2009-\u20096.", "sample_inputs": ["7 3\n7 15 0 19 10 5 12\n2\n1 6\n7 4", "4 2\n10 8 1 17\n2\n2 3\n3 2"], "sample_outputs": ["5.0000000000 15.5000000000", "4.5000000000 13.5000000000"], "notes": "NoteLet's analyze the first sample. Vasya's proficiency in the cards whose content he already knows equals 6 and 15.5 correspondingly. The three theorems that are left are only enough to make one exam card. If we consider all possible variants of theorems included in the card we can see that in the best case scenario Vasya gets the card that contains theorems 4 and 7 (his proficiency would equal 15.5) and in the worst case scenario he gets theorems 3 and 5 (his proficiency would equal 5).The \u230a x\u230b operation denotes taking integer part of real number x (rounding down)."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "899c5b77bfc0b4b99aff310741c9c0dd"} {"nl": {"description": "When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read. His father decided to rearrange them. Help him restore the original number, on condition that it was the maximum possible one. ", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leqslant n \\leqslant 10^5$$$)\u00a0\u2014 the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either \"zero\" which corresponds to the digit $$$0$$$ or \"one\" which corresponds to the digit $$$1$$$.", "output_spec": "Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed.", "sample_inputs": ["4\nezor", "10\nnznooeeoer"], "sample_outputs": ["0", "1 1 0"], "notes": "NoteIn the first example, the correct initial ordering is \"zero\".In the second example, the correct initial ordering is \"oneonezero\"."}, "positive_code": [{"source_code": " 0, n => 0, e => 0);\nfor($x = 0; $x < $a; $x++)\n{\n if($b[$x] == \"o\")\n {\n $c[$b[$x]]++;\n unset($b[$x]);\n }\n elseif($b[$x] == \"n\")\n {\n $c[$b[$x]]++;\n unset($b[$x]);\n }\n elseif($b[$x] == \"e\")\n {\n $c[$b[$x]]++;\n unset($b[$x]);\n }\n}\n$d = min($c);\n$c[o] -= $d;\n$c[n] -= $d;\n$c[e] -= $d;\n$e = array_fill(0, $c[o], \"o\");\n$b = array_merge($b, $e);\n$e = array_fill(0, $c[n], \"n\");\n$b = array_merge($b, $e);\n$e = array_fill(0, $c[e], \"e\");\n$b = array_merge($b, $e);\nsort($b);\n$e = array(z => 0, e => 0, r => 0, o => 0);\nfor($x = 0; $x < count($b); $x++)\n{\n if($b[$x] == \"z\")\n {\n $e[z]++;\n }\n elseif($b[$x] == \"e\")\n {\n $e[e]++;\n }\n elseif($b[$x] == \"r\")\n {\n $e[r]++;\n }\n elseif($b[$x] == \"o\")\n {\n $e[o]++;\n }\n}\n$f = min($e);\n$g = \"\";\nfor($x = 1; $x <= $d; $x++)\n{\n $g .= \"1 \";\n}\nfor($x = 1; $x <= $f; $x++)\n{\n $g .= \"0 \";\n}\nprint $g;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $v){\n if($v == 'n'){\n $n .= '1 ';\n }\n if($v == 'z'){\n $z.= '0 ';\n }\n}\necho $n.$z;\n"}], "negative_code": [{"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if($n == 2)\n {\n $i2 = $i;\n $j2 = $j;\n $l--;\n $i2 -= $d[$l];\n $j2 = array_slice($j2, 0, -1);\n if($c[$k] == TRUE)\n {\n $i2 += $c[$k];\n $j2[count($j2)] = $g[$k];\n }\n $i3 = $i;\n $j3 = $j;\n $k--;\n $i3 -= $c[$k];\n for($x = count($j3) - 1; $x >= 0; $x--)\n {\n if($j3[$x] == $g[$k])\n {\n array_splice($j3, $x, 1);\n break;\n }\n }\n if($i2 >= $i3)\n {\n print $i2 . \"\\n\";\n print implode(\" \", $j2);\n }\n else\n {\n print $i3 . \"\\n\";\n print implode(\" \", $j3);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= 2) {\n\tif ($b[$lb][3] > $c[$lc][3]) {\n\t\tif ($lb == $lengb - 1 && $w % 2 == 0) {\n\t\t\t$temp = $w;\n\t\t\t$temp1 = $temp2 = 0;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp1 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$temp2 = $b[$lb][2];\n\t\t\t$temp = $w - 1;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp2 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($temp1 >= $temp2) {\n\t\t\t\t$tong += $c[$lc][2];\n\t\t\t\t$w -= 2;\n\t\t\t\t$result[] = $c[$lc++][0];\n\t\t\t\t$lb++;\n\t\t\t} else {\n\t\t\t\t$tong += $b[$lb][2];\n\t\t\t\t$w--;\n\t\t\t\t$result[] = $b[$lb++][0];\n\t\t\t}\n\t\t} else {\n\t\t\t$tong += $b[$lb][2];\n\t\t\t$w--;\n\t\t\t$result[] = $b[$lb++][0];\n\t\t}\n\t} else {\n\t\t$tong += $c[$lc][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$lc++][0];\n\t}\n}\n\nfor ($i = $lb; $i < $lengb; $i++) {\n\tif ($w >= 1) {\n\t\t$tong += $b[$i][2];\n\t\t$w--;\n\t\t$result[] = $b[$i][0];\n\t}\n}\n\nfor ($i = $lc; $i < $lengc; $i++) {\n\tif ($w >= 2) {\n\t\t$tong += $c[$i][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$i][0];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\nif ($tong > 0) {\n\t$leng = count($result);\n\tfor ($i = 0; $i < $leng - 1; $i++) {\n\t\tprintf(\"%d \", $result[$i]);\n\t}\n\tprintf(\"%d\", $result[$leng - 1]);\n}\n"}], "negative_code": [{"source_code": " $e[$r]) && ($c[$p + 1] == TRUE))\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 2;\n $y = $s;\n }\n elseif($c[$p] > $e[$r])\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 1;\n $y = $s;\n }\n else\n {\n $n[$s] = $m[$r] + 1;\n $t += $e[$r];\n $s++;\n $r++;\n $o += 2;\n $z = $s;\n }\n }\n elseif($o == $b)\n {\n break;\n }\n elseif($o > $b)\n {\n if(count($c) == 0)\n {\n $r--;\n $t -= $e[$r];\n $z--;\n unset($n[$z]);\n }\n elseif(count($d) == 0)\n {\n $p--;\n $t -= $e[$r];\n $y--;\n unset($n[$y]);\n }\n else\n {\n $u = $n;\n $w = $t;\n $p--;\n $w -= $c[$p];\n $y--;\n unset($u[$y]);\n $uu = $n;\n $ww = $t;\n $r--;\n $ww -= $e[$r];\n $z--;\n unset($uu[$z]);\n $p++;\n $ww += $c[$p];\n $y++;\n $uu[$y] = $k[$p] + 1;\n if($w >= $ww)\n {\n $n = $u;\n $t = $w;\n }\n else\n {\n $n = $uu;\n $t = $ww;\n }\n break;\n } \n }\n}\nprint $t . \"\\n\";\nprint implode(\" \", $n);\n?>"}, {"source_code": "= $c[$g[$m]] + $c[$g[$m + 1]])\n {\n $b -= 2;\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n $k++;\n $l++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $n = $c[$g[$m - 1]] + $c[$g[$m]];\n if($d[$h[$l + 1]] > $n)\n {\n $i -= $c[$g[$m - 1]];\n array_splice($j, $o, 1);\n $i += $d[$h[$l + 1]];\n $j[$k] = $h[$l + 1] + 1;\n break;\n }\n else\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n } \n }\n }\n else\n {\n $b -= 2;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $o = $k;\n $k++;\n $m++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $n = $c[$g[$m - 1]] + $c[$g[$m]];\n if($d[$h[$l + 1]] > $n)\n {\n $i -= $c[$g[$m - 1]];\n array_splice($j, $o, 1);\n $i += $d[$h[$l + 1]];\n $j[$k] = $h[$l + 1] + 1;\n break;\n }\n else\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n } \n }\n }\n }\n print $i . \"\\n\";\n print implode(\" \", $j);\n}\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if(($a == 5000) && ($b == 3649) && ($n == 2))\n {\n print $c[$k - 3] . \" \" . $c[$k - 2] . \" \" . $c[$k - 1] . \" \" . $c[$k] . \" \" . $c[$k + 1] . \" \" . $c[$k + 2] . \" \" . $c[$k + 3] . \"\\n\";\n print $d[$l - 1] . \" \" . $d[$l - 2] . \" \" . $d[$l - 3] . \"\\n\";\n }\n if($n == 2)\n {\n $l--;\n $i -= $d[$l];\n $j = array_slice($j, 0, -1);\n if($c[$k] == TRUE)\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n break;\n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n array_push($o, $j[$m]);\n array_push($o, $j[$m + 1]);\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n } \n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n elseif($p > $b)\n {\n $v = $m;\n $v--;\n $w = $r;\n $w -= $c[$v];\n $y = $o;\n unset($y[$m]); \n $i = $n;\n $i--;\n $k = $r;\n $k -= $e[$i];\n $z = $o;\n unset($z[$n]);\n $k += $c[$m];\n array_push($z, $j[$m]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $w;\n $o = $z;\n }\n break; \n }\n}\nprint $r . \"\\n\";\nprint implode(\" \", $o);\n?>"}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n break;\n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n $o .= $j[$m] . \" \" . $j[$m + 1] . \" \";\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n $o .= $l[$n] . \" \";\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n else\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n $o .= $l[$n] . \" \";\n $n++;\n }\n } \n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n }\n}\nprint $r . \"\\n\";\nprint trim($o);\n?>"}, {"source_code": "= $c[$g[$m]] + $c[$g[$m + 1]])\n {\n $b -= 2;\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n $k++;\n $l++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n else\n {\n $b -= 2;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m + 1]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n }\n print $i . \"\\n\";\n print implode(\" \", $j);\n}\n?>"}, {"source_code": "= 2) {\n\tif ($b[$lb][3] > $c[$lc][3]) {\n\t\tif ($lb == $lengb - 1 && $w % 2 == 0) {\n\t\t\t$temp = $w;\n\t\t\t$temp1 = $temp2 = 0;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($w >= 2) {\n\t\t\t\t\t$temp1 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$temp2 = $b[$lb][2];\n\t\t\t$temp = $w - 1;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($w >= 2) {\n\t\t\t\t\t$temp2 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($temp1 >= $temp2) {\n\t\t\t\t$tong += $c[$lc][2];\n\t\t\t\t$w -= 2;\n\t\t\t\t$result[] = $c[$lc++][0];\n\t\t\t\t$lb++;\n\t\t\t} else {\n\t\t\t\t$tong += $b[$lb][2];\n\t\t\t\t$w--;\n\t\t\t\t$result[] = $b[$lb++][0];\n\t\t\t}\n\t\t} else {\n\t\t\t$tong += $b[$lb][2];\n\t\t\t$w--;\n\t\t\t$result[] = $b[$lb++][0];\n\t\t}\n\t} else {\n\t\t$tong += $c[$lc][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$lc++][0];\n\t}\n}\n\nfor ($i = $lb; $i < $lengb; $i++) {\n\tif ($w >= 1) {\n\t\t$tong += $b[$i][2];\n\t\t$w--;\n\t\t$result[] = $b[$i][0];\n\t}\n}\n\nfor ($i = $lc; $i < $lengc; $i++) {\n\tif ($w >= 2) {\n\t\t$tong += $c[$i][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$i][0];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\n$leng = count($result);\nfor ($i = 0; $i < $leng - 1; $i++) {\n\tprintf(\"%d \", $result[$i]);\n}\nprintf(\"%d\", $result[$leng - 1]);"}, {"source_code": "= 2) {\n\tif ($b[$lb][3] > $c[$lc][3]) {\n\t\tif ($lb == $lengb - 1 && $w % 2 == 0) {\n\t\t\t$temp = $w;\n\t\t\t$temp1 = $temp2 = 0;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp1 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$temp2 = $b[$lb][2];\n\t\t\t$temp = $w - 1;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp2 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($temp1 >= $temp2) {\n\t\t\t\t$tong += $c[$lc][2];\n\t\t\t\t$w -= 2;\n\t\t\t\t$result[] = $c[$lc++][0];\n\t\t\t\t$lb++;\n\t\t\t} else {\n\t\t\t\t$tong += $b[$lb][2];\n\t\t\t\t$w--;\n\t\t\t\t$result[] = $b[$lb++][0];\n\t\t\t}\n\t\t} else {\n\t\t\t$tong += $b[$lb][2];\n\t\t\t$w--;\n\t\t\t$result[] = $b[$lb++][0];\n\t\t}\n\t} else {\n\t\t$tong += $c[$lc][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$lc++][0];\n\t}\n}\n\nfor ($i = $lb; $i < $lengb; $i++) {\n\tif ($w >= 1) {\n\t\t$tong += $b[$i][2];\n\t\t$w--;\n\t\t$result[] = $b[$i][0];\n\t}\n}\n\nfor ($i = $lc; $i < $lengc; $i++) {\n\tif ($w >= 2) {\n\t\t$tong += $c[$i][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$i][0];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\n$leng = count($result);\nfor ($i = 0; $i < $leng - 1; $i++) {\n\tprintf(\"%d \", $result[$i]);\n}\nprintf(\"%d\", $result[$leng - 1]);"}, {"source_code": "= 2) {\n\tif ($b[$lb][3] > $c[$lc][3]) {\n\t\tif ($lb == $lengb - 1 && $w % 2 == 0) {\n\t\t\t$temp = $w;\n\t\t\t$temp1 = $temp2 = 0;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp1 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$temp2 = $b[$lb][2];\n\t\t\t$temp = $w - 1;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp2 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($temp1 >= $temp2) {\n\t\t\t\t$tong += $c[$lc][2];\n\t\t\t\t$w -= 2;\n\t\t\t\t$result[] = $c[$lc++][0];\n\t\t\t\t$lb++;\n\t\t\t} else {\n\t\t\t\t$tong += $b[$lb][2];\n\t\t\t\t$w--;\n\t\t\t\t$result[] = $b[$lb++][0];\n\t\t\t}\n\t\t} else {\n\t\t\t$tong += $b[$lb][2];\n\t\t\t$w--;\n\t\t\t$result[] = $b[$lb++][0];\n\t\t}\n\t} else {\n\t\t$tong += $c[$lc][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$lc++][0];\n\t}\n}\n\nfor ($i = $lb; $i < $lengb; $i++) {\n\tif ($w >= 1) {\n\t\t$tong += $b[$i][2];\n\t\t$w--;\n\t\t$result[] = $b[$i][0];\n\t}\n}\n\nfor ($i = $lc; $i < $lengc; $i++) {\n\tif ($w >= 2) {\n\t\t$tong += $c[$i][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$i][0];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\nif ($tong == 0) {\n\t$leng = count($result);\n\tfor ($i = 0; $i < $leng - 1; $i++) {\n\t\tprintf(\"%d \", $result[$i]);\n\t}\n\tprintf(\"%d\", $result[$leng - 1]);\n}\n"}, {"source_code": "= 2) {\n\tif ($b[$lb][3] > $c[$lc][3]) {\n\t\tif ($lb == $lengb - 1 && $w % 2 == 0) {\n\t\t\t$temp = $w;\n\t\t\t$temp1 = $temp2 = 0;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp1 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t$temp2 = $b[$lb][2];\n\t\t\t$temp = $w - 1;\n\t\t\tfor ($i = $lc; $i < $lengc; $i++) {\n\t\t\t\tif ($temp >= 2) {\n\t\t\t\t\t$temp2 += $c[$i][2];\n\t\t\t\t\t$temp -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}var_dump($temp1, $temp2);\n\t\t\tif ($temp1 >= $temp2) {\n\t\t\t\t$tong += $c[$lc][2];\n\t\t\t\t$w -= 2;\n\t\t\t\t$result[] = $c[$lc++][0];\n\t\t\t\t$lb++;\n\t\t\t} else {\n\t\t\t\t$tong += $b[$lb][2];\n\t\t\t\t$w--;\n\t\t\t\t$result[] = $b[$lb++][0];\n\t\t\t}\n\t\t} else {\n\t\t\t$tong += $b[$lb][2];\n\t\t\t$w--;\n\t\t\t$result[] = $b[$lb++][0];\n\t\t}\n\t} else {\n\t\t$tong += $c[$lc][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$lc++][0];\n\t}\n}\n\nfor ($i = $lb; $i < $lengb; $i++) {\n\tif ($w >= 1) {\n\t\t$tong += $b[$i][2];\n\t\t$w--;\n\t\t$result[] = $b[$i][0];\n\t}\n}\n\nfor ($i = $lc; $i < $lengc; $i++) {\n\tif ($w >= 2) {\n\t\t$tong += $c[$i][2];\n\t\t$w -= 2;\n\t\t$result[] = $c[$i][0];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\n$leng = count($result);\nfor ($i = 0; $i < $leng - 1; $i++) {\n\tprintf(\"%d \", $result[$i]);\n}\nprintf(\"%d\", $result[$leng - 1]);"}, {"source_code": "= $a[$i][0]) {\n\t\t\t$b[$i][$j] = max($b[$i - 1][$j - $a[$i][0]] + $a[$i][0], $b[$i - 1][$j]);\n\t\t} else {\n\t\t\t$b[$i][$j] = $b[$i - 1][$j];\n\t\t}\n\t}\n}\n\n// echo \"
\";\n\n// for ($i = 1; $i <= $n; $i++) { \n// \techo $a[$i][0].\"___\";\n// \tfor ($j = 1; $j <= $w ; $j++) { \n// \t\techo $b[$i][$j].\".....\";\n// \t}\n// \techo \"
\";\n// }\n\n\n$chon = array();\n$t = $w;\nwhile ($t > 0) {\n\tfor ($i = $n; $i > 0; $i--) { \n\t\tif ($b[$i][$t] > $b[$i - 1][$t]) {\n\t\t\t$chon[$i] = 1;\n\t\t\t$t = $b[$i][$t] - $a[$i][0];\n\t\t} else {\n\t\t\t$chon[$i] = 0;\n\t\t}\n\t}\n}\n\n$tong = 0;\n\nfor ($i = 1; $i <= $n; $i++) { \n\tif ($chon[$i] == 1) {\n\t\t$tong += $a[$i][1];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\n\n\n\nfor ($i = 1; $i <= $n; $i++) { \n\tif ($chon[$i] == 1) {\n\t\tprintf(\"%d \", $a[$i][0]);\n\t}\n}"}, {"source_code": "= $a[$i][0]) {\n\t\t\t$b[$i][$j] = max($b[$i - 1][$j - $a[$i][0]] + $a[$i][0], $b[$i - 1][$j]);\n\t\t\t$c[$i][$j] = max($c[$i - 1][$j - $a[$i][0]] + $a[$i][1], $c[$i - 1][$j]);\n\t\t} else {\n\t\t\t$b[$i][$j] = $b[$i - 1][$j];\n\t\t\t$c[$i][$j] = $c[$i - 1][$j];\n\t\t}\n\t}\n}\n\n// echo \"
\";\n\n// for ($i = 1; $i <= $n; $i++) { \n// \techo $a[$i][0].\"___\";\n// \tfor ($j = 1; $j <= $w ; $j++) { \n// \t\techo $b[$i][$j].\".....\";\n// \t}\n// \techo \"
\";\n// }\n\n// echo \"
\";\n\n// for ($i = 1; $i <= $n; $i++) { \n// \techo $a[$i][0].\"___\";\n// \tfor ($j = 1; $j <= $w ; $j++) { \n// \t\techo $c[$i][$j].\".....\";\n// \t}\n// \techo \"
\";\n// }\n\n\n$chon = array();\n$t = $w;\nwhile ($t > 0) {\n\tfor ($i = $n; $i > 0; $i--) { \n\t\tif ($c[$i][$t] > $c[$i - 1][$t]) {\n\t\t\t$chon[$i] = 1;\n\t\t\t$t = $b[$i][$t] - $a[$i][0];\n\t\t} else {\n\t\t\t$chon[$i] = 0;\n\t\t}\n\t}\n}\n\n$tong = 0;\n\nfor ($i = 1; $i <= $n; $i++) { \n\tif ($chon[$i] == 1) {\n\t\t$tong += $a[$i][1];\n\t}\n}\n\nprintf(\"%d\\n\", $tong);\n\n\n\nfor ($i = 1; $i <= $n; $i++) { \n\tif ($chon[$i] == 1) {\n\t\tprintf(\"%d \", $i);\n\t}\n}"}, {"source_code": " $g_2)\n{\n print $l . \"\\n\" . $m;\n}\nelse\n{\n print $g_2 . \"\\n\" . $h_2;\n}\n?>"}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $w = $r;\n $w += $c[$m];\n $y = $o;\n array_push($y, $j[$m]); \n $v = $m;\n $v--;\n $k = $r;\n $k -= $c[$v];\n $z = $o;\n unset($z[$m]);\n $k += $e[$n];\n array_push($z, $l[$n]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n array_push($o, $j[$m]);\n array_push($o, $j[$m + 1]);\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n } \n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n elseif($p > $b)\n {\n $v = $m;\n $v--;\n $w = $r;\n $w -= $c[$v];\n $y = $o;\n unset($y[$m]); \n $i = $n;\n $i--;\n $k = $r;\n $k -= $e[$i];\n $z = $o;\n unset($z[$n]);\n $k += $c[$m];\n array_push($z, $j[$m]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n}\nprint $r . \"\\n\";\nprint implode(\" \", $o);\n?>"}, {"source_code": " $e[$r]) && ($c[$p + 1] == TRUE))\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 2;\n $y = $s;\n }\n elseif($c[$p] > $e[$r])\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 1;\n $y = $s;\n }\n else\n {\n $n[$s] = $m[$r] + 1;\n $t += $e[$r];\n $s++;\n $r++;\n $o += 2;\n $z = $s;\n }\n }\n elseif($o == $b)\n {\n break;\n }\n elseif($o > $b)\n {\n if(count($c) == 0)\n {\n $r--;\n $t -= $e[$r];\n $z--;\n unset($n[$z]);\n }\n elseif(count($d) == 0)\n {\n $p--;\n $t -= $e[$r];\n $y--;\n unset($n[$y]);\n }\n else\n {\n $u = $n;\n $w = $t;\n $p--;\n $w -= $c[$p];\n $y--;\n unset($u[$y]);\n $uu = $n;\n $ww = $t;\n $r--;\n $ww -= $e[$r];\n $z--;\n unset($uu[$z]);\n $p++;\n $ww += $c[$p];\n $y++;\n $uu[$y] = $k[$p] + 1;\n if($w >= $ww)\n {\n $n = $u;\n $t = $w;\n }\n else\n {\n $n = $uu;\n $t = $ww;\n }\n break;\n } \n }\n}\nsort($n);\nprint $t . \"\\n\";\nprint implode(\" \", $n);\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if($n == 2)\n {\n $i2 = $i;\n $j2 = $j;\n $l--;\n $i2 -= $d[$l];\n $j2 = array_slice($j2, 0, -1);\n if($c[$k] == TRUE)\n {\n $i2 += $c[$k];\n $j2[count($j2)] = $g[$k];\n }\n $i3 = $i;\n $j3 = $j;\n $k -= 2;\n $i3 -= $c[$k];\n for($x = count($j3) - 1; $x >= 0; $x--)\n {\n if($j3[$x] == $g[$k])\n {\n array_splice($j3, $x, 1);\n break;\n }\n }\n if($i2 >= $i3)\n {\n print $i2 . \"\\n\";\n print implode(\" \", $j2);\n }\n else\n {\n print $i3 . \"\\n\";\n print implode(\" \", $j3);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if($n == 2)\n {\n $l--;\n $i -= $d[$l];\n $j = array_slice($j, 0, -1);\n if($c[$k] == TRUE)\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $e[$r]) && ($c[$p + 1] == TRUE))\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 2;\n $y = $s;\n }\n elseif($c[$p] > $e[$r])\n {\n $n[$s] = $k[$p] + 1;\n $t += $c[$p];\n $s++;\n $p++;\n $o += 1;\n $y = $s;\n }\n else\n {\n $n[$s] = $m[$r] + 1;\n $t += $e[$r];\n $s++;\n $r++;\n $o += 2;\n $z = $s;\n }\n }\n elseif($o == $b)\n {\n break;\n }\n elseif($o > $b)\n {\n if(count($c) == 0)\n {\n $r--;\n $t -= $e[$r];\n $z--;\n unset($n[$z]);\n }\n elseif(count($d) == 0)\n {\n $p--;\n $t -= $e[$r];\n $y--;\n unset($n[$y]);\n }\n else\n {\n $u = $n;\n $w = $t;\n $p--;\n $w -= $c[$p];\n $y--;\n unset($u[$y]);\n $uu = $n;\n $ww = $t;\n $r--;\n $ww -= $e[$r];\n $z--;\n unset($uu[$z]);\n $p++;\n $ww += $c[$p];\n $uu[$y] = $k[$p] + 1;\n if($w >= $ww)\n {\n $n = $u;\n $t = $w;\n }\n else\n {\n $n = $uu;\n $t = $ww;\n }\n break;\n } \n }\n}\nprint $t . \"\\n\";\nprint implode(\" \", $n);\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if($n == 2)\n {\n $i2 = $i;\n $j2 = $j;\n $l--;\n $i2 -= $d[$l];\n $j2 = array_slice($j2, 0, -1);\n if($c[$k] == TRUE)\n {\n $i2 += $c[$k];\n $j2[count($j2)] = $g[$k];\n }\n $i3 = $i;\n $j3 = $j;\n $k -= 2;\n $i3 -= $c[$k];\n for($x = count($j3) - 1; $x >= 0; $x--)\n {\n if($j3[$x] == $h[$k])\n {\n array_splice($j3, $x, 1);\n break;\n }\n }\n if($i2 >= $i3)\n {\n print $i2 . \"\\n\";\n print implode(\" \", $j2);\n }\n else\n {\n print $i3 . \"\\n\";\n print implode(\" \", $j3);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $w = $r;\n $w += $c[$m];\n $y = $o;\n array_push($y, $j[$m]); \n $v = $m;\n $v--;\n $k = $r;\n $k -= $c[$v];\n $z = $o;\n unset($z[$m]);\n $k += $e[$n];\n array_push($z, $l[$n]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n array_push($o, $j[$m]);\n array_push($o, $j[$m + 1]);\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n } \n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n elseif($p > $b)\n {\n $v = $m;\n $v--;\n $w = $r;\n $w -= $c[$v];\n $y = $o;\n unset($y[$m]); \n $i = $n;\n $i--;\n $k = $r;\n $k -= $e[$i];\n $z = $o;\n unset($z[$n]);\n $k += $c[$m];\n array_push($z, $j[$m]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n}\nprint $r . \"\\n\";\nprint implode(\" \", $o);\n?>"}, {"source_code": ""}, {"source_code": "= $c[$g[$m]] + $c[$g[$m + 1]])\n {\n $b -= 2;\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n $k++;\n $l++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n else\n {\n $b -= 2;\n $i += $c[$g[$m]];\n $i += $c[$g[$m + 1]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n $j[$k] = $g[$m + 1] + 1;\n $k++;\n $m++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m + 2]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n}\nprint $i . \"\\n\";\nprint implode(\" \", $j);\n?>"}, {"source_code": ""}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n break;\n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n $o .= $j[$m] . \" \" . $j[$m + 1] . \" \";\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n $o .= $l[$n] . \" \";\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n $o .= $l[$n] . \" \";\n $n++;\n }\n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p++;\n $r += $c[$m];\n $o .= $j[$m] . \" \";\n $m++;\n }\n }\n}\nprint $r . \"\\n\";\nprint trim($o);\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if(($a == 5000) && ($b == 3649))\n {\n print $n . \"\\n\";\n }\n if($n == 2)\n {\n $l--;\n $i -= $d[$l];\n $j = array_slice($j, 0, -1);\n if($c[$k] == TRUE)\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if(($a == 5000) && ($b == 3649) && ($n == 2))\n {\n print $d[$l - 1] . \"\\n\";\n print $c[$k] . \"\\n\";\n }\n if($n == 2)\n {\n $l--;\n $i -= $d[$l];\n $j = array_slice($j, 0, -1);\n if($c[$k] == TRUE)\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if(($a == 5000) && ($b == 3649) && ($n == 2))\n {\n print $d[$l - 1] . \"\\n\";\n print $c[$k] . \"\\n\";\n }\n if($n == 2)\n {\n $i2 = $i;\n $j2 = $j;\n $l--;\n $i2 -= $d[$l];\n $j2 = array_slice($j2, 0, -1);\n if($c[$k] == TRUE)\n {\n $i2 += $c[$k];\n $j2[count($j2)] = $g[$k];\n }\n $i3 = $i;\n $j3 = $j;\n $k -= 2;\n $i3 -= $c[$k];\n for($x = count($j3) - 1; $x >= 0; $x--)\n {\n if($j3[$x] == $h[$k])\n {\n array_splice($j3, $x, 1);\n break;\n }\n }\n if($i2 >= $i3)\n {\n print $i2 . \"\\n\";\n print implode(\" \", $j2);\n }\n else\n {\n print $i3 . \"\\n\";\n print implode(\" \", $j3);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}, {"source_code": "= 2) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $w = $r;\n $w += $c[$m];\n $y = $o;\n array_push($y, $j[$m]);\n $k = $r;\n $k -= $c[$v];\n $z = $o;\n unset($z[$m]);\n $k += $e[$n];\n array_push($z, $l[$n]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n else\n {\n if(($c[$m] + $c[$m + 1]) > $e[$n])\n {\n $p += 2;\n $r += $c[$m];\n $r += $c[$m + 1];\n array_push($o, $j[$m]);\n array_push($o, $j[$m + 1]);\n $m += 2;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n }\n elseif(($s == 0) && ($t == 0))\n {\n break;\n }\n elseif(($s >= 1) && ($t == 0))\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n elseif(($s == 1) && ($t >= 1))\n {\n $u = $b - $p;\n if($u == 1)\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n if($c[$m] > $e[$n])\n {\n $p++;\n $r += $c[$m];\n array_push($o, $j[$m]);\n $m++;\n }\n else\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n } \n }\n elseif(($s == 0) && ($t >= 1))\n {\n $p += 2;\n $r += $e[$n];\n array_push($o, $l[$n]);\n $n++;\n }\n }\n elseif($p > $b)\n {\n $v = $m;\n $v--;\n $w = $r;\n $w -= $c[$v];\n $y = $o;\n unset($y[$m]); \n $i = $n;\n $i--;\n $k = $r;\n $k -= $e[$i];\n $z = $o;\n unset($z[$n]);\n $k += $c[$m];\n array_push($z, $j[$m]);\n if($w >= $k)\n {\n $r = $w;\n $o = $y;\n }\n else\n {\n $r = $k;\n $o = $z;\n }\n break; \n }\n}\nprint $r . \"\\n\";\nprint implode(\" \", $o);\n?>"}, {"source_code": "= $c[$g[$m]] + $c[$g[$m + 1]])\n {\n $b -= 2;\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n $k++;\n $l++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n if($d[$h[$l + 1]] > $c[$g[$m - 1]])\n {\n $i -= $c[$g[$m - 1]];\n array_splice($j, $o, 1);\n $i += $d[$h[$l + 1]];\n $j[$k] = $h[$l + 1] + 1;\n break;\n }\n else\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n } \n }\n }\n else\n {\n $b -= 2;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $o = $k;\n $k++;\n $m++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n if($d[$h[$l]] > $c[$g[$m - 1]])\n {\n $i -= $c[$g[$m - 1]];\n array_splice($j, $o, 1);\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n break;\n }\n else\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n } \n }\n }\n }\n print $i . \"\\n\";\n print implode(\" \", $j);\n}\n?>"}, {"source_code": "= $c[$g[$m]] + $c[$g[$m + 1]])\n {\n $b -= 2;\n $i += $d[$h[$l]];\n $j[$k] = $h[$l] + 1;\n $k++;\n $l++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n else\n {\n $b -= 2;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n $i += $c[$g[$m]];\n $j[$k] = $g[$m] + 1;\n $k++;\n $m++;\n if($b == 0)\n {\n break;\n }\n elseif($b == 1)\n {\n $i += $c[$g[$m + 1]];\n $j[$k] = $g[$m] + 1;\n break;\n }\n }\n}\nprint $i . \"\\n\";\nprint implode(\" \", $j);\n?>"}, {"source_code": "= (count($c) + count($d)))\n {\n $m = 1;\n break;\n }\n elseif((($l * 2) + $k) == $b)\n {\n $m = 2;\n break;\n }\n elseif((($l * 2) + $k) > $b)\n {\n $m = 3;\n break;\n }\n else\n {\n if($c[$k] > $d[$l])\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n $k++;\n $n = 1;\n }\n elseif($d[$l] >= $c[$k] + $c[$k + 1])\n {\n $i += $d[$l];\n $j[count($j)] = $h[$l];\n $l++;\n $n = 2;\n }\n elseif($c[$k] + $c[$k + 1] > $d[$l])\n {\n $i += $c[$k];\n $i += $c[$k + 1];\n $j[count($j)] = $g[$k];\n $j[count($j)] = $g[$k + 1];\n $k += 2;\n $n = 3;\n }\n }\n }\n if(($m == 1) || ($m == 2))\n {\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n elseif($m == 3)\n {\n if($n == 2)\n {\n $l--;\n $i -= $d[$l];\n $j = array_slice($j, 0, -1);\n if($c[$k] == TRUE)\n {\n $i += $c[$k];\n $j[count($j)] = $g[$k];\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n elseif($n == 3)\n {\n $k--;\n $i -= $c[$k];\n $j = array_slice($j, 0, -1);\n print $i . \"\\n\";\n print implode(\" \", $j);\n }\n }\n}\n?>"}], "src_uid": "a1f98b06650a5755e784cd6ec6f3b211"} {"nl": {"description": "You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, with edges numbered from $$$1$$$ to $$$n-1$$$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree.A prime tree is a tree where the weight of every path consisting of one or two edges is prime. A path should not visit any vertex twice. The weight of a path is the sum of edge weights on that path.Consider the graph below. It is a prime tree as the weight of every path of two or less edges is prime. For example, the following path of two edges: $$$2 \\to 1 \\to 3$$$ has a weight of $$$11 + 2 = 13$$$, which is prime. Similarly, the path of one edge: $$$4 \\to 3$$$ has a weight of $$$5$$$, which is also prime. Print any valid assignment of weights such that the resultant tree is a prime tree. If there is no such assignment, then print $$$-1$$$. It can be proven that if a valid assignment exists, one exists with weights between $$$1$$$ and $$$10^5$$$ as well.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \\leq n \\leq 10^5$$$)\u00a0\u2014 the number of vertices in the tree. Then, $$$n-1$$$ lines follow. The $$$i$$$-th line contains two integers $$$u$$$ and $$$v$$$ ($$$1 \\leq u, v \\leq n$$$) denoting that edge number $$$i$$$ is between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case, if a valid assignment exists, then print a single line containing $$$n-1$$$ integers $$$a_1, a_2, \\dots, a_{n-1}$$$ ($$$1 \\leq a_i \\le 10^5$$$), where $$$a_i$$$ denotes the weight assigned to the edge numbered $$$i$$$. Otherwise, print $$$-1$$$. If there are multiple solutions, you may print any.", "sample_inputs": ["3\n2\n1 2\n4\n1 3\n4 3\n2 1\n7\n1 2\n1 3\n3 4\n3 5\n6 2\n7 2"], "sample_outputs": ["17\n2 5 11\n-1"], "notes": "NoteFor the first test case, there are only two paths having one edge each: $$$1 \\to 2$$$ and $$$2 \\to 1$$$, both having a weight of $$$17$$$, which is prime. The second test case is described in the statement.It can be proven that no such assignment exists for the third test case."}, "positive_code": [{"source_code": "= 3)\r\n {\r\n echo \"-1\\n\";\r\n continue 2;\r\n }\r\n }\r\n \r\n echo implode (\" \", Task1627C ($Edges)) . \"\\n\";\r\n}\r\n\r\nfunction NextPrime (&$i)\r\n{\r\n $i = ($i == 2) ? 3 : 2;\r\n}\r\n\r\nfunction Task1627C (&$Edges)\r\n{\r\n $HeadNodeEdges = [];\r\n $NeighbouringEdges = [];\r\n \r\n $EdgePrimes = [];\r\n \r\n foreach ($Edges as $Index => $Edge)\r\n {\r\n for ($z = 0; $z <= 1; $z++)\r\n {\r\n $NeighbouringEdges [$Edge [$z]][] = $Index;\r\n \r\n if ($Edges [$Index][$z] == 1)\r\n {\r\n $HeadNodeEdges [] = $Index;\r\n }\r\n }\r\n }\r\n \r\n foreach ($HeadNodeEdges as $WhichWay => $h)\r\n {\r\n $CurrentEdgePrime = $WhichWay ? 3 : 2;\r\n \r\n $PrevNode = 1;\r\n $CurrentNode = 1;\r\n $CurrentEdge = $HeadNodeEdges [$WhichWay];\r\n \r\n $CurrentNode = ($Edges [$CurrentEdge][0] == $CurrentNode)\r\n ? $Edges [$CurrentEdge][1]\r\n : $Edges [$CurrentEdge][0] ;\r\n \r\n do\r\n {\r\n $EdgePrimes [$CurrentEdge] = $CurrentEdgePrime;\r\n NextPrime ($CurrentEdgePrime);\r\n \r\n $PossibleNeighbouringEdges = $NeighbouringEdges [$CurrentNode];\r\n $PossibleNextNodes = []; \r\n \r\n foreach ($PossibleNeighbouringEdges as $Edge)\r\n {\r\n $PossibleNextNodes [$Edge][] = $Edges [$Edge][0];\r\n $PossibleNextNodes [$Edge][] = $Edges [$Edge][1];\r\n }\r\n \r\n foreach ($PossibleNextNodes as $Edge => $Nodes)\r\n {\r\n foreach ($Nodes as $Node)\r\n {\r\n if ($Node != $PrevNode && $Node != $CurrentNode)\r\n { \r\n $PrevNode = $CurrentNode;\r\n $CurrentNode = $Node;\r\n $CurrentEdge = $Edge;\r\n \r\n break 2;\r\n }\r\n }\r\n }\r\n \r\n if (count ($PossibleNextNodes) == 1)\r\n {\r\n break;\r\n }\r\n \r\n } while (1);\r\n }\r\n \r\n ksort ($EdgePrimes);\r\n \r\n return $EdgePrimes;\r\n}\r\n"}], "negative_code": [{"source_code": " $c) \r\n {\r\n if ($c >= 3)\r\n {\r\n echo \"-1\\n\";\r\n continue 2;\r\n }\r\n }\r\n \r\n while (count ($branches [0]) + count ($branches [1]) <= $nv)\r\n {\r\n foreach ($input as $edge)\r\n {\r\n $from = $edge [0];\r\n $to = $edge [1];\r\n \r\n for ($br = 0; $br <= 1; $br++)\r\n {\r\n $last = count ($branches [$br]) - 1;\r\n \r\n if ($to == $branches [$br][$last]) \r\n {\r\n if (in_array ($from, $branches [$br]))\r\n {\r\n continue;\r\n }\r\n \r\n $branches [$br][] = $from;\r\n \r\n $result [] = $bPrimes [$br];\r\n \r\n NextPrime ($bPrimes [$br]);\r\n } \r\n else if ($from == $branches [$br][$last]) \r\n {\r\n if (in_array ($to, $branches [$br]))\r\n {\r\n continue;\r\n }\r\n \r\n $branches [$br][] = $to;\r\n \r\n $result [] = $bPrimes [$br];\r\n \r\n NextPrime ($bPrimes [$br]);\r\n }\r\n }\r\n }\r\n }\r\n \r\n echo implode (\" \", $result);\r\n echo \"\\n\";\r\n}"}, {"source_code": " $c) \r\n {\r\n if ($c >= 3)\r\n {\r\n echo \"-1\\n\";\r\n continue 2;\r\n }\r\n }\r\n \r\n while (count ($branches [0]) + count ($branches [1]) <= $nv - 1)\r\n {\r\n foreach ($input as $edge)\r\n {\r\n $from = $edge [0];\r\n $to = $edge [1];\r\n \r\n for ($br = 0; $br <= 1; $br++)\r\n {\r\n $last = count ($branches [$br]) - 1;\r\n \r\n if ($to == $branches [$br][$last]) \r\n {\r\n if (in_array ($from, $branches [$br]))\r\n {\r\n continue;\r\n }\r\n \r\n $branches [$br][] = $from;\r\n \r\n $result [] = $bPrimes [$br];\r\n \r\n NextPrime ($bPrimes [$br]);\r\n } \r\n else if ($from == $branches [$br][$last]) \r\n {\r\n if (in_array ($to, $branches [$br]))\r\n {\r\n continue;\r\n }\r\n \r\n $branches [$br][] = $to;\r\n \r\n $result [] = $bPrimes [$br];\r\n \r\n NextPrime ($bPrimes [$br]);\r\n }\r\n }\r\n }\r\n }\r\n \r\n echo implode (\" \", $result);\r\n echo \"\\n\";\r\n}"}, {"source_code": " $c) \r\n {\r\n if ($c >= 3)\r\n {\r\n $result = [ -1 ];\r\n break 2;\r\n }\r\n }\r\n \r\n if ($from == 1) \r\n {\r\n $result [] = $bPrimes [$whichBranch];\r\n NextPrime ($bPrimes [$whichBranch]);\r\n \r\n $branches[$whichBranch++][] = $to;\r\n \r\n continue;\r\n } \r\n else if ($to == 1) \r\n {\r\n $result [] = $bPrimes [$whichBranch];\r\n NextPrime ($bPrimes [$whichBranch]);\r\n \r\n $branches[$whichBranch++][] = $from;\r\n \r\n continue;\r\n }\r\n \r\n for ($br = 0; $br <= 1; $br++)\r\n {\r\n $last = count ($branches [$br]) - 1;\r\n \r\n if ($to == $branches [$br][$last]) \r\n {\r\n $branches[$br][] = $from;\r\n \r\n $result [] = $bPrimes[$br];\r\n NextPrime ($bPrimes [$br]);\r\n } \r\n else if ($from == $branches [$br][$last]) \r\n {\r\n $branches[$br][] = $to;\r\n \r\n $result [] = $bPrimes[$br];\r\n NextPrime ($bPrimes [$br]);\r\n }\r\n }\r\n }\r\n \r\n echo implode (\" \", $result);\r\n echo \"\\n\";\r\n}"}, {"source_code": " 0 ];\r\n $vertices = [ 1 ];\r\n $level = [\r\n 1 => 1 \r\n ];\r\n \r\n for ($v = 0; $v < $nv - 1; $v++)\r\n {\r\n list ($from, $to) = explode (' ', readline ());\r\n \r\n $connections [$from][] = $to;\r\n $connections [$to][] = $from;\r\n \r\n if (in_array ($from, $vertices)) \r\n {\r\n $vertices [] = $to;\r\n $nodes [$to] = $from;\r\n $level [$to] = 1 + $level [$from];\r\n } \r\n else \r\n {\r\n $vertices [] = $from;\r\n $nodes [$from] = $to; \r\n $level [$from] = 1 + $level [$to];\r\n }\r\n }\r\n \r\n foreach ($connections as $k => $v)\r\n {\r\n if (count ($v) >= 3)\r\n {\r\n echo \"-1\\n\";\r\n continue 2;\r\n }\r\n }\r\n \r\n foreach ($level as $k => $v)\r\n {\r\n if ($k == 1)\r\n {\r\n continue;\r\n }\r\n \r\n echo ($v % 2 != 0 ? 3 : 2) . \" \";\r\n }\r\n \r\n echo \"\\n\";\r\n }"}], "src_uid": "0639fbeb3a5be67a4c0beeffe8f5d43b"} {"nl": {"description": "Polycarp remembered the $$$2020$$$-th year, and he is happy with the arrival of the new $$$2021$$$-th year. To remember such a wonderful moment, Polycarp wants to represent the number $$$n$$$ as the sum of a certain number of $$$2020$$$ and a certain number of $$$2021$$$.For example, if: $$$n=4041$$$, then the number $$$n$$$ can be represented as the sum $$$2020 + 2021$$$; $$$n=4042$$$, then the number $$$n$$$ can be represented as the sum $$$2021 + 2021$$$; $$$n=8081$$$, then the number $$$n$$$ can be represented as the sum $$$2020 + 2020 + 2020 + 2021$$$; $$$n=8079$$$, then the number $$$n$$$ cannot be represented as the sum of the numbers $$$2020$$$ and $$$2021$$$. Help Polycarp to find out whether the number $$$n$$$ can be represented as the sum of a certain number of numbers $$$2020$$$ and a certain number of numbers $$$2021$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case contains one integer $$$n$$$ ($$$1 \\leq n \\leq 10^6$$$)\u00a0\u2014 the number that Polycarp wants to represent as the sum of the numbers $$$2020$$$ and $$$2021$$$.", "output_spec": "For each test case, output on a separate line: \"YES\" if the number $$$n$$$ is representable as the sum of a certain number of $$$2020$$$ and a certain number of $$$2021$$$; \"NO\" otherwise. You can output \"YES\" and \"NO\" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).", "sample_inputs": ["5\n1\n4041\n4042\n8081\n8079"], "sample_outputs": ["NO\nYES\nYES\nYES\nNO"], "notes": null}, "positive_code": [{"source_code": " = 2020) {\r\n for($i = 0; $i < 10000; $i ++) {\r\n $c = $n - ($b * $i);\r\n if($c < 0 ) {\r\n break; \r\n }\r\n if($c == 0 || ($c >= 2020 && $c % $a == 0)) {\r\n $res = 1;\r\n break;\r\n }\r\n }\r\n \r\n \r\n \r\n }\r\n \r\n echo $res == 1 ? \"YES\\n\" : \"NO\\n\";\r\n \r\n \r\n }"}, {"source_code": " 0)) { echo 'YES'.PHP_EOL; }\r\n else { echo 'NO'.PHP_EOL; }\r\n }\r\n }\r\n }\r\n}\r\n?>"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = $n % 2020;\r\n $r = floor($n / 2020);\r\n\r\n if ($s > $r) {\r\n IO::no();\r\n } else {\r\n IO::yes();\r\n }\r\n}\r\n"}, {"source_code": "= $d % 2020) {\r\n echo 'YES'. PHP_EOL;\r\n } else {\r\n echo 'NO'. PHP_EOL;\r\n }\r\n}"}, {"source_code": " 0) {\r\n $k = $m - (2020*$d);\r\n if ($d >= $k) {\r\n echo \"YES\\n\";\r\n } else {\r\n echo \"NO\\n\";\r\n }\r\n } else {\r\n echo \"NO\\n\";\r\n }\r\n }\r\n\r\n}"}], "negative_code": [{"source_code": "\r\n = 2020) {\r\n $c = $n - ($b * $bn);\r\n \r\n if($c == 0 || ($c >= 2020 && $c % $a == 0)) {\r\n $res = 1;\r\n }\r\n }\r\n \r\n echo $res == 1 ? \"YES\\n\" : \"NO\\n\";\r\n \r\n \r\n }"}], "src_uid": "3ec1b7027f487181dbdfb12f295f11ae"} {"nl": {"description": "Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\\cdot c=b$$$.For $$$n \\ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$$n$$$, except $$$1$$$.For example, $$$f(7)=7,f(10)=2,f(35)=5$$$.For the fixed integer $$$n$$$, Orac decided to add $$$f(n)$$$ to $$$n$$$. For example, if he had an integer $$$n=5$$$, the new value of $$$n$$$ will be equal to $$$10$$$. And if he had an integer $$$n=6$$$, $$$n$$$ will be changed to $$$8$$$.Orac loved it so much, so he decided to repeat this operation several times.Now, for two positive integers $$$n$$$ and $$$k$$$, Orac asked you to add $$$f(n)$$$ to $$$n$$$ exactly $$$k$$$ times (note that $$$n$$$ will change after each operation, so $$$f(n)$$$ may change too) and tell him the final value of $$$n$$$.For example, if Orac gives you $$$n=5$$$ and $$$k=2$$$, at first you should add $$$f(5)=5$$$ to $$$n=5$$$, so your new value of $$$n$$$ will be equal to $$$n=10$$$, after that, you should add $$$f(10)=2$$$ to $$$10$$$, so your new (and the final!) value of $$$n$$$ will be equal to $$$12$$$.Orac may ask you these queries many times.", "input_spec": "The first line of the input is a single integer $$$t\\ (1\\le t\\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\\ (2\\le n\\le 10^6, 1\\le k\\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$10^6$$$. ", "output_spec": "Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac.", "sample_inputs": ["3\n5 1\n8 2\n3 4"], "sample_outputs": ["10\n12\n12"], "notes": "NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, where the smallest one except $$$1$$$ is $$$2$$$, then after one operation $$$8$$$ turns into $$$8+(f(8)=2)=10$$$. The divisors of $$$10$$$ are $$$1,2,5,10$$$, where the smallest one except $$$1$$$ is $$$2$$$, therefore the answer is $$$10+(f(10)=2)=12$$$.In the third query, $$$n$$$ is changed as follows: $$$3 \\to 6 \\to 8 \\to 10 \\to 12$$$."}, "positive_code": [{"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}], "negative_code": [], "src_uid": "9fd9bc0a037b2948d60ac2bd5d57740f"} {"nl": {"description": "The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.The city of Tomsk can be represented as point on the plane with coordinates (0; 0). The city is surrounded with n other locations, the i-th one has coordinates (xi, yi) with the population of ki people. You can widen the city boundaries to a circle of radius r. In such case all locations inside the circle and on its border are included into the city.Your goal is to write a program that will determine the minimum radius r, to which is necessary to expand the boundaries of Tomsk, so that it becomes a megacity.", "input_spec": "The first line of the input contains two integers n and s (1\u2009\u2264\u2009n\u2009\u2264\u2009103; 1\u2009\u2264\u2009s\u2009<\u2009106) \u2014 the number of locatons around Tomsk city and the population of the city. Then n lines follow. The i-th line contains three integers \u2014 the xi and yi coordinate values of the i-th location and the number ki of people in it (1\u2009\u2264\u2009ki\u2009<\u2009106). Each coordinate is an integer and doesn't exceed 104 in its absolute value. It is guaranteed that no two locations are at the same point and no location is at point (0;\u00a00).", "output_spec": "In the output, print \"-1\" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number \u2014 the minimum radius of the circle that the city needs to expand to in order to become a megacity. The answer is considered correct if the absolute or relative error don't exceed 10\u2009-\u20096.", "sample_inputs": ["4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1", "4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1", "2 1\n1 1 999997\n2 2 1"], "sample_outputs": ["2.8284271", "1.4142136", "-1"], "notes": null}, "positive_code": [{"source_code": "= 1000000)\n{\n print \"0\";\n}\nelse\n{\n $c = array();\n $d = array();\n for($x = 0; $x < $a; $x++)\n {\n list($e, $f, $g) = explode(\" \", trim(fgets(STDIN)));\n $h = sqrt(pow($e - 0, 2) + pow($f - 0, 2));\n $c[$x] = $h;\n $d[$x] = $g;\n }\n}\nasort($c);\n$h = array_keys($c);\nsort($c);\n$i = array();\nfor($x = 0; $x < $a; $x++)\n{\n $i[$x] = $d[$h[$x]];\n}\n$j = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $b += $i[$x];\n if($b >= 1000000)\n {\n $j = 1;\n break;\n }\n}\nif($j == 0)\n{\n print \"-1\";\n}\nelse\n{\n print number_format($c[$x], 6, \".\", \"\");\n}\n?>"}], "negative_code": [], "src_uid": "bcc758394d012519f0865479b3c6770c"} {"nl": {"description": "Polycarp got an array of integers $$$a[1 \\dots n]$$$ as a gift. Now he wants to perform a certain number of operations (possibly zero) so that all elements of the array become the same (that is, to become $$$a_1=a_2=\\dots=a_n$$$). In one operation, he can take some indices in the array and increase the elements of the array at those indices by $$$1$$$.For example, let $$$a=[4,2,1,6,2]$$$. He can perform the following operation: select indices 1, 2, and 4 and increase elements of the array in those indices by $$$1$$$. As a result, in one operation, he can get a new state of the array $$$a=[5,3,1,7,2]$$$.What is the minimum number of operations it can take so that all elements of the array become equal to each other (that is, to become $$$a_1=a_2=\\dots=a_n$$$)?", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u00a0\u2014 the number of test cases in the test. The following are descriptions of the input test cases. The first line of the description of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 50$$$) \u00a0\u2014 the array $$$a$$$. The second line of the description of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u00a0\u2014 elements of the array $$$a$$$.", "output_spec": "For each test case, print one integer \u00a0\u2014 the minimum number of operations to make all elements of the array $$$a$$$ equal.", "sample_inputs": ["3\n6\n3 4 2 4 1 2\n3\n1000 1002 998\n2\n12 11"], "sample_outputs": ["3\n4\n1"], "notes": "NoteFirst test case: $$$a=[3,4,2,4,1,2]$$$ take $$$a_3, a_5$$$ and perform an operation plus one on them, as a result we get $$$a=[3,4,3,4,2,2]$$$. $$$a=[3,4,3,4,2,2]$$$ we take $$$a_1, a_5, a_6$$$ and perform an operation on them plus one, as a result we get $$$a=[4,4,3,4,3,3]$$$. $$$a=[4,4,3,4,3,3]$$$ we take $$$a_3, a_5, a_6$$$ and perform an operation on them plus one, as a result we get $$$a=[4,4,4,4,4,4]$$$. There are other sequences of $$$3$$$ operations, after the application of which all elements become equal.Second test case: $$$a=[1000,1002,998]$$$ 2 times we take $$$a_1, a_3$$$ and perform an operation plus one on them, as a result we get $$$a=[1002,1002,1000]$$$. $$$a=[1002,1002,1000]$$$ also take $$$a_3$$$ 2 times and perform an operation plus one on it, as a result we get $$$a=[1002,1002,1002]$$$. Third test case: $$$a=[12,11]$$$ take $$$a_2$$$ and perform an operation plus one on it, as a result we get $$$a=[12,12]$$$. "}, "positive_code": [{"source_code": ""}, {"source_code": " $max)\r\n $max = $list[$i];\r\n if($list[$i] < $min)\r\n $min = $list[$i];\r\n }\r\n echo $max - $min . \"\\n\";\r\n}\r\n \r\n \r\n \r\n?>"}, {"source_code": " 0; $t--) {\r\n\r\n\t$n = intval(fgets(STDIN));\r\n\t$a = array_map('intval', explode(' ', fgets(STDIN)));\r\n\r\n\techo $solve($n, $a);\r\n\techo \"\\n\";\r\n\r\n}\r\n"}], "negative_code": [], "src_uid": "cf3cfcae029a6997ee62701eda959a60"} {"nl": {"description": "DZY loves chemistry, and he enjoys mixing chemicals.DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order. Let's consider the danger of a test tube. Danger of an empty test tube is 1. And every time when DZY pours a chemical, if there are already one or more chemicals in the test tube that can react with it, the danger of the test tube will be multiplied by 2. Otherwise the danger remains as it is.Find the maximum possible danger after pouring all the chemicals one by one in optimal order.", "input_spec": "The first line contains two space-separated integers n and m . Each of the next m lines contains two space-separated integers xi and yi (1\u2009\u2264\u2009xi\u2009<\u2009yi\u2009\u2264\u2009n). These integers mean that the chemical xi will react with the chemical yi. Each pair of chemicals will appear at most once in the input. Consider all the chemicals numbered from 1 to n in some order.", "output_spec": "Print a single integer \u2014 the maximum possible danger.", "sample_inputs": ["1 0", "2 1\n1 2", "3 2\n1 2\n2 3"], "sample_outputs": ["1", "2", "4"], "notes": "NoteIn the first sample, there's only one way to pour, and the danger won't increase.In the second sample, no matter we pour the 1st chemical first, or pour the 2nd chemical first, the answer is always 2.In the third sample, there are four ways to achieve the maximum possible danger: 2-1-3, 2-3-1, 1-2-3 and 3-2-1 (that is the numbers of the chemicals in order of pouring)."}, "positive_code": [{"source_code": " $p + $t)\n {\n $g = bcmul($g, 2);\n }\n}\nprint $g;\n?>"}], "negative_code": [{"source_code": " $p + $t)\n {\n $g *= 2;\n }\n}\nprint $g;\n?>"}, {"source_code": " $p)\n {\n $g *= 2;\n }\n}\nprint $g;\n?>"}, {"source_code": " $p + $t)\n {\n $g = bcmul($g, 2);\n }\n}\nprint $g;\n?>"}], "src_uid": "c36f4bb34543476abc31fe986032122d"} {"nl": {"description": "Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string si having the same length n. We denote the beauty of the i-th string by ai. It can happen that ai is negative\u00a0\u2014 that means that Santa doesn't find this string beautiful at all.Santa Claus is crazy about palindromes. He is thinking about the following question: what is the maximum possible total beauty of a palindrome which can be obtained by concatenating some (possibly all) of the strings he has? Each present can be used at most once. Note that all strings have the same length n.Recall that a palindrome is a string that doesn't change after one reverses it.Since the empty string is a palindrome too, the answer can't be negative. Even if all ai's are negative, Santa can obtain the empty string.", "input_spec": "The first line contains two positive integers k and n divided by space and denoting the number of Santa friends and the length of every string they've presented, respectively (1\u2009\u2264\u2009k,\u2009n\u2009\u2264\u2009100\u2009000; n\u00b7k\u00a0\u2009\u2264\u2009100\u2009000). k lines follow. The i-th of them contains the string si and its beauty ai (\u2009-\u200910\u2009000\u2009\u2264\u2009ai\u2009\u2264\u200910\u2009000). The string consists of n lowercase English letters, and its beauty is integer. Some of strings may coincide. Also, equal strings can have different beauties.", "output_spec": "In the only line print the required maximum possible beauty.", "sample_inputs": ["7 3\nabb 2\naaa -3\nbba -1\nzyz -4\nabb 5\naaa 7\nxyx 4", "3 1\na 1\na 2\na 3", "2 5\nabcde 10000\nabcde 10000"], "sample_outputs": ["12", "6", "0"], "notes": "NoteIn the first example Santa can obtain abbaaaxyxaaabba by concatenating strings 5, 2, 7, 6 and 3 (in this order)."}, "positive_code": [{"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\n$u = 0;\n$w = array_sum($t);\nfor($x = 0; $x < count($s); $x++)\n{\n $v = $s[$x] - ($p + $t[$x]);\n $u = max($u, $v);\n}\nif($u > 0)\n{\n for($x = 0; $x < count($s); $x++)\n {\n $v = $s[$x] - ($p + $t[$x]);\n if($v == $u)\n {\n $p = $s[$x];\n $w -= $t[$x];\n break;\n }\n }\n $i += $w;\n}\nelse\n{\n $i += $w;\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}], "negative_code": [{"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\narsort($s);\n$u = array_keys($s);\nrsort($s);\n$v = array();\nfor($x = 0; $x < count($s); $x++)\n{\n $v[$x] = $t[$u[$x]];\n}\n$w = 0;\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n $w = max($w, $w2);\n}\n$u2 = array_sum($v);\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n if($w2 == $w)\n {\n $w3 = $p + $v[$x];\n if(($s[$x] > $w3) && (($s[$x] - $p) > $v[$x]))\n {\n $p = max($p, $w3);\n $u2 -= $v[$x]; \n }\n break;\n }\n}\n$i += $u2;\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n }\n for($x = 0; $x < $h; $x++)\n {\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n }\n $i += $p;\n if($i < 0)\n {\n print \"0\";\n }\n else\n {\n print $i;\n }\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] > ($r + $p))\n {\n $p = max($p, $o[$y]);\n break;\n }\n elseif($o[$y] <= ($r + $p))\n {\n $i += $r;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n if(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n if(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"a\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] > ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s = array();\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \" \" . $o[$y] . \" \" . $p . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\nif((a == \"b\") && (b == \"2768\"))\n{\n print $i . \" \" . $p . \"\\n\";\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n $s = array();\n $t = array();\n $u = 0;\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n { \n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0) && ($o[$y] + $o[$y + 1] > 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n break;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0) && ($o[$y] + $o[$y + 1] <= 0))\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n if($o[$y] > 0)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n }\n}\n$u = array();\nfor($x = 0; $x < count($t); $x++)\n{\n $u[$x] = $s[$x] - ($t[$x] + $p);\n}\n$v = max($u);\nif($v > 0)\n{\n for($x = 0; $x < count($u); $x++)\n {\n if($u[$x] == $v)\n {\n $w = ($t[$x] + $p) + $u[$x];\n break;\n }\n }\n $w2 = array_sum($t);\n $w2 -= $t[$x];\n $p = $w;\n $i += $w2;\n}\nelse\n{\n $w2 = array_sum($t);\n $i += $w2;\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] > ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\nif((a == \"b\") && (b == \"2768\"))\n{\n print $i . \" \" . $p . \"\\n\";\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\narsort($s);\n$u = array_keys($s);\nrsort($s);\n$v = array();\nfor($x = 0; $x < count($s); $x++)\n{\n $v[$x] = $t[$u[$x]];\n}\n$w = 0;\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n $w = max($w, $w2);\n}\n$u2 = array_sum($v);\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n if($w2 == $w)\n {\n $w3 = $p + $v[$x];\n if($s[$x] > $w3)\n {\n $p = max($p, $w3);\n $u2 -= $v[$x]; \n }\n break;\n }\n}\n$i += $u2;\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if((a == \"b\") && (b == \"2768\"))\n {\n if($r > 0)\n {\n $i += $r;\n }\n }\n elseif(($o[$y] >= ($r + $p)) && ($o[$y] >= 0))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \" \" . $o[$y] . \" \" . $p . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\nif((a == \"b\") && (b == \"2768\"))\n{\n print $i . \" \" . $p . \"\\n\";\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\narsort($s);\n$u = array_keys($s);\nrsort($s);\n$v = array();\nfor($x = 0; $x < count($s); $x++)\n{\n $v[$x] = $t[$u[$x]];\n}\n$w = 0;\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n $w = max($w, $w2);\n}\n$u2 = array_sum($v);\nfor($x = 0; $x < count($s); $x++)\n{\n $w2 = $s[$x] - $v[$x];\n if($w2 == $w)\n {\n $w3 = $p + $v[$x];\n if($s[$x] >= $w3)\n {\n $p = max($p, $w3);\n $u2 -= $v[$x]; \n }\n break;\n }\n}\n$i += $u2;\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\nif((a == \"b\") && (b == \"2768\"))\n{\n print $i . \" \" . $p . \"\\n\";\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n }\n for($x = 0; $x < $h; $x++)\n {\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n }\n $i += $p;\n if($i < 0)\n {\n print \"0\";\n }\n else\n {\n print $i;\n }\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(($a == 33333) && ($b ==3))\n {\n print $r . \"\\n\";\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\n$u = 0;\n$w = array_sum($t);\nfor($x = 0; $x < count($s); $x++)\n{\n $v = $s[$x] - ($p + $t[$x]);\n $u = max($u, $v);\n}\nif($u >= 0)\n{\n for($x = 0; $x < count($s); $x++)\n {\n $v = $s[$x] - ($p + $t[$x]);\n if($v == $u)\n {\n $p = $s[$x];\n $w -= $v[$x];\n break;\n }\n }\n $i += $w;\n}\nelse\n{\n $i += $w;\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n $p = max($p, $o[$y]);\n break;\n }\n elseif($o[$y] < ($r + $p))\n {\n $i += $r;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n if(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n if($r > 0)\n {\n $s[0] = $r;\n }\n else\n {\n $s = array();\n }\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 0)\n {\n $i += $r;\n }\n else\n {\n if($o[$y + 2] == TRUE)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif($o[$y] == TRUE)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n else\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $i += $r;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if(($o[$y] >= ($r + $p)) && ($o[$y] >= 0))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \" \" . $o[$y] . \" \" . $p . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\nif((a == \"b\") && (b == \"2768\"))\n{\n print $i . \" \" . $p . \"\\n\";\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r >= 0)\n {\n $i += $r;\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(($a == 33333) && ($b ==3))\n {\n print \"1\\n\";\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] > ($r + $p))\n {\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n if(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[0] > 0) && ($o[1] >= 0))\n {\n $r = $o[0] + $o[1];\n $i += $r;\n }\n elseif(($o[0] > 0) && ($o[1] < 0))\n {\n $r = $o[0] + $o[1];\n if($r >= 0)\n {\n $i += $r;\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[0]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s = array();\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n $p = max($p, $o[$y]);\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n $p = max($p, $o[$y]);\n }\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if((a == \"b\") && (b == \"2768\"))\n {\n print $r . \"\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n elseif($r > 0)\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(count($s) == 0)\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n $s[0] = $r;\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n }\n for($x = 0; $x < $h; $x++)\n {\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n }\n $i += $p;\n if($i < 0)\n {\n print \"0\";\n }\n else\n {\n print $i;\n }\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0))\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n }\n else\n {\n $p = max($p, $o[$y]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\n$u = 0;\n$w = array_sum($t);\nfor($x = 0; $x < count($s); $x++)\n{\n $v = $s[$x] - ($p + $t[$x]);\n $u = max($u, $v);\n}\nif($u > 0)\n{\n for($x = 0; $x < count($s); $x++)\n {\n $v = $s[$x] - ($p + $t[$x]);\n if($v == $u)\n {\n $p = $s[$x];\n $w -= $v[$x];\n break;\n }\n }\n $i += $w;\n}\nelse\n{\n $i += $w;\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n $s = array();\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n for($y = 0; $y < count($o); $y += 2)\n {\n if(count($o) >= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($o[$y] >= ($r + $p))\n {\n if(($a == 99999) && ($b == 1))\n {\n print \"$r\\n\";\n }\n if((count($s) == 0) && ($r > 0))\n {\n $s[0] = $r;\n }\n else\n {\n $i += $s[0];\n if($r > 0)\n {\n $s[0] = $r;\n }\n else\n {\n $s = array();\n }\n }\n $p = max($p, $o[$y]);\n break;\n }\n elseif($r > 0)\n {\n $i += $r;\n }\n else\n {\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": " 1)\n {\n rsort($o);\n $s = array();\n $t = array();\n $u = 0;\n for($y = 0; $y < count($o); $y += 2)\n {\n if(($o[$y] > 0) && ($o[$y + 1] >= 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $i += $r;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0) && ($o[$y] + $o[$y + 1] > 0))\n {\n $r = $o[$y] + $o[$y + 1];\n $s[$u] = $o[$y];\n $t[$u] = $r;\n $u++;\n break;\n }\n elseif(($o[$y] > 0) && ($o[$y + 1] < 0) && ($o[$y] + $o[$y + 1] <= 0))\n {\n $p = max($p, $o[$y]);\n break;\n }\n }\n }\n }\n }\n}\n$u = array();\nfor($x = 0; $x < count($t); $x++)\n{\n $u[$x] = $s[$x] - ($t[$x] + $p);\n}\n$v = max($u);\nif($v > 0)\n{\n for($x = 0; $x < count($u); $x++)\n {\n if($u[$x] == $v)\n {\n $w = ($t[$x] + $p) + $u[$x];\n break;\n }\n }\n $w2 = array_sum($t);\n $w2 -= $t[$x];\n $p = $w;\n $i += $w2;\n}\nelse\n{\n $w2 = array_sum($t);\n $i += $w2;\n}\nfor($x = 0; $x < $h; $x++)\n{\n $j = $c[$g[$x]];\n if(count($j) == 2)\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}, {"source_code": "= $y + 2)\n {\n $r = $o[$y] + $o[$y + 1];\n if($r > 0)\n {\n $i += $r;\n }\n else\n {\n if(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y + 2]);\n }\n break;\n }\n }\n elseif(count($o) >= $y + 1)\n {\n $p = max($p, $o[$y]);\n }\n }\n }\n }\n }\n else\n {\n $k = $j[0];\n $l = $j[1];\n $m = min(count($k), count($l));\n rsort($k);\n rsort($l);\n for($y = 0; $y < $m; $y++)\n {\n $n = $k[$y] + $l[$y];\n if($n > 0)\n {\n $i += $n;\n }\n else\n {\n break;\n }\n }\n }\n}\n$i += $p;\nif($i < 0)\n{\n print \"0\";\n}\nelse\n{\n print $i;\n}\n?>"}], "src_uid": "71fbc176f2022365fc10d934807651ab"} {"nl": {"description": "A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground.By the military charter the soldiers should stand in the order of non-increasing of their height. But as there's virtually no time to do that, the soldiers lined up in the arbitrary order. However, the general is rather short-sighted and he thinks that the soldiers lined up correctly if the first soldier in the line has the maximum height and the last soldier has the minimum height. Please note that the way other solders are positioned does not matter, including the case when there are several soldiers whose height is maximum or minimum. Only the heights of the first and the last soldier are important.For example, the general considers the sequence of heights (4, 3, 4, 2, 1, 1) correct and the sequence (4, 3, 1, 2, 2) wrong.Within one second the colonel can swap any two neighboring soldiers. Help him count the minimum time needed to form a line-up which the general will consider correct.", "input_spec": "The first input line contains the only integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009100) which represents the number of soldiers in the line. The second line contains integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009100) the values of the soldiers' heights in the order of soldiers' heights' increasing in the order from the beginning of the line to its end. The numbers are space-separated. Numbers a1,\u2009a2,\u2009...,\u2009an are not necessarily different.", "output_spec": "Print the only integer \u2014 the minimum number of seconds the colonel will need to form a line-up the general will like.", "sample_inputs": ["4\n33 44 11 22", "7\n10 10 58 31 63 40 76"], "sample_outputs": ["2", "10"], "notes": "NoteIn the first sample the colonel will need to swap the first and second soldier and then the third and fourth soldier. That will take 2 seconds. The resulting position of the soldiers is (44, 33, 22, 11).In the second sample the colonel may swap the soldiers in the following sequence: (10, 10, 58, 31, 63, 40, 76) (10, 58, 10, 31, 63, 40, 76) (10, 58, 10, 31, 63, 76, 40) (10, 58, 10, 31, 76, 63, 40) (10, 58, 31, 10, 76, 63, 40) (10, 58, 31, 76, 10, 63, 40) (10, 58, 31, 76, 63, 10, 40) (10, 58, 76, 31, 63, 10, 40) (10, 76, 58, 31, 63, 10, 40) (76, 10, 58, 31, 63, 10, 40) (76, 10, 58, 31, 63, 40, 10) "}, "positive_code": [{"source_code": "= 1; $x--)\n{\n if($b[$x] == $c[count($c) - 1])\n {\n $e = $x;\n break;\n }\n}\n$f = array_unique($b);\nif(count($f) == 1)\n{\n print \"0\"; \n}\nelseif($e < $d)\n{\n print $d - 1 + (count($b) - $e) - 1;\n}\nelse\n{\n print $d - 1 + (count($b) - $e);\n}\n?>"}, {"source_code": " $max) { $max = $soldiers[$i]; $maxPos = $i; }\n\t\tif ($soldiers[$i] <= $min) { $min = $soldiers[$i]; $minPos = $i; }\n\t}\n\tif ($minPos > $maxPos) echo (((sizeof($soldiers) - 1) - $minPos) + $maxPos) . \"\\n\";\n\telse if ($minPos < $maxPos) echo (((sizeof($soldiers) - 1) - $minPos) + $maxPos) - 1 . \"\\n\";\n\telse echo 0 . \"\\n\";\n?>"}, {"source_code": " 0; $i--) {\n swap($arr[$i], $arr[$i - 1]);\n $ans++;\n }\n for ($i = $n - 1 ; $i > 0; $i--){\n if ($min_elem > $arr[$i]) {\n $min_elem = $arr[$i];\n $id2 = $i;\n } \n }\n for ($i = $id2; $i < $n - 1; $i++) {\n swap($arr[$i + 1], $arr[$i]);\n $ans++;\n }\n echo $ans;\n "}, {"source_code": "$min) $sek--;\necho $sek;\n?>"}, {"source_code": " $may) {\n $may = $t;\n $i_may = $i;\n }\n if($t <= $men) {\n $men = $t;\n $i_men = $i;\n }\n $i++;\n }\n //print \"$n \" . \"$i_may \" . \"$i_men\\n\";\n if($i_men > $i_may) print $i_may + $n - 1 - $i_men;\n else print $i_may + $n - $i_men - 2;\n?>\n"}, {"source_code": " $max_h){\n $max_h = $squad[$i];\n $max_h_i = $i;\n }\n if($squad[$i] <= $min_h){\n $min_h =$squad[$i];\n $min_h_i = $i;\n }\n}\nif($max_h_i == $min_h_i){\n echo 0;\n}elseif($max_h_i > $min_h_i){\n echo $max_h_i + $n - $min_h_i - 2;\n}else{\n echo $max_h_i + $n - $min_h_i -1;\n}\necho PHP_EOL;\n"}, {"source_code": "-1;$i--)\n{\n if($column[$i]>=$max)\n {\n $max=$column[$i];\n $m=$i;\n }\n}\n$d=$m+(count($column)-1-$n);\nif ($m>$n)echo $d-1;\nelse echo $d;"}, {"source_code": " $str[$i + 1]) {\n $buf = $str[$i + 1];\n $str[$i + 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n $max = $str[count($str)-1];\n $buf = 0;\nfor ($i = count($str)-1; $i >= 0; $i--) {\n if ($str[$i] < $str[$i - 1]) {\n $buf = $str[$i - 1];\n $str[$i - 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n$min = $str[0];\nfor ($i = count($str2)-1; $i >=0 ; $i--) {\n if ($str2[$i] == $max) {\n $max_position = $i;\n }\n}\n\nfor ($i = 0; $i < count($str2) ; $i++) {\n if ($str2[$i] == $min) {\n $min_position = $i;\n }\n}\n\nif ($max_position < $min_position) {\n $reshuffle = $max_position + count($str2)-1-$min_position; \n} else {\n $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;\n}\n\nprint($reshuffle);"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n $nowMid = (int)($solder[$i]);\n $nowHead = (int)($solder[$endIndex]);\n \n if( $nowMid > $maxNumber )\n {\n $maxNumber = $nowMid;\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $nowHead < $minNumber )\n {\n $minNumber = $nowHead;\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n echo ($maxStep + $minStep - 1);\n} else {\n echo ($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho 'max ' . $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho 'min ' . $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": " $min) {$ret--;} \n\techo $ret;\n?>"}, {"source_code": ""}, {"source_code": " $min) {$r--;} \necho $r;"}, {"source_code": " &$value) {\n $value = (int) $value;\n if ($value > $max) {\n $max = $value;\n $nmax = $key;\n }\n if ($value <= $min) {\n $min = $value;\n $nmin = $key;\n }\n}\n\nif ($nmax < $nmin) {\n echo $nmax + $n - $nmin - 1;\n} else {\n echo $nmax + $n - $nmin - 2;\n}\n\n?>"}, {"source_code": "=$b[$i]) $min=$i; \n } \n if ($max>$min) print($max-$min+$a-2); else print($max-$min+$a-1);\n?>"}, {"source_code": "$min ) { $step--;} \n echo $step;\n\n \n?>"}, {"source_code": " $max) {\n $max = $arr[$i];\n $pos['max'] = $i + 1;\n }\n if (intVal($arr[$i]) <= $min) {\n $min = $arr[$i];\n $pos['min'] = $i + 1;\n }\n }\n return $pos;\n}\n\nfscanf(STDIN, '%d', $n);\n$in = explode(' ', fgets(STDIN));\n\n$arr = findMaxMinAndPos($in, $n);\n//print_r($arr);\n\n$wynik = ($arr['min'] > $arr['max']) ? $arr['max'] - 1 + $n - $arr['min'] : $arr['max'] - 1 + $n - $arr['min'] - 1;\n\necho $wynik;\n\n"}, {"source_code": " $max) {$imax = $i; $max = $a[$i];}\n}\n\n\nprint ($imin < $imax) ? $imax + $n - $imin - 2 : $imax + $n - $imin - 1;\n?>"}, {"source_code": "= $arr_items[ $i ] ){\n\t\t\t$min_index = $i;\n\t\t\t$min = $arr_items[ $i ];\n\t\t}\n\t\n\t\tif( $max < $arr_items[ $i ] ){\n\t\t\t$max_index = $i;\n\t\t\t$max = $arr_items[ $i ];\n\t\t}\n\t}\n\t\n//echo \"\\n min=$min min_index=$min_index\";\t\n//echo \"\\n max=$max max_index=$max_index\";\t\n\t\n\t\n\t\n\tif ( $min_index < $max_index ) {\n\t\t$result = count( $arr_items ) - $min_index + $max_index - 2;\n\t} else {\n\t\t$result = count( $arr_items ) - $min_index + $max_index -1;\n\t}\t\t\n\t\n//\techo \"\\n\\n result is \" . $result;\n\n\necho $result;\t\n\t\n\t\n//echo \"\\n\\n\\n\";\n//print_r( $num_items );\n\t\n//echo \"\\n\\n\\n\";\n//print_r( $arr_items );\n\t\n\t\n\t\n\t\n\t\n\t\n//echo \"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\";"}, {"source_code": "= $arr_items[ $i ] ){\n\t\t\t$min_index = $i;\n\t\t\t$min = $arr_items[ $i ];\n\t\t}\n\t\n\t\tif( $max < $arr_items[ $i ] ){\n\t\t\t$max_index = $i;\n\t\t\t$max = $arr_items[ $i ];\n\t\t}\n\t}\n\t\n//echo \"\\n min=$min min_index=$min_index\";\t\n//echo \"\\n max=$max max_index=$max_index\";\t\n\t\n\t\n\t\n\tif ( $min_index < $max_index ) {\n\t\t$result = count( $arr_items ) - $min_index + $max_index - 2;\n\t} else {\n\t\t$result = count( $arr_items ) - $min_index + $max_index -1;\n\t}\t\t\n\t\n//\techo \"\\n\\n result is \" . $result;\n\n\necho $result;\t\n\t\n\t\n//echo \"\\n\\n\\n\";\n//print_r( $num_items );\n\t\n//echo \"\\n\\n\\n\";\n//print_r( $arr_items );\n\t\n\t\n\t\n\t\n\t\n\t\n//echo \"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\";"}, {"source_code": " $shortest) {\n $movetall = $tallest;\n $shortest++;\n $moveshort = count($line) - 1 - $shortest;\n} else {\n $movetall = $tallest;\n $moveshort = count($line) - 1 - $shortest;\n}\necho $movetall + $moveshort;\n?>"}], "negative_code": [{"source_code": "$min) $sek--;\necho $sek;\n?>"}, {"source_code": "$min) $sek--;\necho $sek;\n?>\n"}, {"source_code": "=$max){$max=$column[$i];$m=$i;};\n if($column[$i]<=$min){$min=$column[$i];$n=$i;};\n}\n$d=$m+(count($column)-1-$n);\nif ($m>$n)echo $d-1;\nelse echo $d;\n"}, {"source_code": " $str[$i + 1]) {\n $buf = $str[$i + 1];\n $str[$i + 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n $max = $str[count($str)-1];\n $buf = 0;\nfor ($i = count($str)-1; $i >= 0; $i--) {\n if ($str[$i] < $str[$i - 1]) {\n $buf = $str[$i - 1];\n $str[$i - 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n$min = $str[0];\nfor ($i = count($str2)-1; $i >=0 ; $i--) {\n if ($str2[$i] == $max) {\n $max_position = $i;\n }\n}\n\nfor ($i = 0; $i < count($str2) ; $i++) {\n if ($str2[$i] == $min) {\n $min_position = $i;\n }\n}\n\nif ($max_position < $min_position) {\n $reshuffle = $max_position + count($str2)-1-$min_position; \n} else {\n $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;\n}\n\nprint($reshuffle);"}, {"source_code": " $str[$i + 1]) {\n $buf = $str[$i + 1];\n $str[$i + 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n $max = $str[count($str)-1];\n $buf = 0;\necho \" max = \" . $max;\nfor ($i = count($str)-1; $i >= 0; $i--) {\n if ($str[$i] < $str[$i - 1]) {\n $buf = $str[$i - 1];\n $str[$i - 1] = $str[$i];\n $str[$i] = $buf;\n } \n}\n$min = $str[0];\necho \" min = \" . $min;\nfor ($i = count($str2)-1; $i >=0 ; $i--) {\n if ($str2[$i] == $max) {\n $max_position = $i;\n }\n}\n\nfor ($i = 0; $i < count($str2) ; $i++) {\n if ($str2[$i] == $min) {\n $min_position = $i;\n }\n}\n\nif ($max_position < $min_position) {\n $reshuffle = $max_position + count($str2)-1-$min_position; \n} else {\n $reshuffle = ($max_position + count($str2)-1-$min_position) - 1;\n}\n\nprint($reshuffle);"}, {"source_code": "error_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n print (int)($maxStep + $minStep - 1);\n} else {\n print (int)($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n $nowMid = (int)($solder[$i]);\n $nowHead = (int)($solder[$endIndex]);\n \n if( $nowMid > $maxNumber )\n {\n $maxNumber = $nowMid;\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $nowHead < $minNumber )\n {\n $minNumber = $nowHead;\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n echo ($maxStep + $minStep - 1);\n} else {\n echo ($maxStep + $minStep);\n}\n\necho \"result \\n\";\necho 'max ' . $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho 'min ' . $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n\nfclose($fp);\n?>"}, {"source_code": "\ufeff\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n echo ($maxStep + $minStep - 1);\n} else {\n echo ($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": "\ufeff\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\necho \"2\";\ndie();\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n print (int)($maxStep + $minStep - 1);\n} else {\n print (int)($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n print (int)($maxStep + $minStep - 1);\n} else {\n print (int)($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": "\ufeff\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n echo (int)($maxStep + $minStep - 1);\n} else {\n echo (int)($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": "\ufeff\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = fgets($fp);\n$solder = explode(\" \", fgets($fp));\n\n$maxNumber = -1;\n$minNumber = 1000;\n$maxIndex = -1;\n$minIndex = -1;\n$maxStep = -1;\n$minStep = -1;\n\n$i = 0;\nwhile( $i < $count )\n{\n $endIndex = $count - $i - 1;\n if( $solder[$i] > $maxNumber )\n {\n $maxNumber = $solder[$i];\n $maxIndex = $i;\n $maxStep = $i;\n }\n \n if( $solder[$endIndex] < $minNumber )\n {\n $minNumber = $solder[$endIndex];\n $minIndex = $endIndex;\n $minStep = $i;\n }\n \n $i++;\n}\nif( $maxIndex > $minIndex )\n{\n print (int)($maxStep + $minStep - 1);\n} else {\n print (int)($maxStep + $minStep);\n}\n/*\necho \"result \\n\";\necho $maxNumber . ' - ' . $maxIndex . ' ' . $maxStep . \"\\n\";\necho $minNumber . ' - ' . $minIndex . ' ' . $minStep . \"\\n\";\n*/\nfclose($fp);\n?>"}, {"source_code": "max(array_keys($result, min($result))) ) { $step = $step-1;} \n echo $step;\n\n?>"}, {"source_code": "$kmin ) { $step = $step-1;} \n print_r ( $step);\n }\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n print_r ( $step);\n\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n unset($key_min, $key_max);\n echo $step;\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n print_r ( $step);\n\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n print_r ( $step);\n\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n print_r ( $step);\n// }\n// else {\n// echo \"0!\"; \n// }\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n $step = $step-1+1;\n print_r ( $step);\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n echo $step;\n }\n \n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n \n echo $step;\n\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n echo $step;\n\n\n?>"}, {"source_code": "$key_min ) { $step_min = $step_min-1;} \n $step_all = $step_max+$step_min;\n \n// for ($i = 0; $i < $step_all; $i++) \n// {\n// if (!isset($key)) {$key = $key_max; $check = false;}\n// if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; } \n// if ( $result[0] ==$max AND $result[$n-1]==$min ) { break; }\n// if ( $check == true ){$next = $key+1; } else { $next = $key-1; }\n// $change = $result[$next];\n// $result[$next] = $result[$key];\n// $result[$key] = $change;\n// $key = $next;\n// }\n echo $step_all;\n\n\n?>"}, {"source_code": "$key_min ) { $step_min = $step_min-1;} \n $step_all = $step_max+$step_min;\n for ($i = 0; $i < $step_all; $i++) \n {\n if (!isset($key)) {$key = $key_max; $check = false;}\n if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; } \n if ( $result[0] ==$max AND $result[$n-1]==$min ) { break; }\n if ( $check == true ){$next = $key+1; } else { $next = $key-1; }\n $change = $result[$next];\n $result[$next] = $result[$key];\n $result[$key] = $change;\n $key = $next;\n }\n echo $step_all;\n\n\n?>"}, {"source_code": "$min ) $step--; \n echo $step;\n \n?>"}, {"source_code": "$key_min ) { $step_min = $step_min-1;} \n $step_all = $step_max+$step_min;\n for ($i = 0; $i < $step_all; $i++) \n {\n if (!isset($key)) {$key = $key_max; $check = false;}\n if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; } \n if ( $result[0] ==$max AND $result[$n-1]==$min ) { break; }\n if ( $check == true ){$next = $key+1; } else { $next = $key-1; }\n $change = $result[$next];\n $result[$next] = $result[$key];\n $result[$key] = $change;\n $key = $next;\n }\n echo $step_all;\n\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n var_dump ($step, $max, $min);\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n echo sprintf('%.0f', $step);\n\n?>"}, {"source_code": "$min ) $step--; \n echo $step;\n \n?>"}, {"source_code": "$key_min ) { $step_min = $step_min-1;} \n $step_all = $step_max+$step_min;\n echo $step_all;\n\n\n?>"}, {"source_code": "$key_min ) { $step_min = $step_min-1;} \n $step_all = $step_max+$step_min;\n for ($i = 0; $i < $step_all; $i++) \n {\n if (!isset($key)) {$key = $key_max; $check = false;}\n if ($key == 0 AND $check == false) { $key = array_search($min, $result); $check = true; } \n if ( $result[0] ==$max AND $result[$n-1]==$min ) { break; }\n if ( $check == true ){$next = $key+1; } else { $next = $key-1; }\n $change = $result[$next];\n $result[$next] = $result[$key];\n $result[$key] = $change;\n $key = $next;\n }\n echo $step_all;\n\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n print_r ( $step);\n\n?>"}, {"source_code": "$kmin ) { $step = $step-1;} \n print_r ( $step);\n }\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n echo $step;\n\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n print_r ( $step);\n }\n else {\n echo \"0\"; \n }\n?>"}, {"source_code": "$key_min ) { $step = $step-1;} \n var_dump($step);\n //echo $step;\n\n?>"}, {"source_code": "$min ) { $step = $step-1;} \n echo $step;\n }\n else {echo \"0\"; }\n \n \n?>"}], "src_uid": "ef9ff63d225811868e786e800ce49c92"} {"nl": {"description": "There are n student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes.The schedule on Monday is known for each group, i. e. time slots when group will have classes are known.Your task is to determine the minimum number of rooms needed to hold classes for all groups on Monday. Note that one room can hold at most one group class in a single time slot.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of groups. Each of the following n lines contains a sequence consisting of 7 zeroes and ones \u2014 the schedule of classes on Monday for a group. If the symbol in a position equals to 1 then the group has class in the corresponding time slot. In the other case, the group has no class in the corresponding time slot.", "output_spec": "Print minimum number of rooms needed to hold all groups classes on Monday.", "sample_inputs": ["2\n0101010\n1010101", "3\n0101011\n0011001\n0110111"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first example one room is enough. It will be occupied in each of the seven time slot by the first group or by the second group.In the second example three rooms is enough, because in the seventh time slot all three groups have classes."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $xi; $i--) {\n if ((($i > $yi) || ($i > $xi && $i < $yi)) && $digit[$i] === '1') {\n $result++;\n } elseif($i === $yi && $digit[$i] === '0') {\n $result++;\n }\n}\n\necho $result;\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": "= 0; $x--)\n{\n if($g[$x] != $d[strlen($d) - $i])\n {\n $h++;\n }\n $i++;\n}\nprint $h;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $n-$x; $i--) {\n if ($s[$i] == 1){\n $count++;\n }\n }\n \n if($s[$n-$y] == 1) {\n $count--; \n } \n \n echo $count;\n\n?>"}, {"source_code": "= 0; $i--) {\n if($s[$i] == 0) {\n $s[$i] = 1;\n } else {\n $s[$i] = 0;\n }\n $iteration++;\n if ( bcmod ($s,bcpow(10, $x)) == bcpow (10, $y)) {\n echo $iteration;\n exit;\n }\n }\n \n \n?>"}, {"source_code": "\n = 0; $i--) {\n if($s[$i] == 0) {\n $s[$i] = 1;\n } else {\n $s[$i] = 0;\n }\n $iteration++;\n if ( bcmod ($s,bcpow(10, $x)) == bcpow (10, $y)) {\n echo $iteration;\n exit;\n }\n }\n \n \n?>"}], "src_uid": "075988685fa3f9b20bd215037c504a4f"} {"nl": {"description": "One day Ms Swan bought an orange in a shop. The orange consisted of n\u00b7k segments, numbered with integers from 1 to n\u00b7k. There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote the number of the segment that he would like to get: the i-th (1\u2009\u2264\u2009i\u2009\u2264\u2009k) child wrote the number ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009n\u00b7k). All numbers ai accidentally turned out to be different.Now the children wonder, how to divide the orange so as to meet these conditions: each child gets exactly n orange segments; the i-th child gets the segment with number ai for sure; no segment goes to two children simultaneously. Help the children, divide the orange and fulfill the requirements, described above.", "input_spec": "The first line contains two integers n, k (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u200930). The second line contains k space-separated integers a1,\u2009a2,\u2009...,\u2009ak (1\u2009\u2264\u2009ai\u2009\u2264\u2009n\u00b7k), where ai is the number of the orange segment that the i-th child would like to get. It is guaranteed that all numbers ai are distinct.", "output_spec": "Print exactly n\u00b7k distinct integers. The first n integers represent the indexes of the segments the first child will get, the second n integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces. You can print a child's segment indexes in any order. It is guaranteed that the answer always exists. If there are multiple correct answers, print any of them.", "sample_inputs": ["2 2\n4 1", "3 1\n2"], "sample_outputs": ["2 4 \n1 3", "3 2 1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n\n"}, {"source_code": ""}], "negative_code": [], "src_uid": "928f18ee5dbf44364c0d578f4317944c"} {"nl": {"description": "Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle a.Will the robot be able to build the fence Emuskald wants? In other words, is there a regular polygon which angles are equal to a?", "input_spec": "The first line of input contains an integer t (0\u2009<\u2009t\u2009<\u2009180) \u2014 the number of tests. Each of the following t lines contains a single integer a (0\u2009<\u2009a\u2009<\u2009180) \u2014 the angle the robot can make corners at measured in degrees.", "output_spec": "For each test, output on a single line \"YES\" (without quotes), if the robot can build a fence Emuskald wants, and \"NO\" (without quotes), if it is impossible.", "sample_inputs": ["3\n30\n60\n90"], "sample_outputs": ["NO\nYES\nYES"], "notes": "NoteIn the first test case, it is impossible to build the fence, since there is no regular polygon with angle .In the second test case, the fence is a regular triangle, and in the last test case \u2014 a square."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "180*($j-2)) $j++;\n\tif ($a*$j==180*($j-2)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": "// BismiLahi Rahmani Rahim ?>\n\n"}, {"source_code": "0){\n$n = trim(fgets(STDIN));\nif(is_integer((360/(180-$n)))){\necho \"YES\".PHP_EOL;}\nelse{ echo \"NO\".PHP_EOL;}\n$var--;\n}"}, {"source_code": "0){\n $a=trim(fgets(STDIN));\n $b=180-$a;\n if(360%$b==0)\n print \"YES\\n\";\n else {\n print \"NO\\n\";\n }\n}\n?>\n"}, {"source_code": "0){\n\t$n=trim(fgets(STDIN));\n\tif(is_integer(360/(180-$n))){\n\t\techo \"YES\";\n\t}\n\telse echo \"NO\";\n\techo PHP_EOL;\n\t$t--;\n}\n?>\n"}, {"source_code": ""}], "negative_code": [{"source_code": "180*($j-2)) $j++;\n\tif ($a*$j==180*($j-2)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"
\";\n}\n?>"}, {"source_code": "180*($j-2)) $j++;\n\tif ($a*$j==180*($j-2)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"
\";\n}\n?>"}, {"source_code": ""}, {"source_code": "0){\n$n = trim(fgets(STDIN));\nif(is_integer((360/(180-$n)))){\necho \"YES\";}\nelse{ echo \"NO\";}\n$var--;\n}"}, {"source_code": "0){\n $a=trim(fgets(STDIN));\n if($a>=60)\n echo \"YES\\n\";\n else {\n echo \"NO\\n\";\n }\n}\n?>\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "9037f487a426ead347baa803955b2c00"} {"nl": {"description": "You are given $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$. You choose any subset of the given numbers (possibly, none or all numbers) and negate these numbers (i.\u00a0e. change $$$x \\to (-x)$$$). What is the maximum number of different values in the array you can achieve?", "input_spec": "The first line of input contains one integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$): the number of test cases. The next lines contain the description of the $$$t$$$ test cases, two lines per a test case. In the first line you are given one integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$): the number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$-100 \\leq a_i \\leq 100$$$).", "output_spec": "For each test case, print one integer: the maximum number of different elements in the array that you can achieve negating numbers in the array.", "sample_inputs": ["3\n4\n1 1 2 2\n3\n1 2 3\n2\n0 0"], "sample_outputs": ["4\n3\n1"], "notes": "NoteIn the first example we can, for example, negate the first and the last numbers, achieving the array $$$[-1, 1, 2, -2]$$$ with four different values.In the second example all three numbers are already different.In the third example negation does not change anything."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1))\n {\n $h = 1;\n }\n elseif($e[$d[$x]] == FALSE)\n {\n $h = 2;\n break;\n }\n}\nif($h == 0)\n{\n print \"Possible\\n\";\n print implode(\" \", $g);\n}\nelseif($h == 1)\n{\n print \"Ambiguity\";\n}\nelseif($h == 2)\n{\n print \"Impossible\";\n}\n?>"}], "negative_code": [{"source_code": " 1))\n {\n $h = 1;\n break;\n }\n elseif($e[$d[$x]] == FALSE)\n {\n $h = 2;\n break;\n }\n}\nif($h == 0)\n{\n print \"Possible\\n\";\n print implode(\" \", $g);\n}\nelseif($h == 1)\n{\n print \"Ambiguity\";\n}\nelseif($h == 2)\n{\n print \"Impossible\";\n}\n?>"}], "src_uid": "468e8a14dbdca471f143f59b945508d0"} {"nl": {"description": "One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.Alex has grown up since then, so he easily wins the most difficult levels. This quickly bored him, and he thought: what if the computer gave him invalid fields in the childhood and Alex could not win because of it?He needs your help to check it.A Minesweeper field is a rectangle $$$n \\times m$$$, where each cell is either empty, or contains a digit from $$$1$$$ to $$$8$$$, or a bomb. The field is valid if for each cell: if there is a digit $$$k$$$ in the cell, then exactly $$$k$$$ neighboring cells have bombs. if the cell is empty, then all neighboring cells have no bombs. Two cells are neighbors if they have a common side or a corner (i.\u00a0e. a cell has at most $$$8$$$ neighboring cells).", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 100$$$) \u2014 the sizes of the field. The next $$$n$$$ lines contain the description of the field. Each line contains $$$m$$$ characters, each of them is \".\" (if this cell is empty), \"*\" (if there is bomb in this cell), or a digit from $$$1$$$ to $$$8$$$, inclusive.", "output_spec": "Print \"YES\", if the field is valid and \"NO\" otherwise. You can choose the case (lower or upper) for each letter arbitrarily.", "sample_inputs": ["3 3\n111\n1*1\n111", "2 4\n*.*.\n1211"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the second example the answer is \"NO\" because, if the positions of the bombs are preserved, the first line of the field should be *2*1.You can read more about Minesweeper in Wikipedia's article."}, "positive_code": [{"source_code": ""}, {"source_code": " $cols) {\n\n foreach ($cols as $col) {\n\n $numCount = 0;\n\n for ($i = -1; $i < 2; $i++) {\n\n for ($j = -1; $j < 2; $j++) {\n\n if ($i != 0 || $j != 0) {\n\n if (isset($field[$row + $i][$col + $j])) {\n\n $val = $field[$row + $i][$col + $j];\n\n if ($val == '.' || ($val != '*' && $val == 0)) {\n\n $result = 'NO';\n break;\n } elseif ($val != '*') {\n\n $numCount++;\n $field[$row + $i][$col + $j]--;\n $totalSum--;\n }\n }\n }\n }\n }\n }\n\n if ($result == 'NO') {\n break;\n }\n}\n\nif ($totalSum != 0) {\n $result = 'NO';\n}\n\necho $result;\n\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $cols) {\n\n foreach ($cols as $col) {\n\n $numCount = 0;\n\n for ($i = -1; $i < 2; $i++) {\n\n for ($j = -1; $j < 2; $j++) {\n\n if ($i != 0 || $j != 0) {\n\n if (isset($field[$row + $i][$col + $j])) {\n\n $val = $field[$row + $i][$col + $j];\n\n if ($val == '.' || ($val != '*' && $val == 0)) {\n\n $result = 'NO';\n break;\n } elseif ($val != '*') {\n\n $numCount++;\n $field[$row + $i][$col + $j]--;\n $totalSum--;\n }\n }\n\n }\n }\n\n if ($numCount == 0) {\n\n $result = 'NO';\n break;\n }\n }\n }\n\n if ($numCount == 0) {\n\n $result = 'NO';\n break;\n }\n}\n\nif ($totalSum != 0) {\n $result = 'NO';\n}\n\necho $result;\n\n"}, {"source_code": " $cols) {\n\n foreach ($cols as $col) {\n\n $numCount = 0;\n\n for ($i = -1; $i < 2; $i++) {\n\n for ($j = -1; $j < 2; $j++) {\n\n if ($i != 0 || $j != 0) {\n\n if (isset($field[$row + $i][$col + $j])) {\n\n $val = $field[$row + $i][$col + $j];\n\n if ($val == '.' || ($val != '*' && $val == 0)) {\n\n $result = 'NO';\n break;\n } elseif ($val != '*') {\n\n $numCount++;\n $field[$row + $i][$col + $j]--;\n $totalSum--;\n }\n }\n }\n }\n }\n\n if ($numCount == 0) {\n\n $result = 'NO';\n break;\n }\n }\n\n if ($result == 'NO') {\n break;\n }\n}\n\nif ($totalSum != 0) {\n $result = 'NO';\n}\n\necho $result;\n\n"}], "src_uid": "0d586ba7d304902caaeb7cd9e6917cd6"} {"nl": {"description": "Monocarp is a little boy who lives in Byteland and he loves programming.Recently, he found a permutation of length $$$n$$$. He has to come up with a mystic permutation. It has to be a new permutation such that it differs from the old one in each position.More formally, if the old permutation is $$$p_1,p_2,\\ldots,p_n$$$ and the new one is $$$q_1,q_2,\\ldots,q_n$$$ it must hold that $$$$$$p_1\\neq q_1, p_2\\neq q_2, \\ldots ,p_n\\neq q_n.$$$$$$Monocarp is afraid of lexicographically large permutations. Can you please help him to find the lexicographically minimal mystic permutation?", "input_spec": "There are several test cases in the input data. The first line contains a single integer $$$t$$$ ($$$1\\leq t\\leq 200$$$)\u00a0\u2014 the number of test cases. This is followed by the test cases description. The first line of each test case contains a positive integer $$$n$$$ ($$$1\\leq n\\leq 1000$$$)\u00a0\u2014 the length of the permutation. The second line of each test case contains $$$n$$$ distinct positive integers $$$p_1, p_2, \\ldots, p_n$$$ ($$$1 \\leq p_i \\leq n$$$). It's guaranteed that $$$p$$$ is a permutation, i.\u00a0e. $$$p_i \\neq p_j$$$ for all $$$i \\neq j$$$. It is guaranteed that the sum of $$$n$$$ does not exceed $$$1000$$$ over all test cases.", "output_spec": "For each test case, output $$$n$$$ positive integers\u00a0\u2014 the lexicographically minimal mystic permutations. If such a permutation does not exist, output $$$-1$$$ instead.", "sample_inputs": ["4\n\n3\n\n1 2 3\n\n5\n\n2 3 4 5 1\n\n4\n\n2 3 1 4\n\n1\n\n1"], "sample_outputs": ["2 3 1\n1 2 3 4 5\n1 2 4 3\n-1"], "notes": "NoteIn the first test case possible permutations that are mystic are $$$[2,3,1]$$$ and $$$[3,1,2]$$$. Lexicographically smaller of the two is $$$[2,3,1]$$$.In the second test case, $$$[1,2,3,4,5]$$$ is the lexicographically minimal permutation and it is also mystic.In third test case possible mystic permutations are $$$[1,2,4,3]$$$, $$$[1,4,2,3]$$$, $$$[1,4,3,2]$$$, $$$[3,1,4,2]$$$, $$$[3,2,4,1]$$$, $$$[3,4,2,1]$$$, $$$[4,1,2,3]$$$, $$$[4,1,3,2]$$$ and $$$[4,3,2,1]$$$. The smallest one is $$$[1,2,4,3]$$$."}, "positive_code": [{"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i$y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $n/2) {\r\n IO::pr('-1'); \r\n } else {\r\n for($i=0; $i < $n; $i++) {\r\n if($ans[$i] == $a[$i]) {\r\n $temp = $ans[$i];\r\n for($j=0; $j < $n; $j++) {\r\n $tt = $i-$j == 0 ? $n : $i-$j-1; \r\n if($ans[$tt] != $a[$i] && $ans[$i] != $a[$tt]) {\r\n break;\r\n }\r\n }\r\n \r\n $ans[$i] = $ans[$tt];\r\n $ans[$tt] = $temp;\r\n }\r\n }\r\n IO::prArray($ans); \r\n }\r\n \r\n }\r\n \r\n }\r\n \r\n \r\n class IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i "}, {"source_code": " $val) {\n if (isset($list2[$key])) {\n $sub = min($list1[$key], $list2[$key]);\n $list1[$key] -= $sub;\n $list2[$key] -= $sub;\n }\n}\nforeach ($list2 as $key => $val) {\n if (isset($list1[$key])) {\n $sub = min($list1[$key], $list2[$key]);\n $list1[$key] -= $sub;\n $list2[$key] -= $sub;\n }\n}\n\necho array_sum($list1), \"\\n\";\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $val) {\n $ans += abs($list1[$key] - $list2[$key]);\n}\n\necho $ans;\n"}], "src_uid": "c8321b60a6ad04093dee3eeb9ee27b6f"} {"nl": {"description": "A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values \u2014 the start time li and the finish time ri (li\u2009\u2264\u2009ri).Restaurant management can accept and reject orders. What is the maximal number of orders the restaurant can accept?No two accepted orders can intersect, i.e. they can't share even a moment of time. If one order ends in the moment other starts, they can't be accepted both.", "input_spec": "The first line contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u20095\u00b7105) \u2014 number of orders. The following n lines contain integer values li and ri each (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009109).", "output_spec": "Print the maximal number of orders that can be accepted.", "sample_inputs": ["2\n7 11\n4 7", "5\n1 2\n2 3\n3 4\n4 5\n5 6", "6\n4 8\n1 5\n4 7\n2 5\n1 3\n6 8"], "sample_outputs": ["1", "3", "2"], "notes": null}, "positive_code": [{"source_code": " $j)\n {\n $i++;\n $j = $c[$x];\n }\n}\nprint $i;\n?>"}], "negative_code": [{"source_code": " $i)\n {\n $h++;\n $i = $b[$e[$x]];\n $j++;\n }\n else\n {\n $j++;\n $x--;\n }\n }\n else\n {\n $g[$b[$e[$x]]] = TRUE;\n }\n }\n else\n {\n $j++;\n $x--;\n }\n}\nprint $h;\n?>"}, {"source_code": " $i)\n {\n $h++;\n $i = $b[$e[$x]];\n $j++;\n }\n else\n {\n $j++;\n }\n }\n else\n {\n $g[$b[$e[$x]]] = TRUE;\n }\n }\n else\n {\n $j++;\n $x--;\n }\n}\nprint $h;\n?>"}, {"source_code": " $f[$j])\n {\n $j = $i;\n $i++;\n $k++;\n }\n else\n {\n $i++;\n }\n}\nprint $k;\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n }\n }\n}\nprint $f;\n?>"}, {"source_code": " $f[$j])\n {\n $j = $i;\n $i++;\n $k++;\n }\n else\n {\n $i++;\n }\n}\nprint $k;\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n }\n }\n}\nprint $f;\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n }\n }\n}\nprint $f;\n?>"}, {"source_code": " $k)\n {\n $j++;\n $k = $i[$x];\n }\n}\nprint $j;\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n}\nprint $f;\n?>"}, {"source_code": " $i)\n {\n $h++;\n $i = $b[$e[$x]];\n $j++;\n }\n else\n {\n $j++;\n }\n }\n else\n {\n $g[$b[$e[$x]]] = TRUE;\n }\n }\n else\n {\n $j++;\n $x--;\n }\n}\nif($w == 1)\n{\n print \"533\";\n}\nelse\n{\n print $h;\n}\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n}\nprint $f;\n?>"}, {"source_code": " $b[$e[$g]])\n {\n $f++;\n $g = $h;\n }\n else\n {\n $h++;\n }\n }\n }\n}\nprint $f;\n?>"}, {"source_code": " $i)\n {\n $h++;\n $i = $b[$e[$x]];\n $j++;\n }\n else\n {\n $j++;\n }\n }\n else\n {\n $g[$b[$e[$x]]] = TRUE;\n }\n }\n else\n {\n $j++;\n $x--;\n }\n}\nprint $h;\n?>"}, {"source_code": " $i)\n {\n $h++;\n $i = $b[$e[$x]];\n $j++;\n }\n else\n {\n $j++;\n }\n }\n else\n {\n $g[$b[$e[$x]]] = TRUE;\n }\n }\n else\n {\n $j++;\n $x--;\n }\n}\nprint $h;\n?>"}], "src_uid": "73e8984cceded15027c4ab89c5624a92"} {"nl": {"description": "Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the vertices with cats in them.The leaf vertices of the park contain restaurants. Kefa wants to choose a restaurant where he will go, but unfortunately he is very afraid of cats, so there is no way he will go to the restaurant if the path from the restaurant to his house contains more than m consecutive vertices with cats. Your task is to help Kefa count the number of restaurants where he can go.", "input_spec": "The first line contains two integers, n and m (2\u2009\u2264\u2009n\u2009\u2264\u2009105, 1\u2009\u2264\u2009m\u2009\u2264\u2009n) \u2014 the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1 (then vertex i has a cat). Next n\u2009-\u20091 lines contains the edges of the tree in the format \"xi yi\" (without the quotes) (1\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009n, xi\u2009\u2260\u2009yi), where xi and yi are the vertices of the tree, connected by an edge. It is guaranteed that the given set of edges specifies a tree.", "output_spec": "A single integer \u2014 the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.", "sample_inputs": ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7"], "sample_outputs": ["2", "2"], "notes": "NoteLet us remind you that a tree is a connected graph on n vertices and n\u2009-\u20091 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if it has no children.Note to the first sample test: The vertices containing cats are marked red. The restaurants are at vertices 2, 3, 4. Kefa can't go only to the restaurant located at vertex 2.Note to the second sample test: The restaurants are located at vertices 4, 5, 6, 7. Kefa can't go to restaurants 6, 7."}, "positive_code": [{"source_code": "$m) {\n return;\n }\n }else{\n $cN = 0;\n }\n for ($i = 0; $i < $c; $i++) {\n if ($map[$cur][$i] == $dest) {\n continue;\n }\n solve($cur, $map[$cur][$i], $cN, $mCN);\n }\n\n}\n\nsolve(0, 1, 0, 0);\necho $result;"}, {"source_code": "$m) {\n return;\n }\n }else{\n $cN = 0;\n }\n if ($c == 1 && $map[$cur][0] == $dest) {\n $result++;\n return;\n }\n\n for ($i = 0; $i < $c; $i++) {\n if ($map[$cur][$i] == $dest) {\n continue;\n }\n solve($cur, $map[$cur][$i], $cN);\n }\n\n}\n\nsolve(0, 1, 0);\necho $result;"}], "negative_code": [{"source_code": "$m) {\n return;\n }\n }else{\n $cN = 0;\n }\n for ($i = 0; $i < $c; $i++) {\n if ($map[$cur][$i] == $dest) {\n continue;\n }\n solve($cur, $map[$cur][$i], $cN);\n }\n\n}\n\nsolve(0, 1, 0);\necho $result;"}, {"source_code": "$m) {\n return;\n }\n }else{\n $cN = 0;\n }\n for ($i = 0; $i < $c; $i++) {\n if ($map[$cur][$i] == $dest) {\n continue;\n }\n solve($cur, $map[$cur][$i], $cN, $mCN);\n }\n\n}\n\nsolve(0, 1, 0, 0);\necho $result;"}, {"source_code": " $k))\n {\n print \"0\" . \"\\n\";\n }\n}\nlist($d, $e) = explode(\" \", trim(fgets(STDIN)));\n $j = $e - $d + 1;\n if((($j % 2) == 0) && (($j / 2) <= $k))\n {\n print \"1\";\n }\n elseif((($j % 2) != 0) || (($j / 2) > $k))\n {\n print \"0\";\n }\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "deeb49969ac4bc4f1c7d76b89ac1402f"} {"nl": {"description": "Last year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had such a stick, he sold it and got 2x berllars. Bob won some programming competition and got a 2x MB memory stick as a prize. Bob could choose whether to present this memory stick to one of his friends, or keep it. Bob never kept more than one memory stick, as he feared to mix up their capacities, and deceive a customer unintentionally. It is also known that for each memory stick capacity there was at most one customer, who wanted to buy that memory stick. Now, knowing all the customers' demands and all the prizes won at programming competitions during the last n days, Bob wants to know, how much money he could have earned, if he had acted optimally.", "input_spec": "The first input line contains number n (1\u2009\u2264\u2009n\u2009\u2264\u20095000) \u2014 amount of Bob's working days. The following n lines contain the description of the days. Line sell x stands for a day when a customer came to Bob to buy a 2x MB memory stick (0\u2009\u2264\u2009x\u2009\u2264\u20092000). It's guaranteed that for each x there is not more than one line sell x. Line win x stands for a day when Bob won a 2x MB memory stick (0\u2009\u2264\u2009x\u2009\u2264\u20092000).", "output_spec": "Output the maximum possible earnings for Bob in berllars, that he would have had if he had known all the events beforehand. Don't forget, please, that Bob can't keep more than one memory stick at a time.", "sample_inputs": ["7\nwin 10\nwin 5\nwin 3\nsell 5\nsell 3\nwin 10\nsell 10", "3\nwin 5\nsell 6\nsell 4"], "sample_outputs": ["1056", "0"], "notes": null}, "positive_code": [{"source_code": "= 0; $i--) {\n\t$f[$i] = $f[$i + 1];\n\tif ($type[$i] == \"sell\") \n\t\t$last[$x[$i]] = $i;\n\telse if ($last[$x[$i]] < $n) {\n\t\t$value = bcadd($f[$last[$x[$i]] + 1], $deg[$x[$i]]);\n\t\tif (bccomp($value, $f[$i]) > 0)\n\t\t\t$f[$i] = $value;\n\t} \n}\nprint($f[0].\"\\n\");\n\n?>\n"}], "negative_code": [], "src_uid": "217a3a48b927213f4d5e0a19048e2a32"} {"nl": {"description": "ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear! More formally, if you typed a word at second a and then the next word at second b, then if b\u2009-\u2009a\u2009\u2264\u2009c, just the new word is appended to other words on the screen. If b\u2009-\u2009a\u2009>\u2009c, then everything on the screen disappears and after that the word you have typed appears on the screen.For example, if c\u2009=\u20095 and you typed words at seconds 1,\u20093,\u20098,\u200914,\u200919,\u200920 then at the second 8 there will be 3 words on the screen. After that, everything disappears at the second 13 because nothing was typed. At the seconds 14 and 19 another two words are typed, and finally, at the second 20, one more word is typed, and a total of 3 words remain on the screen.You're given the times when ZS the Coder typed the words. Determine how many words remain on the screen after he finished typing everything.", "input_spec": "The first line contains two integers n and c (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000,\u20091\u2009\u2264\u2009c\u2009\u2264\u2009109)\u00a0\u2014 the number of words ZS the Coder typed and the crazy computer delay respectively. The next line contains n integers t1,\u2009t2,\u2009...,\u2009tn (1\u2009\u2264\u2009t1\u2009<\u2009t2\u2009<\u2009...\u2009<\u2009tn\u2009\u2264\u2009109), where ti denotes the second when ZS the Coder typed the i-th word.", "output_spec": "Print a single positive integer, the number of words that remain on the screen after all n words was typed, in other words, at the second tn.", "sample_inputs": ["6 5\n1 3 8 14 19 20", "6 1\n1 3 5 7 9 10"], "sample_outputs": ["3", "2"], "notes": "NoteThe first sample is already explained in the problem statement.For the second sample, after typing the first word at the second 1, it disappears because the next word is typed at the second 3 and 3\u2009-\u20091\u2009>\u20091. Similarly, only 1 word will remain at the second 9. Then, a word is typed at the second 10, so there will be two words on the screen, as the old word won't disappear because 10\u2009-\u20099\u2009\u2264\u20091."}, "positive_code": [{"source_code": ""}, {"source_code": " $c)\n\t\t$count = 1;\n\n\t$a = $data[$i];\n}\n\nwrite($count);\n\n"}, {"source_code": " $time){\n if ($mes[$num+1] - $time > $maxTime){\n $sum = 0;\n }else{\n $sum++;\n }\n \n}\necho ($sum);\n\n?>"}], "negative_code": [{"source_code": " $c)\n\t\t$count = 1;\n\n\t$a = $data[$i];\n}\n\nwrite($count);\n\n"}], "src_uid": "fb58bc3be4a7a78bdc001298d35c6b21"} {"nl": {"description": "You are given two arrays $$$a$$$ and $$$b$$$ both consisting of $$$n$$$ positive (greater than zero) integers. You are also given an integer $$$k$$$.In one move, you can choose two indices $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) and swap $$$a_i$$$ and $$$b_j$$$ (i.e. $$$a_i$$$ becomes $$$b_j$$$ and vice versa). Note that $$$i$$$ and $$$j$$$ can be equal or different (in particular, swap $$$a_2$$$ with $$$b_2$$$ or swap $$$a_3$$$ and $$$b_9$$$ both are acceptable moves).Your task is to find the maximum possible sum you can obtain in the array $$$a$$$ if you can do no more than (i.e. at most) $$$k$$$ such moves (swaps).You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 200$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 30; 0 \\le k \\le n$$$) \u2014 the number of elements in $$$a$$$ and $$$b$$$ and the maximum number of moves you can do. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 30$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of the test case contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$1 \\le b_i \\le 30$$$), where $$$b_i$$$ is the $$$i$$$-th element of $$$b$$$.", "output_spec": "For each test case, print the answer \u2014 the maximum possible sum you can obtain in the array $$$a$$$ if you can do no more than (i.e. at most) $$$k$$$ swaps.", "sample_inputs": ["5\n2 1\n1 2\n3 4\n5 5\n5 5 6 6 5\n1 2 5 4 3\n5 3\n1 2 3 4 5\n10 9 10 10 9\n4 0\n2 2 4 3\n2 4 2 3\n4 4\n1 2 2 1\n4 4 5 4"], "sample_outputs": ["6\n27\n39\n11\n17"], "notes": "NoteIn the first test case of the example, you can swap $$$a_1 = 1$$$ and $$$b_2 = 4$$$, so $$$a=[4, 2]$$$ and $$$b=[3, 1]$$$.In the second test case of the example, you don't need to swap anything.In the third test case of the example, you can swap $$$a_1 = 1$$$ and $$$b_1 = 10$$$, $$$a_3 = 3$$$ and $$$b_3 = 10$$$ and $$$a_2 = 2$$$ and $$$b_4 = 10$$$, so $$$a=[10, 10, 10, 4, 5]$$$ and $$$b=[1, 9, 3, 2, 9]$$$.In the fourth test case of the example, you cannot swap anything.In the fifth test case of the example, you can swap arrays $$$a$$$ and $$$b$$$, so $$$a=[4, 4, 5, 4]$$$ and $$$b=[1, 2, 2, 1]$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $a[$i]){\n $ans += $b[$n - 1 - $i];\n $k--;\n }\n else $ans += $a[$i];\n }\n echo $ans . \"\\n\";\n }\n"}, {"source_code": " $arrA[$i]){\n $arrA[$i]=$arrB[$n-$i-1];\n }else break;\n }\n $sum=0;\n for ($i=0; $i < $n; $i++) { \n $sum+=$arrA[$i];\n }\n echo $sum.\"\\n\";\n}\n\n$T=inputInt($stdin);\nwhile($T--){\n slove($stdin);\n}"}], "negative_code": [], "src_uid": "7c2337c1575b4a62e062fc9990c0b098"} {"nl": {"description": "You are given two very long integers a,\u2009b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java. Don't use the function input() in Python2 instead of it use the function raw_input().", "input_spec": "The first line contains a non-negative integer a. The second line contains a non-negative integer b. The numbers a,\u2009b may contain leading zeroes. Each of them contains no more than 106 digits.", "output_spec": "Print the symbol \"<\" if a\u2009<\u2009b and the symbol \">\" if a\u2009>\u2009b. If the numbers are equal print the symbol \"=\".", "sample_inputs": ["9\n10", "11\n10", "00012345\n12345", "0123\n9", "0123\n111"], "sample_outputs": ["<", ">", "=", ">", ">"], "notes": null}, "positive_code": [{"source_code": " $b) echo \">\";\nif ($a < $b) echo \"<\";\nif ($a == $b) echo \"=\";\n?>"}, {"source_code": "\n $str2)\n print \">\";\n\n?>"}, {"source_code": " $b)\n{\n print \">\";\n}\n?>"}], "negative_code": [{"source_code": "//Br34k\n $str2)\n print \">\";\n\n?>"}], "src_uid": "fd63aeefba89bef7d16212a0d9e756cd"} {"nl": {"description": "It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. If it is turns to be too large, then the servers might have not enough time to assign tanks into teams and the whole game will collapse!There are exactly n distinct countries in the world and the i-th country added ai tanks to the game. As the developers of the game are perfectionists, the number of tanks from each country is beautiful. A beautiful number, according to the developers, is such number that its decimal representation consists only of digits '1' and '0', moreover it contains at most one digit '1'. However, due to complaints from players, some number of tanks of one country was removed from the game, hence the number of tanks of this country may not remain beautiful.Your task is to write the program that solves exactly the same problem in order to verify Gena's code correctness. Just in case.", "input_spec": "The first line of the input contains the number of countries n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000). The second line contains n non-negative integers ai without leading zeroes\u00a0\u2014 the number of tanks of the i-th country. It is guaranteed that the second line contains at least n\u2009-\u20091 beautiful numbers and the total length of all these number's representations doesn't exceed 100\u2009000.", "output_spec": "Print a single number without leading zeroes\u00a0\u2014 the product of the number of tanks presented by each country.", "sample_inputs": ["3\n5 10 1", "4\n1 1 10 11", "5\n0 3 1 100 1"], "sample_outputs": ["50", "110", "0"], "notes": "NoteIn sample 1 numbers 10 and 1 are beautiful, number 5 is not not.In sample 2 number 11 is not beautiful (contains two '1's), all others are beautiful.In sample 3 number 3 is not beautiful, all others are beautiful."}, "positive_code": [{"source_code": " 1)\n {\n define(h, $b[$x]);\n $g -= $g2;\n $i = h;\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n $g2++;\n }\n else\n {\n define(h, $b[$x]);\n $g -= $g2;\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n if($i == \"\")\n {\n $i = 1;\n }\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": " 1)\n return FALSE;\n } else if($tmp != 0){\n return FALSE;\n }\n }\n return TRUE;\n}"}, {"source_code": " 1) {\n\t\t\t$s = $a[$i];\n\t\t} else {\n\t\t\t$k += strlen($a[$i]) - 1;\n\t\t}\n\t}\n\t$chk = false;\n\tfor ($i = 0; $i < $n; $i++) if ($a[$i] == '0') {\n\t\t$chk = true;\n\t\tbreak;\n\t}\n\techo (!$chk) ? $s.str_repeat('0',(int) $k) : '0'\n?> "}, {"source_code": " 1) {\n\t\t\t$s = $a[$i];\n\t\t} else {\n\t\t\t$k += strlen($a[$i]) - 1;\n\t\t}\n\t}\n\techo (!$chk) ? $s.str_repeat('0',(int) $k) : '0'\n?> "}, {"source_code": " 1 ){\n $head = $t;\n }else{\n $et = false;\n for($i = 0 ; $i < strlen($t);$i++){\n if($t[$i] != '0' and $t[$i] != '1'){\n $head = $t;\n $et = true;\n }\n }\n\n if(!$et)\n $res += strlen($t) - 1;\n }\n }\n if($flag){\n fprintf(STDOUT,0);\n }else{\n if(isset($head)) {\n fprintf(STDOUT,\"%s\",$head);\n }else{\n fprintf(STDOUT,1);\n }\n for($i = 0 ; $i < count($res) ; $i++){\n for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){\n fprintf(STDOUT,\"0\");\n }\n }\n }\n exit();\n}"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n $g = 0;\n $i = h;\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n $g = 0;\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n if($i == \"\")\n {\n $i = 1;\n }\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n $i = h;\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n if($i == \"\")\n {\n $i = 1;\n }\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n if($i == \"\")\n {\n $i = 1;\n }\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n elseif($b[$x][$y] < 1)\n {\n $g++;\n }\n else\n {\n define(h, $b[$x]);\n $i = h;\n break;\n }\n }\n }\n}\nif($c == 0)\n{\n if($i == \"\")\n {\n $i = 1;\n }\n for($x = 1; $x <= $g; $x++)\n {\n $i .= 0;\n }\n print $i;\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n return FALSE;\n } else if($tmp != 0){\n return FALSE;\n }\n }\n return TRUE;\n}"}, {"source_code": " 1)\n return FALSE;\n } else if($tmp != 0){\n return FALSE;\n }\n }\n return TRUE;\n}"}, {"source_code": " 1)\n return FALSE;\n } else if($tmp != 0){\n return FALSE;\n }\n }\n return TRUE;\n}"}, {"source_code": " 1)\n return FALSE;\n } else if($tmp != 0){\n return FALSE;\n }\n }\n return TRUE;\n}"}, {"source_code": " 1) {\n\t\t\t$s = $a[$i];\n\t\t} else {\n\t\t\t$k += strlen($a[$i]) - 1;\n\t\t}\n\t}\n\techo (strpos($b,'0') !== true) ? $s.str_repeat('0',(int) $a) : '0'\n?> "}, {"source_code": " 1 ){\n $head = $t;\n }else{\n $et = false;\n for($i = 0 ; $i < strlen($t);$i++){\n if($t[$i] != '0' and $t[$i] != '1'){\n $head = $t;\n $et = true;\n }\n }\n\n if(!$et)\n $res += strlen($t) - 1;\n }\n }\n if($flag){\n fprintf(STDOUT,0);\n }else{\n if(isset($head)) {\n fprintf(STDOUT,\"%s\",$head);\n }else{\n fprintf(STDOUT,1);\n }\n for($i = 0 ; $i < count($res) ; $i++){\n for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){\n fprintf(STDOUT,\"0\");\n }\n }\n }\n exit();\n}"}, {"source_code": " 1){\n $head = $t;\n }else{\n $et = false;\n for($i = 0 ; $i < strlen($t);$i++){\n if($t[$i] != '0' and $t[$i] != '1'){\n $head = $t;\n $et = true;\n }\n }\n\n if(!$et)\n $res += strlen($t) - 1;\n }\n }\n if($flag){\n fprintf(STDOUT,0);\n }else{\n if(isset($head)) {\n fprintf(STDOUT,\"%s\",$head);\n }else{\n fprintf(STDOUT,1);\n }\n for($i = 0 ; $i < count($res) ; $i++){\n for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){\n fprintf(STDOUT,\"0\");\n }\n }\n }\n exit();\n}"}, {"source_code": " 1){\n $head = $t;\n }else{\n $res += strlen($t) - 1;\n }\n }\n if($flag){\n fprintf(STDOUT,0);\n }else{\n if(isset($head)) {\n fprintf(STDOUT,\"%s\",$head);\n }else{\n fprintf(STDOUT,1);\n }\n for($i = 0 ; $i < count($res) ; $i++){\n for($zeroNum = 0 ; $zeroNum < $res ; $zeroNum++){\n fprintf(STDOUT,\"0\");\n }\n }\n }\n exit();\n}"}, {"source_code": "= $try / 2) &&\n\t\t($y % $try >= $try / 2)\n\t) {\n\t\techo 'YES' . PHP_EOL;\n\t} else {\n\t\techo 'NO' . PHP_EOL;\n\t}\n}"}, {"source_code": "= 2 * $l) {\n echo \"NO\\n\";\n } else {\n echo \"YES\\n\";\n }\n}"}], "negative_code": [], "src_uid": "5172d358f1d451b42efff1019219a54d"} {"nl": {"description": "DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now he wants to find a connected induced subgraph G' of the graph, such that the density of G' is as large as possible.An induced subgraph G'(V',\u2009E') of a graph G(V,\u2009E) is a graph that satisfies: ; edge if and only if , and edge ; the value of an edge in G' is the same as the value of the corresponding edge in G, so as the value of a node. Help DZY to find the induced subgraph with maximum density. Note that the induced subgraph you choose must be connected. ", "input_spec": "The first line contains two space-separated integers n\u00a0(1\u2009\u2264\u2009n\u2009\u2264\u2009500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xi\u00a0(1\u2009\u2264\u2009xi\u2009\u2264\u2009106), where xi represents the value of the i-th node. Consider the graph nodes are numbered from 1 to n. Each of the next m lines contains three space-separated integers ai,\u2009bi,\u2009ci\u00a0(1\u2009\u2264\u2009ai\u2009<\u2009bi\u2009\u2264\u2009n;\u00a01\u2009\u2264\u2009ci\u2009\u2264\u2009103), denoting an edge between node ai and bi with value ci. The graph won't contain multiple edges.", "output_spec": "Output a real number denoting the answer, with an absolute or relative error of at most 10\u2009-\u20099.", "sample_inputs": ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63"], "sample_outputs": ["0.000000000000000", "3.000000000000000", "2.965517241379311"], "notes": "NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\nsscanf(fgets($k=STDIN),$h='%d%d',$n,$m);\n$u=explode(\" \",fgets($k));\nwhile($i++<$m)sscanf(fgets($k),$h.'%d',$a,$b,$c)|$z=max($z,($u[$a-1]+$u[$b-1])/$c);\necho $z+0;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "ba4304e79d85d13c12233bcbcce6d0a6"} {"nl": {"description": "After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.At the start of the day they have x ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the queue wants either to take several ice cream packs for himself and his friends or to give several ice cream packs to Kay and Gerda (carriers that bring ice cream have to stand in the same queue).If a carrier with d ice cream packs comes to the house, then Kay and Gerda take all his packs. If a child who wants to take d ice cream packs comes to the house, then Kay and Gerda will give him d packs if they have enough ice cream, otherwise the child will get no ice cream at all and will leave in distress.Kay wants to find the amount of ice cream they will have after all people will leave from the queue, and Gerda wants to find the number of distressed kids.", "input_spec": "The first line contains two space-separated integers n and x (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 0\u2009\u2264\u2009x\u2009\u2264\u2009109). Each of the next n lines contains a character '+' or '-', and an integer di, separated by a space (1\u2009\u2264\u2009di\u2009\u2264\u2009109). Record \"+ di\" in i-th line means that a carrier with di ice cream packs occupies i-th place from the start of the queue, and record \"- di\" means that a child who wants to take di packs stands in i-th place.", "output_spec": "Print two space-separated integers\u00a0\u2014 number of ice cream packs left after all operations, and number of kids that left the house in distress.", "sample_inputs": ["5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20", "5 17\n- 16\n- 2\n- 98\n+ 100\n- 98"], "sample_outputs": ["22 1", "3 2"], "notes": "NoteConsider the first sample. Initially Kay and Gerda have 7 packs of ice cream. Carrier brings 5 more, so now they have 12 packs. A kid asks for 10 packs and receives them. There are only 2 packs remaining. Another kid asks for 20 packs. Kay and Gerda do not have them, so the kid goes away distressed. Carrier bring 40 packs, now Kay and Gerda have 42 packs. Kid asks for 20 packs and receives them. There are 22 packs remaining. "}, "positive_code": [{"source_code": ""}, {"source_code": "= $num)) {\n $ic -= $num;\n }\n}\nprint $ic . \" \" . $c;\n?>\n\n\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n\nfunction addIce(&$ice_cnt,$count){\n\t$ice_cnt+=$count;\n}\n\nfunction getIce(&$ice_cnt,$count){\n\tif($ice_cnt>=$count){\n\t\t$ice_cnt-=$count;\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n$stdin = fopen('php://stdin', 'r');\n$s = trim(fgets($stdin));\n$cards = explode(\" \",$s);\n$ice_cnt = $cards[1];\n$people_cnt=$cards[0];\n$sad =0;\nwhile (!feof($stdin)) {\n\t\n\t$s = trim(fgets($stdin));\n\t$cards = explode(\" \",$s);\n\tif($cards[0]==\"+\"){\n\t\taddIce($ice_cnt,$cards[1]);\n\t}elseif($cards[0]==\"-\"){\n\t\tif(!getIce($ice_cnt,$cards[1])){\n\t\t\t$sad+=1;\n\t\t}\n\t\t\n\t}\n\t\n}\n\necho $ice_cnt.\" \".$sad; \n\n"}, {"source_code": "=$b)\n\t\t\t $x=bcsub($x,$b);\n\t\t else\n\t\t\t $ans++;\n\t }\n }\n print $x.\" \".$ans.\"\\n\";\n ?>"}], "negative_code": [], "src_uid": "0a9ee8cbfa9888caef39b024563b7dcd"} {"nl": {"description": "Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.The classroom contains $$$n$$$ rows of seats and there are $$$m$$$ seats in each row. Then the classroom can be represented as an $$$n \\times m$$$ matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find $$$k$$$ consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs.", "input_spec": "The first line contains three positive integers $$$n,m,k$$$ ($$$1 \\leq n, m, k \\leq 2\\,000$$$), where $$$n,m$$$ represent the sizes of the classroom and $$$k$$$ is the number of consecutive seats you need to find. Each of the next $$$n$$$ lines contains $$$m$$$ characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat.", "output_spec": "A single number, denoting the number of ways to find $$$k$$$ empty seats in the same row or column.", "sample_inputs": ["2 3 2\n**.\n...", "1 2 2\n..", "3 3 4\n.*.\n*.*\n.*."], "sample_outputs": ["3", "1", "0"], "notes": "NoteIn the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. $$$(1,3)$$$, $$$(2,3)$$$ $$$(2,2)$$$, $$$(2,3)$$$ $$$(2,1)$$$, $$$(2,2)$$$ "}, "positive_code": [{"source_code": "= $k) $rows += $count_of_pt - $k + 1;\n $count_of_pt = 0;\n }\n }\n if($count_of_pt >= $k) $rows += $count_of_pt - $k + 1;\n}\nif($k == 1) {\n echo $rows;\n exit;\n}\nfor($j = 0 ; $j < $m ; $j++){\n $count_of_pt = 0;\n for($i = 0 ; $i < $n ; $i++){\n if($Grid[$i][$j] == '.'){\n ++$count_of_pt;\n }\n else{\n if($count_of_pt >= $k) $cols += $count_of_pt - $k + 1;\n $count_of_pt = 0;\n }\n }\n if($count_of_pt >= $k) $cols += $count_of_pt - $k + 1;\n}\necho $rows + $cols;"}], "negative_code": [{"source_code": "= $k) $rows += $count_of_pt - $k + 1;\n $count_of_pt = 0;\n }\n }\n if($count_of_pt >= $k) $rows += $count_of_pt - $k + 1;\n}\n\nfor($j = 0 ; $j < $m ; $j++){\n $count_of_pt = 0;\n for($i = 0 ; $i < $n ; $i++){\n if($Grid[$i][$j] == '.'){\n ++$count_of_pt;\n }\n else{\n if($count_of_pt >= $k) $cols += $count_of_pt - $k + 1;\n $count_of_pt = 0;\n }\n }\n if($count_of_pt >= $k) $cols += $count_of_pt - $k + 1;\n}\necho $rows + $cols;"}], "src_uid": "c1f247150831e9b52389bae697a1ca3d"} {"nl": {"description": "There is a rectangular grid of n rows of m initially-white cells each.Arkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset of columns Ci are chosen. For each row r in Ri and each column c in Ci, the intersection of row r and column c is coloured black.There's another constraint: a row or a column can only be chosen at most once among all operations. In other words, it means that no pair of (i,\u2009j) (i\u2009<\u2009j) exists such that or , where denotes intersection of sets, and denotes the empty set.You are to determine whether a valid sequence of operations exists that produces a given final grid.", "input_spec": "The first line contains two space-separated integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u200950)\u00a0\u2014 the number of rows and columns of the grid, respectively. Each of the following n lines contains a string of m characters, each being either '.' (denoting a white cell) or '#' (denoting a black cell), representing the desired setup.", "output_spec": "If the given grid can be achieved by any valid sequence of operations, output \"Yes\"; otherwise output \"No\" (both without quotes). You can print each character in any case (upper or lower).", "sample_inputs": ["5 8\n.#.#..#.\n.....#..\n.#.#..#.\n#.#....#\n.....#..", "5 5\n..#..\n..#..\n#####\n..#..\n..#..", "5 9\n........#\n#........\n..##.#...\n.......#.\n....#.#.#"], "sample_outputs": ["Yes", "No", "No"], "notes": "NoteFor the first example, the desired setup can be produced by 3 operations, as is shown below. For the second example, the desired setup cannot be produced, since in order to colour the center row, the third row and all columns must be selected in one operation, but after that no column can be selected again, hence it won't be possible to colour the other cells in the center column."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "ac718922461f3187d8b7587c360b05fc"} {"nl": {"description": "There are $$$n$$$ positive integers $$$a_1, a_2, \\dots, a_n$$$. For the one move you can choose any even value $$$c$$$ and divide by two all elements that equal $$$c$$$.For example, if $$$a=[6,8,12,6,3,12]$$$ and you choose $$$c=6$$$, and $$$a$$$ is transformed into $$$a=[3,8,12,3,3,12]$$$ after the move.You need to find the minimal number of moves for transforming $$$a$$$ to an array of only odd integers (each element shouldn't be divisible by $$$2$$$).", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the input. Then $$$t$$$ test cases follow. The first line of a test case contains $$$n$$$ ($$$1 \\le n \\le 2\\cdot10^5$$$) \u2014 the number of integers in the sequence $$$a$$$. The second line contains positive integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$). The sum of $$$n$$$ for all test cases in the input doesn't exceed $$$2\\cdot10^5$$$.", "output_spec": "For $$$t$$$ test cases print the answers in the order of test cases in the input. The answer for the test case is the minimal number of moves needed to make all numbers in the test case odd (i.e. not divisible by $$$2$$$).", "sample_inputs": ["4\n6\n40 6 40 3 20 1\n1\n1024\n4\n2 4 8 16\n3\n3 1 7"], "sample_outputs": ["4\n10\n4\n0"], "notes": "NoteIn the first test case of the example, the optimal sequence of moves can be as follows: before making moves $$$a=[40, 6, 40, 3, 20, 1]$$$; choose $$$c=6$$$; now $$$a=[40, 3, 40, 3, 20, 1]$$$; choose $$$c=40$$$; now $$$a=[20, 3, 20, 3, 20, 1]$$$; choose $$$c=20$$$; now $$$a=[10, 3, 10, 3, 10, 1]$$$; choose $$$c=10$$$; now $$$a=[5, 3, 5, 3, 5, 1]$$$ \u2014 all numbers are odd. Thus, all numbers became odd after $$$4$$$ moves. In $$$3$$$ or fewer moves, you cannot make them all odd."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "afcd41492158e68095b01ff1e88c3dd4"} {"nl": {"description": "Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.GukiZ has strings a, b, and c. He wants to obtain string k by swapping some letters in a, so that k should contain as many non-overlapping substrings equal either to b or c as possible. Substring of string x is a string formed by consecutive segment of characters from x. Two substrings of string x overlap if there is position i in string x occupied by both of them.GukiZ was disappointed because none of his students managed to solve the problem. Can you help them and find one of possible strings k?", "input_spec": "The first line contains string a, the second line contains string b, and the third line contains string c (1\u2009\u2264\u2009|a|,\u2009|b|,\u2009|c|\u2009\u2264\u2009105, where |s| denotes the length of string s). All three strings consist only of lowercase English letters. It is possible that b and c coincide.", "output_spec": "Find one of possible strings k, as described in the problem statement. If there are multiple possible answers, print any of them.", "sample_inputs": ["aaa\na\nb", "pozdravstaklenidodiri\nniste\ndobri", "abbbaaccca\nab\naca"], "sample_outputs": ["aaa", "nisteaadddiiklooprrvz", "ababacabcc"], "notes": "NoteIn the third sample, this optimal solutions has three non-overlaping substrings equal to either b or c on positions 1\u2009\u2013\u20092 (ab), 3\u2009\u2013\u20094 (ab), 5\u2009\u2013\u20097 (aca). In this sample, there exist many other optimal solutions, one of them would be acaababbcc."}, "positive_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 5)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] == $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " $lena) and ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\n$arr_a = $arr_b = $arr_c = array();\n\nfor ($i=0; $i < $lena; $i++) { \n $k = $a[$i];\n $arr_a[$k] ++;\n}\n\nfor ($i=0; $i < $lenb; $i++) { \n $k = $b[$i];\n $arr_b[$k] ++;\n}\n\nfor ($i=0; $i < $lenc; $i++) { \n $k = $c[$i];\n $arr_c[$k] ++;\n}\n\n$max_b = $lena;\nforeach ($arr_b as $key => $value) {\n if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {\n $max_b = 0;\n break;\n } elseif ($max_b > intval($arr_a[$key] / $value)) {\n $max_b = intval($arr_a[$key] / $value);\n }\n}\n\n$max = 0;\n$col_b = $col_c = 0;\n$arr_x = $arr_a;\nfor ($i=0; $i <= $max_b ; $i++) { \n\n $max_c = $lena;\n foreach ($arr_c as $key => $value) {\n if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {\n $max_c = 0;\n break;\n } elseif ($max_c > intval($arr_x[$key] / $value)) {\n $max_c = intval($arr_x[$key] / $value);\n }\n }\n\n if ($max < ($i + $max_c)) {\n $max = $i + $max_c;\n $col_b = $i;\n $col_c = $max_c;\n }\n\n foreach ($arr_b as $key => $value) {\n $arr_x[$key] -= $value;\n } \n}\n\n$out = '';\n\nfor ($i=1; $i <= $col_b ; $i++) { \n $out .= $b;\n// echo \"$b\";\n foreach ($arr_b as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nfor ($i=1; $i <= $col_c ; $i++) { \n $out .= $c;\n// echo \"$c\";\n foreach ($arr_c as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nforeach ($arr_a as $key => $value) {\n if ($value !== 0) {\n $out .= str_repeat(\"$key\", $value);\n// echo str_repeat(\"$key\", $value);\n }\n}\n\necho \"$out\\n\";\n\n?> "}], "negative_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 20) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 39) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 39;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 35) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 35;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print \"1\";\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print \"2\";\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 50) * $f[$h[$x]]);\n $l -= 50;\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 51) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 51;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n if($a[0] == \"i\")\n {\n print implode(\" \", $r) . \"\\n\";\n }\n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $c . \"\\n\";\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array(0);\n $r = array($l + 0);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n $j = $e;\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n }\n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($x = 1; $x <= $p[$x]; $x++)\n {\n $v .= $b;\n }\n for($x = 1; $x <= $q[$x]; $x++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= (($l - 1) * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] === TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] === TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] === TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] === TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] === TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] === TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] === TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] === TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n if($a[0] == \"i\")\n {\n print $x . \"\\n\";\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $j = $e;\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 49) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 49;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 1) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 1;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] == $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n \n}\nelseif(($l != 0) && ($o == 0))\n{\n \n}\nelse\n{\n \n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 1) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n if($a[0] == \"i\")\n {\n print \"0\";\n }\n else\n {\n print $u . implode($v); \n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 21) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print implode(\" \", $u);\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n if($a[0] == \"i\")\n {\n print \"0\";\n }\n else\n {\n print $u . implode($v); \n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 50) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$l -= 50;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 78) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 78;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 40) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 40;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 52) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 52;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n $j = $e;\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 78) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 78;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 35) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 35;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 60) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 60;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 5) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 5;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n if($a[0] == \"i\")\n {\n print $p[$x] . \"\\n\";\n print $q[$x] . \"\\n\";\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 53) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 53;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 78) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 78;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 129) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 129;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n if($a[0] == \"i\")\n {\n print implode(\" \", $q) . \"\\n\";\n }\n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $b . \"\\n\";\n print $c . \"\\n\";\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 49) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 49;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 100)\n {\n break;\n }\n $j = $e;\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelseif(($l == 0) && ($o != 0))\n{\n $p = \"\";\n for($x = 1; $x <= $o; $x++)\n {\n $p .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelseif(($l != 0) && ($o == 0))\n{\n $p = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $p .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $p .= $h[$x];\n }\n }\n print $p;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n $j = $e;\n $l--;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] > 0)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print implode(\" \", $t);\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 70) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 70;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 10) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 10;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 70) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 70;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 30) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 30;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 55) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 55;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($g[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $t[$h[$x]] -= (($s - 1) * $g[$h[$x]]);\n }\n else\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $s -= 1;\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 50) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\nif($a[0] == \"i\")\n{\n $l -= 50;\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n if($a[0] == \"i\")\n {\n print $u . \"\\n\";\n }\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n strlen($a) . \" \" . strlen($w);\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$j = $e;\n$i = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$m = $e;\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n}\n$o = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n}\n$n2 = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n2[$x] = $k;\n }\n}\n$o2 = 0;\n$o2 = min($n2);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o2 * $g[$h[$x]]);\n }\n}\nif(($l == 0) && ($o == 0))\n{\n print $a;\n}\nelse\n{\n $p = array($l);\n $q = array($o2);\n $r = array($l + $o2);\n $s = array($j);\n $t = 1;\n $u = $l;\n for($y = 1; $y <= $u; $y++)\n {\n if(strlen($b) < 10)\n {\n break;\n }\n $l--;\n $j = $e;\n for($x = 0; $x < 26; $x++)\n {\n if($f[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n }\n $n = array();\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($j[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $k;\n }\n }\n $o = min($n);\n for($x = 0; $x < 26; $x++)\n {\n if($g[$h[$x]] == TRUE)\n {\n $j[$h[$x]] -= ($o * $g[$h[$x]]);\n }\n }\n $p[$t] = $l;\n $q[$t] = $o;\n $r[$t] = $l + $o;\n $s[$t] = $j;\n $t++;\n } \n if($a[0] == \"i\")\n {\n print implode(\" \", $p) . \"\\n\";\n print implode(\" \", $q) . \"\\n\";\n print implode(\" \", $r) . \"\\n\";\n }\n $u = max($r);\n for($x = 0; $x < count($r); $x++)\n {\n if($r[$x] = $u)\n {\n break;\n }\n }\n $v = \"\";\n for($y = 1; $y <= $p[$x]; $y++)\n {\n $v .= $b;\n }\n for($y = 1; $y <= $q[$x]; $y++)\n {\n $v .= $c;\n }\n $j = $s[$x];\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $j[$h[$x]]; $y++)\n {\n $v .= $h[$x];\n }\n }\n print $v;\n}\n?>"}, {"source_code": " 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($h); $x++)\n {\n $u .= $b;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($s == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($k); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\nelseif($r == $p)\n{\n if($t == 1)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $b;\n }\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 2)\n {\n $u = \"\";\n for($x = 1; $x <= min($m); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n elseif($t == 3)\n {\n $u = \"\";\n for($x = 1; $x <= min($l); $x++)\n {\n $u .= $c;\n }\n $v = str_split($a);\n $w = array();\n for($x = 0; $x < strlen($u); $x++)\n {\n $w[$u[$x]]++;\n }\n $q = count($v);\n for($x = 0; $x < $q; $x++)\n {\n if($w[$v[$x]] > 0)\n {\n $w[$v[$x]]--;\n unset($v[$x]);\n }\n }\n print $u . implode($v); \n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if(($f[$h[$x]] == TRUE) && ($a[0] == \"i\"))\n {\n $m[$h[$x]] -= (($l - 20) * $f[$h[$x]]);\n }\n else\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print $l . \" \" . $p . \" \" . $s . \" \" . $v;\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$h = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n$e = $d;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e[$a[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($e[$h[$x]] == 0)\n {\n unset($e[$h[$x]]);\n }\n}\n$f = $d;\nfor($x = 0; $x < strlen($b); $x++)\n{\n $f[$b[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == 0)\n {\n unset($f[$h[$x]]);\n }\n}\n$g = $d;\nfor($x = 0; $x < strlen($c); $x++)\n{\n $g[$c[$x]]++;\n}\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == 0)\n {\n unset($g[$h[$x]]);\n }\n}\n$i = array();\n$j = $g;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $f[$h[$x]]);\n $i[$x] = $k;\n }\n}\n$l = min($i);\n$m = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($l * $f[$h[$x]]);\n }\n}\n$n = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $o = floor($m[$h[$x]] / $g[$h[$x]]);\n $n[$x] = $o;\n }\n}\n$p = min($n);\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $m[$h[$x]] -= ($p * $g[$h[$x]]);\n }\n}\n$r = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $k = floor($e[$h[$x]] / $g[$h[$x]]);\n $r[$x] = $k;\n }\n}\n$s = min($r);\n$t = $e;\nfor($x = 0; $x < 26; $x++)\n{\n if($g[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($s * $g[$h[$x]]);\n }\n}\n$u = array();\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $o = floor($t[$h[$x]] / $f[$h[$x]]);\n $u[$x] = $o;\n }\n}\n$v = min($u);\nfor($x = 0; $x < 26; $x++)\n{\n if($f[$h[$x]] == TRUE)\n {\n $t[$h[$x]] -= ($v * $f[$h[$x]]);\n }\n}\nif(($l + $p) >= ($s + $v))\n{\n $w = \"\";\n for($x = 1; $x <= $l; $x++)\n {\n $w .= $b;\n }\n for($x = 1; $x <= $p; $x++)\n {\n $w .= $c;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $m[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n print $w;\n}\nelse\n{\n $w = \"\";\n for($x = 1; $x <= $s; $x++)\n {\n $w .= $c;\n }\n for($x = 1; $x <= $v; $x++)\n {\n $w .= $b;\n }\n for($x = 0; $x < 26; $x++)\n {\n for($y = 0; $y < $t[$h[$x]]; $y++)\n {\n $w .= $h[$x];\n }\n }\n if($a[0] == \"i\")\n {\n print strlen($a) . \" \" . strlen($w);\n }\n else\n {\n print $w;\n }\n}\n?>"}, {"source_code": " $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$n = 0;\n\nwhile ( $n <= $lena ) {\n\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho $a;\n\n?> "}, {"source_code": " $lena) and ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\n$arr_a = $arr_b = $arr_c = array();\n\nfor ($i=0; $i < $lena; $i++) { \n $k = $a[$i];\n $arr_a[$k] ++;\n}\n\nfor ($i=0; $i < $lenb; $i++) { \n $k = $b[$i];\n $arr_b[$k] ++;\n}\n\nfor ($i=0; $i < $lenc; $i++) { \n $k = $c[$i];\n $arr_c[$k] ++;\n}\n\n$max_b = $lena;\nforeach ($arr_b as $key => $value) {\n if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {\n $max_b = 0;\n break;\n } elseif ($max_b > intval($arr_x[$key] / $value)) {\n $max_b = intval($arr_a[$key] / $value);\n }\n}\n\n$max = 0;\n$col_b = $col_c = 0;\n$arr_x = $arr_a;\nfor ($i=0; $i <= $max_b ; $i++) { \n\n $max_c = $lena;\n foreach ($arr_c as $key => $value) {\n if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {\n $max_c = 0;\n break;\n } elseif ($max_c > intval($arr_x[$key] / $value)) {\n $max_c = intval($arr_x[$key] / $value);\n }\n }\n\n if ($max < ($i + $max_c)) {\n $max = $i + $max_c;\n $col_b = $i;\n $col_c = $max_c;\n }\n\n foreach ($arr_b as $key => $value) {\n $arr_x[$key] -= $value;\n } \n}\n\n$out = '';\n\nfor ($i=1; $i <= $col_b ; $i++) { \n $out .= $b;\n foreach ($arr_b as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nfor ($i=1; $i <= $col_c ; $i++) { \n $out .= $c;\n foreach ($arr_c as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nforeach ($arr_a as $key => $value) {\n if ($value !== 0) {\n $out .= str_repeat(\"$key\", $value);\n }\n}\n\necho \"$out\\n\";\n\n?> "}, {"source_code": " $lena) or ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\nif ($lenb > $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$n = 0;\n\nwhile ( $n < $lena ) {\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenb; $i++) { \n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $b[$i];\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenc; $i++) { \n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n// $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $c[$i];\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho \"$a\\n\";\n\n?> "}, {"source_code": " $lena) and ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\n$arr_a = $arr_b = $arr_c = array();\n\nfor ($i=0; $i < $lena; $i++) { \n $k = $a[$i];\n $arr_a[$k] ++;\n}\n\nfor ($i=0; $i < $lenb; $i++) { \n $k = $b[$i];\n $arr_b[$k] ++;\n}\n\nfor ($i=0; $i < $lenc; $i++) { \n $k = $c[$i];\n $arr_c[$k] ++;\n}\n\n$max_b = $lena;\nforeach ($arr_b as $key => $value) {\n if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {\n $max_b = 0;\n break;\n } elseif ($max_b > intval($arr_x[$key] / $value)) {\n $max_b = intval($arr_a[$key] / $value);\n }\n}\n\n$max = 0;\n$col_b = $col_c = 0;\n$arr_x = $arr_a;\nfor ($i=0; $i <= $max_b ; $i++) { \n\n $max_c = $lena;\n foreach ($arr_c as $key => $value) {\n if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {\n $max_c = 0;\n break;\n } elseif ($max_c > intval($arr_x[$key] / $value)) {\n $max_c = intval($arr_x[$key] / $value);\n }\n }\n\n if ($max < ($i + $max_c)) {\n $max = $i + $max_c;\n $col_b = $i;\n $col_c = $max_c;\n }\n\n foreach ($arr_b as $key => $value) {\n $arr_x[$key] -= $value;\n } \n}\n\n$out = '';\n\nfor ($i=1; $i <= $col_b ; $i++) { \n// $out .= $b;\n echo \"$b\";\n foreach ($arr_b as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nfor ($i=1; $i <= $col_c ; $i++) { \n// $out .= $c;\n echo \"$c\";\n foreach ($arr_c as $key => $value) {\n $arr_a[$key] -= $value;\n } \n}\n\nforeach ($arr_a as $key => $value) {\n if ($value !== 0) {\n// $out .= str_repeat(\"$key\", $value);\n echo str_repeat(\"$key\", $value);\n }\n}\n\necho \"$out\\n\";\n\n?> "}, {"source_code": " $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$n = 0;\n\nwhile ( $n <= $lena ) {\n\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho \"$a\\n\";\n\n?> "}, {"source_code": " $lena) or ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\nif ($lenb > $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$n = 0;\n\nwhile ( $n < $lena ) {\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenb; $i++) { \n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n// $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $b[$i];\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenc; $i++) { \n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n// $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $c[$i];\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho \"$a\\n\";\n\n?> "}, {"source_code": " $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$flag = true;\n$n = 0;\n\nwhile ( $n <= $lena ) {\n\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho $a;\n\n?> "}, {"source_code": " $lena) or ($lenc > $lena)) {\n echo \"$a\\n\";\n exit;\n}\n\nif ($lenb > $lenc) {\n $x = $b;\n $b = $c;\n $c = $x;\n $x = $lenb;\n $lenb = $lenc;\n $lenc = $x;\n}\n\n$n = 0;\n\nwhile ( $n < $lena ) {\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenb; $i++) { \n if (strpos ($str, $b[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenb) {\n for ($i=0; $i < $lenb; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $b[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n if ($n >= $lena) {\n break;\n }\n\n $str = substr($a, $n);\n for ($i=0; $i < $lenc; $i++) { \n if (strpos ($str, $c[$i]) === false) {\n break;\n } \n }\n\n if ($i === $lenc) {\n for ($i=0; $i < $lenc; $i++) { \n $str = substr($a, $n);\n $pos = strpos ($str, $c[$i]);\n $x = substr($a, $n+$pos, 1);\n $a[$n+$pos] = $a[$n];\n $a[$n] = $x;\n $n ++; \n }\n continue;\n }\n\n break;\n}\n\necho \"$a\\n\";\n\n?> "}], "src_uid": "9dc956306e2826229e393657f2d0d9bd"} {"nl": {"description": "You are both a shop keeper and a shop assistant at a small nearby shop. You have $$$n$$$ goods, the $$$i$$$-th good costs $$$a_i$$$ coins.You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for all $$$n$$$ goods you have.However, you don't want to lose any money so you want to choose the price in such a way that the sum of new prices is not less than the sum of the initial prices. It means that if you sell all $$$n$$$ goods for the new price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.On the other hand, you don't want to lose customers because of big prices so among all prices you can choose you need to choose the minimum one.So you need to find the minimum possible equal price of all $$$n$$$ goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.You have to answer $$$q$$$ independent queries.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 100$$$) \u2014 the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \\le n \\le 100)$$$ \u2014 the number of goods. The second line of the query contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^7$$$), where $$$a_i$$$ is the price of the $$$i$$$-th good.", "output_spec": "For each query, print the answer for it \u2014 the minimum possible equal price of all $$$n$$$ goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.", "sample_inputs": ["3\n5\n1 2 3 4 5\n3\n1 2 2\n4\n1 1 1 1"], "sample_outputs": ["3\n2\n1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " $iSum - $iMax){\n echo \"NO\";\n } else {\n echo \"YES\";\n }\n}\n\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " array_sum($d))\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " $c - $b[0])\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " $e)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " $c - $d)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $a) || ($b == 1))\n{\n print \"-1\";\n}\nelse\n{\n $d = $b - 2;\n $e = implode(array_slice($c, 2, $d));\n $f = \"ab\";\n $g = $a - strlen($e);\n $h = $g / 2;\n $i = \"\";\n $j = floor($h);\n if($g % 2 == 0)\n {\n for($x = 1; $x <= $j + 1; $x++)\n {\n if($x == $j + 1)\n {\n $i .= $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n else\n {\n for($x = 1; $x <= $j + 1; $x++)\n {\n if($x == $j + 1)\n {\n $i = $i . \"a\" . $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n print $i;\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " $a) || ($b == 1))\n{\n print \"-1\";\n}\nelseif($a == $b)\n{\n print implode(array_slice($c, 0, $a));\n}\nelse\n{\n $d = $b - 2;\n $e = implode(array_slice($c, 2, $d));\n $f = \"ab\";\n $g = $a - strlen($e);\n $h = $g / 2;\n $i = \"\";\n $j = floor($h);\n if($g % 2 == 0)\n {\n for($x = 1; $x <= $j; $x++)\n {\n if($x == $j)\n {\n $i .= $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n else\n {\n for($x = 1; $x <= $j + 1; $x++)\n {\n if($x == $j + 1)\n {\n $i = $i . \"a\" . $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n print $i;\n}\n?>"}, {"source_code": " $a) || ($b == 1))\n{\n print \"-1\";\n}\nelseif($a == $b)\n{\n print implode(array_slice($c, 0, $a));\n}\nelse\n{\n $d = $b - 2;\n $e = implode(array_slice($c, 2, $d));\n $f = \"ab\";\n $g = $a - strlen($e);\n $h = $g / 2;\n $i = \"\";\n $j = floor($h);\n if($g % 2 == 0)\n {\n for($x = 1; $x <= $j + 1; $x++)\n {\n if($x == $j + 1)\n {\n $i .= $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n else\n {\n for($x = 1; $x <= $j + 1; $x++)\n {\n if($x == $j + 1)\n {\n $i = $i . \"a\" . $e;\n }\n else\n {\n $i .= $f;\n }\n }\n }\n print $i;\n}\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "2f659be28674a81f58f5c587b6a0f465"} {"nl": {"description": "Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much. A song is a sequence of notes. Dima and Inna want to play each note at the same time. At that, they can play the i-th note at volume v (1\u2009\u2264\u2009v\u2009\u2264\u2009ai; v is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the i-th note was played on the guitar and the piano must equal bi. If Dima and Inna cannot play a note by the described rules, they skip it and Sereja's joy drops by 1. But if Inna and Dima play the i-th note at volumes xi and yi (xi\u2009+\u2009yi\u2009=\u2009bi) correspondingly, Sereja's joy rises by xi\u00b7yi. Sereja has just returned home from the university and his current joy is 0. Help Dima and Inna play the song so as to maximize Sereja's total joy after listening to the whole song!", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of notes in the song. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009106). The third line contains n integers bi (1\u2009\u2264\u2009bi\u2009\u2264\u2009106).", "output_spec": "In a single line print an integer \u2014 the maximum possible joy Sereja feels after he listens to a song.", "sample_inputs": ["3\n1 1 2\n2 2 3", "1\n2\n5"], "sample_outputs": ["4", "-1"], "notes": "NoteIn the first sample, Dima and Inna play the first two notes at volume 1 (1\u2009+\u20091\u2009=\u20092, the condition holds), they should play the last note at volumes 1 and 2. Sereja's total joy equals: 1\u00b71\u2009+\u20091\u00b71\u2009+\u20091\u00b72\u2009=\u20094.In the second sample, there is no such pair (x,\u2009y), that 1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u20092, x\u2009+\u2009y\u2009=\u20095, so Dima and Inna skip a note. Sereja's total joy equals -1."}, "positive_code": [{"source_code": "= $c[$x]) && ($c[$x] != 1))\n {\n $e = floor($c[$x] / 2);\n $f = ceil($c[$x] / 2);\n $d = bcadd($d, bcmul($e, $f));\n }\n else\n {\n $d--;\n }\n}\nprint $d;\n?>"}, {"source_code": "= $vol && $vol > 1) {\n\t\tif ($vol % 2 == 0) {\n\t\t\t$tosquare = $vol / 2;\n\t\t\t$joyadd = pow($tosquare, 2);\n\t\t\t$joy += $joyadd;\n\t\t} else {\n\t\t\t$down = floor($vol / 2);\n\t\t\t$up = ceil($vol / 2);\n\t\t\t$joy += $up * $down;\n\t\t}\n\t} else {\n\t\t$joy--;\n\t}\n}\necho implode(explode(\",\", number_format($joy, 0)));\n?>"}], "negative_code": [{"source_code": "= $c[$x])\n {\n $e = floor($c[$x] / 2);\n $f = ceil($c[$x] / 2);\n $d += $e * $f;\n }\n else\n {\n $d--;\n }\n}\nprint $d;\n?>"}, {"source_code": "= $c[$x]) && ($c[$x] != 1))\n {\n $e = floor($c[$x] / 2);\n $f = ceil($c[$x] / 2);\n $d += $e * $f;\n }\n else\n {\n $d--;\n }\n}\nprint $d;\n?>"}], "src_uid": "986a7d97e62856d5301d5a70ea01466a"} {"nl": {"description": "Ezzat has an array of $$$n$$$ integers (maybe negative). He wants to split it into two non-empty subsequences $$$a$$$ and $$$b$$$, such that every element from the array belongs to exactly one subsequence, and the value of $$$f(a) + f(b)$$$ is the maximum possible value, where $$$f(x)$$$ is the average of the subsequence $$$x$$$. A sequence $$$x$$$ is a subsequence of a sequence $$$y$$$ if $$$x$$$ can be obtained from $$$y$$$ by deletion of several (possibly, zero or all) elements.The average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.For example, the average of $$$[1,5,6]$$$ is $$$(1+5+6)/3 = 12/3 = 4$$$, so $$$f([1,5,6]) = 4$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^3$$$)\u2014 the number of test cases. Each test case consists of two lines. The first line contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$-10^9 \\le a_i \\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3\\cdot10^5$$$.", "output_spec": "For each test case, print a single value \u2014 the maximum value that Ezzat can achieve. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\\frac{|a - b|}{\\max{(1, |b|)}} \\le 10^{-6}$$$.", "sample_inputs": ["4\n3\n3 1 2\n3\n-7 -6 -6\n3\n2 2 2\n4\n17 3 5 -3"], "sample_outputs": ["4.500000000\n-12.500000000\n4.000000000\n18.666666667"], "notes": "NoteIn the first test case, the array is $$$[3, 1, 2]$$$. These are all the possible ways to split this array: $$$a = [3]$$$, $$$b = [1,2]$$$, so the value of $$$f(a) + f(b) = 3 + 1.5 = 4.5$$$. $$$a = [3,1]$$$, $$$b = [2]$$$, so the value of $$$f(a) + f(b) = 2 + 2 = 4$$$. $$$a = [3,2]$$$, $$$b = [1]$$$, so the value of $$$f(a) + f(b) = 2.5 + 1 = 3.5$$$. Therefore, the maximum possible value $$$4.5$$$.In the second test case, the array is $$$[-7, -6, -6]$$$. These are all the possible ways to split this array: $$$a = [-7]$$$, $$$b = [-6,-6]$$$, so the value of $$$f(a) + f(b) = (-7) + (-6) = -13$$$. $$$a = [-7,-6]$$$, $$$b = [-6]$$$, so the value of $$$f(a) + f(b) = (-6.5) + (-6) = -12.5$$$. Therefore, the maximum possible value $$$-12.5$$$."}, "positive_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = IO::arr();\r\n sort($a);\r\n $b = $c = $d = $x = [];\r\n $res = 0;\r\n $key = $n - 1;\r\n $b = [$a[$key]];\r\n unset($a[$key]);\r\n $res = (array_sum($b) / count($b)) + (array_sum($a) / count($a));\r\n IO::line($res);\r\n\r\n}\r\n\r\n\r\n?>"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = IO::arr();\r\n sort($a);\r\n $b = $c = $d = $x = [];\r\n $res = 0;\r\n $last = $last2 = 0;\r\n $bool = true;\r\n foreach ($a as $v) {\r\n if ($v < 0) {\r\n if (isset($b[$v])) {\r\n $x[$v] = $v;\r\n } else {\r\n $last = $v;\r\n $b[$v] = $v;\r\n }\r\n } else {\r\n if (isset($c[$v])) {\r\n $d[$v] = $v;\r\n } else {\r\n $last2 = $v;\r\n $c[$v] = $v;\r\n }\r\n }\r\n }\r\n foreach ($d as $v) {\r\n $b[$v] = $v;\r\n }\r\n foreach ($x as $v) {\r\n $c[$v] = $v;\r\n }\r\n if (count($b) == 0) {\r\n $b[$last2] = $last2;\r\n unset($c[$last2]);\r\n }\r\n if (count($c) == 0) {\r\n $c[$last] = $last;\r\n unset($b[$last]);\r\n }\r\n $res = (array_sum($b) / count($b)) + (array_sum($c) / count($c));\r\n IO::line($res);\r\n\r\n}\r\n\r\n\r\n?>"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = IO::arr();\r\n sort($a);\r\n $b = $c = $d = $x = [];\r\n $res = 0;\r\n $last = $last2 = 0;\r\n $bool = true;\r\n foreach ($a as $v) {\r\n if ($v < 0) {\r\n if (isset($b[$v])) {\r\n $x[$v] = $v;\r\n } else {\r\n $last = $v;\r\n $b[$v] = $v;\r\n }\r\n } else {\r\n if (isset($c[$v])) {\r\n $d[$v] = $v;\r\n } else {\r\n $last2 = $v;\r\n $c[$v] = $v;\r\n }\r\n }\r\n }\r\n if (count($b) % 2 == 1) {\r\n unset($b[$last]);\r\n $c[$last] = $last;\r\n }\r\n foreach ($d as $v) {\r\n $b[$v] = $v;\r\n }\r\n foreach ($x as $v) {\r\n $c[$v] = $v;\r\n }\r\n if (count($b) == 0) {\r\n $b[$last2] = $last2;\r\n unset($c[$last2]);\r\n }\r\n if (count($c) == 0) {\r\n $c[$last] = $last;\r\n unset($b[$last]);\r\n }\r\n $res = (array_sum($b) / count($b)) + (array_sum($c) / count($c));\r\n IO::line($res);\r\n\r\n}\r\n\r\n\r\n?>"}], "src_uid": "159b9c743d6d8792548645b9f7be2753"} {"nl": {"description": "Suppose you are living with two cats: A and B. There are $$$n$$$ napping spots where both cats usually sleep.Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically: Cat A changes its napping place in order: $$$n, n - 1, n - 2, \\dots, 3, 2, 1, n, n - 1, \\dots$$$ In other words, at the first hour it's on the spot $$$n$$$ and then goes in decreasing order cyclically; Cat B changes its napping place in order: $$$1, 2, 3, \\dots, n - 1, n, 1, 2, \\dots$$$ In other words, at the first hour it's on the spot $$$1$$$ and then goes in increasing order cyclically. The cat B is much younger, so they have a strict hierarchy: A and B don't lie together. In other words, if both cats'd like to go in spot $$$x$$$ then the A takes this place and B moves to the next place in its order (if $$$x < n$$$ then to $$$x + 1$$$, but if $$$x = n$$$ then to $$$1$$$). Cat B follows his order, so it won't return to the skipped spot $$$x$$$ after A frees it, but will move to the spot $$$x + 2$$$ and so on.Calculate, where cat B will be at hour $$$k$$$?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. The first and only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\le n \\le 10^9$$$; $$$1 \\le k \\le 10^9$$$)\u00a0\u2014 the number of spots and hour $$$k$$$.", "output_spec": "For each test case, print one integer\u00a0\u2014 the index of the spot where cat B will sleep at hour $$$k$$$.", "sample_inputs": ["7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1337"], "sample_outputs": ["1\n2\n1\n3\n2\n2\n65"], "notes": "NoteIn the first and second test cases $$$n = 2$$$, so: at the $$$1$$$-st hour, A is on spot $$$2$$$ and B is on $$$1$$$; at the $$$2$$$-nd hour, A moves to spot $$$1$$$ and B\u00a0\u2014 to $$$2$$$. If $$$n = 3$$$ then: at the $$$1$$$-st hour, A is on spot $$$3$$$ and B is on $$$1$$$; at the $$$2$$$-nd hour, A moves to spot $$$2$$$; B'd like to move from $$$1$$$ to $$$2$$$, but this spot is occupied, so it moves to $$$3$$$; at the $$$3$$$-rd hour, A moves to spot $$$1$$$; B also would like to move from $$$3$$$ to $$$1$$$, but this spot is occupied, so it moves to $$$2$$$. In the sixth test case: A's spots at each hour are $$$[5, 4, 3, 2, 1]$$$; B's spots at each hour are $$$[1, 2, 4, 5, 2]$$$. "}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": "=18);\n}\necho $cnt;"}, {"source_code": "=18);\n}\necho $cnt;"}, {"source_code": "=18);\n}\necho $cnt;"}, {"source_code": "=18);\n}\necho $cnt;"}, {"source_code": "=18);\n}\necho $cnt;"}, {"source_code": ""}, {"source_code": "\n$n=trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++)\n $arr[]=trim(fgets(STDIN));\n$alc=array('ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE');\n$count=0;\nforeach($arr as $val){\n if(in_array($val,$alc) || ((int)$val<18 && (int)$val!=0))\n $count++;\n}\necho $count;\n?>"}], "src_uid": "4b7b0fba7b0af78c3956c34c29785e7c"} {"nl": {"description": "As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's twins help him: they've already made n snowballs with radii equal to r1, r2, ..., rn. To make a snowman, one needs any three snowballs whose radii are pairwise different. For example, the balls with radii 1, 2 and 3 can be used to make a snowman but 2, 2, 3 or 2, 2, 2 cannot. Help Sergey and his twins to determine what maximum number of snowmen they can make from those snowballs.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of snowballs. The next line contains n integers \u2014 the balls' radii r1, r2, ..., rn (1\u2009\u2264\u2009ri\u2009\u2264\u2009109). The balls' radii can coincide.", "output_spec": "Print on the first line a single number k \u2014 the maximum number of the snowmen. Next k lines should contain the snowmen's descriptions. The description of each snowman should consist of three space-separated numbers \u2014 the big ball's radius, the medium ball's radius and the small ball's radius. It is allowed to print the snowmen in any order. If there are several solutions, print any of them.", "sample_inputs": ["7\n1 2 3 4 5 6 7", "3\n2 2 3"], "sample_outputs": ["2\n3 2 1\n6 5 4", "0"], "notes": null}, "positive_code": [{"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n $k = $k - 1;\n $k = strval($k);\n $l = $l - 1;\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(w == 454100276)\n {\n print $j . \" \" . $k . \" \" . $l . \"\\n\";\n print $d[$j] . \" \" . $d[$k] . \" \" . $d[$l] . \"\\n\";\n }\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] != 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] != 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] != 1)\n {\n $l .= \"1\";\n }\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n if(strlen($j) > 10)\n {\n $j = bcsub($j, 1);\n }\n else\n {\n $j = $j - 1;\n }\n $j = strval($j);\n if(strlen($k) > 10)\n {\n $k = bcsub($k, 1);\n }\n else\n {\n $k = $k - 1;\n }\n $k = strval($k);\n if(strlen($l) > 10)\n {\n $l = bcsub($l, 1);\n }\n else\n {\n $l = $l - 1;\n }\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $b[$y]) && ($d[$y] == FALSE))\n {\n $g = $y;\n break;\n }\n }\n for($y = $h; $y < $a; $y++)\n {\n if($b[$g] > $b[$y])\n {\n $h = $y;\n break;\n }\n }\n if(($f == ($a - 1)) || ($g == ($a - 1)))\n {\n break;\n }\n if($h == ($a - 1))\n {\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n $i++;\n break;\n }\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n $i++;\n }\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e) - 1; $x++)\n {\n print $e[$x] . \"\\n\";\n }\n print $e[$x];\n}\n?>"}, {"source_code": "= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $g = $y;\n if($h == $y)\n {\n $h = $y + 1;\n }\n break;\n }\n }\n }\n if(($c[$d[$f]] < $c[$d[$f + 1]]) || ($c[$d[$f]] == 0))\n {\n $k = $f;\n for($y = $k; $y < $a - 2; $y++)\n {\n if(($c[$d[$y]] >= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $f = $y;\n if($g == $y)\n {\n $g = $y + 1;\n if($h == $y + 1)\n {\n $h = $y + 2;\n }\n }\n break;\n }\n }\n }\n }\n if(count($e) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(w == 454100276)\n {\n print $j . \" \" . $k . \" \" . $l . \"\\n\";\n print $d[$j] . \" \" . $d[$k] . \" \" . $d[$l] . \"\\n\";\n }\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] !== 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] !== 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] !== 1)\n {\n $l .= \"1\";\n }\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] !== 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": "= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $g = $y;\n if($h == $y)\n {\n $h = $y + 1;\n }\n break;\n }\n }\n }\n if(($c[$d[$f]] < $c[$d[$f + 1]]) || ($c[$d[$f]] == 0))\n {\n $k = $f;\n for($y = $k; $y < $a - 2; $y++)\n {\n if(($c[$d[$y]] >= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $f = $y;\n if($g == $y)\n {\n $g = $y + 1;\n if($h == $y + 1)\n {\n $h = $y + 2;\n }\n }\n break;\n }\n }\n }\n }\n if(count($e) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n for($x = 0; $x < $a; $x++)\n {\n $c[$b[$x]]++;\n }\n $d = array_keys($c);\n $e = array();\n for($x = 0; $x < count($c); $x++)\n {\n $e[$c[$d[$x]]][count($e[$c[$d[$x]]])] = $d[$x];\n }\n $f = new SplMaxHeap();\n for($x = 0; $x < count($c); $x++)\n {\n $f -> insert($c[$d[$x]]);\n }\n $g = array();\n while(TRUE)\n {\n if(count($f) < 3)\n {\n break;\n }\n $h = $f -> top();\n $f -> extract();\n $i = $f -> top();\n $f -> extract();\n $j = $f -> top();\n $f -> extract();\n if(($h == $i) && ($i == $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = next($e[$h]);\n $n = next($e[$h]);\n unset($e[$h][$o]);\n unset($e[$h][$o + 1]);\n unset($e[$h][$o + 2]);\n $k = array($l, $m, $n);\n rsort($k);\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g[count($g)] = implode(\" \", $k);\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n elseif(($h == $i) && ($i != $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = next($e[$h]);\n $n = reset($e[$j]);\n $o2 = key($e[$j]);\n unset($e[$h][$o]);\n unset($e[$h][$o + 1]);\n unset($e[$j][$o2]);\n $k = array($l, $m, $n);\n rsort($k);\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g[count($g)] = implode(\" \", $k);\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[1];\n $f -> insert($h);\n }\n if($j != 0)\n {\n $p = end($e[$j]);\n $r = key($e[$j]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n elseif(($h != $i) && ($i == $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = reset($e[$i]);\n $o2 = key($e[$i]);\n $n = next($e[$i]);\n unset($e[$h][$o]);\n unset($e[$i][$o2]);\n unset($e[$i][$o2 + 1]);\n $k = array($l, $m, $n);\n rsort($k);\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g[count($g)] = implode(\" \", $k);\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[2];\n $f -> insert($i);\n }\n }\n elseif(($h != $i) && ($i != $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = reset($e[$i]);\n $o2 = key($e[$i]);\n $n = reset($e[$j]);\n $o3 = key($e[$j]);\n unset($e[$h][$o]);\n unset($e[$i][$o2]);\n unset($e[$j][$o3]);\n $k = array($l, $m, $n);\n rsort($k);\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g[count($g)] = implode(\" \", $k);\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$j]);\n $r = key($e[$j]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n }\n if(count($g) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($g) . \"\\n\";\n for($x = 0; $x < count($g); $x++)\n {\n print $g[$x] . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $b[$y]) && ($d[$y] == FALSE))\n {\n $g = $y;\n break;\n }\n }\n for($y = $h; $y < $a; $y++)\n {\n if($b[$g] > $b[$y])\n {\n $h = $y;\n break;\n }\n }\n if(($f == ($a - 1)) || ($g == ($a - 1)))\n {\n break;\n }\n if($h == ($a - 1))\n {\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n break;\n }\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n $i++;\n }\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e) - 1; $x++)\n {\n print $e[$x] . \"\\n\";\n }\n print $e[$x];\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(w == 585134828)\n {\n print_r($c);\n break;\n print $j . \" \" . $k . \" \" . $l . \"\\n\";\n print $d[$j] . \" \" . $d[$k] . \" \" . $d[$l] . \"\\n\";\n }\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n unset($d[$j + 1]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n unset($d[$k + 1]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n unset($d[$l + 1]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n unset($d[$j + 1]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n unset($d[$k + 1]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n unset($d[$l + 1]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] != 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] != 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] != 1)\n {\n $l .= \"1\";\n }\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " 0)\n {\n $e[$h] = $d[$i];\n $c[$d[$i]]--;\n if($c[$d[$j]] > 0)\n {\n $f[$h] = $d[$j];\n $c[$d[$j]]--;\n if($c[$d[$k]] > 0)\n {\n $g[$h] = $d[$k];\n $c[$d[$k]]--;\n $h++;\n if($c[$d[$i]] == 0)\n {\n unset($c[$d[$i]]);\n }\n if($c[$d[$j]] == 0)\n {\n unset($c[$d[$j]]);\n }\n if($c[$d[$k]] == 0)\n {\n unset($c[$d[$k]]);\n }\n if(count($c) < 3)\n {\n break;\n }\n }\n else\n {\n unset($e[$h]);\n $c[$d[$i]]++;\n unset($f[$h]);\n $c[$d[$j]]++;\n $k++;\n }\n }\n else\n {\n unset($e[$h]);\n $c[$d[$i]]++;\n $j++;\n }\n }\n else\n {\n $i++;\n }\n }\n if(count($e) != 0)\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n $l = array($e[$x], $f[$x], $g[$x]);\n rsort($l);\n print implode(\" \", $l) . \"\\n\";\n }\n }\n else\n {\n print \"0\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": "= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $g = $y;\n if($h == $y)\n {\n $h = $y + 1;\n }\n break;\n }\n }\n }\n if(($c[$d[$f]] < $c[$d[$f + 1]]) || ($c[$d[$f]] == 0))\n {\n $k = $f;\n for($y = $k; $y < $a - 2; $y++)\n {\n if(($c[$d[$y]] >= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $f = $y;\n if($g == $y)\n {\n $g = $y + 1;\n if($h == $y + 1)\n {\n $h = $y + 2;\n }\n }\n break;\n }\n }\n }\n }\n if(count($e) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(w == 585134828)\n {\n print $j . \" \" . $k . \" \" . $l . \"\\n\";\n print $d[$j] . \" \" . $d[$k] . \" \" . $d[$l] . \"\\n\";\n }\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n unset($d[$j + 1]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n unset($d[$k + 1]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n unset($d[$l + 1]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " $b[$y]) && ($d[$y] == FALSE))\n {\n $g = $y;\n break;\n }\n }\n $j = 0;\n for($y = $h; $y < $a; $y++)\n {\n if($b[$g] > $b[$y])\n {\n $j = 1;\n $h = $y;\n break;\n }\n }\n if((($f == ($a - 1)) || ($g == ($a - 1))) || ($j == 0))\n {\n break;\n }\n if($h == ($a - 1))\n {\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n break;\n }\n $e[$i] = $b[$f] . \" \" . $b[$g] . \" \" . $b[$h];\n $d[$f] = 1;\n $d[$g] = 1;\n $d[$h] = 1;\n $i++;\n }\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e) - 1; $x++)\n {\n print $e[$x] . \"\\n\";\n }\n print $e[$x];\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n $k = $k - 1;\n $k = strval($k);\n $l = $l - 1;\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": "= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $g = $y;\n if($h == $y)\n {\n $h = $y + 1;\n }\n break;\n }\n }\n }\n if(($c[$d[$f]] < $c[$d[$f + 1]]) || ($c[$d[$f]] == 0))\n {\n $k = $f;\n for($y = $k; $y < $a - 2; $y++)\n {\n if(($c[$d[$y]] >= $c[$d[$y + 1]]) && ($c[$d[$y]] != 0))\n {\n $f = $y;\n if($g == $y)\n {\n $g = $y + 1;\n if($h == $y + 1)\n {\n $h = $y + 2;\n }\n }\n break;\n }\n }\n }\n }\n if(count($e) == 0)\n {\n print \"0\";\n }\n else\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n $c = array();\n for($x = 0; $x < $a; $x++)\n {\n $c[$b[$x]]++;\n }\n $d = array_keys($c);\n $e = array();\n $f = new SplMaxHeap();\n for($x = 0; $x < count($c); $x++)\n {\n $e[$c[$d[$x]]][count($e[$c[$d[$x]]])] = $d[$x];\n $f -> insert($c[$d[$x]]);\n }\n $g = \"\";\n $g2 = 0;\n while(TRUE)\n {\n if(count($f) < 3)\n {\n break;\n }\n $h = $f -> top();\n $f -> extract();\n $i = $f -> top();\n $f -> extract();\n $j = $f -> top();\n $f -> extract();\n $k = array();\n if(($h == $i) && ($i == $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = next($e[$h]);\n $n = next($e[$h]);\n unset($e[$h][$o]);\n unset($e[$h][$o + 1]);\n unset($e[$h][$o + 2]);\n if(($l >= $m) && ($l >= $n))\n {\n if($m >= $n)\n {\n $k[0] = $l;\n $k[1] = $m;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $l;\n $k[1] = $n;\n $k[2] = $m;\n }\n }\n elseif(($m >= $l) && ($m >= $n))\n {\n if($l >= $n)\n {\n $k[0] = $m;\n $k[1] = $l;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $m;\n $k[1] = $n;\n $k[2] = $l;\n }\n }\n elseif(($n >= $m) && ($n >= $l))\n {\n if($m >= $l)\n {\n $k[0] = $n;\n $k[1] = $m;\n $k[2] = $l;\n }\n else\n {\n $k[0] = $n;\n $k[1] = $l;\n $k[2] = $m;\n }\n }\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g .= $k[0] . \" \" . $k[1] . \" \" . $k[2] . \"\\n\";\n $g2++;\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n elseif(($h == $i) && ($i != $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = next($e[$h]);\n $n = reset($e[$j]);\n $o2 = key($e[$j]);\n unset($e[$h][$o]);\n unset($e[$h][$o + 1]);\n unset($e[$j][$o2]);\n if(($l >= $m) && ($l >= $n))\n {\n if($m >= $n)\n {\n $k[0] = $l;\n $k[1] = $m;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $l;\n $k[1] = $n;\n $k[2] = $m;\n }\n }\n elseif(($m >= $l) && ($m >= $n))\n {\n if($l >= $n)\n {\n $k[0] = $m;\n $k[1] = $l;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $m;\n $k[1] = $n;\n $k[2] = $l;\n }\n }\n elseif(($n >= $m) && ($n >= $l))\n {\n if($m >= $l)\n {\n $k[0] = $n;\n $k[1] = $m;\n $k[2] = $l;\n }\n else\n {\n $k[0] = $n;\n $k[1] = $l;\n $k[2] = $m;\n }\n }\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g .= $k[0] . \" \" . $k[1] . \" \" . $k[2] . \"\\n\";\n $g2++;\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[1];\n $f -> insert($h);\n }\n if($j != 0)\n {\n $p = end($e[$j]);\n $r = key($e[$j]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n elseif(($h != $i) && ($i == $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = reset($e[$i]);\n $o2 = key($e[$i]);\n $n = next($e[$i]);\n unset($e[$h][$o]);\n unset($e[$i][$o2]);\n unset($e[$i][$o2 + 1]);\n if(($l >= $m) && ($l >= $n))\n {\n if($m >= $n)\n {\n $k[0] = $l;\n $k[1] = $m;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $l;\n $k[1] = $n;\n $k[2] = $m;\n }\n }\n elseif(($m >= $l) && ($m >= $n))\n {\n if($l >= $n)\n {\n $k[0] = $m;\n $k[1] = $l;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $m;\n $k[1] = $n;\n $k[2] = $l;\n }\n }\n elseif(($n >= $m) && ($n >= $l))\n {\n if($m >= $l)\n {\n $k[0] = $n;\n $k[1] = $m;\n $k[2] = $l;\n }\n else\n {\n $k[0] = $n;\n $k[1] = $l;\n $k[2] = $m;\n }\n }\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g .= $k[0] . \" \" . $k[1] . \" \" . $k[2] . \"\\n\";\n $g2++;\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[2];\n $f -> insert($i);\n }\n }\n elseif(($h != $i) && ($i != $j))\n {\n $l = reset($e[$h]);\n $o = key($e[$h]);\n $m = reset($e[$i]);\n $o2 = key($e[$i]);\n $n = reset($e[$j]);\n $o3 = key($e[$j]);\n unset($e[$h][$o]);\n unset($e[$i][$o2]);\n unset($e[$j][$o3]);\n if(($l >= $m) && ($l >= $n))\n {\n if($m >= $n)\n {\n $k[0] = $l;\n $k[1] = $m;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $l;\n $k[1] = $n;\n $k[2] = $m;\n }\n }\n elseif(($m >= $l) && ($m >= $n))\n {\n if($l >= $n)\n {\n $k[0] = $m;\n $k[1] = $l;\n $k[2] = $n;\n }\n else\n {\n $k[0] = $m;\n $k[1] = $n;\n $k[2] = $l;\n }\n }\n elseif(($n >= $m) && ($n >= $l))\n {\n if($m >= $l)\n {\n $k[0] = $n;\n $k[1] = $m;\n $k[2] = $l;\n }\n else\n {\n $k[0] = $n;\n $k[1] = $l;\n $k[2] = $m;\n }\n }\n if(($k[0] == $k[1]) || ($k[1] == $k[2]))\n {\n break;\n }\n $g .= $k[0] . \" \" . $k[1] . \" \" . $k[2] . \"\\n\";\n $g2++;\n $h--;\n $i--;\n $j--; \n if($h != 0)\n {\n $p = end($e[$h]);\n $r = key($e[$h]);\n $e[$h][$r + 1] = $k[0];\n $f -> insert($h);\n }\n if($i != 0)\n {\n $p = end($e[$i]);\n $r = key($e[$i]);\n $e[$i][$r + 1] = $k[1];\n $f -> insert($i);\n }\n if($j != 0)\n {\n $p = end($e[$j]);\n $r = key($e[$j]);\n $e[$j][$r + 1] = $k[2];\n $f -> insert($j);\n }\n }\n }\n if($g2 == 0)\n {\n print $g2;\n }\n else\n {\n print $g2 . \"\\n\";\n print $g;\n }\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $k = $k - 1;\n $l = $l - 1;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " 0)\n {\n $e[$h] = $d[$i];\n $c[$d[$i]]--;\n if($c[$d[$j]] > 0)\n {\n $f[$h] = $d[$j];\n $c[$d[$j]]--;\n if($c[$d[$k]] > 0)\n {\n $g[$h] = $d[$k];\n $c[$d[$k]]--;\n $h++;\n if($c[$d[$i]] == 0)\n {\n unset($c[$d[$i]]);\n }\n if($c[$d[$j]] == 0)\n {\n unset($c[$d[$j]]);\n }\n if($c[$d[$k]] == 0)\n {\n unset($c[$d[$k]]);\n }\n if(count($c) < 3)\n {\n break;\n }\n }\n else\n {\n unset($e[$h]);\n $c[$d[$i]]++;\n unset($f[$h]);\n $c[$d[$j]]++;\n $k++;\n }\n }\n else\n {\n unset($e[$h]);\n $c[$d[$i]]++;\n $j++;\n }\n }\n else\n {\n $i++;\n }\n }\n if(count($e) != 0)\n {\n print count($e) . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \" \" . $f[$x] . \" \" . $g[$x] . \"\\n\";\n }\n }\n else\n {\n print \"0\";\n }\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n unset($d[$j + 1]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n unset($d[$k + 1]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n unset($d[$l + 1]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] != 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] != 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] != 1)\n {\n $l .= \"1\";\n }\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] != 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] != 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] != 1)\n {\n $l .= \"1\";\n }\n if($j >= 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($k >= 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n if($l >= 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j = $j - 1;\n $j = strval($j);\n if($j[strlen($j) - 1] != 1)\n {\n $j .= \"1\";\n }\n $k = $k - 1;\n $k = strval($k);\n if($k[strlen($k) - 1] != 1)\n {\n $k .= \"1\";\n }\n $l = $l - 1;\n $l = strval($l);\n if($l[strlen($l) - 1] != 1)\n {\n $l .= \"1\";\n }\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n $m = $j + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n $m = $k + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n $m = $l + 1;\n $m = strval($m);\n if($m[strlen($m) - 1] != 1)\n {\n $m .= \"1\";\n }\n unset($d[$m]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}, {"source_code": " insert($g);\n}\n$i = array();\nwhile(count($h) > 2)\n{\n $j = $h -> extract();\n $k = $h -> extract();\n $l = $h -> extract();\n if(($d[$j] > $d[$k]) && ($d[$j] > $d[$l]))\n {\n if($d[$k] > $d[$l])\n {\n $m = $d[$j] . \" \" . $d[$k] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$j] . \" \" . $d[$l] . \" \" . $d[$k];\n }\n }\n elseif(($d[$k] > $d[$j]) && ($d[$k] > $d[$l]))\n {\n if($d[$j] > $d[$l])\n {\n $m = $d[$k] . \" \" . $d[$j] . \" \" . $d[$l];\n }\n else\n {\n $m = $d[$k] . \" \" . $d[$l] . \" \" . $d[$j];\n }\n }\n elseif(($d[$l] > $d[$j]) && ($d[$l] > $d[$k]))\n {\n if($d[$j] > $d[$k])\n {\n $m = $d[$l] . \" \" . $d[$j] . \" \" . $d[$k];\n }\n else\n {\n $m = $d[$l] . \" \" . $d[$k] . \" \" . $d[$j];\n }\n }\n $i[count($i)] = $m;\n $j--;\n $k--;\n $l--;\n $j = strval($j);\n $k = strval($k);\n $l = strval($l);\n if($j > 1)\n {\n $m = $j + 1;\n $m = strval($m);\n $d[$j] = $d[$m];\n unset($d[$m]);\n $h -> insert($j);\n }\n else\n {\n unset($d[$j + 1]);\n }\n if($k > 1)\n {\n $m = $k + 1;\n $m = strval($m);\n $d[$k] = $d[$m];\n unset($d[$m]);\n $h -> insert($k);\n }\n else\n {\n unset($d[$k + 1]);\n }\n if($l > 1)\n {\n $m = $l + 1;\n $m = strval($m);\n $d[$l] = $d[$m];\n unset($d[$m]);\n $h -> insert($l);\n }\n else\n {\n unset($d[$l + 1]);\n }\n}\nprint count($i) . \"\\n\";\nfor($x = 0; $x < count($i); $x++)\n{\n print $i[$x] . \"\\n\";\n}\n?>"}], "src_uid": "551e66a4b3da71682652d84313adb8ab"} {"nl": {"description": "Alice has a grid with $$$2$$$ rows and $$$n$$$ columns. She fully covers the grid using $$$n$$$ dominoes of size $$$1 \\times 2$$$\u00a0\u2014 Alice may place them vertically or horizontally, and each cell should be covered by exactly one domino.Now, she decided to show one row of the grid to Bob. Help Bob and figure out what the other row of the grid looks like!", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 5000$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 the width of the grid. The second line of each test case contains a string $$$s$$$ consisting of $$$n$$$ characters, each of which is either L, R, U, or D, representing the left, right, top, or bottom half of a domino, respectively (see notes for better understanding). This string represents one of the rows of the grid. Additional constraint on the input: each input corresponds to at least one valid tiling.", "output_spec": "For each test case, output one string\u00a0\u2014 the other row of the grid, using the same format as the input string. If there are multiple answers, print any.", "sample_inputs": ["4\n1\nU\n2\nLR\n5\nLRDLR\n6\nUUUUUU"], "sample_outputs": ["D\nLR\nLRULR\nDDDDDD"], "notes": "NoteIn the first test case, Alice shows Bob the top row, the whole grid may look like: In the second test case, Alice shows Bob the bottom row, the whole grid may look like: In the third test case, Alice shows Bob the bottom row, the whole grid may look like: In the fourth test case, Alice shows Bob the top row, the whole grid may look like: "}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "b894e16e8c00f8d97fde4a104466b3ef"} {"nl": {"description": "You are given a string s, consisting of lowercase English letters, and the integer m.One should choose some symbols from the given string so that any contiguous subsegment of length m has at least one selected symbol. Note that here we choose positions of symbols, not the symbols themselves.Then one uses the chosen symbols to form a new string. All symbols from the chosen position should be used, but we are allowed to rearrange them in any order.Formally, we choose a subsequence of indices 1\u2009\u2264\u2009i1\u2009<\u2009i2\u2009<\u2009...\u2009<\u2009it\u2009\u2264\u2009|s|. The selected sequence must meet the following condition: for every j such that 1\u2009\u2264\u2009j\u2009\u2264\u2009|s|\u2009-\u2009m\u2009+\u20091, there must be at least one selected index that belongs to the segment [j,\u2009\u00a0j\u2009+\u2009m\u2009-\u20091], i.e. there should exist a k from 1 to t, such that j\u2009\u2264\u2009ik\u2009\u2264\u2009j\u2009+\u2009m\u2009-\u20091.Then we take any permutation p of the selected indices and form a new string sip1sip2... sipt.Find the lexicographically smallest string, that can be obtained using this procedure.", "input_spec": "The first line of the input contains a single integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009100\u2009000). The second line contains the string s consisting of lowercase English letters. It is guaranteed that this string is non-empty and its length doesn't exceed 100\u2009000. It is also guaranteed that the number m doesn't exceed the length of the string s.", "output_spec": "Print the single line containing the lexicographically smallest string, that can be obtained using the procedure described above.", "sample_inputs": ["3\ncbabc", "2\nabcab", "3\nbcabcbaccba"], "sample_outputs": ["a", "aab", "aaabb"], "notes": "NoteIn the first sample, one can choose the subsequence {3} and form a string \"a\".In the second sample, one can choose the subsequence {1,\u20092,\u20094} (symbols on this positions are 'a', 'b' and 'a') and rearrange the chosen symbols to form a string \"aab\"."}, "positive_code": [{"source_code": " 0, \"b\" => 0, \"c\" => 0, \"d\" => 0, \"e\" => 0, \"f\" => 0, \"g\" => 0, \"h\" => 0, \"i\" => 0, \"j\" => 0, \"k\" => 0, \"l\" => 0, \"m\" => 0, \"n\" => 0, \"o\" => 0, \"p\" => 0, \"q\" => 0, \"r\" => 0, \"s\" => 0, \"t\" => 0, \"u\" => 0, \"v\" => 0, \"w\" => 0, \"x\" => 0, \"y\" => 0, \"z\" => 0);\n$d = 0;\n$e = array(\"a\" => 0, \"b\" => 0, \"c\" => 0, \"d\" => 0, \"e\" => 0, \"f\" => 0, \"g\" => 0, \"h\" => 0, \"i\" => 0, \"j\" => 0, \"k\" => 0, \"l\" => 0, \"m\" => 0, \"n\" => 0, \"o\" => 0, \"p\" => 0, \"q\" => 0, \"r\" => 0, \"s\" => 0, \"t\" => 0, \"u\" => 0, \"v\" => 0, \"w\" => 0, \"x\" => 0, \"y\" => 0, \"z\" => 0);\n$f2 = array();\nfor($x = 0; $x < count($b); $x++)\n{\n $e[$b[$x]] = $x;\n $f2[$d] = $b[$x];\n $d++;\n $f = $d % $a;\n if($f == 0)\n {\n $d = 0;\n $f3 = min($f2);\n $c[$f3]++;\n $x = $e[$f3];\n $f2 = array();\n $e = array(\"a\" => 0, \"b\" => 0, \"c\" => 0, \"d\" => 0, \"e\" => 0, \"f\" => 0, \"g\" => 0, \"h\" => 0, \"i\" => 0, \"j\" => 0, \"k\" => 0, \"l\" => 0, \"m\" => 0, \"n\" => 0, \"o\" => 0, \"p\" => 0, \"q\" => 0, \"r\" => 0, \"s\" => 0, \"t\" => 0, \"u\" => 0, \"v\" => 0, \"w\" => 0, \"x\" => 0, \"y\" => 0, \"z\" => 0);\n }\n}\n$g = array(\"a\" => 0, \"b\" => 0, \"c\" => 0, \"d\" => 0, \"e\" => 0, \"f\" => 0, \"g\" => 0, \"h\" => 0, \"i\" => 0, \"j\" => 0, \"k\" => 0, \"l\" => 0, \"m\" => 0, \"n\" => 0, \"o\" => 0, \"p\" => 0, \"q\" => 0, \"r\" => 0, \"s\" => 0, \"t\" => 0, \"u\" => 0, \"v\" => 0, \"w\" => 0, \"x\" => 0, \"y\" => 0, \"z\" => 0);\nfor($x = 0; $x < count($b); $x++)\n{\n $g[$b[$x]]++;\n}\nif($c[z] == TRUE)\n{\n $h = $c[z];\n $i = z;\n}\nelseif($c[y] == TRUE)\n{\n $h = $c[y];\n $i = y;\n}\nelseif($c[x] == TRUE)\n{\n $h = $c[x];\n $i = x;\n}\nelseif($c[w] == TRUE)\n{\n $h = $c[w];\n $i = w;\n}\nelseif($c[v] == TRUE)\n{\n $h = $c[v];\n $i = v;\n}\nelseif($c[u] == TRUE)\n{\n $h = $c[u];\n $i = u;\n}\nelseif($c[t] == TRUE)\n{\n $h = $c[t];\n $i = t;\n}\nelseif($c[s] == TRUE)\n{\n $h = $c[s];\n $i = s;\n}\nelseif($c[r] == TRUE)\n{\n $h = $c[r];\n $i = r;\n}\nelseif($c[q] == TRUE)\n{\n $h = $c[q];\n $i = q;\n}\nelseif($c[p] == TRUE)\n{\n $h = $c[p];\n $i = p;\n}\nelseif($c[o] == TRUE)\n{\n $h = $c[o];\n $i = o;\n}\nelseif($c[n] == TRUE)\n{\n $h = $c[n];\n $i = n;\n}\nelseif($c[m] == TRUE)\n{\n $h = $c[m];\n $i = m;\n}\nelseif($c[l] == TRUE)\n{\n $h = $c[l];\n $i = l;\n}\nelseif($c[k] == TRUE)\n{\n $h = $c[k];\n $i = k;\n}\nelseif($c[j] == TRUE)\n{\n $h = $c[j];\n $i = j;\n}\nelseif($c[i] == TRUE)\n{\n $h = $c[i];\n $i = i;\n}\nelseif($c[h] == TRUE)\n{\n $h = $c[h];\n $i = h;\n}\nelseif($c[g] == TRUE)\n{\n $h = $c[g];\n $i = g;\n}\nelseif($c[f] == TRUE)\n{\n $h = $c[f];\n $i = f;\n}\nelseif($c[e] == TRUE)\n{\n $h = $c[e];\n $i = e;\n}\nelseif($c[d] == TRUE)\n{\n $h = $c[d];\n $i = d;\n}\nelseif($c[c] == TRUE)\n{\n $h = $c[c];\n $i = c;\n}\nelseif($c[b] == TRUE)\n{\n $h = $c[b];\n $i = b;\n}\nelseif($c[a] == TRUE)\n{\n $h = $c[a];\n $i = a;\n}\n$j = \"\";\n$k = array_keys($c);\nfor($x = 0; $x < 26; $x++)\n{\n if($k[$x] == $i)\n {\n $l = implode(array_fill(0, $h, $i));\n $j .= $l;\n break;\n }\n else\n {\n $l = implode(array_fill(0, $g[$k[$x]], $k[$x]));\n $j .= $l;\n }\n}\nprint $j;\n?>"}], "negative_code": [], "src_uid": "2924053ee058c531254d690f0b12d324"} {"nl": {"description": "There are three cells on an infinite 2-dimensional grid, labeled $$$A$$$, $$$B$$$, and $$$F$$$. Find the length of the shortest path from $$$A$$$ to $$$B$$$ if: in one move you can go to any of the four adjacent cells sharing a side; visiting the cell $$$F$$$ is forbidden (it is an obstacle). ", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases in the input. Then $$$t$$$ test cases follow. Before each test case, there is an empty line. Each test case contains three lines. The first one contains two integers $$$x_A, y_A$$$ ($$$1 \\le x_A, y_A \\le 1000$$$)\u00a0\u2014 coordinates of the start cell $$$A$$$. The second one contains two integers $$$x_B, y_B$$$ ($$$1 \\le x_B, y_B \\le 1000$$$)\u00a0\u2014 coordinates of the finish cell $$$B$$$. The third one contains two integers $$$x_F, y_F$$$ ($$$1 \\le x_F, y_F \\le 1000$$$)\u00a0\u2014 coordinates of the forbidden cell $$$F$$$. All cells are distinct. Coordinate $$$x$$$ corresponds to the column number and coordinate $$$y$$$ corresponds to the row number (see the pictures below).", "output_spec": "Output $$$t$$$ lines. The $$$i$$$-th line should contain the answer for the $$$i$$$-th test case: the length of the shortest path from the cell $$$A$$$ to the cell $$$B$$$ if the cell $$$F$$$ is not allowed to be visited.", "sample_inputs": ["7\n\n1 1\n3 3\n2 2\n\n2 5\n2 1\n2 3\n\n1000 42\n1000 1\n1000 1000\n\n1 10\n3 10\n2 10\n\n3 8\n7 8\n3 7\n\n2 1\n4 1\n1 1\n\n1 344\n1 10\n1 1"], "sample_outputs": ["4\n6\n41\n4\n4\n2\n334"], "notes": "Note An example of a possible shortest path for the first test case. An example of a possible shortest path for the second test case. "}, "positive_code": [{"source_code": " $y[2]) { $r += 2; }\r\n }\r\n \r\n if ($y[0] == $y[1] && $y[2] == $y[0]) { \r\n $min = min($x[0], $x[1]);\r\n $max = max($x[0], $x[1]);\r\n if ($min < $x[2] && $max > $x[2]) { $r += 2; }\r\n }\r\n \r\n echo $r.PHP_EOL;\r\n}\r\n\r\n?>"}], "negative_code": [], "src_uid": "6422d76f71702e77808b1cc041962bb8"} {"nl": {"description": "You are given an array $$$a_1, a_2, \\dots , a_n$$$, which is sorted in non-decreasing order ($$$a_i \\le a_{i + 1})$$$. Find three indices $$$i$$$, $$$j$$$, $$$k$$$ such that $$$1 \\le i < j < k \\le n$$$ and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$ (for example it is possible to construct a non-degenerate triangle with sides $$$3$$$, $$$4$$$ and $$$5$$$ but impossible with sides $$$3$$$, $$$4$$$ and $$$7$$$). If it is impossible to find such triple, report it.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \\le n \\le 5 \\cdot 10^4$$$)\u00a0\u2014 the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots , a_n$$$ ($$$1 \\le a_i \\le 10^9$$$; $$$a_{i - 1} \\le a_i$$$)\u00a0\u2014 the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case print the answer to it in one line. If there is a triple of indices $$$i$$$, $$$j$$$, $$$k$$$ ($$$i < j < k$$$) such that it is impossible to construct a non-degenerate triangle having sides equal to $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$, print that three indices in ascending order. If there are multiple answers, print any of them. Otherwise, print -1.", "sample_inputs": ["3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000"], "sample_outputs": ["2 3 6\n-1\n1 2 3"], "notes": "NoteIn the first test case it is impossible with sides $$$6$$$, $$$11$$$ and $$$18$$$. Note, that this is not the only correct answer.In the second test case you always can construct a non-degenerate triangle."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "341555349b0c1387334a0541730159ac"} {"nl": {"description": "Casimir has a string $$$s$$$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions: he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent); or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent). Therefore, each turn the length of the string is decreased exactly by $$$2$$$. All turns are independent so for each turn, Casimir can choose any of two possible actions.For example, with $$$s$$$\u00a0$$$=$$$\u00a0\"ABCABC\" he can obtain a string $$$s$$$\u00a0$$$=$$$\u00a0\"ACBC\" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.For a given string $$$s$$$ determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. Each test case is described by one string $$$s$$$, for which you need to determine if it can be fully erased by some sequence of turns. The string $$$s$$$ consists of capital letters 'A', 'B', 'C' and has a length from $$$1$$$ to $$$50$$$ letters, inclusive.", "output_spec": "Print $$$t$$$ lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).", "sample_inputs": ["6\nABACAB\nABBA\nAC\nABC\nCABCBB\nBCBCBCBCBCBCBCBC"], "sample_outputs": ["NO\nYES\nNO\nNO\nYES\nYES"], "notes": null}, "positive_code": [{"source_code": " $value)\r\n\tprint($value.\"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n\tprint($value.\"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": " $value)\r\n\tprint($value.\"\\r\\n\");\r\n$end = readline();\r\n?>"}, {"source_code": ""}, {"source_code": " 0 || $iC > 0) {\r\n echo 'NO' . PHP_EOL;\r\n } else if ($iC - $iB > 0 || $iA) {\r\n echo 'NO' . PHP_EOL;\r\n } else {\r\n echo 'YES' . PHP_EOL;\r\n }\r\n \r\n\r\n}"}, {"source_code": " 0) {\r\n echo 'NO' . PHP_EOL;\r\n } else if ($iC - $iB > 0) {\r\n echo 'NO' . PHP_EOL;\r\n } else {\r\n echo 'YES' . PHP_EOL;\r\n }\r\n}"}], "src_uid": "ca6b162f945d4216055bf92d7263dbd5"} {"nl": {"description": "Are you going to Scarborough Fair?Parsley, sage, rosemary and thyme.Remember me to one who lives there.He once was the true love of mine.Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.Although the girl wants to help, Willem insists on doing it by himself.Grick gave Willem a string of length n.Willem needs to do m operations, each operation has four parameters l,\u2009r,\u2009c1,\u2009c2, which means that all symbols c1 in range [l,\u2009r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.Grick wants to know the final string after all the m operations.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). The second line contains a string s of length n, consisting of lowercase English letters. Each of the next m lines contains four parameters l,\u2009r,\u2009c1,\u2009c2 (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009n, c1,\u2009c2 are lowercase English letters), separated by space.", "output_spec": "Output string s after performing m operations described above.", "sample_inputs": ["3 1\nioi\n1 1 i n", "5 3\nwxhak\n3 3 h x\n1 5 x a\n1 3 w g"], "sample_outputs": ["noi", "gaaak"], "notes": "NoteFor the second example:After the first operation, the string is wxxak.After the second operation, the string is waaak.After the third operation, the string is gaaak."}, "positive_code": [{"source_code": ""}, {"source_code": " $replacement]) .\n substr($string, $to + 1);\n}\necho $string, PHP_EOL;\n"}], "negative_code": [], "src_uid": "3f97dc063286a7af4838b7cd1c01df69"} {"nl": {"description": "There are $$$n$$$ pieces of cake on a line. The $$$i$$$-th piece of cake has weight $$$a_i$$$ ($$$1 \\leq i \\leq n$$$).The tastiness of the cake is the maximum total weight of two adjacent pieces of cake (i.\u00a0e., $$$\\max(a_1+a_2,\\, a_2+a_3,\\, \\ldots,\\, a_{n-1} + a_{n})$$$).You want to maximize the tastiness of the cake. You are allowed to do the following operation at most once (doing more operations would ruin the cake): Choose a contiguous subsegment $$$a[l, r]$$$ of pieces of cake ($$$1 \\leq l \\leq r \\leq n$$$), and reverse it. The subsegment $$$a[l, r]$$$ of the array $$$a$$$ is the sequence $$$a_l, a_{l+1}, \\dots, a_r$$$.If you reverse it, the array will become $$$a_1, a_2, \\dots, a_{l-2}, a_{l-1}, \\underline{a_r}, \\underline{a_{r-1}}, \\underline{\\dots}, \\underline{a_{l+1}}, \\underline{a_l}, a_{r+1}, a_{r+2}, \\dots, a_{n-1}, a_n$$$.For example, if the weights are initially $$$[5, 2, 1, 4, 7, 3]$$$, you can reverse the subsegment $$$a[2, 5]$$$, getting $$$[5, \\underline{7}, \\underline{4}, \\underline{1}, \\underline{2}, 3]$$$. The tastiness of the cake is now $$$5 + 7 = 12$$$ (while before the operation the tastiness was $$$4+7=11$$$).Find the maximum tastiness of the cake after doing the operation at most once.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 50$$$) \u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 1000$$$) \u2014 the number of pieces of cake. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$) \u2014 $$$a_i$$$ is the weight of the $$$i$$$-th piece of cake.", "output_spec": "For each test case, print a single integer: the maximum tastiness of the cake after doing the operation at most once.", "sample_inputs": ["5\n6\n5 2 1 4 7 3\n3\n32 78 78\n3\n69 54 91\n8\n999021 999021 999021 999021 999652 999021 999021 999021\n2\n1000000000 1000000000"], "sample_outputs": ["12\n156\n160\n1998673\n2000000000"], "notes": "NoteIn the first test case, after reversing the subsegment $$$a[2, 5]$$$, you get a cake with weights $$$[5, \\underline{7}, \\underline{4}, \\underline{1}, \\underline{2}, 3]$$$. The tastiness of the cake is now $$$\\max(5+7, 7+4, 4+1, 1+2, 2+3) = 12$$$. This is the maximum possible tastiness of the cake one can obtain by performing the operation at most once.In the second test case, it's optimal not to do any operation. The tastiness is $$$78+78 = 156$$$.In the third test case, after reversing the subsegment $$$a[1, 2]$$$, you get a cake with weights $$$[\\underline{54}, \\underline{69}, 91]$$$. The tastiness of the cake is now $$$\\max(54+69, 69+91) = 160$$$. There is no way to make the tastiness of the cake greater than $$$160$$$ by performing at most one operation."}, "positive_code": [{"source_code": " $a[1] ? $a[0] : $a[1];\r\n $max2 = $a[0] < $a[1] ? $a[0] : $a[1];\r\n for($i=2; $i<$n; $i++) {\r\n if($a[$i] > $max1) {\r\n $max2 = $max1;\r\n $max1 = $a[$i];\r\n } elseif($a[$i] > $max2) {\r\n $max2 = $a[$i];\r\n }\r\n \r\n }\r\n \r\n echo $max1 + $max2 . \"\\n\";\r\n \r\n }\r\n "}], "negative_code": [{"source_code": " $a[1] ? $a[0] : $a[1];\r\n $max2 = $a[0] < $a[1] ? $a[0] : $a[1];\r\n for($i=2; $i<$n-1; $i++) {\r\n if($a[$i] > $max1) {\r\n $max2 = $max1;\r\n $max1 = $a[$i];\r\n } elseif($a[$i] > $max2) {\r\n $max2 = $a[$i];\r\n }\r\n \r\n }\r\n \r\n echo $max1 + $max2 . \"\\n\";\r\n \r\n }"}], "src_uid": "b856eafe350fccaabd39b97fb18d9c2f"} {"nl": {"description": "A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters \"-\".We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format \"dd-mm-yyyy\". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy \"0012-10-2012-10-2012\" mentions date 12-10-2012 twice (first time as \"0012-10-2012-10-2012\", second time as \"0012-10-2012-10-2012\").The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format \"dd-mm-yyyy\", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date \"1-1-2013\" isn't recorded in the format \"dd-mm-yyyy\", and date \"01-01-2013\" is recorded in it.Notice, that any year between 2013 and 2015 is not a leap year.", "input_spec": "The first line contains the Prophesy: a non-empty string that only consists of digits and characters \"-\". The length of the Prophesy doesn't exceed 105 characters.", "output_spec": "In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.", "sample_inputs": ["777-444---21-12-2013-12-2013-12-2013---444-777"], "sample_outputs": ["13-12-2013"], "notes": null}, "positive_code": [{"source_code": "= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"02\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"28\"))) || (($i == \"03\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"04\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"30\"))) || (($i == \"05\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"06\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"30\"))) || (($i == \"07\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"08\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"09\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"30\"))) || (($i == \"10\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))) || (($i == \"11\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"30\"))) || (($i == \"12\") && (($j >= \"2013\") && ($j <= \"2015\")) && (($h >= \"01\") && ($h <= \"31\"))))\n {\n array_push($b, substr($a, $x - 2, 10));\n }\n }\n}\nsort($b);\n$c = array_unique($b);\n$d = array_keys($c);\narray_push($d, count($b));\n$e = $c;\nsort($e);\n$f = array();\nfor($x = 0; $x < count($e); $x++)\n{\n array_push($f, $d[$x + 1] - $d[$x]);\n}\narsort($f);\n$g = array_keys($f);\nprint $e[$g[0]];\n?>"}, {"source_code": "\n$s = trim(fgets(STDIN));\n$time = 1356998400;\nfor ($i=0;$i<1095;++$i){\n$a[$i] = date('d-m-Y',$time);\n$time=$time+86400;\n}\n$l = strlen($s);\nfor ($i=0;$i<$l;++$i) {\n$count[substr($s,$i,10)]++;\n}\n\nfor ($i=0;$i<1095;++$i){\nif ($count[$a[$i]] > $max) {\n $ind = $a[$i];\n $max = $count[$a[$i]];\n}\n}\n\necho $ind;\n"}, {"source_code": " 0 && $month > 0 && $month < 13 && $day <= $months[$month - 1]) {\n if (array_key_exists($value, $dates))\n $dates[$value] += 1;\n else\n $dates[$value] = intval(\"1\");\n }\n\t}\n\n\t$max = 0;\n\t$answer = \"\";\n\tforeach ($dates as $key => $value) {\n\t\tif ($max < $value) {\n\t\t\t$max = $value;\n\t\t\t$answer = $key;\n\t\t}\n\t}\n\n\techo $answer;\n?>"}, {"source_code": "0&&$day>0&&$day<=$months[$month-1]){\n\t\t\tif(array_key_exists($cur,$date)){\n\t\t\t\t$date[$cur]++;\n\t\t\t}\t\n\t\t\telse $date[$cur]=1;\n\t\t}\n\t}\n\t$max=0;\n\t$ans=\"\";\n\tforeach($date as $key=>$value){\n\t\tif($max<$value){\n\t\t\t\t$max=$value;\n\t\t\t\t$ans=$key;\n\t\t\t}\t\n\t}\n\techo $ans.PHP_EOL;\n?>\n"}], "negative_code": [{"source_code": ""}], "src_uid": "dd7fd84f7915ad57b0e21f416e2a3ea0"} {"nl": {"description": "Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all numbers from this segment was maximal possible. Help him with that.The xor operation is the bitwise exclusive \"OR\", that is denoted as \"xor\" in Pascal and \"^\" in C/C++/Java.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of elements in the array. The second line contains the space-separated integers from the array. All numbers are non-negative integers strictly less than 230.", "output_spec": "Print a single integer \u2014 the required maximal xor of a segment of consecutive elements.", "sample_inputs": ["5\n1 2 1 1 2", "3\n1 2 7", "4\n4 2 4 8"], "sample_outputs": ["3", "7", "14"], "notes": "NoteIn the first sample one of the optimal segments is the segment that consists of the first and the second array elements, if we consider the array elements indexed starting from one.The second sample contains only one optimal segment, which contains exactly one array element (element with index three)."}, "positive_code": [{"source_code": " $c)\n{\n $c = $j;\n}\n$d = 2;\n$g = range(0, $a - 1);\n$h = 0;\n$i = 1;\nif($a != 1)\n{\n while(TRUE)\n {\n $e = array_slice($b, $g[$h], $d);\n $h++;\n $f = intval($e[0]);\n for($y = 1; $y < count($e); $y++)\n {\n $f = $f ^ $e[$y];\n }\n if($f > $c)\n {\n $c = $f;\n }\n if($h == count($g) - $i)\n {\n $h = 0;\n if($d == count($g))\n {\n break;\n }\n $d++;\n $i++;\n }\n }\n}\nprint $c;\n?>"}, {"source_code": "\n$f = fopen( 'php://stdin', 'r' );\n \nfgets($f);\n$nums = explode(\" \", fgets($f));\n \n$last = array();\n$otr = array();\n$max = 0;\nfor ($i = 0; $i <= count($nums); $i++) {\nfor ($j = $i; $j <= count($nums); $j++) {\nif (!array_search(implode(\"\", $otr), $last)) {\n$xor = getxor($otr);\nif ($xor > $max) $max = $xor;\n}\n$otr[] = $nums[$j];\n}\n$otr = array();\n}\n \necho $max;\n \nfunction getxor($otr) {\n$xor = 0;\nforeach ($otr as $num) {\n$xor ^= $num;\n}\nreturn $xor;\n}"}, {"source_code": " $max_round){\n $max_round = $current;\n }\n }\n if($max_round > $max){\n $max = $max_round;\n }\n}\n\necho $max;"}, {"source_code": "= $max) $max = $res;\n }\n echo $max;"}], "negative_code": [{"source_code": " $c)\n {\n $c = $f;\n }\n if($h == count($g) - $i)\n {\n $h = 0;\n $d++;\n if($d == count($g))\n {\n break;\n }\n $i++;\n }\n}\nprint $c;\n?>"}, {"source_code": " $max_round){\n $max_round = $current;\n }\n }\n if($max_round > $max){\n $max = $max_round;\n }\n}\necho $max;"}], "src_uid": "a33991c9d7fdb4a4e00c0d0e6902bee1"} {"nl": {"description": "In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second \u2014 number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 \u2014 AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23. Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.", "input_spec": "The first line of the input contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 .", "output_spec": "Write n lines, each line should contain a cell coordinates in the other numeration system.", "sample_inputs": ["2\nR23C55\nBC23"], "sample_outputs": ["BC23\nR23C55"], "notes": null}, "positive_code": [{"source_code": " $baseNum)\n\t\t{\n\t\t\t$left = $num % $baseNum;\n\t\t\t$num = intval($num / $baseNum);\n\t\t\tif(!$left)\n\t\t\t{\n\t\t\t\t$left = 26;\n\t\t\t\t$num--;\n\t\t\t}\n\t\t\t\n\t\t\t$res = chr($left + $baseChar) . $res;\n\t\t\t\n\t\t\n\t\t}\n\t\t\n\t\tif($num)\n\t\t{\n\t\t\t$res = chr($num + $baseChar) . $res;\n\t\t}\n\t\t\n\t\t$res .= $matches[1];\n\t\t\n\t\techo $res . PHP_EOL;\n\t}\n\telse\n\t{\n\t\tpreg_match('/([A-Z]+)(\\d+)/', $str, $matches);\n\t\t\n\t\t$res = 'R' . $matches[2] . 'C';\n\t\t\n\t\t$str = str_split($matches[1]);\n\t\t$pos = count($str) - 1;\n\t\t$sum = 0;\n\t\tforeach($str as $chr)\n\t\t{\n\t\t\t$sum += (ord($chr) - $baseChar) * pow($baseNum, $pos);\n\t\t\t$pos--;\n\t\t}\n\t\t\n\t\techo $res . $sum . PHP_EOL;\n\t\t\n\t}\n}"}, {"source_code": "=0; $j--, $d*=26)\n\t\t\t\t$c += (ord($s[$j])-64)*$d;\n\t\t\techo 'R', $matches[2], 'C', $c, \"\\n\";\n\t\t}\n\t}\n?>"}, {"source_code": " \"0\",\n \"A\" => \"1\",\n \"B\" => \"2\",\n \"C\" => \"3\",\n \"D\" => \"4\",\n \"E\" => \"5\",\n \"F\" => \"6\",\n \"G\" => \"7\",\n \"H\" => \"8\",\n \"I\" => \"9\",\n \"J\" => \"A\",\n \"K\" => \"B\",\n \"L\" => \"C\",\n \"M\" => \"D\",\n \"N\" => \"E\",\n \"O\" => \"F\",\n \"P\" => \"G\",\n \"Q\" => \"H\",\n \"R\" => \"I\",\n \"S\" => \"J\",\n \"T\" => \"K\",\n \"U\" => \"L\",\n \"V\" => \"M\",\n \"W\" => \"N\",\n \"X\" => \"O\",\n \"Y\" => \"P\",\n \"Z\" => \"Q\");\n\n$letters = array(\n \"0\" => \"0\",\n \"1\" => \"1\",\n \"2\" => \"2\",\n \"3\" => \"3\",\n \"4\" => \"4\",\n \"5\" => \"5\",\n \"6\" => \"6\",\n \"7\" => \"7\",\n \"8\" => \"8\",\n \"9\" => \"9\",\n \"10\" => \"A\",\n \"11\" => \"B\",\n \"12\" => \"C\",\n \"13\" => \"D\",\n \"14\" => \"E\",\n \"15\" => \"F\",\n \"16\" => \"G\",\n \"17\" => \"H\",\n \"18\" => \"I\",\n \"19\" => \"J\",\n \"20\" => \"K\",\n \"21\" => \"L\",\n \"22\" => \"M\",\n \"23\" => \"N\",\n \"24\" => \"O\",\n \"25\" => \"P\",\n \"26\" => \"Q\");\n\n$newcells = array();\n\nfunction mybase26($number) { //something funky that takes out the zeros and replaces them with \"Z\"s (non-existent in base 26) and decrements the next highest place value\n //coming from base 10\n global $letters;\n $places = array();\n $places[4] = 0;\n $places[3] = 0;\n $places[2] = 0;\n $places[1] = 0;\n $places[0] = 0;\n //the number can't have a fives place since it's smaller than 10^6\n //yes we're brute forcing here\n if ($number > 456976 && $number - 456976 > 17576 && $number - 456976 - 17576 > 676 && $number - 456976 - 17576 - 676 > 26 && $number - 456976 - 17576 - 676 - 26 > 0) { //notice how we're not using >=, this is so that we don't reach a zero and we can use the Zs. In a normal conversion function this would take out allll the 456976s possible, here, we leave one, if there's one left.\n do {\n $number = $number - 456976; //26^4\n $places[4]++;\n } while ($number > 456976 && $number - 456976 > 17576 && $number - 456976 - 17576 > 676 && $number - 456976 - 17576 - 676 > 26 && $number - 456976 - 17576 - 676 - 26 > 0); //also we're making sure we're not taking out a threes place here\n }\n if ($number > 17576 && $number - 17576 > 676 && $number - 17576 - 676 > 26 && $number - 17576 - 676 - 26 > 0) { \n do {\n $number = $number - 17576; //26^3\n $places[3]++;\n } while ($number > 17576 && $number - 17576 > 676 && $number - 17576 - 676 > 26 && $number - 17576 - 676 - 26 > 0);\n }\n if ($number > 676 && $number - 676 > 26 && $number - 676 - 26 > 0) {\n do {\n $number = $number - 676;\n $places[2]++;\n } while ($number > 676 && $number - 676 > 26 && $number - 676 - 26 > 0);\n }\n if ($number > 26 && $number - 26 > 0) {\n do {\n $number = $number - 26;\n $places[1]++;\n } while ($number > 26 && $number - 26 > 0);\n }\n if ($number <= 26) { //because we close this baby out and take it all home in the last place, we use <= here.\n $places[0] = $number;\n }\n\n //now we have the place values; just get them into letters if bigger than 9.\n $places[4] = $letters[$places[4]];\n $places[3] = $letters[$places[3]];\n $places[2] = $letters[$places[2]];\n $places[1] = $letters[$places[1]];\n $places[0] = $letters[$places[0]];\n\n return ltrim($places[4].$places[3].$places[2].$places[1].$places[0], \"0\");\n}\n\nfunction mybase10($number) { //with an array that includes Z = 26\n //from base 26\n global $letters;\n $explode = str_split($number);\n $power = 0; //of 26\n $sum = 0; //result\n\n foreach ($explode as $key => $value) { //convert from A to 10, for example\n $explode[$key] = array_search($value, $letters);\n }\n\n //tricky way of reversing number to start with zeros place and then increase\n $reversedAndReindexed = array_values(array_reverse($explode));\n $places = count($reversedAndReindexed);\n\n for ($i = 0; $i < $places; $i++) {\n $sum = $sum + (pow(26, $power) * $reversedAndReindexed[$i]); //learn something new everyday. pow is the base to exponent function. And to think I guessed it from my text editor.\n $power++;\n }\n\n return $sum;\n}\n\nfunction numbertoletter($number) {\n global $shiftover;\n $base26 = str_split(mybase26($number)); //get from base 10 to base 26\n $shift = \"\";\n foreach ($base26 as $value) { //now shift all the characters over to start at A instead of 1\n $shift .= array_search($value, $shiftover);\n }\n return $shift;\n}\n\nfunction lettertonumber($letter) {\n global $shiftover;\n $explode = str_split($letter);\n $shift = \"\";\n foreach ($explode as $value) { //shift all the characters over to start at 1 instead of A\n $shift .= $shiftover[$value];\n }\n\n $base10 = mybase10($shift);\n return $base10;\n}\n\n//main(), if you will\nfor ($i = 0; $i < $n; $i++) {\n $cell = trim(fgets(STDIN)); //$cell = $array[$i];\n if (preg_match(\"/R([0-9]+)C([0-9]+)/\", $cell, $matches) == TRUE) {\n $matches[2] = numbertoletter($matches[2]);\n $newcells[] = $matches[2].$matches[1];\n } else {\n preg_match(\"/([A-Z]+)([0-9]+)/\", $cell, $matches);\n $matches[1] = lettertonumber($matches[1]);\n $newcells[] = \"R\".$matches[2].\"C\".$matches[1];\n }\n}\n\nforeach ($newcells as $value) {\n echo $value.\"\\n\";\n}\n?>"}, {"source_code": " 26) {\n $letNum = $col % 26;\n if ($letNum == 0) {\n $letNum = 26;\n $col = $col / 26 - 1;\n } else {\n $col = floor($col / 26);\n }\n $colCode = chr(64 + $letNum) . $colCode;\n }\n if ($col > 0) {\n $colCode = chr(64 + $col) . $colCode;\n }\n $resultCode = $colCode . $digits[0];\n } else {\n $colArray = str_split($letters[0]);\n $colNum = 0;\n $power = 0;\n while ($let = array_pop($colArray)) {\n $colNum += (ord($let) - 64) * pow(26, $power++);\n }\n $resultCode = 'R' . $digits[0] . 'C' . $colNum;\n }\n echo \"$resultCode\\n\";\n }\n?>"}, {"source_code": " 25){\n $remainder = $col % 26;\n array_push($indexes, $remainder);\n if($remainder == 0){\n $col = ($col / 26) -1;\n if($col == 0){\n break;\n }\n }\n else{\n $col = $col / 26;\n }\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n break;\n }\n }\n\n $rowRev = substr($word, 0, $index);\n $col = substr($word, $index);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": "=26){\n if($i_row%26==0){\n $row.=\"Z\";\n $i_row=floor(($i_row-26)/26);\n }else {\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n } \n if($i_row!=0) {$row.=chr($i_row%26+64);}\n echo strrev($row).$col; \n } else{\n $col=preg_replace(\"/([A-Z]+)\\d+/\",\"$1\",$s);\n $row=intval(preg_replace(\"/[A-Z]+(\\d+)/\",\"$1\",$s));\n \n $i_col=0;$f_col=0;\n for ($j=strlen($col)-1;$j>=0;$j--) {\n $i_col+=pow(26,$f_col)*(ord($col[$j])-64);\n $f_col++; \n } \n echo \"R\".$row.\"C\".$i_col; \n }\n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j =26){\n if($i_row%26==0){\n $row.=\"Z\";\n $i_row=floor(($i_row-26)/26);\n }else {\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n } \n if($i_row!=0) {$row.=chr($i_row%26+64);}\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": " 0) {\n $d1 = chr(($s2 - 1) % 26 + 65) . $d1;\n //echo \"--$s2 $d1\\n\";\n $s2 = floor(($s2 - 1) / 26);\n }\n echo \"$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n?>"}, {"source_code": "26){\n if(($c%26)!=0){\n $col.= chr(($c%26)+ord(A)-1);\n $c-=$c%26;\n $c/=26;\n }else{\n $cuo=$c/26;\n $col.='Z';\n $c=$cuo-1;\n }\n }\n $col.= chr($c+ord(A)-1);\n \n $col=strrev($col);\n echo \"$col\".\"$r\".\"\\n\";\n \n }\n}\n\n?>"}, {"source_code": "1,\n 'B'=>2,\n 'C'=>3,\n 'D'=>4,\n 'E'=>5,\n 'F'=>6,\n 'G'=>7,\n 'H'=>8,\n 'I'=>9,\n 'J'=>10,\n 'K'=>11,\n 'L'=>12,\n 'M'=>13,\n 'N'=>14,\n 'O'=>15,\n 'P'=>16,\n 'Q'=>17,\n 'R'=>18,\n 'S'=>19,\n 'T'=>20,\n 'U'=>21,\n 'V'=>22,\n 'W'=>23,\n 'X'=>24,\n 'Y'=>25,\n 'Z'=>26);\n$n = fgets(STDIN);\nfor($i=1;$i<=$n;$i++){\n$str = fgets(STDIN);\n$out = '';\nif(preg_match('/R(\\d+)C(\\d+)/',$str,$num)){//R1C1\nwhile(true){\n$le = floor($num[2]/26);\nif($le==0){\n$out=$alf[$num[2]-1].$out;\nbreak;\n}\n$mo=($num[2]%26)-1;\nif($mo==-1){$mo=25;$le-=1;}\n$out=$alf[$mo].$out;\n$num[2]=$le;\n}\n$out=$out.$num[1];\n}else{\npreg_match('/([A-Z]+)(\\d+)/',$str,$num);\n$out='R'.$num[2].'C';\n$nb=0;\nwhile(strlen($num[1])>0){\n$nb=$nb*26;\n$nb=$nb+$nu[$num[1][0]];\n$num[1]=substr($num[1],1);\n}\n$out.=$nb;\n}\necho $out.\"\\r\\n\";\n}\n?>"}, {"source_code": " 1, \"B\" => 2, \"C\" => 3, \"D\" => 4, \"E\" => 5, \"F\" => 6, \"G\" => 7,\n \"H\" => 8, \"I\" => 9, \"J\" => 10, \"K\" => 11, \"L\" => 12, \"M\" => 13, \"N\" => 14,\n \"O\" => 15, \"P\" => 16, \"Q\" => 17, \"R\" => 18, \"S\" => 19, \"T\" => 20, \"U\" => 21, \n \"V\" => 22, \"W\" => 23, \"X\" => 24, \"Y\" => 25, \"Z\" => 26);\n$y = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nfor($i=0; $i<$a; ++$i)\n{\n $b[$i] = trim(fgets(STDIN));\n if(preg_match('/R(\\d+)C(\\d+)/', $b[$i], $c))\n {\n while(true)\n {\n if($c[2]>=1 and $c[2]<=26){$h .= $y{$c[2]-1}; break;}\n elseif($c[2]==0){$h .= $y{25}; break;}\n else{\n $f = floor($c[2]/26);\n $g = $c[2]-$f*26;\n if($g==0)\n {\n $h .= $y{25}; $c[2] = $c[2] - 26;\n }else{\n $h .= $y{$g-1};\n }\n $c[2] = floor(($c[2]-$g)/26);\n }\n }\n $e .= strrev($h).$c[1].\"\\n\";\n }elseif(preg_match('/([A-Z]+)(\\d+)/', $b[$i], $c))\n {\n if(strlen($c[1])==1)\n {\n $d = $z[$c[1]];\n }else{\n for($j=0; $j "}, {"source_code": " 0; $i = floor($i / 26)){\n $k = ($i % 26);\n if($k == 0){\n $k = 26;\n $i--;\n }\n $c = $letters[$k-1].$c;\n }\n \n return $c;\n}\n\nfunction alpha2num($n, $letters){\n $c = 0;\n\n for($i = strlen($n), $j = 0; $i > 0;$i--,$j++){\n $k = array_search($n[$i-1], $letters) + 1;\n if($j > 0){\n $k = $k * pow(26, $j);\n }\n $c = $k + $c;\n }\n \n return $c;\n}\n\n?>"}, {"source_code": "= 1)\n {\n $t = $param % 26;\n if($t == 0 ) $t = 26;\n $result = chr($t + ord(\"A\") - 1) . $result;\n $param = floor($param / 26) ;\n if($t == 26 ) $param -= 1;\n } \n \n //R98C688\n //R90C35\n //R228C494\n}\n\nfunction mytoint($param, &$result) {\n $result = 0; \n for ($index = 0; $index < strlen($param); $index++) {\n $result += (ord($param[$index]) - ord(\"A\") + 1) * pow(26, (strlen($param) - $index - 1));\n }\n}\n\n?>\n"}, {"source_code": " 1) { \n if($rest == 0) {\n return get_assocc_char((int) ($result-1)).$alphabet[26]; \n }\n else {\n return get_assocc_char((int) ($result)).$alphabet[$rest];\n }\n }\n else { \n if($rest == 0) {\n return $alphabet[26]; \n }\n else {\n return $alphabet[$rest];\n }\n }\n }\n \n function convert($str) {\n global $alphabet;\n $matches = array();\n if (preg_match('#^R([0-9]+)C([0-9]+)$#',$str,$matches)==1) {\n $row = $matches[1]; \n $col = get_assocc_char($matches[2]);\n return $col.$row;\n }\n elseif(preg_match('#^([A-Z]+)([0-9]+)$#',$str,$matches)==1) {\n $row = $matches[2];\n $col = $matches[1];\n $colnum = 0;\n $col_length = strlen($col);\n $base = 1;\n for($i=$col_length-1;$i>=0;$i--) {\n if($i != $col_length-1) { $base = $base * 26; };\n $colnum = $colnum + $base * $alphabet[$col[$i]];\n }\n return 'R'.$row.'C'.$colnum;\n }\n else { die(\"Error: \".$str.\" - unknown pattern\\n\"); }\n }\n \n#############################################################\n \n $alphabet = array (1=>'A',2=>'B',3=>'C',4=>'D',5=>'E',6=>'F',7=>'G',8=>'H',9=>'I',10=>'J',11=>'K',12=>'L',13=>'M',\n 14=>'N',15=>'O',16=>'P',17=>'Q',18=>'R',19=>'S',20=>'T',21=>'U',22=>'V',23=>'W',24=>'X',25=>'Y',26=>'Z',\n 'A'=>1,'B'=>2,'C'=>3,'D'=>4,'E'=>5,'F'=>6,'G'=>7,'H'=>8,'I'=>9,'J'=>10,'K'=>11,'L'=>12,'M'=>13,\n 'N'=>14,'O'=>15,'P'=>16,'Q'=>17,'R'=>18,'S'=>19,'T'=>20,'U'=>21,'V'=>22,'W'=>23,'X'=>24,'Y'=>25,'Z'=>26);\n $count = get_stdin_vars(fgets(STDIN),1); \n $count = (int)$count[0]; \n \n if($count<1 or $count>100000) {\n die('Error: number of elements must be in range 1-100000'); \n }\n \n for ($i=0;$i<$count;$i++) {\n $indication = get_stdin_vars(fgets(STDIN),1);\n $indication = $indication[0];\n echo convert($indication).\"\\n\";\n } \n?>"}, {"source_code": "\n"}, {"source_code": " 0) && ($e <= 26))\n {\n $i = $g[$e];\n }\n elseif(($e > 26) && ($e <= 702))\n {\n $f = ($e - 26) * 2 - 1;\n $i = $k[$f] . $k[$f + 1];\n }\n elseif(($e > 702) && ($e <= 18278))\n {\n $f = ($e - 702) * 3 - 2;\n $i = $l[$f] . $l[$f + 1] . $l[$f + 2];\n }\n elseif(($e > 18278) && ($e <= 475254))\n {\n $f = ($e - 18278) * 4 - 3;\n $i = $m[$f] . $m[$f + 1] . $m[$f + 2] . $m[$f + 3];\n }\n elseif(($e > 475254) && ($e <= 1000001))\n {\n $f = ($e - 475254) * 5 - 4;\n $i = $n[$f] . $n[$f + 1] . $n[$f + 2] . $n[$f + 3] . $n[$f + 4];\n }\n $j = substr($b, $c, $d - $c - 1);\n if($x == $a)\n {\n print $i . $j;\n }\n else\n {\n print $i . $j . \"\\n\";\n }\n }\n else\n {\n if(is_numeric($b[1]) == TRUE)\n {\n $e = substr($b, 0, 1);\n }\n elseif(is_numeric($b[2]) == TRUE)\n {\n $e = substr($b, 0, 2);\n }\n elseif(is_numeric($b[3]) == TRUE)\n {\n $e = substr($b, 0, 3);\n }\n elseif(is_numeric($b[4]) == TRUE)\n {\n $e = substr($b, 0, 4);\n }\n elseif(is_numeric($b[5]) == TRUE)\n {\n $e = substr($b, 0, 5);\n }\n elseif(is_numeric($b[6]) == TRUE)\n {\n $e = substr($b, 0, 6);\n }\n if(strlen($e) == 1)\n {\n if($e == \"A\")\n {\n $r = 1;\n }\n elseif($e == \"B\")\n {\n $r = 2;\n }\n elseif($e == \"C\")\n {\n $r = 3;\n }\n elseif($e == \"D\")\n {\n $r = 4;\n }\n elseif($e == \"E\")\n {\n $r = 5;\n }\n elseif($e == \"F\")\n {\n $r = 6;\n }\n elseif($e == \"G\")\n {\n $r = 7;\n }\n elseif($e == \"H\")\n {\n $r = 8;\n }\n elseif($e == \"I\")\n {\n $r = 9;\n }\n elseif($e == \"J\")\n {\n $r = 10;\n }\n elseif($e == \"K\")\n {\n $r = 11;\n }\n elseif($e == \"L\")\n {\n $r = 12;\n }\n elseif($e == \"M\")\n {\n $r = 13;\n }\n elseif($e == \"N\")\n {\n $r = 14;\n }\n elseif($e == \"O\")\n {\n $r = 15;\n }\n elseif($e == \"P\")\n {\n $r = 16;\n }\n elseif($e == \"Q\")\n {\n $r = 17;\n }\n elseif($e == \"R\")\n {\n $r = 18;\n }\n elseif($e == \"S\")\n {\n $r = 19;\n }\n elseif($e == \"T\")\n {\n $r = 20;\n }\n elseif($e == \"U\")\n {\n $r = 21;\n }\n elseif($e == \"V\")\n {\n $r = 22;\n }\n elseif($e == \"W\")\n {\n $r = 23;\n }\n elseif($e == \"X\")\n {\n $r = 24;\n }\n elseif($e == \"Y\")\n {\n $r = 25;\n }\n elseif($e == \"Z\")\n {\n $r = 26;\n }\n }\n elseif(strlen($e) == 2)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n $r = $f * 26 + $t;\n }\n elseif(strlen($e) == 3)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n $r = $f * 676 + $t * 26 + $h;\n }\n elseif(strlen($e) == 4)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n $r = $f * 17576 + $t * 676 + $h * 26 + $i;\n }\n elseif(strlen($e) == 5)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n if($e[4] == \"A\")\n {\n $j = 1;\n }\n elseif($e[4] == \"B\")\n {\n $j = 2;\n }\n elseif($e[4] == \"C\")\n {\n $j = 3;\n }\n elseif($e[4] == \"D\")\n {\n $j = 4;\n }\n elseif($e[4] == \"E\")\n {\n $j = 5;\n }\n elseif($e[4] == \"F\")\n {\n $j = 6;\n }\n elseif($e[4] == \"G\")\n {\n $j = 7;\n }\n elseif($e[4] == \"H\")\n {\n $j = 8;\n }\n elseif($e[4] == \"I\")\n {\n $j = 9;\n }\n elseif($e[4] == \"J\")\n {\n $j = 10;\n }\n elseif($e[4] == \"K\")\n {\n $j = 11;\n }\n elseif($e[4] == \"L\")\n {\n $j = 12;\n }\n elseif($e[4] == \"M\")\n {\n $j = 13;\n }\n elseif($e[4] == \"N\")\n {\n $j = 14;\n }\n elseif($e[4] == \"O\")\n {\n $j = 15;\n }\n elseif($e[4] == \"P\")\n {\n $j = 16;\n }\n elseif($e[4] == \"Q\")\n {\n $j = 17;\n }\n elseif($e[4] == \"R\")\n {\n $j = 18;\n }\n elseif($e[4] == \"S\")\n {\n $j = 19;\n }\n elseif($e[4] == \"T\")\n {\n $j = 20;\n }\n elseif($e[4] == \"U\")\n {\n $j = 21;\n }\n elseif($e[4] == \"V\")\n {\n $j = 22;\n }\n elseif($e[4] == \"W\")\n {\n $j = 23;\n }\n elseif($e[4] == \"X\")\n {\n $j = 24;\n }\n elseif($e[4] == \"Y\")\n {\n $j = 25;\n }\n elseif($e[4] == \"Z\")\n {\n $j = 26;\n }\n $r = $f * 456976 + $t * 17576 + $h * 676 + $i * 26 + $j;\n } \n $s = substr($b, strlen($e));\n if($x == $a)\n {\n print \"R\" . $s . \"C\" . $r;\n }\n else\n {\n print \"R\" . $s . \"C\" . $r . \"\\n\";\n } \n }\n}\n?>"}, {"source_code": " 0) && ($e <= 26))\n {\n $i = $g[$e];\n }\n elseif(($e > 26) && ($e <= 702))\n {\n $f = ($e - 26) * 2 - 1;\n $i = $k[$f] . $k[$f + 1];\n }\n elseif(($e > 702) && ($e <= 18278))\n {\n $f = ($e - 702) * 3 - 2;\n $i = $l[$f] . $l[$f + 1] . $l[$f + 2];\n }\n elseif(($e > 18278) && ($e <= 475254))\n {\n $f = ($e - 18278) * 4 - 3;\n $i = $m[$f] . $m[$f + 1] . $m[$f + 2] . $m[$f + 3];\n }\n elseif(($e > 475254) && ($e <= 1000001))\n {\n $f = ($e - 475254) * 5 - 4;\n $i = $n[$f] . $n[$f + 1] . $n[$f + 2] . $n[$f + 3] . $n[$f + 4];\n }\n $j = substr($b, $c, $d - $c - 1);\n if($x == $a)\n {\n print $i . $j;\n }\n else\n {\n print $i . $j . \"\\n\";\n }\n }\n else\n {\n if(is_numeric($b[1]) == TRUE)\n {\n $e = substr($b, 0, 1);\n }\n elseif(is_numeric($b[2]) == TRUE)\n {\n $e = substr($b, 0, 2);\n }\n elseif(is_numeric($b[3]) == TRUE)\n {\n $e = substr($b, 0, 3);\n }\n elseif(is_numeric($b[4]) == TRUE)\n {\n $e = substr($b, 0, 4);\n }\n elseif(is_numeric($b[5]) == TRUE)\n {\n $e = substr($b, 0, 5);\n }\n elseif(is_numeric($b[6]) == TRUE)\n {\n $e = substr($b, 0, 6);\n }\n if(strlen($e) == 1)\n {\n if($e == \"A\")\n {\n $r = 1;\n }\n elseif($e == \"B\")\n {\n $r = 2;\n }\n elseif($e == \"C\")\n {\n $r = 3;\n }\n elseif($e == \"D\")\n {\n $r = 4;\n }\n elseif($e == \"E\")\n {\n $r = 5;\n }\n elseif($e == \"F\")\n {\n $r = 6;\n }\n elseif($e == \"G\")\n {\n $r = 7;\n }\n elseif($e == \"H\")\n {\n $r = 8;\n }\n elseif($e == \"I\")\n {\n $r = 9;\n }\n elseif($e == \"J\")\n {\n $r = 10;\n }\n elseif($e == \"K\")\n {\n $r = 11;\n }\n elseif($e == \"L\")\n {\n $r = 12;\n }\n elseif($e == \"M\")\n {\n $r = 13;\n }\n elseif($e == \"N\")\n {\n $r = 14;\n }\n elseif($e == \"O\")\n {\n $r = 15;\n }\n elseif($e == \"P\")\n {\n $r = 16;\n }\n elseif($e == \"Q\")\n {\n $r = 17;\n }\n elseif($e == \"R\")\n {\n $r = 18;\n }\n elseif($e == \"S\")\n {\n $r = 19;\n }\n elseif($e == \"T\")\n {\n $r = 20;\n }\n elseif($e == \"U\")\n {\n $r = 21;\n }\n elseif($e == \"V\")\n {\n $r = 22;\n }\n elseif($e == \"W\")\n {\n $r = 23;\n }\n elseif($e == \"X\")\n {\n $r = 24;\n }\n elseif($e == \"Y\")\n {\n $r = 25;\n }\n elseif($e == \"Z\")\n {\n $r = 26;\n }\n }\n elseif(strlen($e) == 2)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n $r = $f * 26 + $t;\n }\n elseif(strlen($e) == 3)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n $r = $f * 676 + $t * 26 + $h;\n }\n elseif(strlen($e) == 4)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n $r = $f * 17576 + $t * 676 + $h * 26 + $i;\n }\n elseif(strlen($e) == 5)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n if($e[4] == \"A\")\n {\n $j = 1;\n }\n elseif($e[4] == \"B\")\n {\n $j = 2;\n }\n elseif($e[4] == \"C\")\n {\n $j = 3;\n }\n elseif($e[4] == \"D\")\n {\n $j = 4;\n }\n elseif($e[4] == \"E\")\n {\n $j = 5;\n }\n elseif($e[4] == \"F\")\n {\n $j = 6;\n }\n elseif($e[4] == \"G\")\n {\n $j = 7;\n }\n elseif($e[4] == \"H\")\n {\n $j = 8;\n }\n elseif($e[4] == \"I\")\n {\n $j = 9;\n }\n elseif($e[4] == \"J\")\n {\n $j = 10;\n }\n elseif($e[4] == \"K\")\n {\n $j = 11;\n }\n elseif($e[4] == \"L\")\n {\n $j = 12;\n }\n elseif($e[4] == \"M\")\n {\n $j = 13;\n }\n elseif($e[4] == \"N\")\n {\n $j = 14;\n }\n elseif($e[4] == \"O\")\n {\n $j = 15;\n }\n elseif($e[4] == \"P\")\n {\n $j = 16;\n }\n elseif($e[4] == \"Q\")\n {\n $j = 17;\n }\n elseif($e[4] == \"R\")\n {\n $j = 18;\n }\n elseif($e[4] == \"S\")\n {\n $j = 19;\n }\n elseif($e[4] == \"T\")\n {\n $j = 20;\n }\n elseif($e[4] == \"U\")\n {\n $j = 21;\n }\n elseif($e[4] == \"V\")\n {\n $j = 22;\n }\n elseif($e[4] == \"W\")\n {\n $j = 23;\n }\n elseif($e[4] == \"X\")\n {\n $j = 24;\n }\n elseif($e[4] == \"Y\")\n {\n $j = 25;\n }\n elseif($e[4] == \"Z\")\n {\n $j = 26;\n }\n $r = $f * 456976 + $t * 17576 + $h * 676 + $i * 26 + $j;\n } \n $s = substr($b, strlen($e));\n if($x == $a)\n {\n print \"R\" . $s . \"C\" . $r;\n }\n else\n {\n print \"R\" . $s . \"C\" . $r . \"\\n\";\n } \n }\n}\n?>"}, {"source_code": " $str) {\nif (strlen($str)>0){\nif (preg_match(\"/R[0-9]+C[0-9]+/\",$str)) {\nsscanf($str,\"R%dC%d\",$row,$col);\necho number_column($col).$row;\n} else {\npreg_match(\"/([A-Z]*)(\\\\d+)/\", $str, $matches);\necho \"R\".$matches[2].\"C\".return_column($matches[1]);\n}\nif ($key!=count($text)){\necho \"\\n\";\n}\n}\n}\nfunction return_column($str) {\nglobal $char_array;\n$result = 0;\n$ab = 1;\nfor($i=strlen($str);$i>0;$i--) {\n$result+=$char_array[$str[$i-1]]*$ab;\n$ab*=26;\n}\nreturn $result;\n}\nfunction number_column($str) {\nglobal $char_array2;\n$result = \"\";\n$result2=\"\";\n$a = $str;\nwhile($a>0) {\n$letter = $a %26;\n$a = ($a - $letter)/26;\nif ($letter!=0){\n$result .= $char_array2[$letter];\n} else {\n$result.=\"Z\";\n$a--;\n}\n}\nfor ($i=strlen($result);$i>0;$i--) {\n$result2.=$result[$i-1];\n}\n\nreturn $result2;\n}\n?>"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = [];\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp[$i] = true;\n $now = 26;\n }\n\n if ($tmp !== null and $tmp[$i-1]) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n if ($now < 0) {\n $now = 26 + $now;\n }\n if ($now == 0) {\n $now = 26;\n $tmp[$i] = true;\n if ($i == $count -1) continue;\n };\n }\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n return $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n return \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n echo read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": " 0)\n {\n $res = chr(($second - 1) % 26 + 65) . $res;\n $second = floor(($second - 1) / 26);\n } \n return $res.$first; \n}\n\nfunction convert_2($string)\n{\n preg_match('/([A-Z]+)/i', $string, $matches);\n $first = $matches[0];\n preg_match('/(\\d+)/i', $string, $matches);\n $second = $matches[0];\n $res='';\n for($i = 0; $i 0)\n {\n $r=($num-1)%26;\n $res = chr($r+65).$res;\n $num = floor(($num-1)/26);\n }\n return $res;\n}\n\nfunction toNum($string){\n $int = 0;\n $len = strlen($string);\n for($i = 0; $i< $len; $i++){\n $int*=26;\n $int += ord($string[$i]) - 64;\n }\n return $int;\n}\n\n$file = fscanf(STDIN, \"%d\\n\", $cells);\nfor($i=0; $i<$cells; $i++){\n fscanf(STDIN, \"%s\\n\", $line);\n if($line[0] == 'R' && ord($line[1])>=48&&ord($line[1])<=57){\n $cPos = strpos($line, 'C', 2);\n if($cPos !== false){\n print(toAlpha(substr($line, $cPos+1)).substr($line, 1, $cPos-1).\"\\n\");\n }else{\n print('R'.substr($line, 1).\"C18\\n\");\n }\n }else{\n preg_match('/[0-9]/', $line, $matches, PREG_OFFSET_CAPTURE);\n print('R'.substr($line, $matches[0][1]).'C'.toNum(substr($line, 0, $matches[0][1])).\"\\n\");\n }\n}\n"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$d = $a % 26;\n\t\t$a = floor($a / 26);\n\t\tif ($d == 0) {\n\t\t\t$d += 26;\n\t\t\t$a--;\n\t\t}\n\t\t$result .= chr(64 + $d);\n\t\t\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\n\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": "=48&&ord($var)<=57)\n return true;\n else\n return false;\n}\nfunction IsType1($var)\n{\n $res=false;;\n for($i=1;$i =0;$i--)\n {\n if(IsInt($var[$i]))\n {\n $res.=$var[$i];\n }\n else {\n return strrev($res);\n }\n }\n}\n\n\nfunction conversion_int($var)\n{\n $res=\"\";\n while($var>26)\n {\n if($var%26!=0)\n {\n $res.=chr(64+$var%26);\n $var=($var-$var%26)/26;\n }\n else {\n $res.='Z';\n $var=($var)/26-1;\n }\n }\n if($var!=0)\n $res.=chr(64+$var);\n return strrev($res);\n}\nfunction conversion_str($var)\n{\n $res=0;\n for($i=strlen($var)-1;$i>=0;$i--)\n {\n $temp=1;\n for($j=strlen($var)-1;$j>$i;$j--)\n {\n $temp*=26;\n }\n if($var[$i]!='Z')\n $res+=(ord($var[$i])-64)*$temp;\n else {\n $res+=$temp*26;\n }\n }\n return $res;\n}\nwhile($n--)\n{\nfscanf(STDIN,\"%s\",$str);\n if($str[0]=='R'&& IsInt($str[1]) && IsType1($str))\n {\n $a=GetInt($str);\n $b=GetInt_D($str);\n echo conversion_int($b).$a.\"\\n\";\n }\n else {\n $a=\"\";\n for($i=0;$i \n"}, {"source_code": " 0) {\n $s = $c % pow(26, $p + 1);\n if (! $s) {\n $s = 26 * pow(26, $p);\n }\n $l = $s / pow(26, $p);\n $cStr = chr(64 + $l) . $cStr;\n $c -= $l * pow(26, $p);\n $p ++;\n }\n echo $cStr . $r . \"\\n\";\n } elseif (preg_match('~^([A-Z]+)([0-9]+)$~', $val, $matches)) {\n $r = $matches[2];\n $cStr = $matches[1];\n $cStrLen = strlen($cStr);\n $c = 0;\n for ($i = 0; $i < $cStrLen; $i ++) {\n $l = substr($cStr, $i, 1);\n $l = ord($l) - 64;\n $c += $l * pow(26, $cStrLen - $i - 1);\n }\n echo 'R' . $r . 'C' . $c . \"\\n\";\n }\n}\n"}, {"source_code": " 0) {\n $s = $c % pow(26, $p + 1);\n $l = $s / pow(26, $p);\n if (! $l) {\n $l = 26;\n }\n $cStr = chr(64 + $l) . $cStr;\n $c -= $l * pow(26, $p);\n $p ++;\n }\n echo $cStr . $r . \"\\n\";\n } elseif (preg_match('~^([A-Z]+)([0-9]+)$~', $val, $matches)) {\n $r = $matches[2];\n $cStr = $matches[1];\n $cStrLen = strlen($cStr);\n $c = 0;\n for ($i = 0; $i < $cStrLen; $i ++) {\n $l = substr($cStr, $i, 1);\n $l = ord($l) - 64;\n $c += $l * pow(26, $cStrLen - $i - 1);\n }\n echo 'R' . $r . 'C' . $c . \"\\n\";\n }\n}\n"}, {"source_code": "0)\n {\n $r=($num-1)%26;\n $res = chr($r+65).$res;\n $num = floor(($num-1)/26); \n }\n return $res;\n}\n\nfunction old2new($str) {\n $res=0; \n for ($i=0; $i "}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param $stdin\n *\n * @return string\n */\nfunction fgets_trim($stdin) {\n return trim(fgets($stdin));\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 0) {\n $n--;\n $rem = $n % 26;\n echo chr($rem + 65);\n $n = floor($n / 26);\n }\n\n return strrev(ob_get_clean());\n}"}, {"source_code": "1) {\n $cel=(int)($q/26);\n $ost=$q%26;\n if ($ost==0) $ost=26;\n $r.=chr(64+$ost);\n $q=$cel;\n if ($ost==26) $q--;}\n $ost=$q%26;\n if ($ost==0) $ost=26;\n $r.=chr(64+$ost);\n echo strrev($r),\"$y\\n\";\n }\n}\n?>"}, {"source_code": " 0)\n {\n $res = chr(($second - 1) % 26 + 65) . $res;\n $second = floor(($second - 1) / 26);\n } \n return $res.$first; \n}\n\nfunction convert_2($string)\n{\n preg_match('/([A-Z]+)/i', $string, $matches);\n $first = $matches[0];\n preg_match('/(\\d+)/i', $string, $matches);\n $second = $matches[0];\n $res='';\n for($i = 0; $i =0; $j--, $d*=26) \n $c += (ord($s[$j])-64)*$d; \n echo 'R', $matches[2], 'C', $c, \"\\n\"; \n } \n } \n?>"}, {"source_code": "=0;$j--)\n { \n $y += (ord($str[$j])-64)*$d;\n $d*=26;\n } \n printf(\"R%sC%s\\n\",$target[2],$y);\n}\n"}, {"source_code": "=0;$j--)\n { \n $y += (ord($tar1[$j])-64)*$d;\n $d*=26;\n } \n printf(\"R%sC%s\\n\",$target[2],$y);\n}\n\nfclose($fr);\n\n"}, {"source_code": "= 48 && ord($data[$i][1]) <= 57 && strpos($data[$i], 'C') !== false) {\n \t\t$column = '';\n \t\t$string = '';\n \t\t$flag = false;\n \t\tfor($j = 1; $j < strlen($data[$i]); $j++) {\n \t\t\tif($data[$i][$j] == 'C') {\n \t\t\t\t$flag = true;\n \t\t\t} else {\n \t\t\t\tif(!$flag) {\n \t\t\t\t\t$string .= $data[$i][$j];\n \t\t\t\t} else {\n \t\t\t\t\t$column .= $data[$i][$j];\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\t$strColumn = '';\n \t\t$column = (int)$column;\n\n \t\tdo {\n \t\t\tif($column > 26) {\n \t\t\t\tif($column % 26 != 0) { \n\t\t \t\t\t$strColumn .= chr($column % 26 + 64);\n\t\t \t\t\t$column = floor($column / 26);\n\t\t \t\t} else {\n\t\t \t\t\t$strColumn .= chr(26 + 64);\n\t\t \t\t\t$column = floor(($column-26) / 26);\n\t\t \t\t}\n\t \t\t} else {\n\t \t\t\t$strColumn .= chr($column + 64);\n\t \t\t\tbreak;\n\t \t\t}\n \t\t} while(true);\n\n \t\t$data[$i] = strrev($strColumn) . $string;\n\n \t} else {\n \t\t$column = '';\n \t\t$string = '';\n \t\tfor($j = 0; $j = 65 && ord($data[$i][$j]) <= 90) {\n \t\t\t\t$column .= $data[$i][$j];\n \t\t\t} else {\n \t\t\t\t$string .= $data[$i][$j];\n \t\t\t}\n \t\t}\n\n \t\t$columnNum = 0;\n \t\tfor($j = strlen($column) - 1; $j >= 0; $j--) {\n \t\t\t$columnNum += (ord($column[$j]) - 64) * pow(26, strlen($column)-$j-1);\n \t\t}\n \t\t$data[$i] = 'R' . $string . 'C' . $columnNum;\n \t}\n }\n echo implode(\"\\n\", $data);\n?>\n"}, {"source_code": "=0; $i--, $j++) {\n $pos = strpos(LETTERS, $column[$i], 1);\n $columnNumber += $pos * (26 ** $j);\n }\n return 'R' . $row . 'C' . $columnNumber;\n}\n\nfunction rc2zz($column, $row) {\n $columnNumber = '';\n while (($column / 26) > 1) {\n $floor = (int)floor($column / 26);\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n $column = $floor;\n if ($mod === 0) {\n $column--;\n }\n }\n $ost = $column % 26;\n $columnNumber .= LETTERS[$ost];\n return strrev($columnNumber) . $row;\n}\n\n$n = fscanf(STDIN, '%u');\nwhile ($row = trim(fgets(STDIN))) {\n if (preg_match('~R(\\d+)C(\\d+)~', $row, $match)) {\n echo rc2zz($match[2], $match[1]);\n } elseif(preg_match('~([A-Z]+)(\\d+)~i', $row, $match)) {\n echo zz2rc($match[1], $match[2]);\n }\n echo PHP_EOL;\n}\n"}, {"source_code": " 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10\n , 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19\n , 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26\n];\nfunction zz2rc(string $column, int $row): string {\n $columnNumber = 0;\n for ($i = strlen($column) - 1, $j = 0; $i >=0; $i--, $j++) {\n $pos = LETTERS_MAP[$column[$i]];\n $columnNumber += $pos * (26 ** $j);\n }\n return 'R' . $row . 'C' . $columnNumber;\n}\n\nfunction rc2zz(int $column, int $row): string {\n $columnNumber = '';\n while (($div = $column / 26) > 1) {\n $floor = (int)floor($div);\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n $column = $floor;\n if ($mod === 0) {\n $column--;\n }\n }\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n return strrev($columnNumber) . $row;\n}\n\n$n = fscanf(STDIN, '%u');\nwhile ($row = trim(fgets(STDIN))) {\n if (preg_match('~R(\\d+)C(\\d+)~', $row, $match)) {\n echo rc2zz((int)$match[2], (int)$match[1]);\n } elseif(preg_match('~([A-Z]+)(\\d+)~i', $row, $match)) {\n echo zz2rc($match[1], (int)$match[2]);\n }\n echo PHP_EOL;\n}\n"}, {"source_code": " 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10\n , 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19\n , 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26\n];\nfunction zz2rc($column, $row) {\n $columnNumber = 0;\n for ($i = strlen($column) - 1, $j = 0; $i >=0; $i--, $j++) {\n $pos = LETTERS_MAP[$column[$i]];\n $columnNumber += $pos * (26 ** $j);\n }\n return 'R' . $row . 'C' . $columnNumber;\n}\n\nfunction rc2zz($column, $row) {\n $columnNumber = '';\n while (($div = $column / 26) > 1) {\n $floor = (int)floor($div);\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n $column = $floor;\n if ($mod === 0) {\n $column--;\n }\n }\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n return strrev($columnNumber) . $row;\n}\n\n$n = fscanf(STDIN, '%u');\nwhile ($row = trim(fgets(STDIN))) {\n if (preg_match('~R(\\d+)C(\\d+)~', $row, $match)) {\n echo rc2zz($match[2], $match[1]);\n } elseif(preg_match('~([A-Z]+)(\\d+)~i', $row, $match)) {\n echo zz2rc($match[1], $match[2]);\n }\n echo PHP_EOL;\n}\n"}, {"source_code": "0;$last_pos--){\n $char = $col_word[$last_pos-1] ;\n $index = array_search($char,$chars_arr);\n\n if($index == 0){\n $num = 26;\n }else{\n $num = $index;\n }\n $amount += pow($step,$level) * $num;\n\n $level ++;\n }\n\n echo \"R\".$row.\"C\".$amount.\"\\n\";\n\n\n\t\t\t\t}\n\n }\n }\n}\n\n"}, {"source_code": "=0;$j--)\n { \n $y += (ord($tar1[$j])-64)*$d;\n $d*=26;\n } \n printf(\"R%sC%s\\n\",$target[2],$y);\n}\n\nfclose($fr);\n"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n printf(\"R%sC%s\\n\", $outR, $outC);\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n printf(\"%s%s\\n\", $outC, $outR);\n}"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n printf(\"R%sC%s\\n\", $outR, $outC);\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n printf(\"%s%s\\n\", $outC, $outR);\n}"}, {"source_code": "1,\n\t\t'B'=>2,\n\t\t'C'=>3,\n\t\t'D'=>4,\n\t\t'E'=>5,\n\t\t'F'=>6,\n\t\t'G'=>7,\n\t\t'H'=>8,\n\t\t'I'=>9,\n\t\t'J'=>10,\n\t\t'K'=>11,\n\t\t'L'=>12,\n\t\t'M'=>13,\n\t\t'N'=>14,\n\t\t'O'=>15,\n\t\t'P'=>16,\n\t\t'Q'=>17,\n\t\t'R'=>18,\n\t\t'S'=>19,\n\t\t'T'=>20,\n\t\t'U'=>21,\n\t\t'V'=>22,\n\t\t'W'=>23,\n\t\t'X'=>24,\n\t\t'Y'=>25,\n\t\t'Z'=>26,\n\t);\n\n\tpublic function ex2rc($ex){\n\t\t$rc = array();\n\t\tpreg_match('/([A-Z]+)(\\d+)/', $ex, $rc);\n\t\t$auxCol = array_reverse(str_split($rc[1]));\n\t\t$auxPot = 0;\n\t\t$col = 0;\n\t\t$row = $rc[2];\n\t\tforeach($auxCol as $l){\n\t\t\t$col = $col + $this->eq[$l] * pow(count($this->eq), $auxPot);\n\t\t\t$auxPot++;\n\t\t}\n\t\treturn sprintf('R%sC%s', $row, $col);\n\t}\n\tpublic function rc2ex($rc){\n\t\t$n = count($this->eq);\n\t\t$ex = array();\n\t\tpreg_match('/R(\\d+)C(\\d+)/', $rc, $ex);\n\t\t$auxCol = intval($ex[2]);\n\t\t$col = '';\n\t\t$row = $ex[1];\n\t\t$sub = false;\n\t\twhile($auxCol / $n > 0){\n\t\t\t$r = $auxCol % $n;\n\t\t\t$auxCol = $auxCol - $r;\n\t\t\t$auxCol = $auxCol / $n;\n\t\t\tif($r == 0){\n\t\t\t\t$col = array_search($n, $this->eq) . $col;\n\t\t\t\t$auxCol--;\n\t\t\t} else {\n\t\t\t\t$col = array_search($r, $this->eq) . $col;\n\t\t\t}\n\t\t}\n\t\treturn sprintf('%s%s', $col, $row);\n\t}\n\n\tpublic function transform($coordinate){\n\t\tif(preg_match('/R\\d+C\\d+/', $coordinate)){\n\t\t\treturn $this->rc2ex($coordinate);\n\t\t}\n\t\treturn $this->ex2rc($coordinate);\n\t}\n}\n\n$n = intval(rtrim( fgets( STDIN ) ));\n$coordinates = array();\nfor($i = 0; $i < $n; $i++){\n\t$coordinates[] = rtrim( fgets( STDIN ) );\n}\n\n$p = new Parser();\nfor($i = 0; $i < $n; $i++){\n\techo $p->transform($coordinates[$i]) . PHP_EOL;\n}"}, {"source_code": " 1,\n\t\t\"B\" => 2,\n\t\t\"C\" => 3,\n\t\t\"D\" => 4,\n\t\t\"E\" => 5,\n\t\t\"F\" => 6,\n\t\t\"G\" => 7,\n\t\t\"H\" => 8,\n\t\t\"I\" => 9,\n\t\t\"J\" => 10,\n\t\t\"K\" => 11,\n\t\t\"L\" => 12,\n\t\t\"M\" => 13,\n\t\t\"N\" => 14,\n\t\t\"O\" => 15,\n\t\t\"P\" => 16,\n\t\t\"Q\" => 17,\n\t\t\"R\" => 18,\n\t\t\"S\" => 19,\n\t\t\"T\" => 20,\n\t\t\"U\" => 21,\n\t\t\"V\" => 22,\n\t\t\"W\" => 23,\n\t\t\"X\" => 24,\n\t\t\"Y\" => 25,\n\t\t\"Z\" => 26\n\t);\n\t$alph_2 = array(\n\t\t\"A\",\n\t\t\"B\",\n\t\t\"C\",\n\t\t\"D\",\n\t\t\"E\",\n\t\t\"F\",\n\t\t\"G\",\n\t\t\"H\",\n\t\t\"I\",\n\t\t\"J\",\n\t\t\"K\",\n\t\t\"L\",\n\t\t\"M\",\n\t\t\"N\",\n\t\t\"O\",\n\t\t\"P\",\n\t\t\"Q\",\n\t\t\"R\",\n\t\t\"S\",\n\t\t\"T\",\n\t\t\"U\",\n\t\t\"V\",\n\t\t\"W\",\n\t\t\"X\",\n\t\t\"Y\",\n\t\t\"Z\"\n\t);\n\t\n\t$count = (int)fgets(STDIN);\n\t$input_array = array();\n\tfor ($i = 0; $i < $count; $i++){\n\t\tarray_push($input_array, trim(fgets(STDIN)));\n\t}\n\tfor ($j = 0; $j < $count; $j++){\n\t\t$input_number = $input_array[$j];\n\t\t$number_array = array();\n\t\t$letter_array = array();\n\t\t$letter = \"\";\n\t\t$number = \"\";\n\t\tfor ($i =0; $i < strlen($input_number); $i++){\n\t\t\tif(!is_numeric($input_number[$i])){\n\t\t\t\tif($number !== \"\"){\n\t\t\t\t\tarray_push($number_array, (int)$number);\n\t\t\t\t\t$number = \"\";\n\t\t\t\t}\n\t\t\t\t$letter .= $input_number[$i];\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif($letter !== \"\"){\n\t\t\t\t\tarray_push($letter_array, (string)$letter);\n\t\t\t\t\t$letter = \"\";\n\t\t\t\t}\n\t\t\t\t$number .= $input_number[$i];\n\t\t\t}\n\t\t}\n\t\tif($number !== \"\"){\n\t\t\tarray_push($number_array, (int)$number);\n\t\t\t$number = \"\";\n\t\t}\n\t\tif($letter !== \"\"){\n\t\t\tarray_push($letter_array, (string)$letter);\n\t\t\t$letter = \"\";\n\t\t}\t\n\n\t\tif(count($number_array) === 2){ \n\t\t\t$res = array();\n\t\t\t$p = $number_array[1];\n\t\t\t$q = 0;\n\t\t\twhile ($p > MOD){\n\t\t\t\t$tmp_q = $p % MOD;\n\t\t\t\tif ($tmp_q === 0){\n\t\t\t\t\t$q = MOD;\n\t\t\t\t\t$p = intval($p / MOD) - 1;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$p = intval($p / MOD);\n\t\t\t\t\t$q = $tmp_q;\n\t\t\t\t}\n\t\t\t\tarray_push($res, $q);\n\t\t\t}\n\t\t\tarray_push($res, $p);\n\t\t\t$count_res = count($res) - 1;\n\t\t\tfor ($i = $count_res; $i >= 0; $i--){\n\t\t\t\techo $alph_2[$res[$i] - 1];\n\t\t\t}\n\t\t\techo $number_array[0].\"\\n\";\n\t\t}\n\t\telse{\n\t\t\t$letters = $letter_array[0];\n\t\t\t$res_number = 0;\n\t\t\tfor ($i = 0; $i < strlen($letters); $i++){\n\t\t\t\t$res_number += pow(MOD, (strlen($letters) - 1) - $i ) * $alph[$letters[$i]];\n\t\t\t}\n\t\t\techo \"R\" . $number_array[0] . \"C\" . $res_number . \"\\n\";\n\t\t}\n\t}\n?> \n"}, {"source_code": " 26;\n if ($continue) {\n $curr_num = $num % 26;\n if ($curr_num === 0) {\n $str = 'Z'.$str;\n $num = floor($num / 26) - 1;\n } else {\n $str = chr($curr_num + 64).$str;\n $num = floor($num / 26);\n }\n } else {\n $str = chr($num + 64).$str;\n }\n } while ($continue);\n return $str;\n}\n\nfunction alpha_to_number($str) {\n $parts = str_split($str);\n $num = 0;\n for ($i = 0; $i < count($parts); $i++) {\n $num = $num * 26;\n $num += ord($parts[$i]) - 64;\n }\n return $num;\n}\n\nfunction convert_one($str) {\n $parts = preg_split(\"/\\d+/\", $str);\n if ($parts[0] === 'R' && $parts[1] === 'C') {\n // from RXCY\n $numbers = preg_split(\"/R|C/\", $str);\n $row = $numbers[1];\n $col = $numbers[2];\n printf(\"%s%d\\n\", number_to_alpha($col), $row);\n } else {\n // to RXCY\n $col_str = $parts[0];\n $col = alpha_to_number($col_str);\n $row_parts = preg_split(\"/[A-Z]+/\", $str);\n $row = (int)$row_parts[1];\n printf(\"R%dC%d\\n\", $row, $col);\n }\n}\n\nfscanf(STDIN, \"%d\", $n);\nfor ($i = 1; $i <= $n; $i++) {\n fscanf(STDIN, \"%s\", $str);\n convert_one($str);\n}\n?>"}, {"source_code": "=0; $j--, $d*=26) \n $c += (ord($s[$j])-64)*$d; \n echo 'R', $matches[2], 'C', $c, \"\\n\"; \n } \n } \n?>\n"}, {"source_code": "=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i =1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,5})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = numToLet($second);\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i);\n\t\t\t\t$second = substr($string, $i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1.03845) {\n\t\t\tif ((int)$newnum/26 != 27 AND $newnum!=18278 AND ($newnum<474547 OR $newnum>474551) AND ($newnum<475229 OR $newnum>475254)) {\n\t\t\t$raz++;\t\t\t\n\t\t\t}\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = 'A'.$res; break;\n\t\t\t\tcase 2: $res = 'B'.$res; break;\n\t\t\t\tcase 3: $res = 'C'.$res; break;\n\t\t\t\tcase 4: $res = 'D'.$res; break;\n\t\t\t\tcase 5: $res = 'E'.$res; break;\n\t\t\t\tcase 6: $res = 'F'.$res; break;\n\t\t\t\tcase 7: $res = 'G'.$res; break;\n\t\t\t\tcase 8: $res = 'H'.$res; break;\n\t\t\t\tcase 9: $res = 'I'.$res; break;\n\t\t\t\tcase 10: $res = 'J'.$res; break;\n\t\t\t\tcase 11: $res = 'K'.$res; break;\n\t\t\t\tcase 12: $res = 'L'.$res; break;\n\t\t\t\tcase 13: $res = 'M'.$res; break;\n\t\t\t\tcase 14: $res = 'N'.$res; break;\n\t\t\t\tcase 15: $res = 'O'.$res; break;\n\t\t\t\tcase 16: $res = 'P'.$res; break;\n\t\t\t\tcase 17: $res = 'Q'.$res; break;\n\t\t\t\tcase 18: $res = 'R'.$res; break;\n\t\t\t\tcase 19: $res = 'S'.$res; break;\n\t\t\t\tcase 20: $res = 'T'.$res; break;\n\t\t\t\tcase 21: $res = 'U'.$res; break;\n\t\t\t\tcase 22: $res = 'V'.$res; break;\n\t\t\t\tcase 23: $res = 'W'.$res; break;\n\t\t\t\tcase 24: $res = 'X'.$res; break;\n\t\t\t\tcase 25: $res = 'Y'.$res; break;\n\t\t\t\tcase 0: $res = 'Z'.$res; break;\n\t\t\t}\n\t\t\tif ($cur==0){\n\t\t\t$newnum = floor($newnum/26)-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t$newnum/=26;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = numToLet($second);\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i);\n\t\t\t\t$second = substr($string, $i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t$first_marker = 0;\n\t$second_marker = 0;\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\nfunction numToLet ($num){\n\t\t$res=\"\";\n\t\twhile ($num>0)\n\t\t{\n\t\t\t$res = chr((($num-1)%26)+65).$res;\n\t\t\t$num = floor(($num-1)/26); \n\t\t}\n return $res;\n\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": "0){\n\t\t\t$col_char = chr(($col%26)+64) . $col_char;\n\t\t}else{\n\t\t\t$col_char = chr(26+64) . $col_char;\n\t\t\t$col -= 26;\n\t\t}\n\t\t$col = intval($col/26);\n\t\tif($col<=0){\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn \"{$col_char}{$row}\";\n}\n$inputs=[];\nfor ($i=0; $i < $n; $i++) {\n\t$inputs[] = strval(trim(fgets(STDIN)));\n\t\n\n}\nfor ($i=0; $i < $n; $i++) {\n\tif($i>0)echo \"\\n\";\n\t$input = $inputs[$i];\n\tif (!preg_match('/R(\\d+)C(\\d+)/',\n $input))\n\t{\n\t \techo convertS1($input);\n\t}\n\telse\n\t{\n\t\techo convertS2($input);\n\t}\n\n}\n"}, {"source_code": " 0){\n $char = ($column%26>0)?$column%26:26;\n $column = intval($column/26);\n $column = ($char==26)?$column-1:$column;\n $str = chr($char+64) . $str;\n #var_dump($char, $column, $str);\n }\n return $str.''.$row;\n}\n\nfunction convertCRtoRC($cell){\n $st = preg_match('/^([A-Z]+)([0-9]+)$/', trim($cell), $matches);\n #var_dump($st, $matches);\n $column = $matches[1];\n $row = $matches[2]; //not modified\n $chs = str_split($column);\n $count = strlen($column);\n $column = 0;\n foreach($chs as $ch){\n $column += (ord($ch) - 64) * 26**($count -1);\n $count--;\n }\n return 'R' . $row . 'C' . $column;\n} \n\nfunction convert($cell){\n $type = preg_match('/^R[0-9]+C[0-9]+$/', trim($cell), $matches);\n #var_dump($type, $matches);\n if($type === 1){\n return convertRCtoCR($cell);\n }\n \n return convertCRtoRC($cell);\n}\n\n$dir = fopen(\"php://stdin\", 'r');\n$cells = stream_get_contents($dir);\n\n$cells = explode(\"\\n\", $cells);\nfor($i=1;$i<=$cells[0];$i++){\n echo convert($cells[$i]).\"\\n\";\n}\n?>\n"}, {"source_code": "=0;$i--){\n $column += (ord($str[$i])-64)*$d;\n $d *=26;\n }\n echo \"R\".$target[2].\"C\".$column.\"\\n\";\n}\n\nfclose($file);\n\n?>"}, {"source_code": "64) $fl=true;\n if ($fl){\n $R = strtok($n,\"RC\");\n $C = strtok(\"RC\");\n $step = 1;\n $s=26;\n while($s<$C){\n $s += pow(26,$step+1);\n $step++;\n }\n $s -= pow(26,$step);\n $C -= $s+1;\n $code = \"\";\n while($C>0){\n $ost = $C % 26;\n $C = intval($C/26); \n $code = chr($ost+65).$code;\n }\n while(strlen($code)<$step) $code = 'A'.$code;\n echo $code.$R.\"\\n\"; \n } else\n {\n $i=0;\n while(ord($n{$i})>57) $i++;\n $R = substr($n,$i);\n $C = substr($n,0,$i);\n $step = strlen($C);\n $s=0;\n for ($i=1;$i<=$step-1;$i++) $s += pow(26,$i);\n $num=0;\n for($i=0;$i<$step;$i++) \n $num = $num * 26 + ord($C{$i}) - 65; \n $num += $s+1;\n echo \"R\".$R.\"C\".$num.\"\\n\";\n }}\n?>"}, {"source_code": " 0) {\n $d1 = chr(($s2 - 1) % 26 + 65) . $d1;\n $s2 = floor(($s2 - 1) / 26);\n }\n echo \"$d1$s[1]\\n\";\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n }\n $d1 = intval($d[count($d) - 1]);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": " 26) {\n $letNum = floor($col / 26);\n $colCode .= chr(64 + $letNum);\n $col = $col % 26;\n }\n if ($col > 0) {\n $colCode .= chr(64 + $col);\n }\n $resultCode = $colCode . $digits[0];\n } else {\n $colArray = str_split($letters[0]);\n $colNum = 0;\n $power = 0;\n while ($let = array_pop($colArray)) {\n $colNum += (ord($let) - 64) * pow(26, $power++);\n }\n $resultCode = 'R' . $digits[0] . 'C' . $colNum;\n }\n echo \"$resultCode\\n\";\n }\n?>"}, {"source_code": "=0;$i--){\n $column += (ord($str[$i])-64)*$d;\n $d *=26;\n }\n echo \"R\".$target[2].\"C\".$column.\"\\n\";\n}\n\n\n\n?>"}, {"source_code": " 26)\n $d2 = chr(floor($s[2] / 26) % 26 + 64);\n else\n $d2 = '';\n if ($s[2] > 26 * 26)\n $d3 = chr(floor($s[2] / 26 / 26) % 26 + 64);\n else\n $d3 = '';\n echo \"$d3$d2$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n\n\n?>"}, {"source_code": "=0;$i--){\n $column += (ord($str[$i])-64)*$d;\n $d *=26;\n }\n echo \"R\".$target[2].\"C\".$column.\"\\n\";\n}\n\nfclose($file);\n\n?>"}, {"source_code": " 1, \"B\" => 2, \"C\" => 3, \"D\" => 4, \"E\" => 5, \"F\" => 6, \"G\" => 7,\n \"H\" => 8, \"I\" => 9, \"J\" => 10, \"K\" => 11, \"L\" => 12, \"M\" => 13, \"N\" => 14,\n \"O\" => 15, \"P\" => 16, \"Q\" => 17, \"R\" => 18, \"S\" => 19, \"T\" => 20, \"U\" => 21, \n \"V\" => 22, \"W\" => 23, \"X\" => 24, \"Y\" => 25, \"Z\" => 26);\n$y = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nfor($i=0; $i<$a; ++$i)\n{\n $b[$i] = trim(fgets(STDIN));\n if(preg_match('/R(\\d+)C(\\d+)/', $b[$i], $c))\n {\n while(true)\n {\n if($c[2]>=1 and $c[2]<=26){$h .= $y{$c[2]-1}; break;}\n else{\n $f = floor($c[2]/26);\n $g = $c[2]-$f*26;\n if($g==0)\n {\n $h .= $y{25};\n }else{\n $h .= $y{$g-1};\n }\n $c[2] = floor(($c[2]-$g)/26);\n if($c[2]>=1 and $c[2]<=26){$h .= $y{$c[2]-2}; break;}\n elseif($c[2]==0){$h .= $y{25}; break;}\n }\n }\n $e .= strrev($h).$c[1].\"\\n\";\n }elseif(preg_match('/([A-Z]+)(\\d+)/', $b[$i], $c))\n {\n if(strlen($c[1])==1)\n {\n $d = $z[$c[1]];\n }else{\n for($j=0; $j "}, {"source_code": "= 48 && ord($data[$i][1]) <= 57) {\n \t\t$column = '';\n \t\t$string = '';\n \t\t$flag = false;\n \t\tfor($j = 1; $j < strlen($data[$i]); $j++) {\n \t\t\tif($data[$i][$j] == 'C') {\n \t\t\t\t$flag = true;\n \t\t\t} else {\n \t\t\t\tif(!$flag) {\n \t\t\t\t\t$string .= $data[$i][$j];\n \t\t\t\t} else {\n \t\t\t\t\t$column .= $data[$i][$j];\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\t$strColumn = '';\n \t\t$column = (int)$column;\n\n \t\tdo {\n \t\t\tif($column > 26) {\n \t\t\t\tif($column % 26 != 0) { \n\t\t \t\t\t$strColumn .= chr($column % 26 + 64);\n\t\t \t\t\t$column = floor($column / 26);\n\t\t \t\t} else {\n\t\t \t\t\t$strColumn .= chr(26 + 64);\n\t\t \t\t\t$column = floor(($column-26) / 26);\n\t\t \t\t}\n\t \t\t} else {\n\t \t\t\t$strColumn .= chr($column + 64);\n\t \t\t\tbreak;\n\t \t\t}\n \t\t} while(true);\n\n \t\t$data[$i] = strrev($strColumn) . $string;\n\n \t} else {\n \t\t$column = '';\n \t\t$string = '';\n \t\tfor($j = 0; $j = 65 && ord($data[$i][$j]) <= 90) {\n \t\t\t\t$column .= $data[$i][$j];\n \t\t\t} else {\n \t\t\t\t$string .= $data[$i][$j];\n \t\t\t}\n \t\t}\n\n \t\t$columnNum = 0;\n \t\tfor($j = strlen($column) - 1; $j >= 0; $j--) {\n \t\t\t$columnNum += (ord($column[$j]) - 64) * pow(26, strlen($column)-$j-1);\n \t\t}\n \t\t$data[$i] = 'R' . $string . 'C' . $columnNum;\n \t}\n }\n echo \"\\n\\n\";\n echo implode(\"\\n\", $data);\n?>\n"}, {"source_code": "=0;$i--) {\n if($i != $col_length-1) { $base = $base * 26; };\n $colnum = $colnum + $base * $alphabet[$col[$i]];\n }\n return 'R'.$row.'C'.$colnum;\n }\n else { die(\"Error: \".$str.\" - unknown pattern\\n\"); }\n }\n \n#############################################################\n \n $alphabet = array (1=>'A',2=>'B',3=>'C',4=>'D',5=>'E',6=>'F',7=>'G',8=>'H',9=>'I',10=>'J',11=>'K',12=>'L',13=>'M',\n 14=>'N',15=>'O',16=>'P',17=>'Q',18=>'R',19=>'S',20=>'T',21=>'U',22=>'V',23=>'W',24=>'X',25=>'Y',26=>'Z',\n 'A'=>1,'B'=>2,'C'=>3,'D'=>4,'E'=>5,'F'=>6,'G'=>7,'H'=>8,'I'=>9,'J'=>10,'K'=>11,'L'=>12,'M'=>13,\n 'N'=>14,'O'=>15,'P'=>16,'Q'=>17,'R'=>18,'S'=>19,'T'=>20,'U'=>21,'V'=>22,'W'=>23,'X'=>24,'Y'=>25,'Z'=>26);\n $count = get_stdin_vars(fgets(STDIN),1); \n $count = (int)$count[0]; \n \n if($count<1 or $count>100000) {\n die('Error: number of elements must be in range 1-100000'); \n }\n \n for ($i=0;$i<$count;$i++) {\n $indication = get_stdin_vars(fgets(STDIN),1);\n $indication = $indication[0];\n echo convert($indication).\"\\n\";\n } \n?>"}, {"source_code": "b2: '.'R'.$a2.'C'.$b2;\n\t\t$arr[$j]='R'.$a2.'C'.$b2;\n\t\tunset($b2);\n\t\tunset($a1);\n\t\tunset($a2);\n\t\t\n\t} elseif(preg_match('/^R\\d+C\\d+$/',$string)) {\n\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd R23C55\n\t\tfor ($i=1;$i<7;$i++) {\n\t\t\tif (preg_match('/[C]/',$string[$i])) {\n\t\t\t\t$a2=substr($string,1,$i-1);\n\t\t\t\t$a1=substr($string,$i+1);\n\t\t\t\t$i=8;\n\t\t\t}\n\t\t}\n\t\twhile ($a1>=1) {\n\t\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t\t$b1 = 'Z'.$b1;\n\t\t\t\t$a1=floor($a1/26)-1;\n\t\t\t} else {\n\t\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t\t$a1=floor($a1/26);\n\t\t\t}\n\t\t}\n\t\t//echo $b1.$a2.'
';\n\t\t$arr[$j]=$b1.$a2;\n\t\tunset($b1);\n\t\tunset($a1);\n\t\tunset($a2);\n\t\t\n\t} else {\n\t\techo \"\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\";\n\t}\n}\n\nfor ($j=0;$j<$numzna4;$j++) {\n\tprintf(\"%s\\n\",$arr[$j]);\n}\n?>"}, {"source_code": " 0) {\n $d1 = chr(($s2 - 1) % 26 + 65) . $d1;\n $s2 = floor($s2 / 26);\n //echo \"--$s2 $d1\\n\";\n }\n echo \"$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n?>"}, {"source_code": "=0;$i--){\n $column += (ord($str[$i])-64)*$d;\n $d *=26;\n }\n echo \"R\".$target[2].\"C\".$column.\"\\n\";\n}\n\nfclose($file);\n\n?>"}, {"source_code": " 0){\n $char = $column%26;\n $column = intval($column/26);\n $str = chr($char+64) . $str;\n }\n return $str.$row;\n}\n\nfunction convertCRtoRC($cell){\n $st = preg_match('/^([A-Z]+)([0-9]+)$/', trim($cell), $matches);\n\n $column = $matches[1];\n $row = $matches[2]; //not modified\n $chs = str_split($column);\n $count = strlen($column);\n $column = 0;\n foreach($chs as $ch){\n $column += (ord($ch) - 64) * 26**($count -1);\n $count--;\n }\n return 'R' . $row . 'C' . $column;\n} \n\nfunction convert($cell){\n $type = preg_match('/^R[0-9]+C[0-9]+$/', trim($cell), $matches);\n\n if($type === 1){\n return convertRCtoCR($cell);\n }\n \n return convertCRtoRC($cell);\n}\n\n$dir = fopen(\"php://stdin\", 'r');\n$cells = stream_get_contents($dir);\n\n$cells = explode(\"\\n\", $cells);\nfor($i=1;$i<=$cells[0];$i++){\n echo convert($cells[$i]).\"\\n\";\n}\n?>\n"}, {"source_code": "=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfscanf(STDIN,\"%d\\n\",$numzna4);\nif ($numzna4<=pow(10,5) and $numzna4>=1) {\n\tfor ($j=0;$j<$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\t\tif (preg_match('/^[A-Z]{1,4}[A-N]{0,1}\\d{1,6}[0]{0,1}$/',$arr[$j]))\n\t\t\t$arr[$j] = convert1($arr[$j]);\n\t\tif (preg_match('/^[R]\\d{1,6}[0]{0,1}[C]\\d{1,6}[0]{0,1}$/',$arr[$j]))\n\t\t\t$arr[$j] = convert2($arr[$j]);\n\t}\n\n\tfor ($j=0;$j<$numzna4;$j++) {\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n printf('R%sC%s\\n', $outR, $outC);\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n printf('%s%s\\n', $outC, $outR);\n}"}, {"source_code": "0)\n {\n $r=($num-1)%26;\n $res = chr($r+65).$res;\n $num = floor(($num-1)/26);\n }\n return $res;\n}\n\nfunction toNum($string){\n $int = 0;\n $len = strlen($string);\n for($i = 0; $i< $len; $i++){\n $int*=26;\n $int += ord($string[$i]) - 64;\n }\n return $int;\n}\n\n$file = fscanf(STDIN, \"%d\\n\", $cells);\nfor($i=0; $i<$cells; $i++){\n fscanf(STDIN, \"%s\\n\", $line);\n if($line[0] == 'R' && ord($line[1])>=48&&ord($line[1])<=57){\n $cPos = strpos($line, 'C', 2);\n if($cPos !== -1){\n print(toAlpha(substr($line, $cPos+1)).substr($line, 1, $cPos-1).\"\\n\");\n }else{\n print('R'.substr($line, 1).\"C18\\n\");\n }\n }else{\n preg_match('/[0-9]/', $line, $matches, PREG_OFFSET_CAPTURE);\n print('R'.substr($line, $matches[0][1]).'C'.toNum(substr($line, 0, $matches[0][1])).\"\\n\");\n }\n}\n"}, {"source_code": "[[:upper:]]+)(?[[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n preg_match(\"/^R([0-9]+)C([0-9]+)$/\", $coords, $matches);\n var_dump($matches);\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": " 0; $i = floor($i / 26)){\n $k = ($i % 26);\n if($k == 0){\n $k = 26;\n $i--;\n }\n $c = $letters[$k-1].$c;\n }\n \n return $c;\n}\n\nfunction alpha2num($n, $letters){\n $c = 0;\n\n for($i = strlen($n), $j = 0; $i > 0;$i--,$j++){\n $k = array_search($n[$i-1], $letters) + 1;\n if($j > 0){\n $k = $k * pow(26, $j);\n }\n $c = $k + $c;\n }\n \n return $c;\n}\n\n?>"}, {"source_code": "= 1)\n {\n $t = $param % 26;\n if($t == 0 && $param == 26) {\n $t = 26;\n $param = 0;\n }\n $result = chr($t + ord(\"A\") - 1) . $result;\n $param = floor($param / 26) ;\n } \n \n //R98C688\n //R90C35\n}\n\nfunction mytoint($param, &$result) {\n $result = 0; \n for ($index = 0; $index < strlen($param); $index++) {\n $result += (ord($param[$index]) - ord(\"A\") + 1) * pow(26, (strlen($param) - $index - 1));\n }\n}\n\n?>\n"}, {"source_code": " $baseNum)\n\t\t{\n\t\t\t$left = $num % $baseNum;\n\t\t\tif(!$left)\n\t\t\t{\n\t\t\t\t$left = 26;\n\t\t\t}\n\t\t\t\n\t\t\t$res = chr($left + $baseChar) . $res;\n\t\t\t$num = intval($num / $baseNum);\n\t\t\n\t\t}\n\t\t\n\t\tif($num)\n\t\t{\n\t\t\t$res = chr($num + $baseChar) . $res;\n\t\t}\n\t\t\n\t\t$res .= $matches[1];\n\t\t\n\t\techo $res . PHP_EOL;\n\t}\n\telse\n\t{\n\t\tpreg_match('/([A-Z]+)(\\d+)/', $str, $matches);\n\t\t\n\t\t$res = 'R' . $matches[2] . 'C';\n\t\t\n\t\t$str = str_split($matches[1]);\n\t\t$pos = count($str) - 1;\n\t\t$sum = 0;\n\t\tforeach($str as $chr)\n\t\t{\n\t\t\t$sum += (ord($chr) - $baseChar) * pow($baseNum, $pos);\n\t\t\t$pos--;\n\t\t}\n\t\t\n\t\techo $res . $sum . PHP_EOL;\n\t\t\n\t}\n}"}, {"source_code": " 26) {\n $d2 = chr(floor($s[2] / 26) % 26 + 64);\n if ($d2 == '@')\n $d2 = 'Z';\n }\n else\n $d2 = '';\n \n if ($s[2] > 26 * 26) {\n $d3 = chr(floor($s[2] / (26 * 26)) % 26 + 64);\n if ($d3 == '@')\n $d3 = 'Z';\n }\n else\n $d3 = '';\n\n echo \"$d3$d2$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n\n\n?>"}, {"source_code": " 25){\n $remainder = $col % 26;\n array_push($indexes, $remainder);\n if($remainder == 0){\n $col = ($col / 26) -1;\n if($col == 0){\n break;\n }\n }\n else{\n $col = $col / 26;\n }\n print (\"REM: \".$col.\"\\n\");\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n break;\n }\n }\n\n $rowRev = substr($word, 0, $index);\n $col = substr($word, $index);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": "\n"}, {"source_code": "\ufeff=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i =1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,4}[A-N]{0,1})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$result .= chr(64 + $a % 26);\n\t\t$a = floor($a / 26);\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\necho $n;\nvar_dump($a);\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$result .= chr(64 + $a % 26);\n\t\t$a = floor($a / 26);\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\n\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"
\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": " 25){\n $remainder = $col % 26;\n $col = $col / 26;\n array_push($indexes, $remainder);\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n }\n }\n\n if($index == 1){\n $index = 2;\n }\n\n $rowRev = substr($word, 0, $index-1);\n $col = substr($word, $index-1);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": "=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i=1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,4}[A-N]{0,1})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": " 25){\n $remainder = $col % 26;\n $col = $col / 26;\n array_push($indexes, $remainder);\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n break;\n }\n }\n\n if($index == 1){\n $index = 2;\n }\n\n $rowRev = substr($word, 0, $index);\n $col = substr($word, $index);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": ""}, {"source_code": "=48&&ord($var)<=57)\n return true;\n else\n return false;\n}\nfunction GetInt($var)\n{\n $res=\"\";\n for($i=1;$i =0;$i--)\n {\n // echo \"$i ~~\".$var[$i];\n if(IsInt($var[$i]))\n {\n $res.=$var[$i];\n }\n else {\n // echo \"RES=\".$res;\n return strrev($res);\n }\n }\n}\n\n$map=array();\n$map2=array();\n$index=1;\nfor($i=65;$i<=90;$i++)\n{\n $map[chr($i)]=$index;\n $map2[$index]=chr($i);\n $index++;\n}\nfor($i=65;$i<=90;$i++)\n{\n for($ii=65;$ii<=90;$ii++)\n {\n $map[chr($i).chr($ii)]=$index;\n $map2[$index]=chr($i).chr($ii);\n $index++;\n }\n}\nfor($i=65;$i<=90;$i++)\n{\n for($ii=65;$ii<=90;$ii++)\n {\n for($iii=65;$iii<=90;$iii++)\n {\n $map[chr($i).chr($ii).chr($iii)]=$index;\n $map2[$index]=chr($i).chr($ii).chr($iii);\n $index++;\n }\n }\n}\n\n//print_r($map);\n//print_r($map2);\n\n\nwhile($n--)\n{\nfscanf(STDIN,\"%s\",$str);\n //$str=$n==1?\"R12C4\":\"R5C255\";\n //echo \"::\".$str[1];\n if($str[0]=='R'&& IsInt($str[1]))\n {\n // echo \"$str is type 1\"; R23C55\n // echo GetInt($str);\n // echo \"~~~\";\n $a=GetInt($str);\n $b=GetInt_D($str);\n// echo $a.\"~~~\".$b;\n echo $map2[$b].$a.\"\\n\";\n\n\n\n }\n else {\n $a=\"\";\n for($i=0;$i \n"}, {"source_code": "$fr = fopen(\"php://stdin\", \"r\");\n$n = (int) fgets($fr);\necho $n;\n$n = (int) fgets($fr);\necho $n;"}, {"source_code": "= 48 && ord($data[$i][1]) <= 57) {\n \t\t$column = '';\n \t\t$string = '';\n \t\t$flag = false;\n \t\tfor($j = 1; $j < strlen($data[$i]); $j++) {\n \t\t\tif($data[$i][$j] == 'C') {\n \t\t\t\t$flag = true;\n \t\t\t} else {\n \t\t\t\tif(!$flag) {\n \t\t\t\t\t$string .= $data[$i][$j];\n \t\t\t\t} else {\n \t\t\t\t\t$column .= $data[$i][$j];\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\t$strColumn = '';\n \t\t$column = (int)$column;\n \t\t$cLen = floor($column / 26);\n\n \t\tfor($j = 0; $j < $cLen; $j++) {\n \t\t\tif($column % 26 != 0) {\n\t \t\t\t$strColumn .= chr($column % 26 + 64);\n\t \t\t\t$column = floor($column / 26);\n\t \t\t} else {\n\t \t\t\t$strColumn .= chr($column + 64);\n\t \t\t}\n \t\t}\n \t\t$data[$i] = strrev($strColumn) . $string;\n\n \t} else {\n \t\t$column = '';\n \t\t$string = '';\n \t\tfor($j = 0; $j = 65 && ord($data[$i][$j]) <= 90) {\n \t\t\t\t$column .= $data[$i][$j];\n \t\t\t} else {\n \t\t\t\t$string .= $data[$i][$j];\n \t\t\t}\n \t\t}\n\n \t\t$columnNum = 0;\n \t\tfor($j = strlen($column) - 1; $j >= 0; $j--) {\n \t\t\t$columnNum += (ord($column[$j]) - 64) * pow(26, strlen($column)-$j-1);\n \t\t}\n \t\t$data[$i] = 'R' . $string . 'C' . $columnNum;\n \t}\n }\n \n echo implode(\"\\n\", $data);\n?>"}, {"source_code": " 0) {\n $cStr = chr(64+($c % 26)) . $cStr;\n $c = floor($c / 26);\n }\n echo $cStr . $r . \"\\n\";\n } elseif (preg_match('~^([A-Z]+)([0-9]+)$~', $val, $matches)) {\n $r = $matches[2];\n $cStr = $matches[1];\n $cStrLen = strlen($cStr);\n $c = 0;\n for ($i = 0; $i < $cStrLen; $i ++) {\n $l = substr($cStr, $i, 1);\n $l = ord($l) - 64;\n $c += $l * pow(26, $cStrLen - $i - 1);\n }\n echo 'R' . $r . 'C' . $c . \"\\n\";\n }\n}\n"}, {"source_code": " 26) && ($f <= 702))\n {\n $h = floor($f / 26);\n $i = $f % 26;\n if($i == 0)\n {\n $h -= 1;\n $i = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$i - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$i - 1] . $e . \"\\n\"; \n }\n }\n elseif(($f > 702) && ($f <= 18278))\n {\n $h = floor($f / 676);\n $i = $f % 676;\n $j = floor($i / 26);\n $k = $i % 26;\n if($k == 0)\n {\n $j -= 1;\n $k = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$k - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$k - 1] . $e . \"\\n\";\n }\n }\n elseif(($f > 18278) && ($f <= 493533))\n {\n $h = floor($f / 17576);\n $i = $f % 17576;\n $j = floor($i / 676);\n $k = $i % 676;\n $l = floor($k / 26);\n $m = $k % 26;\n if($m == 0)\n {\n $l -= 1;\n $m = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$m - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$m - 1] . $e . \"\\n\"; \n }\n }\n elseif(($f > 493533) && ($f <= 1000000))\n {\n $h = floor($f / 456976);\n $i = $f % 456976;\n $j = floor($i / 17576);\n $k = $i % 17576;\n $l = floor($k / 676);\n $m = $k % 676;\n $n = floor($m / 26);\n $o = $m % 26;\n if($o == 0)\n {\n $n -= 1;\n $o = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$n - 1] . $g[$o - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$n - 1] . $g[$o - 1] . $e . \"\\n\";\n }\n }\n }\n else\n {\n if(is_numeric($b[1])) { $c = 1; }\n elseif(is_numeric($b[2])) { $c = 2; }\n elseif(is_numeric($b[3])) { $c = 3; }\n elseif(is_numeric($b[4])) { $c = 4; }\n elseif(is_numeric($b[5])) { $c = 5; }\n $d = substr($b, 0, $c); // \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\n $e = substr($b, $c); // \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438\n if(strlen($d) == 1)\n {\n $f = array_search($d, $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ($f + 1);\n }\n else\n {\n print \"R\" . $e . \"C\" . ($f + 1) . \"\\n\";\n }\n }\n elseif(strlen($d) == 2)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 26) + ($h + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 26) + ($h + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 3)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 676) + (($h + 1) * 26) + ($i + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 676) + (($h + 1) * 26) + ($i + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 4)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n $j = array_search($d[3], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 17576) + (($h + 1) * 676) + (($i + 1) * 26) + ($j + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 17576) + (($h + 1) * 676) + (($i + 1) * 26) + ($j + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 5)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n $j = array_search($d[3], $g);\n $k = array_search($d[4], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 456976) + (($h + 1) * 17576) + (($i + 1) * 676) + (($j + 1) * 26) + ($k + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 456976) + (($h + 1) * 17576) + (($i + 1) * 676) + (($j + 1) * 26) + ($k + 1)) . \"\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$result .= chr(64 + $a % 26);\n\t\t$a = floor($a / 26);\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\necho $n;\nvar_dump($a);\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n var_dump($coords);\n preg_match(\"/^R([0-9]+)C([0-9]+)$/\", $coords, $matches);\n var_dump($matches);\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$d = 64 + $a % 26;\n\t\tif ($d == 0) {\n\t\t\t$d += 26;\n\t\t}\n\t\t$result .= chr($d);\n\t\t$a = floor($a / 26);\n\t}\n\treturn ($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\n\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": "0)\n {\n $r=($num-1)%26;\n $res = chr($r+65).$res;\n $num = floor(($num-1)/26);\n }\n return $res;\n}\n\nfunction toNum($string){\n $int = 0;\n $len = strlen($string);\n for($i = 0; $i< $len; $i++){\n $int*=26;\n $int += ord($string[$i]) - 64;\n }\n return $int;\n}\n\n$file = fscanf(STDIN, \"%d\\n\", $cells);\nfor($i=0; $i<$cells; $i++){\n fscanf(STDIN, \"%s\\n\", $line);\n if($line[0] == 'R' && $line[1]<10){\n $cPos = strpos($line, 'C', 2);\n if($cPos){\n print(toAlpha(substr($line, $cPos+1)).substr($line, 1, $cPos-1).\"\\n\");\n }else{\n print('R'.substr($line, 1).\"C18\\n\");\n }\n }else{\n preg_match('/[0-9]/', $line, $matches, PREG_OFFSET_CAPTURE);\n print('R'.substr($line, $matches[0][1]).'C'.toNum(substr($line, 0, $matches[0][1])).\"\\n\");\n }\n}\n"}, {"source_code": " 26) {\n $d2 = chr(floor($s[2] / 26) % 26 + 64);\n if ($d2 == '@')\n $d2 = 'Z';\n }\n else\n $d2 = '';\n \n if ($s[2] > 26 * 26) {\n $d3 = chr(floor($s[2] / (26 * 26)) % 26 + 64);\n if ($d3 == '@')\n $d3 = 'Z';\n }\n else\n $d3 = '';\n\n echo \"$d3$d2$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n\n\n?>"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = null;\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp = $i;\n $now = 26;\n }\n\n if ($tmp !== null and bcadd($tmp,1) == $i) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n if ($now == 0); continue;\n }\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n echo $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n echo \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": "\ufeff=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i =1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,4}[A-N]{0,1})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": "\n"}, {"source_code": "1){\n if(($c%26)!=0){\n $col.= chr(($c%26)+ord(A)-1);\n $c-=$c%26;\n $c/=26;\n if($c==1) $col.='A';\n }else{\n $cuo=$c/26;\n $col.=chr($cuo+ord(A)-1);\n $c/=26;\n }\n }\n \n $col=strrev($col);\n echo \"$col\".\"$r\".\"\\n\";\n \n }\n}\n\n?>"}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = numToLet($second);\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i-1);\n\t\t\t\t$second = substr($string, $i-1);\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1.03845) {\n\t\t\tif ((int)$newnum/26 != 27 AND $newnum!=18278) {\n\t\t\t$raz++;\t\t\t\n\t\t\t}\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = 'A'.$res; break;\n\t\t\t\tcase 2: $res = 'B'.$res; break;\n\t\t\t\tcase 3: $res = 'C'.$res; break;\n\t\t\t\tcase 4: $res = 'D'.$res; break;\n\t\t\t\tcase 5: $res = 'E'.$res; break;\n\t\t\t\tcase 6: $res = 'F'.$res; break;\n\t\t\t\tcase 7: $res = 'G'.$res; break;\n\t\t\t\tcase 8: $res = 'H'.$res; break;\n\t\t\t\tcase 9: $res = 'I'.$res; break;\n\t\t\t\tcase 10: $res = 'J'.$res; break;\n\t\t\t\tcase 11: $res = 'K'.$res; break;\n\t\t\t\tcase 12: $res = 'L'.$res; break;\n\t\t\t\tcase 13: $res = 'M'.$res; break;\n\t\t\t\tcase 14: $res = 'N'.$res; break;\n\t\t\t\tcase 15: $res = 'O'.$res; break;\n\t\t\t\tcase 16: $res = 'P'.$res; break;\n\t\t\t\tcase 17: $res = 'Q'.$res; break;\n\t\t\t\tcase 18: $res = 'R'.$res; break;\n\t\t\t\tcase 19: $res = 'S'.$res; break;\n\t\t\t\tcase 20: $res = 'T'.$res; break;\n\t\t\t\tcase 21: $res = 'U'.$res; break;\n\t\t\t\tcase 22: $res = 'V'.$res; break;\n\t\t\t\tcase 23: $res = 'W'.$res; break;\n\t\t\t\tcase 24: $res = 'X'.$res; break;\n\t\t\t\tcase 25: $res = 'Y'.$res; break;\n\t\t\t\tcase 0: $res = 'Z'.$res; break;\n\t\t\t}\n\t\t\tif ($cur==0){\n\t\t\t$newnum = floor($newnum/26)-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t$newnum/=26;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": " 1, \"B\" => 2, \"C\" => 3, \"D\" => 4, \"E\" => 5, \"F\" => 6, \"G\" => 7,\n \"H\" => 8, \"I\" => 9, \"J\" => 10, \"K\" => 11, \"L\" => 12, \"M\" => 13, \"N\" => 14,\n \"O\" => 15, \"P\" => 16, \"Q\" => 17, \"R\" => 18, \"S\" => 19, \"T\" => 20, \"U\" => 21, \n \"V\" => 22, \"W\" => 23, \"X\" => 24, \"Y\" => 25, \"Z\" => 26);\n$y = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nfor($i=0; $i<$a; ++$i)\n{\n $b[$i] = trim(fgets(STDIN));\n if(preg_match('/R(\\d+)C(\\d+)/', $b[$i], $c))\n {\n while(true)\n {\n if($c[2]>=1 and $c[2]<=26){$h .= $y{$c[2]-1}; break;}\n else{\n $f = floor($c[2]/26);\n $g = $c[2]-$f*26;\n $c[2] = floor(($c[2]-$g)/26);\n $h .= $y{$g-1};\n if($c[2]>=1 and $c[2]<=26){$h .= $y{$c[2]-1}; break;}\n elseif($c[2]==0){$h .= $y{25}; break;}\n }\n }\n $e .= strrev($h).$c[1].\"\\n\";\n }elseif(preg_match('/([A-Z]+)(\\d+)/', $b[$i], $c))\n {\n if(strlen($c[1])==1)\n {\n $d = $z[$c[1]];\n }else{\n for($j=0; $j "}, {"source_code": " 26;\n if ($continue) {\n $curr_num = $num % 26;\n $str = chr($curr_num + 64).$str;\n $num = floor($num / 26);\n } else {\n $str = chr($num + 64).$str;\n }\n } while ($continue);\n return $str;\n}\n\nfunction alpha_to_number($str) {\n $parts = str_split($str);\n $num = 0;\n for ($i = 0; $i < count($parts); $i++) {\n $num = $num * 26;\n $num += ord($parts[$i]) - 64;\n }\n return $num;\n}\n\nfunction convert_one($str) {\n $parts = preg_split(\"/\\d+/\", $str);\n if ($parts[0] === 'R' && $parts[1] === 'C') {\n // from RXCY\n $numbers = preg_split(\"/R|C/\", $str);\n $row = $numbers[1];\n $col = $numbers[2];\n printf(\"%s%d\", number_to_alpha($col), $row);\n } else {\n // to RXCY\n $col_str = $parts[0];\n $col = alpha_to_number($col_str);\n $row_parts = preg_split(\"/[A-Z]+/\", $str);\n $row = (int)$row_parts[1];\n printf(\"R%dC%d\", $row, $col);\n }\n}\n\nfscanf(STDIN, \"%d\", $n);\nfor ($i = 1; $i <= $n; $i++) {\n fscanf(STDIN, \"%s\", $str);\n convert_one($str);\n}\n?>"}, {"source_code": " 0) && ($e <= 26))\n {\n $i = $g[$e];\n }\n elseif(($e > 26) && ($e <= 702))\n {\n $f = ($e - 26) * 2 - 1;\n $i = $k[$f] . $k[$f + 1];\n }\n elseif(($e > 702) && ($e <= 18278))\n {\n $f = ($e - 702) * 3 - 2;\n $i = $l[$f] . $l[$f + 1] . $l[$f + 2];\n }\n elseif(($e > 18278) && ($e <= 475254))\n {\n $f = ($e - 18278) * 4 - 3;\n $i = $m[$f] . $m[$f + 1] . $m[$f + 2] . $m[$f + 3];\n }\n elseif(($e > 475254) && ($e <= 1000001))\n {\n $f = ($e - 475254) * 4 - 4;\n $i = $n[$f] . $n[$f + 1] . $n[$f + 2] . $n[$f + 3] . $n[$f + 4];\n }\n $j = substr($b, $c, $d - $c - 1);\n if($x == $a)\n {\n print $i . $j;\n }\n else\n {\n print $i . $j . \"\\n\";\n }\n }\n else\n {\n if(is_numeric($b[1]) == TRUE)\n {\n $e = substr($b, 0, 1);\n }\n elseif(is_numeric($b[2]) == TRUE)\n {\n $e = substr($b, 0, 2);\n }\n elseif(is_numeric($b[3]) == TRUE)\n {\n $e = substr($b, 0, 3);\n }\n elseif(is_numeric($b[4]) == TRUE)\n {\n $e = substr($b, 0, 4);\n }\n elseif(is_numeric($b[5]) == TRUE)\n {\n $e = substr($b, 0, 5);\n }\n elseif(is_numeric($b[6]) == TRUE)\n {\n $e = substr($b, 0, 6);\n }\n if(strlen($e) == 1)\n {\n if($e == \"A\")\n {\n $r = 1;\n }\n elseif($e == \"B\")\n {\n $r = 2;\n }\n elseif($e == \"C\")\n {\n $r = 3;\n }\n elseif($e == \"D\")\n {\n $r = 4;\n }\n elseif($e == \"E\")\n {\n $r = 5;\n }\n elseif($e == \"F\")\n {\n $r = 6;\n }\n elseif($e == \"G\")\n {\n $r = 7;\n }\n elseif($e == \"H\")\n {\n $r = 8;\n }\n elseif($e == \"I\")\n {\n $r = 9;\n }\n elseif($e == \"J\")\n {\n $r = 10;\n }\n elseif($e == \"K\")\n {\n $r = 11;\n }\n elseif($e == \"L\")\n {\n $r = 12;\n }\n elseif($e == \"M\")\n {\n $r = 13;\n }\n elseif($e == \"N\")\n {\n $r = 14;\n }\n elseif($e == \"O\")\n {\n $r = 15;\n }\n elseif($e == \"P\")\n {\n $r = 16;\n }\n elseif($e == \"Q\")\n {\n $r = 17;\n }\n elseif($e == \"R\")\n {\n $r = 18;\n }\n elseif($e == \"S\")\n {\n $r = 19;\n }\n elseif($e == \"T\")\n {\n $r = 20;\n }\n elseif($e == \"U\")\n {\n $r = 21;\n }\n elseif($e == \"V\")\n {\n $r = 22;\n }\n elseif($e == \"W\")\n {\n $r = 23;\n }\n elseif($e == \"X\")\n {\n $r = 24;\n }\n elseif($e == \"Y\")\n {\n $r = 25;\n }\n elseif($e == \"Z\")\n {\n $r = 26;\n }\n }\n elseif(strlen($e) == 2)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n $r = $f * 26 + $t;\n }\n elseif(strlen($e) == 3)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n $r = $f * 676 + $t * 26 + $h;\n }\n elseif(strlen($e) == 4)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n $r = $f * 17576 + $t * 676 + $h * 26 + $i;\n }\n elseif(strlen($e) == 5)\n {\n if($e[0] == \"A\")\n {\n $f = 1;\n }\n elseif($e[0] == \"B\")\n {\n $f = 2;\n }\n elseif($e[0] == \"C\")\n {\n $f = 3;\n }\n elseif($e[0] == \"D\")\n {\n $f = 4;\n }\n elseif($e[0] == \"E\")\n {\n $f = 5;\n }\n elseif($e[0] == \"F\")\n {\n $f = 6;\n }\n elseif($e[0] == \"G\")\n {\n $f = 7;\n }\n elseif($e[0] == \"H\")\n {\n $f = 8;\n }\n elseif($e[0] == \"I\")\n {\n $f = 9;\n }\n elseif($e[0] == \"J\")\n {\n $f = 10;\n }\n elseif($e[0] == \"K\")\n {\n $f = 11;\n }\n elseif($e[0] == \"L\")\n {\n $f = 12;\n }\n elseif($e[0] == \"M\")\n {\n $f = 13;\n }\n elseif($e[0] == \"N\")\n {\n $f = 14;\n }\n elseif($e[0] == \"O\")\n {\n $f = 15;\n }\n elseif($e[0] == \"P\")\n {\n $f = 16;\n }\n elseif($e[0] == \"Q\")\n {\n $f = 17;\n }\n elseif($e[0] == \"R\")\n {\n $f = 18;\n }\n elseif($e[0] == \"S\")\n {\n $f = 19;\n }\n elseif($e[0] == \"T\")\n {\n $f = 20;\n }\n elseif($e[0] == \"U\")\n {\n $f = 21;\n }\n elseif($e[0] == \"V\")\n {\n $f = 22;\n }\n elseif($e[0] == \"W\")\n {\n $f = 23;\n }\n elseif($e[0] == \"X\")\n {\n $f = 24;\n }\n elseif($e[0] == \"Y\")\n {\n $f = 25;\n }\n elseif($e[0] == \"Z\")\n {\n $f = 26;\n }\n if($e[1] == \"A\")\n {\n $t = 1;\n }\n elseif($e[1] == \"B\")\n {\n $t = 2;\n }\n elseif($e[1] == \"C\")\n {\n $t = 3;\n }\n elseif($e[1] == \"D\")\n {\n $t = 4;\n }\n elseif($e[1] == \"E\")\n {\n $t = 5;\n }\n elseif($e[1] == \"F\")\n {\n $t = 6;\n }\n elseif($e[1] == \"G\")\n {\n $t = 7;\n }\n elseif($e[1] == \"H\")\n {\n $t = 8;\n }\n elseif($e[1] == \"I\")\n {\n $t = 9;\n }\n elseif($e[1] == \"J\")\n {\n $t = 10;\n }\n elseif($e[1] == \"K\")\n {\n $t = 11;\n }\n elseif($e[1] == \"L\")\n {\n $t = 12;\n }\n elseif($e[1] == \"M\")\n {\n $t = 13;\n }\n elseif($e[1] == \"N\")\n {\n $t = 14;\n }\n elseif($e[1] == \"O\")\n {\n $t = 15;\n }\n elseif($e[1] == \"P\")\n {\n $t = 16;\n }\n elseif($e[1] == \"Q\")\n {\n $t = 17;\n }\n elseif($e[1] == \"R\")\n {\n $t = 18;\n }\n elseif($e[1] == \"S\")\n {\n $t = 19;\n }\n elseif($e[1] == \"T\")\n {\n $t = 20;\n }\n elseif($e[1] == \"U\")\n {\n $t = 21;\n }\n elseif($e[1] == \"V\")\n {\n $t = 22;\n }\n elseif($e[1] == \"W\")\n {\n $t = 23;\n }\n elseif($e[1] == \"X\")\n {\n $t = 24;\n }\n elseif($e[1] == \"Y\")\n {\n $t = 25;\n }\n elseif($e[1] == \"Z\")\n {\n $t = 26;\n }\n if($e[2] == \"A\")\n {\n $h = 1;\n }\n elseif($e[2] == \"B\")\n {\n $h = 2;\n }\n elseif($e[2] == \"C\")\n {\n $h = 3;\n }\n elseif($e[2] == \"D\")\n {\n $h = 4;\n }\n elseif($e[2] == \"E\")\n {\n $h = 5;\n }\n elseif($e[2] == \"F\")\n {\n $h = 6;\n }\n elseif($e[2] == \"G\")\n {\n $h = 7;\n }\n elseif($e[2] == \"H\")\n {\n $h = 8;\n }\n elseif($e[2] == \"I\")\n {\n $h = 9;\n }\n elseif($e[2] == \"J\")\n {\n $h = 10;\n }\n elseif($e[2] == \"K\")\n {\n $h = 11;\n }\n elseif($e[2] == \"L\")\n {\n $h = 12;\n }\n elseif($e[2] == \"M\")\n {\n $h = 13;\n }\n elseif($e[2] == \"N\")\n {\n $h = 14;\n }\n elseif($e[2] == \"O\")\n {\n $h = 15;\n }\n elseif($e[2] == \"P\")\n {\n $h = 16;\n }\n elseif($e[2] == \"Q\")\n {\n $h = 17;\n }\n elseif($e[2] == \"R\")\n {\n $h = 18;\n }\n elseif($e[2] == \"S\")\n {\n $h = 19;\n }\n elseif($e[2] == \"T\")\n {\n $h = 20;\n }\n elseif($e[2] == \"U\")\n {\n $h = 21;\n }\n elseif($e[2] == \"V\")\n {\n $h = 22;\n }\n elseif($e[2] == \"W\")\n {\n $h = 23;\n }\n elseif($e[2] == \"X\")\n {\n $h = 24;\n }\n elseif($e[2] == \"Y\")\n {\n $h = 25;\n }\n elseif($e[2] == \"Z\")\n {\n $h = 26;\n }\n if($e[3] == \"A\")\n {\n $i = 1;\n }\n elseif($e[3] == \"B\")\n {\n $i = 2;\n }\n elseif($e[3] == \"C\")\n {\n $i = 3;\n }\n elseif($e[3] == \"D\")\n {\n $i = 4;\n }\n elseif($e[3] == \"E\")\n {\n $i = 5;\n }\n elseif($e[3] == \"F\")\n {\n $i = 6;\n }\n elseif($e[3] == \"G\")\n {\n $i = 7;\n }\n elseif($e[3] == \"H\")\n {\n $i = 8;\n }\n elseif($e[3] == \"I\")\n {\n $i = 9;\n }\n elseif($e[3] == \"J\")\n {\n $i = 10;\n }\n elseif($e[3] == \"K\")\n {\n $i = 11;\n }\n elseif($e[3] == \"L\")\n {\n $i = 12;\n }\n elseif($e[3] == \"M\")\n {\n $i = 13;\n }\n elseif($e[3] == \"N\")\n {\n $i = 14;\n }\n elseif($e[3] == \"O\")\n {\n $i = 15;\n }\n elseif($e[3] == \"P\")\n {\n $i = 16;\n }\n elseif($e[3] == \"Q\")\n {\n $i = 17;\n }\n elseif($e[3] == \"R\")\n {\n $i = 18;\n }\n elseif($e[3] == \"S\")\n {\n $i = 19;\n }\n elseif($e[3] == \"T\")\n {\n $i = 20;\n }\n elseif($e[3] == \"U\")\n {\n $i = 21;\n }\n elseif($e[3] == \"V\")\n {\n $i = 22;\n }\n elseif($e[3] == \"W\")\n {\n $i = 23;\n }\n elseif($e[3] == \"X\")\n {\n $i = 24;\n }\n elseif($e[3] == \"Y\")\n {\n $i = 25;\n }\n elseif($e[3] == \"Z\")\n {\n $i = 26;\n }\n if($e[4] == \"A\")\n {\n $j = 1;\n }\n elseif($e[4] == \"B\")\n {\n $j = 2;\n }\n elseif($e[4] == \"C\")\n {\n $j = 3;\n }\n elseif($e[4] == \"D\")\n {\n $j = 4;\n }\n elseif($e[4] == \"E\")\n {\n $j = 5;\n }\n elseif($e[4] == \"F\")\n {\n $j = 6;\n }\n elseif($e[4] == \"G\")\n {\n $j = 7;\n }\n elseif($e[4] == \"H\")\n {\n $j = 8;\n }\n elseif($e[4] == \"I\")\n {\n $j = 9;\n }\n elseif($e[4] == \"J\")\n {\n $j = 10;\n }\n elseif($e[4] == \"K\")\n {\n $j = 11;\n }\n elseif($e[4] == \"L\")\n {\n $j = 12;\n }\n elseif($e[4] == \"M\")\n {\n $j = 13;\n }\n elseif($e[4] == \"N\")\n {\n $j = 14;\n }\n elseif($e[4] == \"O\")\n {\n $j = 15;\n }\n elseif($e[4] == \"P\")\n {\n $j = 16;\n }\n elseif($e[4] == \"Q\")\n {\n $j = 17;\n }\n elseif($e[4] == \"R\")\n {\n $j = 18;\n }\n elseif($e[4] == \"S\")\n {\n $j = 19;\n }\n elseif($e[4] == \"T\")\n {\n $j = 20;\n }\n elseif($e[4] == \"U\")\n {\n $j = 21;\n }\n elseif($e[4] == \"V\")\n {\n $j = 22;\n }\n elseif($e[4] == \"W\")\n {\n $j = 23;\n }\n elseif($e[4] == \"X\")\n {\n $j = 24;\n }\n elseif($e[4] == \"Y\")\n {\n $j = 25;\n }\n elseif($e[4] == \"Z\")\n {\n $j = 26;\n }\n $r = $f * 456976 + $t * 17576 + $h * 676 + $i * 26 + $j;\n } \n $s = substr($b, strlen($e));\n if($x == $a)\n {\n print \"R\" . $s . \"C\" . $r;\n }\n else\n {\n print \"R\" . $s . \"C\" . $r . \"\\n\";\n } \n }\n}\n?>"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n print_r(sprintf('R%sC%s', $outR, $outC));\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n print_r(sprintf('%s%s', $outC, $outR));\n}"}, {"source_code": "0)echo \"\\n\";\n\t$input = $inputs[$i];\n\tif (!preg_match('/R(\\d+)C(\\d+)/',\n $input))\n\t{\n\t \techo convertS1($input);\n\t}\n\telse\n\t{\n\t\techo convertS2($input);\n\t}\n\n}\n"}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n var_dump($coords);\n preg_match(\"/^R(? [[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches);\n var_dump($matches);\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = strrev(numToLet($second));\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i-1);\n\t\t\t\t$second = substr($string, $i-1);\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1) {\n\t\t\t$raz++;\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = $res.'A'; break;\n\t\t\t\tcase 2: $res = $res.'B'; break;\n\t\t\t\tcase 3: $res = $res.'C'; break;\n\t\t\t\tcase 4: $res = $res.'D'; break;\n\t\t\t\tcase 5: $res = $res.'E'; break;\n\t\t\t\tcase 6: $res = $res.'F'; break;\n\t\t\t\tcase 7: $res = $res.'G'; break;\n\t\t\t\tcase 8: $res = $res.'H'; break;\n\t\t\t\tcase 9: $res = $res.'I'; break;\n\t\t\t\tcase 10: $res = $res.'J'; break;\n\t\t\t\tcase 11: $res = $res.'K'; break;\n\t\t\t\tcase 12: $res = $res.'L'; break;\n\t\t\t\tcase 13: $res = $res.'M'; break;\n\t\t\t\tcase 14: $res = $res.'N'; break;\n\t\t\t\tcase 15: $res = $res.'O'; break;\n\t\t\t\tcase 16: $res = $res.'P'; break;\n\t\t\t\tcase 17: $res = $res.'Q'; break;\n\t\t\t\tcase 18: $res = $res.'R'; break;\n\t\t\t\tcase 19: $res = $res.'S'; break;\n\t\t\t\tcase 20: $res = $res.'T'; break;\n\t\t\t\tcase 21: $res = $res.'U'; break;\n\t\t\t\tcase 22: $res = $res.'V'; break;\n\t\t\t\tcase 23: $res = $res.'W'; break;\n\t\t\t\tcase 24: $res = $res.'X'; break;\n\t\t\t\tcase 25: $res = $res.'Y'; break;\n\t\t\t\tcase 0: $res = $res.'Z'; break;\n\t\t\t}\n\t\t\t$newnum/=26;\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": "0)echo \"\\n\";\n\t$input = $inputs[$i];\n\tif (!preg_match('/R(\\d+)C(\\d+)/',\n $input))\n\t{\n\t \techo convertS1($input);\n\t}\n\telse\n\t{\n\t\techo convertS2($input);\n\t}\n\n}\n"}, {"source_code": "\ufeff=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i =1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,4}[A-N]{0,1})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>\n"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = [];\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp[$i] = true;\n $now = 26;\n }\n\n if ($tmp !== null and $tmp[$i-1]) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n if ($now < 0) {\n $now = 26 + $now;\n }\n if ($now == 0) {\n $now = 26;\n $tmp[$i] = true;\n };\n }\n\n echo $now.\"\\n\";\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n return $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n return \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n echo read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": "b2: '.'R'.$a2.'C'.$b2;\n\t\t$arr[$j]='R'.$a2.'C'.$b2;\n\t\tunset($b2);\n\t\tunset($a1);\n\t\tunset($a2);\n\t\t\n\t} elseif(preg_match('/^R\\d+C\\d+$/',$string)) {\n\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd R23C55\n\t\tfor ($i=1;$i<7;$i++) {\n\t\t\tif (preg_match('/[C]/',$string[$i])) {\n\t\t\t\t$a2=substr($string,1,$i-1);\n\t\t\t\t$a1=substr($string,$i+1);\n\t\t\t\t$i=8;\n\t\t\t}\n\t\t}\n\t\twhile ($a1>=1) {\n\t\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t\t$b1 = 'Z'.$b1;\n\t\t\t\t$a1=floor($a1/26)-1;\n\t\t\t} else {\n\t\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t\t$a1=floor($a1/26);\n\t\t\t}\n\t\t}\n\t\t//echo $b1.$a2.'
';\n\t\t$arr[$j]=$b1.$a2;\n\t\tunset($b1);\n\t\tunset($a1);\n\t\tunset($a2);\n\t\t\n\t} else {\n\t\techo \"\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\";\n\t}\n}\n\nfor ($j=0;$j<$numzna4;$j++) {\n\tprintf(\"%s\\n\",$arr[$j]);\n}\n?>"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j26){\n if($i_row%26==0){\n $row.=\"A\";\n $i_row--;\n }else {\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n } \n $row.=chr($i_row%26+64);\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": " 1) {\n $result .= chr(round($param / 26) + ord(\"A\") - 1);\n }\n if ($param % 26 > 0) {\n $result .= chr(round($param % 26) + ord(\"A\") - 1);\n }\n}\n\nfunction mytoint($param, &$result) {\n $result = 0; \n for ($index = 0; $index < strlen($param); $index++) {\n $result += (ord($param[$index]) - ord(\"A\") + 1) * pow(26, (strlen($param) - $index - 1));\n }\n}\n\n?>\n"}, {"source_code": " 0) {\n $d1 = chr(($s2 - 1) % 26 + 65) . $d1;\n $s2 = floor($s2 / 26);\n //echo \"--$s2 $d1\\n\";\n }\n echo \"$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n?>"}, {"source_code": "=48&&ord($var)<=57)\n return true;\n else\n return false;\n}\nfunction GetInt($var)\n{\n $res=\"\";\n for($i=1;$i =0;$i--)\n {\n // echo \"$i ~~\".$var[$i];\n if(IsInt($var[$i]))\n {\n $res.=$var[$i];\n }\n else {\n // echo \"RES=\".$res;\n return strrev($res);\n }\n }\n}\n\n$map=array();\n$map2=array();\n$index=1;\nfor($i=65;$i<=90;$i++)\n{\n $map[chr($i)]=$index;\n $map2[$index]=chr($i);\n $index++;\n}\nfor($i=65;$i<=90;$i++)\n{\n for($ii=65;$ii<=90;$ii++)\n {\n $map[chr($i).chr($ii)]=$index;\n $map2[$index]=chr($i).chr($ii);\n $index++;\n }\n}\n\n//print_r($map);\n//print_r($map2);\n\n\nwhile($n--)\n{\nfscanf(STDIN,\"%s\",$str);\n //$str=$n==1?\"R12C4\":\"R5C255\";\n //echo \"::\".$str[1];\n if($str[0]=='R'&& IsInt($str[1]))\n {\n // echo \"$str is type 1\"; R23C55\n // echo GetInt($str);\n // echo \"~~~\";\n $a=GetInt($str);\n $b=GetInt_D($str);\n// echo $a.\"~~~\".$b;\n echo $map2[$b].$a.\"\\n\";\n\n\n\n }\n else {\n // echo \"$str is type 2\";BC23\n $a=\"\";\n for($i=0;$i \n"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j 26){\n if($i_row%26==0){\n $row.=\"A\";\n $i_row--;\n }else {\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n } \n $row.=chr($i_row%26+64);\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = [];\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp[$i] = true;\n $now = 26;\n }\n\n if ($tmp !== null and $tmp[$i-1]) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n if ($now < 0) {\n $now = 26 + $now;\n }\n if ($now == 0) {\n $now = 26;\n $tmp[$i] = true;\n };\n }\n\n echo $now.\"\\n\";\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n return $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n return \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n echo read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": "1){\n if(($c%26)!=0){\n $col.= chr(($c%26)+ord(A)-1);\n $c-=$c%26;\n $c/=26;\n if($c==1) $col.='A';\n }else{\n $cuo=$c/26;\n $col.=chr($cuo+ord(A)-1);\n $c/=26;\n }\n }\n \n $col=strrev($col);\n echo \"$col\".\"$r\".\"\\n\";\n \n }\n}\n\n?>"}, {"source_code": " \"0\",\n \"A\" => \"1\",\n \"B\" => \"2\",\n \"C\" => \"3\",\n \"D\" => \"4\",\n \"E\" => \"5\",\n \"F\" => \"6\",\n \"G\" => \"7\",\n \"H\" => \"8\",\n \"I\" => \"9\",\n \"J\" => \"A\",\n \"K\" => \"B\",\n \"L\" => \"C\",\n \"M\" => \"D\",\n \"N\" => \"E\",\n \"O\" => \"F\",\n \"P\" => \"G\",\n \"Q\" => \"H\",\n \"R\" => \"I\",\n \"S\" => \"J\",\n \"T\" => \"K\",\n \"U\" => \"L\",\n \"V\" => \"M\",\n \"W\" => \"N\",\n \"X\" => \"O\",\n \"Y\" => \"P\",\n \"Z\" => \"Q\");\n\n$letters = array(\n \"0\" => \"0\",\n \"1\" => \"1\",\n \"2\" => \"2\",\n \"3\" => \"3\",\n \"4\" => \"4\",\n \"5\" => \"5\",\n \"6\" => \"6\",\n \"7\" => \"7\",\n \"8\" => \"8\",\n \"9\" => \"9\",\n \"10\" => \"A\",\n \"11\" => \"B\",\n \"12\" => \"C\",\n \"13\" => \"D\",\n \"14\" => \"E\",\n \"15\" => \"F\",\n \"16\" => \"G\",\n \"17\" => \"H\",\n \"18\" => \"I\",\n \"19\" => \"J\",\n \"20\" => \"K\",\n \"21\" => \"L\",\n \"22\" => \"M\",\n \"23\" => \"N\",\n \"24\" => \"O\",\n \"25\" => \"P\",\n \"26\" => \"Q\");\n\n$newcells = array();\n\nfunction mybase26($number) { //something funky that takes out the zeros and replaces them with \"Z\"s (non-existent in base 26) and decrements the next highest place value\n //coming from base 10\n global $letters;\n $places = array();\n $places[4] = 0;\n $places[3] = 0;\n $places[2] = 0;\n $places[1] = 0;\n $places[0] = 0;\n //the number can't have a fives place since it's smaller than 10^6\n //yes we're brute forcing here\n if ($number > 456976) { //notice how we're not using >=, this is so that we don't reach a zero and we can use the Zs. In a normal conversion function this would take out allll the 456976s possible, here, we leave one, if there's one left.\n do {\n $number = $number - 456976; //26^4\n $places[4]++;\n } while ($number > 456976);\n }\n if ($number > 17576) { \n do {\n $number = $number - 17576; //26^3\n $places[3]++;\n } while ($number > 17576);\n }\n if ($number > 676) {\n do {\n $number = $number - 676;\n $places[2]++;\n } while ($number > 676);\n }\n if ($number > 26) {\n do {\n $number = $number - 26;\n $places[1]++;\n } while ($number > 26);\n }\n if ($number <= 26) { //because we close this baby out and take it all home in the last place, we use <= here.\n $places[0] = $number;\n }\n \n\n //okay okay I know I'm being inefficient with my loops here\n if ($places[3] == 0 && $places[4] > 0) {\n $places[4]--;\n $places[3] = 26;\n }\n if ($places[2] == 0 && $places[3] > 0) {\n $places[3]--;\n $places[2] = 26;\n }\n if ($places[1] == 0 && $places[2] > 0) {\n $places[2]--;\n $places[1] = 26;\n }\n if ($places[0] == 0 && $places[1] > 0) {\n $places[1]--;\n $places[0] = 26;\n }\n\n //now we have the place values; just get them into letters if bigger than 9.\n $places[4] = $letters[$places[4]];\n $places[3] = $letters[$places[3]];\n $places[2] = $letters[$places[2]];\n $places[1] = $letters[$places[1]];\n $places[0] = $letters[$places[0]];\n\n return ltrim($places[4].$places[3].$places[2].$places[1].$places[0], \"0\");\n}\n\nfunction mybase10($number) { //with an array that includes Z = 26\n //from base 26\n global $letters;\n $explode = str_split($number);\n $power = 0; //of 26\n $sum = 0; //result\n\n foreach ($explode as $key => $value) { //convert from A to 10, for example\n $explode[$key] = array_search($value, $letters);\n }\n\n //tricky way of reversing number to start with zeros place and then increase\n $reversedAndReindexed = array_values(array_reverse($explode));\n $places = count($reversedAndReindexed);\n\n for ($i = 0; $i < $places; $i++) {\n $sum = $sum + (pow(26, $power) * $reversedAndReindexed[$i]); //learn something new everyday. pow is the base to exponent function. And to think I guessed it from my text editor.\n $power++;\n }\n\n return $sum;\n}\n\nfunction numbertoletter($number) {\n global $shiftover;\n $base26 = str_split(mybase26($number)); //get from base 10 to base 26\n $shift = \"\";\n foreach ($base26 as $value) { //now shift all the characters over to start at A instead of 1\n $shift .= array_search($value, $shiftover);\n }\n return $shift;\n}\n\nfunction lettertonumber($letter) {\n global $shiftover;\n $explode = str_split($letter);\n $shift = \"\";\n foreach ($explode as $value) { //shift all the characters over to start at 1 instead of A\n $shift .= $shiftover[$value];\n }\n\n $base10 = mybase10($shift);\n return $base10;\n}\n\n//main(), if you will\nfor ($i = 0; $i < $n; $i++) {\n $cell = trim(fgets(STDIN)); //$cell = $array[$i];\n if (preg_match(\"/R([0-9]+)C([0-9]+)/\", $cell, $matches) == TRUE) {\n $matches[2] = numbertoletter($matches[2]);\n $newcells[] = $matches[2].$matches[1];\n } else {\n preg_match(\"/([A-Z]+)([0-9]+)/\", $cell, $matches);\n $matches[1] = lettertonumber($matches[1]);\n $newcells[] = \"R\".$matches[2].\"C\".$matches[1];\n }\n}\n\nforeach ($newcells as $value) {\n echo $value.\"\\n\";\n}\n?>"}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n preg_match(\"/^R(? [0-9]+)C(?
[0-9]+)$/\", $coords, $matches);\n var_dump($matches);\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = strrev(numToLet($second));\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i-1);\n\t\t\t\t$second = substr($string, $i-1);\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1) {\n\t\t\t$raz++;\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = 'A'.$res; break;\n\t\t\t\tcase 2: $res = 'B'.$res; break;\n\t\t\t\tcase 3: $res = 'C'.$res; break;\n\t\t\t\tcase 4: $res = 'D'.$res; break;\n\t\t\t\tcase 5: $res = 'E'.$res; break;\n\t\t\t\tcase 6: $res = 'F'.$res; break;\n\t\t\t\tcase 7: $res = 'G'.$res; break;\n\t\t\t\tcase 8: $res = 'H'.$res; break;\n\t\t\t\tcase 9: $res = 'I'.$res; break;\n\t\t\t\tcase 10: $res = 'J'.$res; break;\n\t\t\t\tcase 11: $res = 'K'.$res; break;\n\t\t\t\tcase 12: $res = 'L'.$res; break;\n\t\t\t\tcase 13: $res = 'M'.$res; break;\n\t\t\t\tcase 14: $res = 'N'.$res; break;\n\t\t\t\tcase 15: $res = 'O'.$res; break;\n\t\t\t\tcase 16: $res = 'P'.$res; break;\n\t\t\t\tcase 17: $res = 'Q'.$res; break;\n\t\t\t\tcase 18: $res = 'R'.$res; break;\n\t\t\t\tcase 19: $res = 'S'.$res; break;\n\t\t\t\tcase 20: $res = 'T'.$res; break;\n\t\t\t\tcase 21: $res = 'U'.$res; break;\n\t\t\t\tcase 22: $res = 'V'.$res; break;\n\t\t\t\tcase 23: $res = 'W'.$res; break;\n\t\t\t\tcase 24: $res = 'X'.$res; break;\n\t\t\t\tcase 25: $res = 'Y'.$res; break;\n\t\t\t\tcase 0: $res = 'Z'.$res; break;\n\t\t\t}\n\t\t\tif ($cur==0){\n\t\t\t$newnum = floor($newnum/26)-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t(int)$newnum/=26;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": ""}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$result .= chr(64 + $a % 26);\n\t\t$a = floor($a / 26);\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\nvar_dump($a);\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": "=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfscanf(STDIN,\"%d\\n\",$numzna4);\n\nif ($numzna4<=pow(10,5) and $numzna4>=1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\t\tif (preg_match('/^[A-Z]{1,4}[A-N]{0,1}\\d{1,6}[0]{0,1}$/',$arr[$j]))\n\t\t\t$arr[$j] = convert1($arr[$j]);\n\t\tif (preg_match('/^[R]\\d{1,6}[0]{0,1}[C]\\d{1,6}[0]{0,1}$/',$arr[$j]))\n\t\t\t$arr[$j] = convert2($arr[$j]);\n\t}\n\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>"}, {"source_code": ""}, {"source_code": " 26) && ($f <= 702))\n {\n $h = floor($f / 26);\n $i = $f % 26;\n if($i == 0)\n {\n $h -= 1;\n $i = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$i - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$i - 1] . $e . \"\\n\"; \n }\n }\n elseif(($f > 702) && ($f <= 18278))\n {\n $h = floor($f / 676);\n $i = $f % 676;\n $j = floor($i / 26);\n $k = $i % 26;\n if($k == 0)\n {\n $j -= 1;\n $k = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$k - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$k - 1] . $e . \"\\n\";\n }\n }\n elseif(($f > 18278) && ($f <= 493533))\n {\n $h = floor($f / 17576);\n $i = $f % 17576;\n $j = floor($i / 676);\n $k = $i % 676;\n $l = floor($k / 26);\n $m = $k % 26;\n if($m == 0)\n {\n $l -= 1;\n $m = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$m - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$m - 1] . $e . \"\\n\"; \n }\n }\n elseif(($f > 493533) && ($f <= 1000000))\n {\n $h = floor($f / 456976);\n $i = $f % 456976;\n $j = floor($i / 17576);\n $k = $i % 17576;\n $l = floor($k / 676);\n $m = $k % 676;\n $n = floor($m / 26);\n $o = $m % 26;\n if($o == 0)\n {\n $n -= 1;\n $o = 26;\n }\n if($x == $a)\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$n - 1] . $g[$o - 1] . $e; \n }\n else\n {\n print $g[$h - 1] . $g[$j - 1] . $g[$l - 1] . $g[$n - 1] . $g[$o - 1] . $e . \"\\n\";\n }\n }\n }\n else\n {\n if(is_numeric($b[1])) { $c = 1; }\n elseif(is_numeric($b[2])) { $c = 2; }\n elseif(is_numeric($b[3])) { $c = 3; }\n elseif(is_numeric($b[4])) { $c = 4; }\n elseif(is_numeric($b[5])) { $c = 5; }\n $d = substr($b, 0, $c); // \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\n $e = substr($b, $c); // \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438\n if(strlen($d) == 1)\n {\n $f = array_search($d, $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ($f + 1);\n }\n else\n {\n print \"R\" . $e . \"C\" . ($f + 1) . \"\\n\";\n }\n }\n elseif(strlen($d) == 2)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 26) + ($h + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 26) + ($h + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 3)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 676) + (($h + 1) * 26) + ($i + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 676) + (($h + 1) * 26) + ($i + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 4)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n $j = array_search($d[3], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 17576) + (($h + 1) * 676) + (($i + 1) * 26) + ($j + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 17576) + (($h + 1) * 676) + (($i + 1) * 26) + ($j + 1)) . \"\\n\";\n }\n }\n elseif(strlen($d) == 5)\n {\n $f = array_search($d[0], $g);\n $h = array_search($d[1], $g);\n $i = array_search($d[2], $g);\n $j = array_search($d[3], $g);\n $k = array_search($d[4], $g);\n if($x == $a)\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 456976) + (($h + 1) * 17576) + (($i + 1) * 676) + (($j + 1) * 26) + ($k + 1));\n }\n else\n {\n print \"R\" . $e . \"C\" . ((($f + 1) * 456976) + (($h + 1) * 17576) + (($i + 1) * 676) + (($j + 1) * 26) + ($k + 1)) . \"\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 25){\n $remainder = $col % 26;\n $col = $col / 26;\n array_push($indexes, $remainder);\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n }\n }\n\n if($index == 1){\n $index = 2;\n }\n\n $rowRev = substr($word, 0, $index-1);\n $col = substr($word, $index-1);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": " 26) {\n $letNum = floor($col / 26);\n $colCode .= chr(64 + $letNum);\n $col = $col % 26;\n }\n if ($col > 0) {\n $colCode .= chr(64 + $col);\n }\n $resultCode = $colCode . $digits[0];\n } else {\n $colArray = str_split($letters[0]);\n $colNum = 0;\n $power = 0;\n while ($let = array_pop($colArray)) {\n $colNum += (ord($let) - 64) * pow(26, $power++);\n }\n $resultCode = 'R' . $digits[0] . 'C' . $colNum;\n }\n echo \"$resultCode\\n\";\n }\n?>"}, {"source_code": " 0) {\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$str = substr($str, $a1);\n\t\t$pattern = '/[0-9]/';\n\t\tpreg_match($pattern, $str, $matches);\n\t\t$a1 = strpos($str, $matches[0]);\n\t\t$result[] = substr($str, 0, $a1);\n\t\t$result[] = substr($str, $a1);\t\n\t} else {\n\t\t$result[] = $str;\n\t}\n\treturn $result;\n}\n\nfunction changeSTN($a) {\n\t$leng = strlen($a);\n\t$result = 0;\n\tfor ($i = 0; $i < $leng; $i++) { \n\t\t$result += (ord($a[$i]) - 64) * pow(26, $leng - 1 - $i);\n\t}\n\treturn $result;\n}\n\nfunction changeNTS($a) {\n\t$result = \"\";\n\twhile ($a > 0) {\n\t\t$result .= chr(64 + $a % 26);\n\t\t$a = floor($a / 26);\n\t}\n\treturn strrev($result);\n}\n\nfunction change($str) {\n\t$str = tach($str);\n\tif (count($str) == 2) {\n\t\t$result = \"R\" . $str[1];\n\t\t$result .= \"C\" . changeSTN($str[0]);\n\t} else {\n\t\t$result = changeNTS((int)$str[3]);\n\t\t$result .= $str[1];\n\t}\n\treturn $result;\n}\n\necho $n;\nvar_dump($a);\n\nfor ($i = 0; $i < $n - 1; $i++) {\n\techo change($a[$i]) . \"\\n\";\n}\necho change($a[$n - 1]);\n\n\n\n\n"}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n preg_match(\"/^R(? [0-9]+)C(?
[0-9]+)$/\", $coords, $matches);\n var_dump($matches);\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j 26){\n if($i_row%26==0){\n $row.=\"A\";\n $i_row--;\n }else {\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n } \n $row.=chr($i_row%26+64);\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": "[[:upper:]]+)(? [[:digit:]]+)$/\", $coords, $matches)) {\n echo \"R\";\n echo $matches[\"row\"];\n echo \"C\";\n echo to_numbers($matches[\"letter_column\"]);\n } // RXCY system to Excel system\n elseif (preg_match(\"/^R(?
[[:digit:]]+)C(?
[[:digit:]]+)$/\", $coords, $matches)) {\n echo to_letters(intval($matches[\"column\"]));\n echo $matches[\"row\"];\n } else {\n echo \"hi\";\n }\n\n if ($i < $n - 1) {\n echo PHP_EOL;\n }\n}\n\n/**\n * @param string $letters\n *\n * @return int $letters represented as a number\n */\nfunction to_numbers($letters) {\n return array_reduce(str_split($letters), function($sum, $letter) {\n return $sum * 26 + ord($letter) - 64;\n });\n}\n\n/**\n * @param int $n\n *\n * @return string $n represented with letters\n */\nfunction to_letters($n) {\n ob_start();\n\n while ($n > 26) {\n echo to_letter($n);\n $n /= 26;\n }\n\n echo to_letter($n);\n\n return strrev(ob_get_clean());\n}\n\n/**\n * @param int $n\n *\n * @return string\n */\nfunction to_letter($n) {\n return chr($n % 26 + 64);\n}"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = null;\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp = $i;\n $now = 26;\n }\n\n if ($tmp !== null and bcadd($tmp,1) == $i) {\n $now = bcsub($now,1);\n }\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n echo $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n echo \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n read_sheet($data[0]);\n\n}"}, {"source_code": "=48&&ord($var)<=57)\n return true;\n else\n return false;\n}\nfunction IsType1($var)\n{\n $res=false;;\n for($i=1;$i =0;$i--)\n {\n if(IsInt($var[$i]))\n {\n $res.=$var[$i];\n }\n else {\n return strrev($res);\n }\n }\n}\n\n\nfunction conversion_int($var)\n{\n $res=\"\";\n while($var>26)\n {\n if($var%26!=0)\n $res.=chr(64+$var%26);\n else {\n $res.='Z';\n }\n $var=($var-$var%26)/26;\n }\n if($var!=0)\n $res.=chr(64+$var);\n return strrev($res);\n}\nfunction conversion_str($var)\n{\n $res=0;\n for($i=strlen($var)-1;$i>=0;$i--)\n {\n $temp=1;\n for($j=strlen($var)-1;$j>$i;$j--)\n {\n $temp*=26;\n }\n if($var[$i]!='Z')\n $res+=(ord($var[$i])-64)*$temp;\n }\n return $res;\n}\nwhile($n--)\n{\nfscanf(STDIN,\"%s\",$str);\n if($str[0]=='R'&& IsInt($str[1]) && IsType1($str))\n {\n $a=GetInt($str);\n $b=GetInt_D($str);\n echo conversion_int($b).$a.\"\\n\";\n }\n else {\n $a=\"\";\n for($i=0;$i \n"}, {"source_code": "\ufeff=1) {\n\t\tif (($a1-(floor($a1/26))*26)==0) {\n\t\t\t$b1 = 'Z'.$b1;\n\t\t\t$a1=floor($a1/26)-1;\n\t\t} else {\n\t\t\t$b1 = (chr(64+($a1-(floor($a1/26))*26))).$b1;\n\t\t\t$a1=floor($a1/26);\n\t\t}\n\t}\n\treturn $string=$b1.$a2;\n}\n\nfunction char_cifr($a1,$a2) {\n\tfor($i=0;$i =1) {\n\tfor ($j=1;$j<=$numzna4;$j++) {\n\t\tfscanf(STDIN,\"%s\\n\",$arr[$j]);\t\t\n\n\t\tif (preg_match('/^[R]([1-9]{1}\\d{0,5}[0]{0,1})[C]([1-9]{1}\\d{0,5}[0]{0,1})$/',$arr[$j],$matches)) {\n\t\t\t$arr[$j] = cifr_char($matches[2],$matches[1]);\n\t\t} elseif(preg_match('/^([A-Z]{1,4}[A-N]{0,1})(\\d{1,6}[0]{0,1})$/',$arr[$j],$matches))\n\t\t\t$arr[$j] = char_cifr($matches[1],$matches[2]);\n\t\tprintf(\"%s\\n\",$arr[$j]);\n\t}\n}\n?>\n"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j 26){\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n $row.=chr($i_row%26+64);\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = numToLet($second);\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i-1);\n\t\t\t\t$second = substr($string, $i-1);\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1.0385) {\n\t\t\t$raz++;\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = 'A'.$res; break;\n\t\t\t\tcase 2: $res = 'B'.$res; break;\n\t\t\t\tcase 3: $res = 'C'.$res; break;\n\t\t\t\tcase 4: $res = 'D'.$res; break;\n\t\t\t\tcase 5: $res = 'E'.$res; break;\n\t\t\t\tcase 6: $res = 'F'.$res; break;\n\t\t\t\tcase 7: $res = 'G'.$res; break;\n\t\t\t\tcase 8: $res = 'H'.$res; break;\n\t\t\t\tcase 9: $res = 'I'.$res; break;\n\t\t\t\tcase 10: $res = 'J'.$res; break;\n\t\t\t\tcase 11: $res = 'K'.$res; break;\n\t\t\t\tcase 12: $res = 'L'.$res; break;\n\t\t\t\tcase 13: $res = 'M'.$res; break;\n\t\t\t\tcase 14: $res = 'N'.$res; break;\n\t\t\t\tcase 15: $res = 'O'.$res; break;\n\t\t\t\tcase 16: $res = 'P'.$res; break;\n\t\t\t\tcase 17: $res = 'Q'.$res; break;\n\t\t\t\tcase 18: $res = 'R'.$res; break;\n\t\t\t\tcase 19: $res = 'S'.$res; break;\n\t\t\t\tcase 20: $res = 'T'.$res; break;\n\t\t\t\tcase 21: $res = 'U'.$res; break;\n\t\t\t\tcase 22: $res = 'V'.$res; break;\n\t\t\t\tcase 23: $res = 'W'.$res; break;\n\t\t\t\tcase 24: $res = 'X'.$res; break;\n\t\t\t\tcase 25: $res = 'Y'.$res; break;\n\t\t\t\tcase 0: $res = 'Z'.$res; break;\n\t\t\t}\n\t\t\tif ($cur==0){\n\t\t\t$newnum = floor($newnum/26)-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t$newnum/=26;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": "47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$first = substr($string, 1, $i-1);\n\t\t\t\t\t$second = substr($string, $i+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$second = strrev(numToLet($second));\n\t\t$res = $second.$first;\n\t\treturn $res;\n\t\t\n\t}\n\t\n\tfunction conv ($string) {\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first = substr($string, 0, $i-1);\n\t\t\t\t$second = substr($string, $i-1);\n\t\t\t}\n\t\t}\n\t\t$first = letToNum($first);\n\t\t$res = 'R'.$second.'C'.$first;\n\t\treturn $res;\n\t}\n\t\n\tfunction detect ($string) {\n\t\t\n\t\tfor ($i=0;$i 47 AND ord($string[$i])<58) {\n\t\t\t\t$first_marker = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ($first_marker == 1) {\n\t\t\t\t\t$second_marker = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ($second_marker == 1) {\n\t\t\treturn conv2($string);\n\t\t}\n\t\telse {\n\t\t\treturn conv($string);\n\t\t}\n\t\t\n\t}\n\t\n\tfunction numToLet ($num){\n\t\t$raz = 1;\n\t\t$newnum = $num;\n\t\twhile (($newnum/26)>1) {\n\t\t\t$raz++;\n\t\t\t$newnum /= 26;\n\t\t}\n\t\t$newnum = $num;\n\t\t$res = '';\n\t\tfor ($i=0;$i<$raz;$i++) {\n\t\t\t$cur = $newnum%26;\n\t\t\tswitch ($cur) {\n\t\t\t\tcase 1: $res = 'A'.$res; break;\n\t\t\t\tcase 2: $res = 'B'.$res; break;\n\t\t\t\tcase 3: $res = 'C'.$res; break;\n\t\t\t\tcase 4: $res = 'D'.$res; break;\n\t\t\t\tcase 5: $res = 'E'.$res; break;\n\t\t\t\tcase 6: $res = 'F'.$res; break;\n\t\t\t\tcase 7: $res = 'G'.$res; break;\n\t\t\t\tcase 8: $res = 'H'.$res; break;\n\t\t\t\tcase 9: $res = 'I'.$res; break;\n\t\t\t\tcase 10: $res = 'J'.$res; break;\n\t\t\t\tcase 11: $res = 'K'.$res; break;\n\t\t\t\tcase 12: $res = 'L'.$res; break;\n\t\t\t\tcase 13: $res = 'M'.$res; break;\n\t\t\t\tcase 14: $res = 'N'.$res; break;\n\t\t\t\tcase 15: $res = 'O'.$res; break;\n\t\t\t\tcase 16: $res = 'P'.$res; break;\n\t\t\t\tcase 17: $res = 'Q'.$res; break;\n\t\t\t\tcase 18: $res = 'R'.$res; break;\n\t\t\t\tcase 19: $res = 'S'.$res; break;\n\t\t\t\tcase 20: $res = 'T'.$res; break;\n\t\t\t\tcase 21: $res = 'U'.$res; break;\n\t\t\t\tcase 22: $res = 'V'.$res; break;\n\t\t\t\tcase 23: $res = 'W'.$res; break;\n\t\t\t\tcase 24: $res = 'X'.$res; break;\n\t\t\t\tcase 25: $res = 'Y'.$res; break;\n\t\t\t\tcase 0: $res = 'Z'.$res; break;\n\t\t\t}\n\t\t\tif ($cur==0){\n\t\t\t$newnum = floor($newnum/26)-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t(int)$newnum/=26;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\t\n\t\n\tfunction letToNum ($let){\n\t\t$sum = 0;\n\t\tfor ($i=0;$i "}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = null;\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp = $i;\n $now = 26;\n }\n\n if ($tmp !== null and bcadd($tmp,1) == $i) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n }\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n echo $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n echo \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": " 1)\n {\n $t = $param % 26;\n $result = chr($t + ord(\"A\") - 1) . $result;\n $param = floor($param / 26);\n } \n \n //R98C688\n}\n\nfunction mytoint($param, &$result) {\n $result = 0; \n for ($index = 0; $index < strlen($param); $index++) {\n $result += (ord($param[$index]) - ord(\"A\") + 1) * pow(26, (strlen($param) - $index - 1));\n }\n}\n\n?>\n"}, {"source_code": " 0) {\n $mod[] = bcmod($sub,26);\n $sub = bcdiv($sub,26);\n }\n\n $count = count($mod);\n $column = '';\n $tmp = [];\n for ($i =0;$i< $count;$i++) {\n $now = $mod[$i];\n if ($mod[$i] == 0) {\n $tmp[$i] = true;\n $now = 26;\n }\n\n if ($tmp !== null and $tmp[$i-1]) {\n if ($now == 0){\n $now = 26;\n }\n $now = bcsub($now,1);\n if ($now < 0) {\n $now = 26 + $now;\n }\n if ($now == 0) {\n $now = 26;\n $tmp[$i] = true;\n };\n }\n\n echo $now.\"\\n\";\n\n $column .= chr($now+64);\n }\n $column = strrev($column);\n return $column.$match[1];\n\n } elseif (preg_match(\"/([A-Z]+)(\\d+)/\",$str,$match)) {\n $len = strlen($match[1]);\n $num = 0; // \u5b57\u6bcd\u5e8f\u5217\u548c\n for ($i = 0; $i < $len; $i++) {\n $num = bcadd(bcmul(bcsub(ord($match[1][$i]),64),bcpow(26,bcsub($len,bcadd($i,1)))),$num);\n }\n return \"R\".$match[2].\"C\".$num;\n }\n}\n\n$line = 0;\nwhile ($data = fscanf(STDIN,\"%s\")) {\n if (!$line) {\n $line++;\n continue;\n }\n echo read_sheet($data[0]);\n echo \"\\n\";\n}"}, {"source_code": "=0; $i--, $j++) {\n $pos = strpos(LETTERS, $column[$i], 1);\n $columnNumber += $pos * (26 ** $j);\n }\n return 'R' . $row . 'C' . $columnNumber;\n}\n\nfunction rc2zz($column, $row) {\n $columnNumber = '';\n while ($column / 26 > 1) {\n $floor = (int)floor($column / 26);\n $mod = $column % 26;\n $columnNumber .= LETTERS[$mod];\n $column = $floor;\n }\n $ost = $column % 26;\n $columnNumber .= LETTERS[$ost];\n return strrev($columnNumber) . $row;\n}\n\n$n = fscanf(STDIN, '%u');\nwhile ($row = trim(fgets(STDIN))) {\n if (preg_match('~R(\\d+)C(\\d+)~', $row, $match)) {\n echo rc2zz($match[2], $match[1]);\n } elseif(preg_match('~([A-Z]+)(\\d+)~i', $row, $match)) {\n echo zz2rc($match[1], $match[2]);\n }\n echo PHP_EOL;\n}\n"}, {"source_code": " 25){\n $remainder = $col % 26;\n $col = $col / 26;\n array_push($indexes, $remainder);\n if ($col / 26 < 25){\n $col = floor($col);\n array_push($indexes, $col);\n }\n }\n }\n\n\n $rereversedIndexes = array_reverse($indexes);\n for ($i = 0; $i < sizeof($indexes); $i++){\n $normal = $normal.$alphabet[$rereversedIndexes[$i]];\n }\n\n print($normal.$row.\"\\n\");\n}\n\nfunction convertToRC($word){\n $rowNum = 0;\n\n $alphabet = [\n 'A' => 1,\n 'B' => 2,\n 'C' => 3,\n 'D' => 4,\n 'E' => 5,\n 'F' => 6,\n 'G' => 7,\n 'H' => 8,\n 'I' => 9,\n 'J' => 10,\n 'K' => 11,\n 'L' => 12,\n 'M' => 13,\n 'N' => 14,\n 'O' => 15,\n 'P' => 16,\n 'Q' => 17,\n 'R' => 18,\n 'S' => 19,\n 'T' => 20,\n 'U' => 21,\n 'V' => 22,\n 'W' => 23,\n 'X' => 24,\n 'Y' => 25,\n 'Z' => 26\n ];\n $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\n\n for ($i = 0; $i < strlen($word); $i++){\n if(in_array($word[$i], $digits)){\n $index = $i;\n }\n }\n\n if($index == 1){\n $index = 2;\n }\n\n $rowRev = substr($word, 0, $index-1);\n $col = substr($word, $index-1);\n\n $row = strrev($rowRev);\n\n for($i = strlen($row)-1; $i >= 0; $i--){\n $rowNum += $alphabet[$row[$i]] * pow(26, $i);\n }\n\n print(\"R\".$col.\"C\".$rowNum.\"\\n\");\n}"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n printf('R%sC%s\\n', $outR, $outC);\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n printf('%s%s\\n', $outC, $outR);\n}"}, {"source_code": "=0; $j--)\n {\n $outC += (ord($c[$j])-64)*$d;\n $d*=26;\n }\n\n printf('R%sC%s\\n', $outR, $outC);\n}\n\nfunction toCR($r, $c)\n{\n $outR = $r;\n $outC = '';\n\n while($c)\n {\n $outC = chr(65 + ($c-1)%26) . $outC;\n $c = (integer)(($c - ($c-1)%26)/26);\n }\n\n printf('%s%s\\n', $outC, $outR);\n}"}, {"source_code": "= 48 && ord($data[$i][1]) <= 57) {\n \t\t$column = '';\n \t\t$string = '';\n \t\t$flag = false;\n \t\tfor($j = 1; $j < strlen($data[$i]); $j++) {\n \t\t\tif($data[$i][$j] == 'C') {\n \t\t\t\t$flag = true;\n \t\t\t} else {\n \t\t\t\tif(!$flag) {\n \t\t\t\t\t$string .= $data[$i][$j];\n \t\t\t\t} else {\n \t\t\t\t\t$column .= $data[$i][$j];\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\t$strColumn = '';\n \t\t$column = (int)$column;\n\n \t\tdo {\n \t\t\tif($column % 26 != 0) {\n\t \t\t\t$strColumn .= chr($column % 26 + 64);\n\t \t\t\t$column = floor($column / 26);\n\t \t\t} else {\n\t \t\t\t$strColumn .= chr($column + 64);\n\t \t\t}\n \t\t} while($column % 26 != 0);\n\n \t\t$data[$i] = strrev($strColumn) . $string;\n\n \t} else {\n \t\t$column = '';\n \t\t$string = '';\n \t\tfor($j = 0; $j = 65 && ord($data[$i][$j]) <= 90) {\n \t\t\t\t$column .= $data[$i][$j];\n \t\t\t} else {\n \t\t\t\t$string .= $data[$i][$j];\n \t\t\t}\n \t\t}\n\n \t\t$columnNum = 0;\n \t\tfor($j = strlen($column) - 1; $j >= 0; $j--) {\n \t\t\t$columnNum += (ord($column[$j]) - 64) * pow(26, strlen($column)-$j-1);\n \t\t}\n \t\t$data[$i] = 'R' . $string . 'C' . $columnNum;\n \t}\n }\n echo \"\\n\\n\";\n echo implode(\"\\n\", $data);\n?>\n"}, {"source_code": " 26;\n if ($continue) {\n $curr_num = $num % 26;\n $str = chr($curr_num + 64).$str;\n $num = floor($num / 26);\n } else {\n $str = chr($num + 64).$str;\n }\n } while ($continue);\n return $str;\n}\n\nfunction alpha_to_number($str) {\n $parts = str_split($str);\n $num = 0;\n for ($i = 0; $i < count($parts); $i++) {\n $num = $num * 26;\n $num += ord($parts[$i]) - 64;\n }\n return $num;\n}\n\nfunction convert_one($str) {\n $parts = preg_split(\"/\\d+/\", $str);\n if ($parts[0] === 'R' && $parts[1] === 'C') {\n // from RXCY\n $numbers = preg_split(\"/R|C/\", $str);\n $row = $numbers[1];\n $col = $numbers[2];\n printf(\"%s%d\", number_to_alpha($col), $row);\n } else {\n // to RXCY\n $col_str = $parts[0];\n $col = alpha_to_number($col_str);\n $row_parts = preg_split(\"/[A-Z]+/\", $str);\n $row = (int)$row_parts[1];\n printf(\"R%dC%d\", $row, $col);\n }\n}\n\nfscanf(STDIN, \"%d\", $n);\nfor ($i = 1; $i <= $n; $i++) {\n fscanf(STDIN, \"%s\", $str);\n convert_one($str);\n}\n?>"}, {"source_code": "\n"}, {"source_code": " 0) {\n $d1 = chr(($s2 - 1) % 26 + 65) . $d1;\n $s2 = floor($s2 / 26);\n //echo \"--$s2 $d1\\n\";\n }\n echo \"$d1$s[1]\\n\";\n //print_r ($s);\n }\n else {\n $l = preg_split('\"[0-9]\"',$r[$i]);\n $d = preg_split('\"[A-Z]\"',$r[$i]);\n\n $l1 = str_split($l[0]);\n $re = 0;\n for ($j = 0; $j < count($l1); $j++) {\n $re = 26 * $re + ord($l1[$j]) - 64;\n //echo \"$j $re\\n\";\n }\n $d1 = intval($d[count($d) - 1]);\n //print_r($l1);\n //print_r($d);\n echo \"R$d1\" . \"C$re\\n\";\n }\n}\n?>"}, {"source_code": "\n"}, {"source_code": " 0){\n $char = $column%26;\n $column = intval($column/26);\n $str = chr($char+64) . $str;\n }\n return $str.$row;\n}\n\nfunction convertCRtoRC($cell){\n $st = preg_match('/^([A-Z]+)([0-9]+)$/', $cell, $matches);\n $column = $matches[1];\n $row = $matches[2]; //not modified\n $chs = str_split($column);\n $count = strlen($column);\n $column = 0;\n foreach($chs as $ch){\n $column += (ord($ch) - 64) * pow(26, $count -1);\n $count--;\n }\n return 'R' . $row . 'C' . $column;\n} \n\nfunction convert($cell){\n $type = preg_match('/^R[0-9]+C[0-9]+$/', $cell, $matches);\n if($type === 1){\n return convertRCtoCR($cell);\n }\n \n return convertCRtoRC($cell);\n}\n\n$dir = fopen(\"php://stdin\", 'r');\n$cells = stream_get_contents($dir);\n\n$cells = explode(\"\\n\", $cells);\nfor($i=1;$i<=$cells[0];$i++){\n echo convert($cells[$i]).\"\\n\";\n}\n?>\n"}, {"source_code": " 1) {\n $result .= chr(round($param / 26) + ord(\"A\") - 1);\n }\n if ($param % 26 > 0) {\n $result .= chr(round($param % 26) + ord(\"A\") - 1);\n }\n}\n\nfunction mytoint($param, &$result) {\n $result = 0; \n for ($index = 0; $index < strlen($param); $index++) {\n $result += (ord($param[$index]) - ord(\"A\") + 1) * pow(26, (strlen($param) - $index - 1));\n }\n}\n\n?>\n"}, {"source_code": "1 && ord($s[1])>=48 && ord($s[1])<=57) {\n $col=\"\";\n $row=\"\";\n $ff=\"r\"; \n for($j=1;$j 26){\n $row.=chr($i_row%26+64);\n $i_row=floor($i_row/26);\n } \n $row.=chr($i_row%26+64);\n echo strrev($row).$col;\n }else{\n $f_col=0; $f_row=0; \n $col=0;\n $row=0; \n for($j=strlen($s)-1;$j>=0;$j--){\n //echo $s[$j];\n if (ord($s[$j])>=48 && ord($s[$j])<=57){\n $col+=pow(10,$f_col)*intval($s[$j]);\n $f_col++;\n }else{\n $row+=pow(26,$f_row)*(ord($s[$j])-64);\n $f_row++;\n }\n }\n echo \"R\".$col.\"C\".$row; \n }\n \n echo \"\\n\"; \n }\n \n?>\n"}], "src_uid": "910c0e650d48af22fa51ab05e8123709"} {"nl": {"description": "Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. Let's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be parallel to coordinate axes. The map contains mines with valuable resources, located at some points with integer coordinates. The sizes of mines are relatively small, i.e. they can be treated as points. The city should be built in such a way that all the mines are inside or on the border of the city square. Building a city takes large amount of money depending on the size of the city, so you have to build the city with the minimum area. Given the positions of the mines find the minimum possible area of the city.", "input_spec": "The first line of the input contains number n\u00a0\u2014 the number of mines on the map (2\u2009\u2264\u2009n\u2009\u2264\u20091000). Each of the next n lines contains a pair of integers xi and yi\u00a0\u2014 the coordinates of the corresponding mine (\u2009-\u2009109\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009109). All points are pairwise distinct.", "output_spec": "Print the minimum area of the city that can cover all the mines with valuable resources.", "sample_inputs": ["2\n0 0\n2 2", "2\n0 0\n0 3"], "sample_outputs": ["4", "9"], "notes": null}, "positive_code": [{"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = max($h, $i);\n$k = bcmul($j, $j);\nprint $k;\n?>"}], "negative_code": [{"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = $c - $b;\n$i = $e - $d;\n$j = max($h, $i) - min($h, $i);\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprintf(\"%.0f\", $k);\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i) - min($h, $i));\n$k = bcmul(max($h, $i), $j + min($h, $i));\nprint $k;\n?>"}, {"source_code": "= 0) && ($d >= 0))\n{\n $f = $d - $b;\n}\nelseif(($b < 0) && ($d >= 0))\n{\n $f = $d + abs($b);\n}\nif(($c >= 0) && ($e >= 0))\n{\n $g = $e - $c;\n}\nelseif(($c < 0) && ($e >= 0))\n{\n $g = $c + abs($e);\n}\nif($f == 0)\n{\n print bcmul($g, $g);\n}\nelseif($g == 0)\n{\n print bcmul($f, $f);\n}\nelse\n{\n print bcmul($f, $g);\n}\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprint $k;\n?>"}, {"source_code": "= 0) && ($d >= 0))\n{\n $f = $d - $b;\n}\nelseif(($b < 0) && ($d >= 0))\n{\n $f = $d + abs($b);\n}\nif(($c >= 0) && ($e >= 0))\n{\n $g = $e - $c;\n}\nelseif(($c < 0) && ($e >= 0))\n{\n $g = abs($c) + $e;\n}\nif($f == 0)\n{\n print bcmul($g, $g);\n}\nelseif($g == 0)\n{\n print bcmul($f, $f);\n}\nelse\n{\n if($a == 100)\n {\n print $f . \" \" . $g;\n }\n}\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprint $k;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));;\nprint $k;\n?>"}, {"source_code": ""}, {"source_code": "= 0) && ($d >= 0))\n{\n $f = $d - $b;\n}\nelseif(($b < 0) && ($d >= 0))\n{\n $f = $d + abs($b);\n}\nif(($c >= 0) && ($e >= 0))\n{\n $g = $e - $c;\n}\nelseif(($c < 0) && ($e >= 0))\n{\n $g = abs($c) + $e;\n}\nif($f == 0)\n{\n print bcmul($g, $g);\n}\nelseif($g == 0)\n{\n print bcmul($f, $f);\n}\nelse\n{\n if($a == 100)\n {\n print $f . \" \" . $g;\n }\n else\n {\n print bcmul($g, $f);\n }\n}\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = max($h, $i);\n$k = bcpow($j, 2);\nprint $k;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = max($h, $i);\n$k = bcpow($j, 2);\nprint $k;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i) - min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprint $k;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = max($h, $i);\n$k = bcmul($j, $j);\nprint $k;\n?>"}, {"source_code": "$e = -1000000001;\nfor($x = 1; $x <= $a; $x++)\n{\n list($f, $g) = explode(\" \", trim(fgets(STDIN)));\n if($f < $b)\n {\n $b = $f;\n }\n if($f > $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprint $k;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$k = bcmul(max($h, $i), ($j + min($h, $i)));\nprintf(\"%.0f\", $k);\n?>"}, {"source_code": ""}, {"source_code": "= 0) && ($d >= 0))\n {\n $f = $d - $b;\n }\n elseif(($b < 0) && ($d >= 0))\n {\n $f = $d + abs($b);\n }\n if(($c >= 0) && ($e >= 0))\n {\n $g = $e - $c;\n }\n elseif(($c < 0) && ($e >= 0))\n {\n $g = $c + abs($e);\n }\n if($f == 0)\n {\n print bcmul($g, $g);\n }\n elseif($g == 0)\n {\n print bcmul($f, $f);\n }\n else\n {\n print bcmul($f, $g);\n }\n}\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $d)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcmul(max($h, $i), max($h, $i));\nprint $j;\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = $c - $b;\n$i = $e - $d;\n$j = max($h, $i) - min($h, $i);\n$k = max($h, $i) * ($j + min($h, $i));\nprintf(\"%.0f\", $k);\n?>"}, {"source_code": "= 0) && ($d >= 0))\n{\n $f = $d - $b;\n}\nelseif(($b < 0) && ($d >= 0))\n{\n $f = $d + abs($b);\n}\nif(($c >= 0) && ($e >= 0))\n{\n $g = $e - $c;\n}\nelseif(($c < 0) && ($e >= 0))\n{\n $g = abs($c) + $e;\n}\nif($f == 0)\n{\n print bcmul($g, $g);\n}\nelseif($g == 0)\n{\n print bcmul($f, $f);\n}\nelse\n{\n print bcmul($f, $g);\n}\n?>"}, {"source_code": "= 0) && ($d >= 0))\n{\n $f = $d - $b;\n}\nelseif(($b < 0) && ($d >= 0))\n{\n $f = $d + abs($b);\n}\nif(($c >= 0) && ($e >= 0))\n{\n $g = $e - $c;\n}\nelseif(($c < 0) && ($e >= 0))\n{\n $g = abs($c) + $e;\n}\nif($f == 0)\n{\n print bcmul($g, $g);\n}\nelseif($g == 0)\n{\n print bcmul($f, $f);\n}\nelse\n{\n if($a == 100)\n {\n print $f . \" \" . $g;\n }\n else\n {\n print bcmul($g, $f);\n }\n}\n?>"}, {"source_code": " $c)\n {\n $c = $f;\n }\n if($g < $d)\n {\n $d = $g;\n }\n if($g > $e)\n {\n $e = $g;\n }\n}\n$h = bcsub($c, $b);\n$i = bcsub($e, $d);\n$j = bcsub(max($h, $i), min($h, $i));\n$l = bcmul(max($h, $i), ($j + min($h, $i)));\nprint $l;\n?>"}], "src_uid": "016e00b2b960be792d4ec7fcfb7976e2"} {"nl": {"description": "You are given an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. Your task is to find the number of connected components which are cycles.Here are some definitions of graph theory.An undirected graph consists of two sets: set of nodes (called vertices) and set of edges. Each edge connects a pair of vertices. All edges are bidirectional (i.e. if a vertex $$$a$$$ is connected with a vertex $$$b$$$, a vertex $$$b$$$ is also connected with a vertex $$$a$$$). An edge can't connect vertex with itself, there is at most one edge between a pair of vertices.Two vertices $$$u$$$ and $$$v$$$ belong to the same connected component if and only if there is at least one path along edges connecting $$$u$$$ and $$$v$$$.A connected component is a cycle if and only if its vertices can be reordered in such a way that: the first vertex is connected with the second vertex by an edge, the second vertex is connected with the third vertex by an edge, ... the last vertex is connected with the first vertex by an edge, all the described edges of a cycle are distinct. A cycle doesn't contain any other edges except described above. By definition any cycle contains three or more vertices. There are $$$6$$$ connected components, $$$2$$$ of them are cycles: $$$[7, 10, 16]$$$ and $$$[5, 11, 9, 15]$$$. ", "input_spec": "The first line contains two integer numbers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$, $$$0 \\le m \\le 2 \\cdot 10^5$$$) \u2014 number of vertices and edges. The following $$$m$$$ lines contains edges: edge $$$i$$$ is given as a pair of vertices $$$v_i$$$, $$$u_i$$$ ($$$1 \\le v_i, u_i \\le n$$$, $$$u_i \\ne v_i$$$). There is no multiple edges in the given graph, i.e. for each pair ($$$v_i, u_i$$$) there no other pairs ($$$v_i, u_i$$$) and ($$$u_i, v_i$$$) in the list of edges.", "output_spec": "Print one integer \u2014 the number of connected components which are also cycles.", "sample_inputs": ["5 4\n1 2\n3 4\n5 4\n3 5", "17 15\n1 8\n1 12\n5 11\n11 9\n9 15\n15 5\n4 13\n3 13\n4 3\n10 16\n7 10\n16 7\n14 3\n14 4\n17 6"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first example only component $$$[3, 4, 5]$$$ is also a cycle.The illustration above corresponds to the second example."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "cf7520d88e10ba171de443f36fdd2b73"} {"nl": {"description": "Heidi has finally found the mythical Tree of Life \u2013 a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.On the surface, the Tree of Life is just a regular undirected tree well-known from computer science. This means that it is a collection of n points (called vertices), some of which are connected using n\u2009-\u20091 line segments (edges) so that each pair of vertices is connected by a path (a sequence of one or more edges).To decipher the prophecy, Heidi needs to perform a number of steps. The first is counting the number of lifelines in the tree \u2013 these are paths of length 2, i.e., consisting of two edges. Help her!", "input_spec": "The first line of the input contains a single integer n \u2013 the number of vertices in the tree (1\u2009\u2264\u2009n\u2009\u2264\u200910000). The vertices are labeled with the numbers from 1 to n. Then n\u2009-\u20091 lines follow, each describing one edge using two space-separated numbers a\u2002b \u2013 the labels of the vertices connected by the edge (1\u2009\u2264\u2009a\u2009<\u2009b\u2009\u2264\u2009n). It is guaranteed that the input represents a tree.", "output_spec": "Print one integer \u2013 the number of lifelines in the tree.", "sample_inputs": ["4\n1 2\n1 3\n1 4", "5\n1 2\n2 3\n3 4\n3 5"], "sample_outputs": ["3", "4"], "notes": "NoteIn the second sample, there are four lifelines: paths between vertices 1 and 3, 2 and 4, 2 and 5, and 4 and 5."}, "positive_code": [{"source_code": " 0)\n {\n $g = $f;\n for($y = 1; $y <= $f; $y++)\n {\n $e += $g;\n $g--;\n }\n }\n}\nprint $e;\n?>"}], "negative_code": [], "src_uid": "fdd50853348b6f297a62a3b729d8d4a5"} {"nl": {"description": "Consider the set of all nonnegative integers: $$${0, 1, 2, \\dots}$$$. Given two integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 10^4$$$). We paint all the numbers in increasing number first we paint $$$0$$$, then we paint $$$1$$$, then $$$2$$$ and so on.Each number is painted white or black. We paint a number $$$i$$$ according to the following rules: if $$$i = 0$$$, it is colored white; if $$$i \\ge a$$$ and $$$i - a$$$ is colored white, $$$i$$$ is also colored white; if $$$i \\ge b$$$ and $$$i - b$$$ is colored white, $$$i$$$ is also colored white; if $$$i$$$ is still not colored white, it is colored black. In this way, each nonnegative integer gets one of two colors.For example, if $$$a=3$$$, $$$b=5$$$, then the colors of the numbers (in the order from $$$0$$$) are: white ($$$0$$$), black ($$$1$$$), black ($$$2$$$), white ($$$3$$$), black ($$$4$$$), white ($$$5$$$), white ($$$6$$$), black ($$$7$$$), white ($$$8$$$), white ($$$9$$$), ...Note that: It is possible that there are infinitely many nonnegative integers colored black. For example, if $$$a = 10$$$ and $$$b = 10$$$, then only $$$0, 10, 20, 30$$$ and any other nonnegative integers that end in $$$0$$$ when written in base 10 are white. The other integers are colored black. It is also possible that there are only finitely many nonnegative integers colored black. For example, when $$$a = 1$$$ and $$$b = 10$$$, then there is no nonnegative integer colored black at all. Your task is to determine whether or not the number of nonnegative integers colored black is infinite.If there are infinitely many nonnegative integers colored black, simply print a line containing \"Infinite\" (without the quotes). Otherwise, print \"Finite\" (without the quotes).", "input_spec": "The first line of input contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases in the input. Then $$$t$$$ lines follow, each line contains two space-separated integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 10^4$$$).", "output_spec": "For each test case, print one line containing either \"Infinite\" or \"Finite\" (without the quotes). Output is case-insensitive (i.e. \"infinite\", \"inFiNite\" or \"finiTE\" are all valid answers).", "sample_inputs": ["4\n10 10\n1 10\n6 9\n7 3"], "sample_outputs": ["Infinite\nFinite\nInfinite\nFinite"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $a=$str1[0];\n $b=$str1[1];\n if($a<=$b)\n {\n $black=$a-1;\n $white=$b-$a+1;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }else{\n $black=$b-1;\n $white=$a-$b+1;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $a=$str1[0];\n $b=$str1[1];\n if($a<=$b)\n {\n $black=$a-1;\n $white=$b-$a;\n if($white<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }else{\n $black=$b-1;\n $white=$a-$b;\n if($white<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $a=$str1[0];\n $b=$str1[1];\n if($a<=$b)\n {\n $black=$a-1;\n $white=$a-$black;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }else{\n $black=$b-1;\n $white=$b-$black;\n if($white+1<$black)\n {\n echo \"Infinite\";\n }else{\n echo \"Finite\";\n }\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($local, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $a=$str1[0];\n $b=$str1[1];\n if($a<=$b)\n {\n $black=$a-1;\n $white=$a-$black;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }else{\n $black=$b-1;\n $white=$b-$black;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": " $r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n }\n function solve()\n {\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $a=$str1[0];\n $b=$str1[1];\n if($a<=$b)\n {\n $black=$a-1;\n $white=$a-$black;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }else{\n $black=$b-1;\n $white=$b-$black;\n if($white+1<$black)\n {\n echo \"Infinite\\n\";\n }else{\n echo \"Finite\\n\";\n }\n }\n }\n \n \n }\n \n solve();\n ?>"}], "src_uid": "388450021f2f33177d905879485bb531"} {"nl": {"description": "Polycarp is a great fan of television.He wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment li and ends at moment ri.Polycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only watch one show at any given moment on a single TV. If one show ends at the same moment some other show starts then you can't watch them on a single TV.Polycarp wants to check out all n shows. Are two TVs enough to do so?", "input_spec": "The first line contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105) \u2014 the number of shows. Each of the next n lines contains two integers li and ri (0\u2009\u2264\u2009li\u2009<\u2009ri\u2009\u2264\u2009109) \u2014 starting and ending time of i-th show.", "output_spec": "If Polycarp is able to check out all the shows using only two TVs then print \"YES\" (without quotes). Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["3\n1 2\n2 3\n4 5", "4\n1 2\n2 3\n2 3\n1 2"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": " $j[0]) && ($g[$x] > $j[1]))\n {\n $j = array($i[$x]);\n }\n elseif($g[$x] > $j[0])\n {\n $j[0] = $i[$x];\n sort($j);\n }\n else\n {\n $k = 1;\n break;\n }\n }\n}\nif($k == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "negative_code": [{"source_code": " $j[0]) && ($g[$x] > $j[1]))\n {\n $j = array($i[$x]);\n }\n elseif($g[$x] > $j[0])\n {\n $j[0] = $i[$x];\n }\n else\n {\n $k = 1;\n break;\n }\n }\n}\nif($k == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "= $g[$l]) || ($i[$k + 1] <= $g[$l]))\n {\n $j = 1;\n break;\n }\n else\n {\n $k++;\n $l++;\n }\n }\n if($j == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": "= $g[$l]) && ($i[$k] <= $g[$l + 1]))\n {\n $j = 1;\n break;\n }\n else\n {\n $k++;\n $l++;\n }\n }\n if($j == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $k)\n {\n $n = 4;\n $l = $j;\n $m = $k;\n $j = $o;\n $k = $p;\n }\n }\n elseif($o == $k)\n {\n if($p >= $k)\n {\n $n = 5;\n $l = $j;\n $m = $k;\n $j = $o;\n $k = $p;\n }\n }\n elseif($o > $k)\n {\n $j = $o;\n $k = $p;\n $l = NULL;\n $m = NULL;\n }\n }\n elseif($n = 2)\n {\n if($o <= $k)\n {\n $n = 6;\n break;\n }\n elseif($o > $k)\n {\n $n = 1;\n $j = $o;\n $k = $p;\n $l = NULL;\n $m = NULL;\n }\n }\n elseif($n == 3)\n {\n if($o <= $k)\n {\n $n = 6;\n break;\n }\n else\n {\n $n = 1;\n $j = $o;\n $k = $p;\n $l = NULL;\n $m = NULL;\n }\n }\n elseif($n == 4)\n {\n if($o <= $m)\n {\n $n = 6;\n break;\n }\n elseif($o > $m)\n {\n if($p < $k)\n {\n $n = 2;\n $l = $o;\n $m = $p;\n }\n elseif($p == $k)\n {\n $n = 3;\n $l = $o;\n $m = $p;\n }\n elseif($p > $k)\n {\n $n = 4;\n $l = $j;\n $m = $k;\n $j = $o;\n $k = $p;\n }\n }\n }\n elseif($n == 5)\n {\n if($o <= $l)\n {\n $n = 6;\n break;\n }\n elseif($p <= $k)\n {\n $n = 2;\n $l = $o;\n $m = $p;\n }\n elseif($o == $k)\n {\n $n = 2;\n $l = $j;\n $j = $o;\n $k = $p;\n }\n elseif($o > $k)\n {\n $n = 1;\n $j = $o;\n $k = $p;\n $l = NULL;\n $m = NULL;\n }\n }\n }\n if($n < 6)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": "= $g[$l])\n {\n $j = 1;\n break;\n }\n else\n {\n $k++;\n $l++;\n }\n }\n if($j == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": ""}], "src_uid": "9fa772b53e655a55f2ec502bc96d0e28"} {"nl": {"description": "This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too difficult in large constraints, you can write solution to the simplified version only.Waking up in the morning, Apollinaria decided to bake cookies. To bake one cookie, she needs n ingredients, and for each ingredient she knows the value ai\u00a0\u2014 how many grams of this ingredient one needs to bake a cookie. To prepare one cookie Apollinaria needs to use all n ingredients.Apollinaria has bi gram of the i-th ingredient. Also she has k grams of a magic powder. Each gram of magic powder can be turned to exactly 1 gram of any of the n ingredients and can be used for baking cookies.Your task is to determine the maximum number of cookies, which Apollinaria is able to bake using the ingredients that she has and the magic powder.", "input_spec": "The first line of the input contains two positive integers n and k (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u20091000)\u00a0\u2014 the number of ingredients and the number of grams of the magic powder. The second line contains the sequence a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20091000), where the i-th number is equal to the number of grams of the i-th ingredient, needed to bake one cookie. The third line contains the sequence b1,\u2009b2,\u2009...,\u2009bn (1\u2009\u2264\u2009bi\u2009\u2264\u20091000), where the i-th number is equal to the number of grams of the i-th ingredient, which Apollinaria has.", "output_spec": "Print the maximum number of cookies, which Apollinaria will be able to bake using the ingredients that she has and the magic powder.", "sample_inputs": ["3 1\n2 1 4\n11 3 16", "4 3\n4 3 5 6\n11 12 14 20"], "sample_outputs": ["4", "3"], "notes": "NoteIn the first sample it is profitably for Apollinaria to make the existing 1 gram of her magic powder to ingredient with the index 2, then Apollinaria will be able to bake 4 cookies.In the second sample Apollinaria should turn 1 gram of magic powder to ingredient with the index 1 and 1 gram of magic powder to ingredient with the index 3. Then Apollinaria will be able to bake 3 cookies. The remaining 1 gram of the magic powder can be left, because it can't be used to increase the answer."}, "positive_code": [{"source_code": ""}, {"source_code": "\n\n$a = array();\n$b = array();\n//$fp = fopen('input.txt', 'r');\nfscanf(STDIN, \"%d %d\\n\", $n, $k);\n$a = explode(' ', fgets(STDIN));\n$b = explode(' ', fgets(STDIN));\n\n$l = 0; $r = PHP_INT_MAX;\nfor($i = 0; $i < 50; $i++){\n $m = ($l + $r)/2;\n $m = intval($m);\n if(can($m)){\n $l = $m;\n }else{\n $r = $m;\n }\n}\n\necho $l;\n\n\nfunction can($x){\n $need = 0;\n global $n, $a, $b, $k;\n for($i = 0; $i < $n; $i++){\n $need += max(0, $a[$i]*1*$x - $b[$i]);\n if($need > $k) return false;\n }\n\n return $need <= $k;\n}"}, {"source_code": "\n\nnew Planning();\n\nclass Planning{\n\n private $n;\n private $k;\n private $a = array();\n private $b = array();\n private $inputFilename = '';\n\n public function __construct($inputFilename = 'input.txt')\n {\n $this->inputFilename = $inputFilename;\n $this->readData();\n echo $this->findSolution();\n }\n\n public function readData()\n {\n //$fp = fopen($this->inputFilename, 'r');\n fscanf(STDIN, \"%d %d\\n\", $this->n, $this->k);\n $this->a = explode(' ', fgets(STDIN));\n $this->b = explode(' ', fgets(STDIN));\n }\n\n private function findSolution()\n {\n $l = 0; $r = 1E+15;\n\n for($i = 0; $i < 50; $i++){\n $m = ($l + $r)/2;\n $m = (int)$m;\n if($this->can($m)){\n $l = $m;\n }else{\n $r = $m;\n }\n }\n\n return $l;\n }\n\n private function can($x)\n {\n $need = 0;\n for($i = 0; $i < $this->n; $i++){\n $need += max(0, $this->a[$i]*1*$x - $this->b[$i]);\n if($need > $this->k) return false;\n }\n\n return $need <= $this->k;\n }\n\n}"}], "negative_code": [{"source_code": "\n\n$a = array();\n$b = array();\n//$fp = fopen('input.txt', 'r');\nfscanf(STDIN, \"%d %d\\n\", $n, $k);\n$a = explode(' ', fgets(STDIN));\n$b = explode(' ', fgets(STDIN));\n\n$l = 0; $r = 10000000000;\nfor($i = 0; $i < 50; $i++){\n $m = (int)($l + $r)/2;\n if(can($m)){\n $l = $m;\n }else{\n $r = $m;\n }\n}\n\necho $l;\n\n\nfunction can($x){\n $need = 0;\n global $n, $a, $b, $k;\n for($i = 0; $i < $n; $i++){\n $need += max(0, $a[$i]*1*$x - $b[$i]);\n if($need > $k) return false;\n }\n\n return $need <= $k;\n}"}], "src_uid": "02bb7502135afa0f3bb26527427ba9e3"} {"nl": {"description": "There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning of the line). In other words, if at some time the i-th position has a boy and the (i\u2009+\u20091)-th position has a girl, then in a second, the i-th position will have a girl and the (i\u2009+\u20091)-th one will have a boy.Let's take an example of a line of four people: a boy, a boy, a girl, a girl (from the beginning to the end of the line). Next second the line will look like that: a boy, a girl, a boy, a girl. Next second it will be a girl, a boy, a girl, a boy. Next second it will be a girl, a girl, a boy, a boy. The line won't change any more.Your task is: given the arrangement of the children in the line to determine the time needed to move all girls in front of boys (in the example above it takes 3 seconds). Baking buns takes a lot of time, so no one leaves the line until the line stops changing.", "input_spec": "The first line contains a sequence of letters without spaces s1s2... sn (1\u2009\u2264\u2009n\u2009\u2264\u2009106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.", "output_spec": "Print a single integer \u2014 the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.", "sample_inputs": ["MFM", "MMFF", "FFMMM"], "sample_outputs": ["1", "3", "0"], "notes": "NoteIn the first test case the sequence of changes looks as follows: MFM \u2009\u2192\u2009 FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF \u2009\u2192\u2009 MFMF \u2009\u2192\u2009 FMFM \u2009\u2192\u2009 FFMM."}, "positive_code": [{"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i < $len; $i++) {\n if ($str[$i] == \"F\") {\n $ti = $i - $fcount;\n $t = ($ti != 0) ? ($ti > $t) ? $ti : $t+1 : 0;\n $fcount++;\n }\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i < $len; $i++) {\n if ($str[$i] == \"F\") {\n $ti = $i - $fcount;\n $t = ($ti != 0) ? ($ti > $t) ? $ti : $t+1 : 0;\n $fcount++;\n }\n}\n\nprint $t;"}], "negative_code": [{"source_code": "$str = trim(fgets(STDIN));\n //$str = \"MFMFM\";\n $needle = \"MF\";\n $replace = \"FM\";\n $seconds = 0;\n while(preg_match(\"/$needle/i\", $str)){\n $seconds++;\n $str = str_replace($needle, $replace, $str);\n }\n print $seconds;"}, {"source_code": "$str = trim(fgets(STDIN));\n $needle = \"MF\";\n $replace = \"FM\";\n $seconds = 0;\n $hasRotations = TRUE;\n while($hasRotations){\n $hasRotations = FALSE;\n for($i=0;$i t) ? $i - $fcount : $t+1;\n\t\t$fcount++;\n\t}\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n//$str = \"MMFF\";\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i < $len; $i++) {\n if ($str[$i] == \"F\") {\n $ti = $i - $fcount;\n $t = ($ti > $t) ? $ti : $t+1;\n $fcount++;\n }\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n //$str = \"MFMFM\";\n $needle = \"MF\";\n $replace = \"FM\";\n $seconds = 0;\n \twhile(strripos($str, $needle)) {\n $seconds++;\n $str = str_replace($needle, $replace, $str);\n }\n print $seconds;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n //$str = \"MFMFM\";\n $needle = \"MF\";\n $replace = \"FM\";\n $seconds = 0;\n \twhile(stripos($str, $needle)) {\n $seconds++;\n $str = str_replace($needle, $replace, $str);\n }\n print $seconds;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i; $i >= $len; $i++) {\n if ($str[$i] == \"F\") {\n $t = (($i - $fcount) > t) ? $i - $fcount : $t++;\n $fcount++;\n }\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i < $len; $i++) {\n\tif ($str[$i] == \"F\") {\n\t\t$t = (($i - $fcount) > t) ? $i - $fcount : $t++;\n\t\t$fcount++;\n\t}\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n //$str = \"MFMFM\";\n $needle = \"MF\";\n $replace = \"FM\";\n $seconds = 0;\n \twhile(strpos($str, $needle)) {\n $seconds++;\n $str = str_replace($needle, $replace, $str);\n }\n print $seconds;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i >= $len; $i++) {\n\tif ($str[$i] == \"F\") {\n\t\t$t = (($i - $fcount) > t) ? $i - $fcount : $t++;\n\t\t$fcount++;\n\t}\n}\n\nprint $t;"}, {"source_code": "\n$str = trim(fgets(STDIN));\n\n$t = 0;\n\n$fcount = 0;\n\n$len = strlen($str);\nfor ($i = 0; $i < $len; $i++) {\n if ($str[$i] == \"F\") {\n $t = (($i - $fcount) > $t) ? $i - $fcount : $t++;\n $fcount++;\n }\n}\n\nprint $t;"}], "src_uid": "8423f334ef789ba1238d34f70e7cbbc8"} {"nl": {"description": "You are given integer $$$n$$$. You have to arrange numbers from $$$1$$$ to $$$2n$$$, using each of them exactly once, on the circle, so that the following condition would be satisfied:For every $$$n$$$ consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboard $$$2n$$$ numbers differ not more than by $$$1$$$.For example, choose $$$n = 3$$$. On the left you can see an example of a valid arrangement: $$$1 + 4 + 5 = 10$$$, $$$4 + 5 + 2 = 11$$$, $$$5 + 2 + 3 = 10$$$, $$$2 + 3 + 6 = 11$$$, $$$3 + 6 + 1 = 10$$$, $$$6 + 1 + 4 = 11$$$, any two numbers differ by at most $$$1$$$. On the right you can see an invalid arrangement: for example, $$$5 + 1 + 6 = 12$$$, and $$$3 + 2 + 4 = 9$$$, $$$9$$$ and $$$12$$$ differ more than by $$$1$$$. ", "input_spec": "The first and the only line contain one integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$).", "output_spec": "If there is no solution, output \"NO\" in the first line. If there is a solution, output \"YES\" in the first line. In the second line output $$$2n$$$ numbers\u00a0\u2014 numbers from $$$1$$$ to $$$2n$$$ in the order they will stay in the circle. Each number should appear only once. If there are several solutions, you can output any of them.", "sample_inputs": ["3", "4"], "sample_outputs": ["YES\n1 4 5 2 3 6", "NO"], "notes": "NoteExample from the statement is shown for the first example. It can be proved that there is no solution in the second example."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": " count($b) - 1)\n {\n $i = 1;\n }\n }\n }\n $j = array_merge($f, $g);\n print implode(\" \", $j);\n}\n?>"}], "src_uid": "5e23f02afc7446ecf8688ad2a8fa284d"} {"nl": {"description": "The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from $$$1$$$ to $$$n$$$. Initialize $$$q$$$ as a new queue containing only vertex $$$1$$$, mark the vertex $$$1$$$ as used. Extract a vertex $$$v$$$ from the head of the queue $$$q$$$. Print the index of vertex $$$v$$$. Iterate in arbitrary order through all such vertices $$$u$$$ that $$$u$$$ is a neighbor of $$$v$$$ and is not marked yet as used. Mark the vertex $$$u$$$ as used and insert it into the tail of the queue $$$q$$$. If the queue is not empty, continue from step 2. Otherwise finish. Since the order of choosing neighbors of each vertex can vary, it turns out that there may be multiple sequences which BFS can print.In this problem you need to check whether a given sequence corresponds to some valid BFS traversal of the given tree starting from vertex $$$1$$$. The tree is an undirected graph, such that there is exactly one simple path between any two vertices.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) which denotes the number of nodes in the tree. The following $$$n - 1$$$ lines describe the edges of the tree. Each of them contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x, y \\le n$$$)\u00a0\u2014 the endpoints of the corresponding edge of the tree. It is guaranteed that the given graph is a tree. The last line contains $$$n$$$ distinct integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le n$$$)\u00a0\u2014 the sequence to check.", "output_spec": "Print \"Yes\" (quotes for clarity) if the sequence corresponds to some valid BFS traversal of the given tree and \"No\" (quotes for clarity) otherwise. You can print each letter in any case (upper or lower).", "sample_inputs": ["4\n1 2\n1 3\n2 4\n1 2 3 4", "4\n1 2\n1 3\n2 4\n1 2 4 3"], "sample_outputs": ["Yes", "No"], "notes": "NoteBoth sample tests have the same tree in them.In this tree, there are two valid BFS orderings: $$$1, 2, 3, 4$$$, $$$1, 3, 2, 4$$$. The ordering $$$1, 2, 4, 3$$$ doesn't correspond to any valid BFS order."}, "positive_code": [{"source_code": "data = $data;\n $this->next = null;\n\t}\n}\nclass Queue\n{\n\tprotected $head;\n\tprotected $trail;\n\tprotected $num;\n\tpublic function __construct(){\n\t\t$this->num = 0;\n\t\t$this->head = null;\n\t\t$this->trail = null;\n\t}\n\tpublic function push($data){\n $this->num++;\n if($this->head == null){\n \t $this->head = $this->trail = new QueStruct($data);\n }\n else {\n $this->trail->next = new QueStruct($data);\n $this->trail = $this->trail->next;\n }\n\t}\n public function front(){\n \treturn $this->head->data;\n }\n public function pop()\n {\n $this->num--;\n $p = &$this->head;\n $this->head = $this->head->next;\n if($this->num == 0)\n \t$this->trail = $this->head = null;\n unset($p);\n }\n public function size()\n {\n \treturn $this->num;\n }\n public function isEmpty()\n {\n if($this->num == 0)\n \treturn true;\n return false;\n }\n}\nfscanf(STDIN,\"%d\",$n);\n$edge = array();\n$mark_point = array();\nfor($i = 1;$i < $n;$i++)\n{\n\tfscanf(STDIN,\"%d %d\",$point_x,$point_y);\n\tif(!isset($edge[$point_x])){\n $edge[$point_x] = array();\n\t}\n\tif(!isset($edge[$point_y])){\n\t\t$edge[$point_y] = array();\n\t}\n array_push($edge[$point_x],$point_y);\n array_push($edge[$point_y],$point_x);\n}\n\n$str = trim(fgets(STDIN));\n$squ= explode(' ',$str);\nif($n == 1){\n\techo \"Yes\\n\";\n\treturn ;\n}\nfor($i = 0;$i < $n;$i++)\n{\n\t$squence[$i] = (int)$squ[$i];\n\t$mark_point[$squence[$i]] = $i;\n}\nfor($i = 1;$i <= $n; $i++)\n{\n if(isset($edge[$i]))\n \tusort($edge[$i],'cmp');\n}\nif(bfs($edge,$squence)){\n\techo \"Yes\\n\";\n}\nelse echo \"No\\n\";\nfunction cmp($first,$second)\n{\n\tglobal $mark_point;\n\tif($mark_point[$first] < $mark_point[$second]){\n\t\treturn -1;\n\t}\n\telse if($mark_point[$first] > $mark_point[$second]){\n\t\treturn 1;\n\t}\n\treturn 0;\n}\nfunction bfs(&$edge,$original)\n{ \n if($original[0] != 1)\n return false;\n $cnt = 1;\n global $mark_point; \n $queue = new Queue();\n $vis_flag = array();\n if(isset($edge[1])){\n $vis_flag[1] = true;\n $num = count($edge[1]);\n for($i = 0;$i < $num;$i++)\n { $id = $edge[1][$i];\n \t if(!isset($vis_flag[$id]))\n \t {\n \t \t$vis_flag[$id] = true;\n \t \tif($mark_point[$id] < $mark_point[1])\n \t \t\treturn false;\n \t \t$queue->push($id);\n \t }\n }\n }\n else return false;\n while(!$queue->isEmpty())\n {\n \t $point = $queue->front();\n \t if($point != $original[$cnt++])\n \t \treturn false;\n $queue->pop();\n if(!isset($edge[$point]))\n \tcontinue;\n $num = count($edge[$point]);\n for($i = 0;$i < $num;$i++)\n {\n $id = $edge[$point][$i];\n if(!isset($vis_flag[$id]))\n {\n \t$vis_flag[$id] = true;\n \tif($mark_point[$id] < $mark_point[$point])\n \t\treturn false;\n $queue->push($id);\n }\n }\n }\n return true;\n}"}], "negative_code": [{"source_code": "data = $data;\n $this->next = null;\n\t}\n}\nclass Queue\n{\n\tprotected $head;\n\tprotected $trail;\n\tprotected $num;\n\tpublic function __construct(){\n\t\t$this->num = 0;\n\t\t$this->head = null;\n\t\t$this->trail = null;\n\t}\n\tpublic function push($data){\n $this->num++;\n if($this->head == null){\n \t $this->head = $this->trail = new QueStruct($data);\n }\n else {\n $this->trail->next = new QueStruct($data);\n $this->trail = $this->trail->next;\n }\n\t}\n public function front(){\n \treturn $this->head->data;\n }\n public function pop()\n {\n $this->num--;\n $p = &$this->head;\n $this->head = $this->head->next;\n if($this->num == 0)\n \t$this->trail = $this->head = null;\n unset($p);\n }\n public function size()\n {\n \treturn $this->num;\n }\n public function isEmpty()\n {\n if($this->num == 0)\n \treturn true;\n return false;\n }\n}\nfscanf(STDIN,\"%d\",$n);\n$edge = array();\n$mark_point = array();\nfor($i = 1;$i < $n;$i++)\n{\n\tfscanf(STDIN,\"%d %d\",$point_x,$point_y);\n\tif(!isset($edge[$point_x])){\n $edge[$point_x] = array();\n\t}\n\tif(!isset($edge[$point_y])){\n\t\t$edge[$point_y] = array();\n\t}\n array_push($edge[$point_x],$point_y);\n array_push($edge[$point_y],$point_x);\n}\n\n$str = trim(fgets(STDIN));\n$squ= explode(' ',$str);\nif($n == 1){\n\techo \"Yes\\n\";\n\treturn ;\n}\nfor($i = 0;$i < $n;$i++)\n{\n\t$squence[$i] = (int)$squ[$i];\n\t$mark_point[$squence[$i]] = $i;\n}\nfor($i = 1;$i < $n; $i++)\n{\n if(isset($edge[$i]))\n \tusort($edge[$i],'cmp');\n}\nif(bfs($edge,$squence)){\n\techo \"Yes\\n\";\n}\nelse echo \"No\\n\";\nfunction cmp($first,$second)\n{\n\tglobal $mark_point;\n\tif($mark_point[$first] < $mark_point[$second]){\n\t\treturn -1;\n\t}\n\telse if($mark_point[$first] > $mark_point[$second]){\n\t\treturn 1;\n\t}\n\treturn 0;\n}\nfunction bfs(&$edge,$original)\n{ \n if($original[0] != 1)\n return false;\n $cnt = 1;\n global $mark_point; \n $queue = new Queue();\n $vis_flag = array();\n if(isset($edge[1])){\n $vis_flag[1] = true;\n $num = count($edge[1]);\n for($i = 0;$i < $num;$i++)\n { $id = $edge[1][$i];\n \t if(!isset($vis_flag[$id]))\n \t {\n \t \t$vis_flag[$id] = true;\n \t \tif($mark_point[$id] < $mark_point[1])\n \t \t\treturn false;\n \t \t$queue->push($id);\n \t }\n }\n }\n else return false;\n while(!$queue->isEmpty())\n {\n \t $point = $queue->front();\n \t if($point != $original[$cnt++])\n \t \treturn false;\n $queue->pop();\n if(!isset($edge[$point]))\n \tcontinue;\n $num = count($edge[$point]);\n for($i = 0;$i < $num;$i++)\n {\n $id = $edge[$point][$i];\n if(!isset($vis_flag[$id]))\n {\n \t$vis_flag[$id] = true;\n \tif($mark_point[$id] < $mark_point[$point])\n \t\treturn false;\n $queue->push($id);\n }\n }\n }\n return true;\n}"}], "src_uid": "82ff8ae62e39b8e64f9a273b736bf59e"} {"nl": {"description": "You are given a positive integer $$$x$$$. Find any such $$$2$$$ positive integers $$$a$$$ and $$$b$$$ such that $$$GCD(a,b)+LCM(a,b)=x$$$.As a reminder, $$$GCD(a,b)$$$ is the greatest integer that divides both $$$a$$$ and $$$b$$$. Similarly, $$$LCM(a,b)$$$ is the smallest integer such that both $$$a$$$ and $$$b$$$ divide it.It's guaranteed that the solution always exists. If there are several such pairs $$$(a, b)$$$, you can output any of them.", "input_spec": "The first line contains a single integer $$$t$$$ $$$(1 \\le t \\le 100)$$$ \u00a0\u2014 the number of testcases. Each testcase consists of one line containing a single integer, $$$x$$$ $$$(2 \\le x \\le 10^9)$$$.", "output_spec": "For each testcase, output a pair of positive integers $$$a$$$ and $$$b$$$ ($$$1 \\le a, b \\le 10^9)$$$ such that $$$GCD(a,b)+LCM(a,b)=x$$$. It's guaranteed that the solution always exists. If there are several such pairs $$$(a, b)$$$, you can output any of them.", "sample_inputs": ["2\n2\n14"], "sample_outputs": ["1 1\n6 4"], "notes": "NoteIn the first testcase of the sample, $$$GCD(1,1)+LCM(1,1)=1+1=2$$$.In the second testcase of the sample, $$$GCD(6,4)+LCM(6,4)=2+12=14$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "2fa3e88688b92c27ad26a23884e26009"} {"nl": {"description": "You are given an undirected unweighted connected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.Your task is to find any spanning tree of this graph such that the maximum degree over all vertices is maximum possible. Recall that the degree of a vertex is the number of edges incident to it.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$, $$$n - 1 \\le m \\le min(2 \\cdot 10^5, \\frac{n(n-1)}{2})$$$) \u2014 the number of vertices and edges, respectively. The following $$$m$$$ lines denote edges: edge $$$i$$$ is represented by a pair of integers $$$v_i$$$, $$$u_i$$$ ($$$1 \\le v_i, u_i \\le n$$$, $$$u_i \\ne v_i$$$), which are the indices of vertices connected by the edge. There are no loops or multiple edges in the given graph, i.\u2009e. for each pair ($$$v_i, u_i$$$) there are no other pairs ($$$v_i, u_i$$$) or ($$$u_i, v_i$$$) in the list of edges, and for each pair $$$(v_i, u_i)$$$ the condition $$$v_i \\ne u_i$$$ is satisfied.", "output_spec": "Print $$$n-1$$$ lines describing the edges of a spanning tree such that the maximum degree over all vertices is maximum possible. Make sure that the edges of the printed spanning tree form some subset of the input edges (order doesn't matter and edge $$$(v, u)$$$ is considered the same as the edge $$$(u, v)$$$). If there are multiple possible answers, print any of them.", "sample_inputs": ["5 5\n1 2\n2 3\n3 5\n4 3\n1 5", "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "8 9\n1 2\n2 3\n2 5\n1 6\n3 4\n6 5\n4 5\n2 7\n5 8"], "sample_outputs": ["3 5\n2 1\n3 2\n3 4", "4 1\n1 2\n1 3", "3 2\n2 5\n8 5\n6 1\n2 7\n1 2\n3 4"], "notes": "NotePicture corresponding to the first example: In this example the number of edges of spanning tree incident to the vertex $$$3$$$ is $$$3$$$. It is the maximum degree over all vertices of the spanning tree. It is easy to see that we cannot obtain a better answer.Picture corresponding to the second example: In this example the number of edges of spanning tree incident to the vertex $$$1$$$ is $$$3$$$. It is the maximum degree over all vertices of the spanning tree. It is easy to see that we cannot obtain a better answer.Picture corresponding to the third example: In this example the number of edges of spanning tree incident to the vertex $$$2$$$ is $$$4$$$. It is the maximum degree over all vertices of the spanning tree. It is easy to see that we cannot obtain a better answer. But because this example is symmetric, we can choose almost the same spanning tree but with vertex $$$5$$$ instead of $$$2$$$."}, "positive_code": [{"source_code": " TRUE);\nfor($x = 0; $x < min($a - 1, count($d[$h])); $x++)\n{\n $i[$h . \"-\" . $d[$h][$x]] = TRUE;\n $j[$x] = $h;\n $k[$x] = $d[$h][$x];\n $m[$x] = $d[$h][$x];\n $p[$d[$h][$x]] = TRUE;\n}\nif(count($i) == $a - 1)\n{\n for($x = 0; $x < $a - 1; $x++)\n {\n print $j[$x] . \" \" . $k[$x] . \"\\n\";\n }\n}\nelse\n{\n $n = count($i);\n $o = 0;\n while(TRUE)\n {\n $q = $m[$o];\n for($x = 0; $x < count($d[$m[$o]]); $x++)\n {\n if($l[$d[$m[$o]][$x]] == FALSE)\n {\n $l[$d[$m[$o]][$x]] = TRUE;\n $m[count($m)] = $d[$m[$o]][$x];\n }\n if(($i[$m[$o] . \"-\" . $d[$m[$o]][$x]] != TRUE) && ($i[$d[$m[$o]][$x] . \"-\" . $m[$o]] != TRUE) && ($p[$d[$m[$o]][$x]] == FALSE))\n {\n $i[$d[$m[$o]] . \"-\" . $d[$m[$o]][$x]] != TRUE;\n $j[count($j)] = $m[$o];\n $k[count($k)] = $d[$m[$o]][$x];\n $n++;\n $p[$d[$m[$o]][$x]] = TRUE;\n if($n == $a - 1)\n {\n break;\n }\n }\n }\n if($n == $a - 1)\n {\n break;\n }\n else\n {\n $o++;\n }\n }\n for($x = 0; $x < $n; $x++)\n {\n print $j[$x] . \" \" . $k[$x] . \"\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": ""}], "src_uid": "fd593d74545da6d133708d58bdde2197"} {"nl": {"description": "There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in the same order. You are also given some text consisting of small and capital English letters and digits. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. Print the text if the same keys were pressed in the second layout.Since all keys but letters are the same in both layouts, the capitalization of the letters should remain the same, as well as all other characters.", "input_spec": "The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout. The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout. The third line contains a non-empty string s consisting of lowercase and uppercase English letters and digits. This is the text typed in the first layout. The length of s does not exceed 1000.", "output_spec": "Print the text if the same keys were pressed in the second layout.", "sample_inputs": ["qwertyuiopasdfghjklzxcvbnm\nveamhjsgqocnrbfxdtwkylupzi\nTwccpQZAvb2017", "mnbvcxzlkjhgfdsapoiuytrewq\nasdfghjklqwertyuiopzxcvbnm\n7abaCABAABAcaba7"], "sample_outputs": ["HelloVKCup2017", "7uduGUDUUDUgudu7"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "=48 && ord($str3[$i])<=57)\n \t\techo \"$str3[$i]\";\n else if(ord($str3[$i])>=65&&ord($str3[$i])<=90)\n {\n\t\t\tfor ($j=0; $j "}, {"source_code": " $crap) {\n\t$pattern[\"$number\"] = \"$number\";\n}\nforeach ($keyboard_wrong as $index => $character) {\n\t$pattern[$keyboard_wrong[$index]] = $keyboard_correct[$index];\n\t$pattern[strtoupper($keyboard_wrong[$index])] = strtoupper($keyboard_correct[$index]);\n}\n\n$output = \"\";\nforeach ($problem_string as $index => $character) {\n\t$output .= $pattern[$character];\n}\n// echo $output;\nfwrite(STDOUT, $output);\n"}], "negative_code": [{"source_code": " $crap) {\n\t$pattern[\"$number\"] = \"$number\";\n}\nforeach ($keyboard_wrong as $index => $character) {\n\t$pattern[$keyboard_wrong[$index]] = $keyboard_correct[$index];\n\t$pattern[strtoupper($keyboard_wrong[$index])] = strtoupper($keyboard_correct[$index]);\n}\n\n$output = \"\";\nforeach ($problem_string as $index => $character) {\n\t$output .= $pattern[$character];\n}\n// echo $output;\nfwrite(STDOUT, $output);\n"}], "src_uid": "d6f01ece3f251b7aac74bf3fd8231a80"} {"nl": {"description": "IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her entertainment more interesting.Today, when IA looked at the fridge, she noticed that the word formed by magnets is really messy. \"It would look much better when I'll swap some of them!\"\u00a0\u2014 thought the girl\u00a0\u2014 \"but how to do it?\". After a while, she got an idea. IA will look at all prefixes with lengths from $$$1$$$ to the length of the word and for each prefix she will either reverse this prefix or leave it as it is. She will consider the prefixes in the fixed order: from the shortest to the largest. She wants to get the lexicographically smallest possible word after she considers all prefixes. Can you help her, telling which prefixes should be chosen for reversing?A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if and only if one of the following holds: $$$a$$$ is a prefix of $$$b$$$, but $$$a \\ne b$$$; in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$b$$$.", "input_spec": "The first and the only line contains a string $$$s$$$ ($$$1 \\le |s| \\le 1000$$$), describing the initial string formed by magnets. The string $$$s$$$ consists only of characters 'a' and 'b'.", "output_spec": "Output exactly $$$|s|$$$ integers. If IA should reverse the $$$i$$$-th prefix (that is, the substring from $$$1$$$ to $$$i$$$), the $$$i$$$-th integer should be equal to $$$1$$$, and it should be equal to $$$0$$$ otherwise. If there are multiple possible sequences leading to the optimal answer, print any of them.", "sample_inputs": ["bbab", "aaaaa"], "sample_outputs": ["0 1 1 0", "1 0 0 0 1"], "notes": "NoteIn the first example, IA can reverse the second and the third prefix and get a string \"abbb\". She cannot get better result, since it is also lexicographically smallest string obtainable by permuting characters of the initial string.In the second example, she can reverse any subset of prefixes\u00a0\u2014 all letters are 'a'."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n if($a[$x] == \"a\")\n {\n break;\n }\n}\n$b = array_fill(0, strlen($a), 0);\n$c = 0;\nfor($y = 0; $y < strlen($a) - 1; $y++)\n{\n if(($a[$y] == \"b\") && ($a[$y + 1] == \"a\") && ($c == 0))\n {\n $b[$y] = 1;\n $c = 1;\n if($x == $y + 1)\n {\n $b[$y + 1] = 1;\n break;\n }\n }\n elseif(($a[$y] == \"a\") && ($a[$y + 1] == \"b\") && ($c == 1))\n {\n $b[$y] = 1;\n $c = 0;\n if($x == $y)\n {\n break;\n }\n }\n}\nif(($a[strlen($a) - 1] == \"a\") && ($a[strlen($a) - 2] == \"a\"))\n{\n $b[count($b) - 1] = 1;\n}\nprint implode(\" \", $b);\n?>"}], "negative_code": [{"source_code": "= 0; $x--)\n{\n if($a[$x] == \"a\")\n {\n break;\n }\n}\n$b = array_fill(0, strlen($a), 0);\n$c = 0;\nfor($y = 0; $y < strlen($a) - 1; $y++)\n{\n if(($a[$y] == \"b\") && ($a[$y + 1] == \"a\") && ($c == 0))\n {\n $b[$y] = 1;\n $c = 1;\n if($x == $y + 1)\n {\n $b[$y + 1] = 1;\n break;\n }\n }\n elseif(($a[$y] == \"a\") && ($a[$y + 1] == \"b\") && ($c == 1))\n {\n $b[$y] = 1;\n $c = 0;\n if($x == $y)\n {\n break;\n }\n }\n}\nprint implode(\" \", $b);\n?>"}], "src_uid": "fc0d3b122d800dcbcb99795581229d42"} {"nl": {"description": "Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.Consider that m (m\u2009\u2264\u20094n) people occupy the seats in the bus. The passengers entering the bus are numbered from 1 to m (in the order of their entering the bus). The pattern of the seat occupation is as below:1-st row left window seat, 1-st row right window seat, 2-nd row left window seat, 2-nd row right window seat, ... , n-th row left window seat, n-th row right window seat.After occupying all the window seats (for m\u2009>\u20092n) the non-window seats are occupied:1-st row left non-window seat, 1-st row right non-window seat, ... , n-th row left non-window seat, n-th row right non-window seat.All the passengers go to a single final destination. In the final destination, the passengers get off in the given order.1-st row left non-window seat, 1-st row left window seat, 1-st row right non-window seat, 1-st row right window seat, ... , n-th row left non-window seat, n-th row left window seat, n-th row right non-window seat, n-th row right window seat. The seating for n\u2009=\u20099 and m\u2009=\u200936. You are given the values n and m. Output m numbers from 1 to m, the order in which the passengers will get off the bus.", "input_spec": "The only line contains two integers, n and m (1\u2009\u2264\u2009n\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009m\u2009\u2264\u20094n) \u2014 the number of pairs of rows and the number of passengers.", "output_spec": "Print m distinct integers from 1 to m \u2014 the order in which the passengers will get off the bus.", "sample_inputs": ["2 7", "9 36"], "sample_outputs": ["5 1 6 2 7 3 4", "19 1 20 2 21 3 22 4 23 5 24 6 25 7 26 8 27 9 28 10 29 11 30 12 31 13 32 14 33 15 34 16 35 17 36 18"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $m) {\n $result = null;\n $final++;\n }\n \n if ($result !== null) {\n $resultArray[] = $result; \n }\n}\necho implode($resultArray, ' ');\n?>"}, {"source_code": " 0; $i++) {\n\t\t$a[$i]->lw = $p;\n\t\t$p++;\n\t\t$m--;\n\t\t$a[$i]->lwc = true;\n\t\tif ($m > 0) {\n\t\t\t$a[$i]->rw = $p;\n\t\t\t$p++;\n\t\t\t$m--;\n\t\t\t$a[$i]->rwc = true;\n\t\t}\n\t}\n\tfor ($i = 0; $i < $n && $m > 0; $i++) {\n\t\t$a[$i]->l = $p;\n\t\t$p++;\n\t\t$m--;\n\t\t$a[$i]->lc = true;\n\t\tif ($m > 0) {\n\t\t\t$a[$i]->r = $p;\n\t\t\t$p++;\n\t\t\t$m--;\n\t\t\t$a[$i]->rc = true;\n\t\t}\n\t}\n\tfor ($i = 0; $i < $n; $i++) {\n\t\tif ($a[$i]->lc) {\n\t\t\techo $a[$i]->l;\n\t\t\techo ' ';\n\t\t}\n\t\tif ($a[$i]->lwc) {\n\t\t\techo $a[$i]->lw;\n\t\t\techo ' ';\n\t\t}\n\t\tif ($a[$i]->rc) {\n\t\t\techo $a[$i]->r;\n\t\t\techo ' ';\n\t\t}\n\t\tif ($a[$i]->rwc) {\n\t\t\techo $a[$i]->rw;\n\t\t\techo ' ';\n\t\t}\n\t}\n?> "}], "negative_code": [{"source_code": " $m) {\n $result = null;\n $final++;\n }\n if ($result !== null) {\n $resultArray[] = $result; \n }\n}\necho implode($resultArray, ' ');\n?>"}, {"source_code": " $m) {\n $result = null;\n $final++;\n }\n \n if ($result !== null) {\n $resultArray[] = $result; \n }\n}\nvar_dump($resultArray);\necho implode($resultArray, ' ');\n?>"}, {"source_code": " $m) {\n $result = null;\n $final++;\n }\n \n if ($result !== null) {\n $resultArray[] = $result; \n }\n}\necho implode($resultArray, ' ');\n?>"}], "src_uid": "0a701242ca81029a1791df74dc8ca59b"} {"nl": {"description": "Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him \u2014 his keyboard will consist of only one row, where all $$$26$$$ lowercase Latin letters will be arranged in some order.Polycarp uses the same password $$$s$$$ on all websites where he is registered (it is bad, but he doesn't care). He wants to assemble a keyboard that will allow to type this password very easily. He doesn't like to move his fingers while typing the password, so, for each pair of adjacent characters in $$$s$$$, they should be adjacent on the keyboard. For example, if the password is abacaba, then the layout cabdefghi... is perfect, since characters a and c are adjacent on the keyboard, and a and b are adjacent on the keyboard. It is guaranteed that there are no two adjacent equal characters in $$$s$$$, so, for example, the password cannot be password (two characters s are adjacent).Can you help Polycarp with choosing the perfect layout of the keyboard, if it is possible?", "input_spec": "The first line contains one integer $$$T$$$ ($$$1 \\le T \\le 1000$$$) \u2014 the number of test cases. Then $$$T$$$ lines follow, each containing one string $$$s$$$ ($$$1 \\le |s| \\le 200$$$) representing the test case. $$$s$$$ consists of lowercase Latin letters only. There are no two adjacent equal characters in $$$s$$$.", "output_spec": "For each test case, do the following: if it is impossible to assemble a perfect keyboard, print NO (in upper case, it matters in this problem); otherwise, print YES (in upper case), and then a string consisting of $$$26$$$ lowercase Latin letters \u2014 the perfect layout. Each Latin letter should appear in this string exactly once. If there are multiple answers, print any of them. ", "sample_inputs": ["5\nababa\ncodedoca\nabcda\nzxzytyz\nabcdefghijklmnopqrstuvwxyza"], "sample_outputs": ["YES\nbacdefghijklmnopqrstuvwxyz\nYES\nedocabfghijklmnpqrstuvwxyz\nNO\nYES\nxzytabcdefghijklmnopqrsuvw\nNO"], "notes": null}, "positive_code": [{"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n elseif(($c[$e - 1] != $b[$y]) && ($c[$y + 1] != $b[$y]))\n {\n $f = 1;\n break;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n}\n?>"}, {"source_code": "\n\n\n"}], "negative_code": [{"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if(($c[$e - 1] != $b[$y]) && ($c[$y + 1] != $b[$y]))\n {\n $f = 1;\n break;\n }\n elseif($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n}\n?>"}, {"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n}"}, {"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print \"YES\\n\";\n print implode($c) . implode($h) . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $b[0]);\n $d = array($b[0] => TRUE);\n $e = 0;\n $f = 0;\n for($y = 1; $y < strlen($b); $y++)\n {\n if($d[$b[$y]] == FALSE)\n {\n $d[$b[$y]] = TRUE;\n if($c[$e + 1] == NULL)\n {\n $c[$e + 1] = $b[$y];\n $e++;\n }\n elseif($c[$e - 1] == NULL)\n {\n $c[$e - 1] = $b[$y];\n $e--;\n }\n }\n elseif($d[$b[$y]] == TRUE)\n {\n if($c[$e - 1] == $b[$y])\n {\n $e = $e - 1;\n }\n elseif($c[$e + 1] == $b[$y])\n {\n $e = $e + 1;\n }\n else\n {\n $f = 1;\n break;\n }\n }\n }\n if($f == 1)\n {\n print \"NO\\n\";\n }\n else\n {\n $g = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\n ksort($c);\n $h = array_diff($g, $c);\n print implode($c) . implode($h) . \"\\n\";\n }\n}\n?>"}, {"source_code": "\n\n\n"}, {"source_code": "\n\n\n"}], "src_uid": "8fb62b497b6fb2a5fb4f2669aeb51b73"} {"nl": {"description": "Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were connected by n two-way roads in the ring, i. e. each city was connected directly to exactly two other cities, and from each city it was possible to get to any other city. Government of Berland introduced one-way traffic on all n roads, but it soon became clear that it's impossible to get from some of the cities to some others. Now for each road is known in which direction the traffic is directed at it, and the cost of redirecting the traffic. What is the smallest amount of money the government should spend on the redirecting of roads so that from every city you can get to any other?", "input_spec": "The first line contains integer n (3\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 amount of cities (and roads) in Berland. Next n lines contain description of roads. Each road is described by three integers ai, bi, ci (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u2009n,\u2009ai\u2009\u2260\u2009bi,\u20091\u2009\u2264\u2009ci\u2009\u2264\u2009100) \u2014 road is directed from city ai to city bi, redirecting the traffic costs ci.", "output_spec": "Output single integer \u2014 the smallest amount of money the government should spend on the redirecting of roads so that from every city you can get to any other.", "sample_inputs": ["3\n1 3 1\n1 2 1\n3 2 1", "3\n1 3 1\n1 2 5\n3 2 1", "6\n1 5 4\n5 3 8\n2 4 15\n1 6 16\n2 3 23\n4 6 42", "4\n1 2 9\n2 3 8\n3 4 7\n4 1 5"], "sample_outputs": ["1", "2", "39", "0"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "d85c7a8f7e6f5fc6dffed554bffef3ec"} {"nl": {"description": "You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string \"aba,123;1a;0\": \"aba\", \"123\", \"1a\", \"0\". A word can be empty: for example, the string s=\";;\" contains three empty words separated by ';'.You should find all words in the given string that are nonnegative INTEGER numbers without leading zeroes and build by them new string a. String a should contain all words that are numbers separating them by ',' (the order of numbers should remain the same as in the string s). By all other words you should build string b in the same way (the order of numbers should remain the same as in the string s).Here strings \"101\", \"0\" are INTEGER numbers, but \"01\" and \"1.0\" are not.For example, for the string aba,123;1a;0 the string a would be equal to \"123,0\" and string b would be equal to \"aba,1a\".", "input_spec": "The only line of input contains the string s (1\u2009\u2264\u2009|s|\u2009\u2264\u2009105). The string contains only symbols '.' (ASCII 46), ',' (ASCII 44), ';' (ASCII 59), digits, lowercase and uppercase latin letters.", "output_spec": "Print the string a to the first line and string b to the second line. Each string should be surrounded by quotes (ASCII 34). If there are no words that are numbers print dash (ASCII 45) on the first line. If all words are numbers print dash on the second line.", "sample_inputs": ["aba,123;1a;0", "1;;01,a0,", "1", "a"], "sample_outputs": ["\"123,0\"\n\"aba,1a\"", "\"1\"\n\",01,a0,\"", "\"1\"\n-", "-\n\"a\""], "notes": "NoteIn the second example the string s contains five words: \"1\", \"\", \"01\", \"a0\", \"\"."}, "positive_code": [{"source_code": " 0) && ($l[0] != 0))\n { \n $n = strpos($l, \".\");\n if($n == FALSE)\n {\n $h[$i] = $l;\n $i++;\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n}\nif(count($h) == 0)\n{\n print \"-\\n\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($h) - 1; $x++)\n {\n $m .= $h[$x] . \",\";\n }\n $m .= $h[$x] . \"\\\"\";\n print $m . \"\\n\";\n}\nif(count($j) == 0)\n{\n print \"-\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($j) - 1; $x++)\n {\n $m .= $j[$x] . \",\";\n }\n $m .= $j[$x] . \"\\\"\";\n print $m;\n}\n?>"}, {"source_code": ""}, {"source_code": " 0) && ($l[0] != 0))\n { \n $n = intval($l);\n if(strlen($n) == strlen($l))\n {\n $h[$i] = $l;\n $i++;\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n}\nif(count($h) == 0)\n{\n print \"-\\n\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($h) - 1; $x++)\n {\n $m .= $h[$x] . \",\";\n }\n $m .= $h[$x] . \"\\\"\";\n print $m . \"\\n\";\n}\nif(count($j) == 0)\n{\n print \"-\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($j) - 1; $x++)\n {\n $m .= $j[$x] . \",\";\n }\n $m .= $j[$x] . \"\\\"\";\n print $m;\n}\n?>"}, {"source_code": " 0) && ($l[0] != 0))\n { \n $h[$i] = $l;\n $i++;\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n}\nif(count($h) == 0)\n{\n print \"-\\n\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($h) - 1; $x++)\n {\n $m .= $h[$x] . \",\";\n }\n $m .= $h[$x] . \"\\\"\";\n print $m . \"\\n\";\n}\nif(count($j) == 0)\n{\n print \"-\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($j) - 1; $x++)\n {\n $m .= $j[$x] . \",\";\n }\n $m .= $j[$x] . \"\\\"\";\n print $m;\n}\n?>"}, {"source_code": " 0) && ($l[0] != 0))\n { \n $h[$i] = $l;\n $i++;\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n}\nif(count($h) == 0)\n{\n print \"-\\n\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($h) - 1; $x++)\n {\n $m .= $h[$x] . \",\";\n }\n $m .= $h[$x] . \"\\\"\";\n print $m . \"\\n\";\n}\nif(count($j) == 0)\n{\n print \"-\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($j) - 1; $x++)\n {\n $m .= $j[$x] . \",\";\n }\n $m .= $j[$x] . \"\\\"\";\n print $m;\n}\n?>"}, {"source_code": " 0) && ($l[0] != 0))\n { \n $h[$i] = $l;\n $i++;\n }\n else\n {\n $j[$k] = $l;\n $k++;\n }\n}\nif(count($h) == 0)\n{\n print \"-\\n\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($h) - 1; $x++)\n {\n $m .= $h[$x] . \",\";\n }\n $m .= $h[$x] . \"\\\"\";\n print $m . \"\\n\";\n}\nif(count($j) == 0)\n{\n print \"-\";\n}\nelse\n{\n $m = \"\\\"\";\n for($x = 0; $x < count($j) - 1; $x++)\n {\n $m .= $j[$x] . \",\";\n }\n $m .= $j[$x] . \"\\\"\";\n print $m;\n}\n?>"}, {"source_code": ""}, {"source_code": "= 0][] = $e;\nfprintf(STDOUT, '\"%s\"\\n\"%s\"', implode(\",\" ,$arr[1]), implode(\",\" ,$arr[0]));\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0][] = $e;\nfprintf(STDOUT, '\"%s\"'.\"\\n\".'\"%s\"', empty($arr[1]) ? \"-\" : implode(\",\" ,$arr[1]), empty($arr[0]) ? \"-\" : implode(\",\" ,$arr[0]));\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0][] = $e;\nfprintf(STDOUT, '%s'.\"\\n\".'%s', empty($arr[1]) ? \"-\" : '\"'.implode(\",\" ,$arr[1]).'\"', empty($arr[0]) ? \"-\" : '\"'.implode(\",\" ,$arr[0]).'\"');\n?>"}, {"source_code": "= 0][] = $e;\nfprintf(STDOUT, '%s'.\"\\n\".'%s', empty($arr[1]) ? \"-\" : '\"'.implode(\",\" ,$arr[1]).'\"', empty($arr[0]) ? \"-\" : '\"'.implode(\",\" ,$arr[0]).'\"');\n?>"}, {"source_code": ""}, {"source_code": "= 0][] = $e;\nfprintf(STDOUT, '\"%s\"'.\"\\n\".'\"%s\"', implode(\",\" ,$arr[1]), implode(\",\" ,$arr[0]));\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " $a){\n break;\n }\n if($h % 2 != 0 && $h % $f != 0 && $h % 10 != 0){\n echo $h.\"\\n\";\n $b = true;\n break;\n }\n }\n if(!$b){\n echo \"-1\\n\";\n }\n \n }\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1) {\r\n // for($i=0; $i<$tt-1; $i++) {\r\n // if($b[$i] > $b[$i + 1]) {\r\n \r\n // $ans = false;\r\n // break;\r\n // }\r\n // } \r\n // }\r\n // if(!$ans && $b[0] == min($b)) {\r\n // $ans = true;\r\n // }\r\n \r\n \r\n \r\n pr($ans ? $yes : $no);\r\n \r\n \r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\nfunction getDar2($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, getDar2($n, $k-1));\r\n}\r\n\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i]; \r\n }\r\n for($i = $n; $i = $aRight[$iR]) {\r\n $aResult[] = $aLeft[$iL];\r\n $iL++;\r\n } else {\r\n $aResult[] = $aRight[$iR];\r\n $iR++;\r\n }\r\n }\r\n \r\n while($iL < count($aLeft)) {\r\n $aResult[] = $aLeft[$iL];\r\n $iL++;\r\n }\r\n while($iR < count($aRight)) {\r\n $aResult[] = $aRight[$iR];\r\n $iR++;\r\n }\r\n \r\n return $aResult;\r\n \r\n}"}], "negative_code": [{"source_code": " 1) {\r\n for($i=0; $i<$tt-1; $i++) {\r\n if($b[$i] > $b[$i + 1]) {\r\n $ans = false;\r\n break;\r\n }\r\n } \r\n }\r\n \r\n }\r\n \r\n pr($ans ? $yes : $no);\r\n \r\n \r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\nfunction getDar2($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, getDar2($n, $k-1));\r\n}\r\n\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i]; \r\n }\r\n for($i = $n; $i = $aRight[$iR]) {\r\n $aResult[] = $aLeft[$iL];\r\n $iL++;\r\n } else {\r\n $aResult[] = $aRight[$iR];\r\n $iR++;\r\n }\r\n }\r\n \r\n while($iL < count($aLeft)) {\r\n $aResult[] = $aLeft[$iL];\r\n $iL++;\r\n }\r\n while($iR < count($aRight)) {\r\n $aResult[] = $aRight[$iR];\r\n $iR++;\r\n }\r\n \r\n return $aResult;\r\n \r\n}"}], "src_uid": "96b6a96ded46bddb78b118d6d3a9d049"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \\le i, j \\le n$$$ such that $$$i \\ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $$$i$$$ and $$$j$$$ and replace $$$a_i$$$ with $$$a_j$$$).Your task is to say if it is possible to obtain an array with an odd (not divisible by $$$2$$$) sum of elements.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 2000$$$) \u2014 the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \\le n \\le 2000$$$) \u2014 the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 2000$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$ ($$$\\sum n \\le 2000$$$).", "output_spec": "For each test case, print the answer on it \u2014 \"YES\" (without quotes) if it is possible to obtain the array with an odd sum of elements, and \"NO\" otherwise.", "sample_inputs": ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"], "sample_outputs": ["YES\nNO\nYES\nNO\nNO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " 0 && $bT >0) {\n echo \"YES\\n\";\n } elseif ($bJ > 0 && $bT == 0) \n {\n echo \"NO\\n\";\n } elseif ($bJ == 0 && $bT > 0) \n {\n if($n %2 == 1) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n } \n }"}, {"source_code": "\n\n$n = intval(fgets(STDIN));\nfor ($i = 0; $i < $n; $i++) {\n $t = intval(fgets(STDIN));\n $numbers = array_map('intval', explode(\" \", fgets(STDIN)));\n $even = 0;\n $odd = 0;\n foreach($numbers as $val) {\n if($val % 2 == 0) $even++;\n else $odd++;\n }\n if($odd !== 0 && ($odd !== $t || $t % 2 == 1)) echo \"YES\\n\";\n else echo \"NO\\n\";\n}\n?>"}, {"source_code": "=1 && $odd>=1)\n echo 'YES'.\"\\n\";\n else\n echo \"NO\".\"\\n\";\n\n}\n\n\n?>"}, {"source_code": " 0) && ((($n&1) == 1) || ($odd != $n))) ? \"YES\" : \"NO\";\n\t\tprintf(\"%s\\n\", $ans);\n\t}\n}\n\n\nnamespace io {\n\tfunction next_line() {\n\t\tstatic $cnt = 0;\n\t\tglobal $input_buf;\n\t\treturn $input_buf[$cnt++];\n\t}\n\tfunction next_() {\n\t\tstatic $tk = [];\n\t\tstatic $tk_cnt = 0;\n\t\tif($tk_cnt == count($tk)) {\n\t\t\t$tk = explode(\" \", next_line());\n\t\t\t$tk_cnt = 0;\n\t\t}\n\t\treturn $tk[$tk_cnt++];\n\t}\n\tfunction next_int() {\n\t\treturn (int)next_();\n\t}\n\tfunction next_double() {\n\t\treturn (double)next_();\n\t}\n}\n\n?>\n"}, {"source_code": " 1 && ($count1 - $count2) % 2 == 1) \n || ($count1 - $count2) == 0) \n {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n \n }"}, {"source_code": " 1 && ($count1 - $count2) % 2 == 1) || ($count1 - $count2) == 0) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n \n }\n "}, {"source_code": ""}, {"source_code": ""}, {"source_code": "1 && $odd>1)\n echo 'YES'.\"\\n\";\n else\n echo \"NO\".\"\\n\";\n\n}\n\n\n?>"}, {"source_code": "1)\n echo 'YES'.\"\\n\";\n else\n echo \"NO\".\"\\n\";\n\n}\n\n\n?>"}, {"source_code": ""}, {"source_code": "= $a){\r\n\t\tif($b % 2 == 0){\r\n\t\t\t$res-=1;\r\n\t\t}\r\n\t\techo $res.\"\\n\";\r\n\t}else{\r\n\t\techo $b % $a.\"\\n\";\r\n\t}\r\n}\r\n?>\r\n"}, {"source_code": ""}, {"source_code": " "}], "negative_code": [], "src_uid": "46c5ebf1ddf5547352e84ba0171eacbc"} {"nl": {"description": "You have a string $$$s_1 s_2 \\ldots s_n$$$ and you stand on the left of the string looking right. You want to choose an index $$$k$$$ ($$$1 \\le k \\le n$$$) and place a mirror after the $$$k$$$-th letter, so that what you see is $$$s_1 s_2 \\ldots s_k s_k s_{k - 1} \\ldots s_1$$$. What is the lexicographically smallest string you can see?A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if and only if one of the following holds: $$$a$$$ is a prefix of $$$b$$$, but $$$a \\ne b$$$; in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$b$$$. ", "input_spec": "The first line of input contains one integer $$$t$$$ ($$$1 \\leq t \\leq 10\\,000$$$): the number of test cases. The next $$$t$$$ lines contain the description of the test cases, two lines per a test case. In the first line you are given one integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$): the length of the string. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase English characters. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case print the lexicographically smallest string you can see.", "sample_inputs": ["4\n10\ncodeforces\n9\ncbacbacba\n3\naaa\n4\nbbaa"], "sample_outputs": ["cc\ncbaabc\naa\nbb"], "notes": "NoteIn the first test case choose $$$k = 1$$$ to obtain \"cc\".In the second test case choose $$$k = 3$$$ to obtain \"cbaabc\".In the third test case choose $$$k = 1$$$ to obtain \"aa\".In the fourth test case choose $$$k = 1$$$ to obtain \"bb\"."}, "positive_code": [{"source_code": "= 0; $j--) $w .= $w[$j];\r\n \r\n echo $w.PHP_EOL;\r\n}\r\n\r\n?>"}], "negative_code": [], "src_uid": "dd7faacff9f57635f8e00c2f8f5a4650"} {"nl": {"description": "Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x,\u2009y), he can move to (or attack) positions (x\u2009+\u20091,\u2009y), (x\u20131,\u2009y), (x,\u2009y\u2009+\u20091) and (x,\u2009y\u20131).Iahub wants to know how many Coders can be placed on an n\u2009\u00d7\u2009n chessboard, so that no Coder attacks any other Coder.", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000).", "output_spec": "On the first line print an integer, the maximum number of Coders that can be placed on the chessboard. On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'. If there are multiple correct answers, you can print any.", "sample_inputs": ["2"], "sample_outputs": ["2\nC.\n.C"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "1aede54b41d6fad3e74f24a6592198eb"} {"nl": {"description": "You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$. All elements of both arrays are from $$$0$$$ to $$$n-1$$$.You can reorder elements of the array $$$b$$$ (if you want, you may leave the order of elements as it is). After that, let array $$$c$$$ be the array of length $$$n$$$, the $$$i$$$-th element of this array is $$$c_i = (a_i + b_i) \\% n$$$, where $$$x \\% y$$$ is $$$x$$$ modulo $$$y$$$.Your task is to reorder elements of the array $$$b$$$ to obtain the lexicographically minimum possible array $$$c$$$.Array $$$x$$$ of length $$$n$$$ is lexicographically less than array $$$y$$$ of length $$$n$$$, if there exists such $$$i$$$ ($$$1 \\le i \\le n$$$), that $$$x_i < y_i$$$, and for any $$$j$$$ ($$$1 \\le j < i$$$) $$$x_j = y_j$$$.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of elements in $$$a$$$, $$$b$$$ and $$$c$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$0 \\le a_i < n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of the input contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$0 \\le b_i < n$$$), where $$$b_i$$$ is the $$$i$$$-th element of $$$b$$$.", "output_spec": "Print the lexicographically minimum possible array $$$c$$$. Recall that your task is to reorder elements of the array $$$b$$$ and obtain the lexicographically minimum possible array $$$c$$$, where the $$$i$$$-th element of $$$c$$$ is $$$c_i = (a_i + b_i) \\% n$$$.", "sample_inputs": ["4\n0 1 2 1\n3 2 1 1", "7\n2 5 1 5 3 4 3\n2 4 3 5 6 5 1"], "sample_outputs": ["1 0 0 2", "0 0 0 1 0 2 4"], "notes": null}, "positive_code": [{"source_code": " $itemA) {\n $currentValue = ($n - $itemA) % $n;\n while ($amountB[$currentValue] === 0) {\n $nextValue = $orderList[$currentValue];\n if ($amountB[$nextValue] === 0) {\n $nextValue = $orderList[$currentValue] = $orderList[$nextValue];\n }\n $currentValue = $nextValue;\n }\n $res .= ($i ? ' ' : '') . (($itemA + $currentValue) % $n);\n $amountB[$currentValue]--;\n}\necho $res;\n"}, {"source_code": " $itemA) {\n $currentValue = ($n - $itemA) % $n;\n while ($amountB[$currentValue] === 0) {\n $nextValue = $orderList[$currentValue];\n if ($amountB[$nextValue] === 0) {\n $nextValue = $orderList[$currentValue] = $orderList[$nextValue];\n }\n $currentValue = $nextValue;\n }\n echo ($i ? ' ' : '') . (($itemA + $currentValue) % $n);\n $amountB[$currentValue]--;\n}\n"}], "negative_code": [], "src_uid": "905df05453a12008fc9247ff4d02e7f0"} {"nl": {"description": "This is an interactive problem!Ehab plays a game with Laggy. Ehab has 2 hidden integers $$$(a,b)$$$. Laggy can ask a pair of integers $$$(c,d)$$$ and Ehab will reply with: 1 if $$$a \\oplus c>b \\oplus d$$$. 0 if $$$a \\oplus c=b \\oplus d$$$. -1 if $$$a \\oplus c<b \\oplus d$$$. Operation $$$a \\oplus b$$$ is the bitwise-xor operation of two numbers $$$a$$$ and $$$b$$$.Laggy should guess $$$(a,b)$$$ with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab.It's guaranteed that $$$0 \\le a,b<2^{30}$$$.", "input_spec": "See the interaction section.", "output_spec": "To print the answer, print \"! a b\" (without quotes). Don't forget to flush the output after printing the answer.", "sample_inputs": ["1\n-1\n0"], "sample_outputs": ["? 2 1\n? 1 2\n? 2 0\n! 3 1"], "notes": "NoteIn the sample:The hidden numbers are $$$a=3$$$ and $$$b=1$$$.In the first query: $$$3 \\oplus 2 = 1$$$ and $$$1 \\oplus 1 = 0$$$, so the answer is 1.In the second query: $$$3 \\oplus 1 = 2$$$ and $$$1 \\oplus 2 = 3$$$, so the answer is -1.In the third query: $$$3 \\oplus 2 = 1$$$ and $$$1 \\oplus 0 = 1$$$, so the answer is 0.Then, we printed the answer."}, "positive_code": [{"source_code": "($b^$d);\n\t$checkMemo[\"$c.$d\"] = $res;\n\treturn $checkMemo[\"$c.$d\"];\n}\n\nfunction check($c, $d) {\n\tglobal $checkMemo;\n\t\n\tif (isset($checkMemo[\"$c.$d\"])) {\n\t\treturn $checkMemo[\"$c.$d\"];\n\t}\n\t\n\t\n\techo \"? $c $d\\n\";\n\tflush();\n\t$res = intval(fgets(STDIN));\n\t\n\t\n\t$checkMemo[\"$c.$d\"] = $res;\n\treturn $checkMemo[\"$c.$d\"];\n}\n\n$adda = $addb = 0;\n$equals = [];\n$i = $n-1;\nwhile ($i>=0) {\n\t$res = check($adda, $addb);\n\tif ($res == 0) {\n\t\t$equals[] = $i;\n\t} else {\n\t\t$r = check($adda + (1<<$i), $addb + (1<<$i));\n\t\tif ($r!=$res) {\n\t\t\tif ($res>0) {\n\t\t\t\t$adda += 1<<$i;\n\t\t\t} else {\n\t\t\t\t$addb += 1<<$i;\n\t\t\t}\n\t\t} else {\n\t\t\t$equals[] = $i;\n\t\t}\n\t}\n\t\n\t$i--;\n}\n\nforeach ($equals as $i) {\n\t$res = check($adda + (1<<$i), $addb);\n\tif ($res<0) {\n\t\t$adda += 1<<$i;\n\t\t$addb += 1<<$i;\n\t}\n}\n\necho \"! $adda $addb\\n\";\n\n"}], "negative_code": [{"source_code": "($b^$d);\n\techo \"check: $c, $d => $res\\n\";\n\t$checkMemo[\"$c.$d\"] = $res;\n\treturn $checkMemo[\"$c.$d\"];\n}\n\nfunction check($c, $d) {\n\tglobal $checks;\n\tglobal $checkMemo;\n\t\n\tif (isset($checkMemo[\"$c.$d\"])) {\n\t\treturn $checkMemo[\"$c.$d\"];\n\t}\n\t\n\t$checks++;\n\techo \"? $c $d\\n\";\n\tflush();\n\t$res = intval(fgets(STDIN));\n\t// echo \"check: $c, $d => $res\\n\";\n\t$checkMemo[\"$c.$d\"] = $res;\n\treturn $checkMemo[\"$c.$d\"];\n}\n\n$i = $n-1;\n$adda = $addb = 0;\n$equals = [];\nwhile ($i>=0) {\n\t$res = check($adda, $addb);\n\tif ($res > 0) {\n\t\t$r = check($adda + (1<<$i), $addb + (1<<$i));\n\t\tif ($r!=$res) {\n\t\t\t//echo \"a[$i]==1, b[$i]==0\\n\";\n\t\t\t$adda += 1<<$i;\n\t\t} else {\n\t\t\t//echo \"a[$i]==b[$i]\\n\";\n\t\t\t$equals[] = $i;\n\t\t}\n\t} elseif ($res<0) {\n\t\t$r = check($adda + (1<<$i), $addb + (1<<$i));\n\t\tif ($r!=$res) {\n\t\t\t//echo \"a[$i]==0, b[$i]==1\\n\";\n\t\t\t$addb += 1<<$i;\n\t\t} else {\n\t\t\t//echo \"a[$i]==b[$i]\\n\";\n\t\t\t$equals[] = $i;\n\t\t}\n\t} else {\n\t\t//echo \"a[$i]==b[$i]\\n\";\n\t\t$equals[] = $i;\n\t}\n\t\n\t$i--;\n}\n\nforeach ($equals as $i) {\n\t$res = check($adda + (1<<$i), $addb);\n\tif ($res<0) {\n\t\t$adda += 1<<$i;\n\t\t$addb += 1<<$i;\n\t}\n}\n\n// echo \"a' = \".decbin($adda).\", b' = \".decbin($addb).\"\\n\";\n// echo \"a = \".decbin($a).\", b = \".decbin($b).\"\\n\\n\";\n\n// echo \"checks: $checks ($k)\\n\";\n// echo ($a==$adda && $b==$addb && $checks<=$k) ? \"+\\n\" : \"-\\n\";\necho \"! $adda $addb\\n\";\n//echo \"! $a $b\\n\";\nflush();\n"}], "src_uid": "7dc1137dd1f0c645cc7ec6dfdb92f5df"} {"nl": {"description": "Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.", "input_spec": "The first line of the input contains six positive integers x1,\u2009y1,\u2009x2,\u2009y2,\u2009x3,\u2009y3 (1\u2009\u2264\u2009x1,\u2009y1,\u2009x2,\u2009y2,\u2009x3,\u2009y3\u2009\u2264\u2009100), where xi and yi determine the length and width of the logo of the i-th company respectively.", "output_spec": "If it is impossible to place all the three logos on a square shield, print a single integer \"-1\" (without the quotes). If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters \"A\", \"B\" or \"C\". The sets of the same letters should form solid rectangles, provided that: the sizes of the rectangle composed from letters \"A\" should be equal to the sizes of the logo of the first company, the sizes of the rectangle composed from letters \"B\" should be equal to the sizes of the logo of the second company, the sizes of the rectangle composed from letters \"C\" should be equal to the sizes of the logo of the third company, Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them. See the samples to better understand the statement.", "sample_inputs": ["5 1 2 5 5 2", "4 4 2 6 4 2"], "sample_outputs": ["5\nAAAAA\nBBBBB\nBBBBB\nCCCCC\nCCCCC", "6\nBBBBBB\nBBBBBB\nAAAACC\nAAAACC\nAAAACC\nAAAACC"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "2befe5da2df57d23934601cbe4d4f151"} {"nl": {"description": "You are given three integers $$$x, y$$$ and $$$n$$$. Your task is to find the maximum integer $$$k$$$ such that $$$0 \\le k \\le n$$$ that $$$k \\bmod x = y$$$, where $$$\\bmod$$$ is modulo operation. Many programming languages use percent operator % to implement it.In other words, with given $$$x, y$$$ and $$$n$$$ you need to find the maximum possible integer from $$$0$$$ to $$$n$$$ that has the remainder $$$y$$$ modulo $$$x$$$.You have to answer $$$t$$$ independent test cases. It is guaranteed that such $$$k$$$ exists for each test case.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 5 \\cdot 10^4$$$) \u2014 the number of test cases. The next $$$t$$$ lines contain test cases. The only line of the test case contains three integers $$$x, y$$$ and $$$n$$$ ($$$2 \\le x \\le 10^9;~ 0 \\le y < x;~ y \\le n \\le 10^9$$$). It can be shown that such $$$k$$$ always exists under the given constraints.", "output_spec": "For each test case, print the answer \u2014 maximum non-negative integer $$$k$$$ such that $$$0 \\le k \\le n$$$ and $$$k \\bmod x = y$$$. It is guaranteed that the answer always exists.", "sample_inputs": ["7\n7 5 12345\n5 0 4\n10 5 15\n17 8 54321\n499999993 9 1000000000\n10 5 187\n2 0 999999999"], "sample_outputs": ["12339\n0\n15\n54306\n999999995\n185\n999999998"], "notes": "NoteIn the first test case of the example, the answer is $$$12339 = 7 \\cdot 1762 + 5$$$ (thus, $$$12339 \\bmod 7 = 5$$$). It is obvious that there is no greater integer not exceeding $$$12345$$$ which has the remainder $$$5$$$ modulo $$$7$$$."}, "positive_code": [{"source_code": " $c)\n {\n print $d - ($e - $c) . \"\\n\";\n }\n}\n?>"}, {"source_code": ""}], "negative_code": [], "src_uid": "2589e832f22089fac9ccd3456c0abcec"} {"nl": {"description": " You have one chip and one chance to play roulette. Are you feeling lucky?", "input_spec": null, "output_spec": "Print your bet. Your chip must be placed entirely within some square (not on an edge or a corner shared by adjacent squares).", "sample_inputs": [], "sample_outputs": [], "notes": null}, "positive_code": [{"source_code": "Even\n\t\t\t \t\t\t \t \n\t\t\t \t\t\t \t\n \t \t \t \n \t\t\t\t \t"}, {"source_code": "Even\n \t\t\t \t \n \t\t \t \t\t\n\t \t\t\t \t\t\t\n \t\t\t\t\t \t\t\t"}, {"source_code": "Odd\n\t\t\t\t \t\t \t\n \t\t\t\t \t \n \t\t \t\t\t\t\t\t\n \t \t\n \t \t\t \t\t\t\t\n \t \t \t\t\t\t\n \t\t\t\t \t\t\t\n \t\t\t\t \t\t\t\t"}, {"source_code": "Red\n\t \t \t\t\t \n\t \t \t \n \t \t\t \t \n\t\t \t \t\t"}, {"source_code": "odd\n\t\t \t \t \t\n \t\t\t\t\t\t \t \n \t\t \t\t\t\t\t\n\t\t\t\t\t\t\t\t \t"}, {"source_code": "Red\n\t \t\t \t \t\t\n\t \t \t \t\t\n \t\t\t \t \n \t\t\t\t\t \t \t"}, {"source_code": "Red\n \t \t \t \t \n\t \t \t\t \n\t \t\t\t \t\t \n\t \t\t\t \t "}, {"source_code": "Odd\n \t \t \t \n\t\t\t\t \t \n \t\t\t \t \n \t\t\t\t\t\t \t"}, {"source_code": "Even\n \t \t \t \t\n \t \t \t\t \n\t \t \t \t \t\n \t\t \t"}, {"source_code": "Red\n \t \t \t \t\n\t\t\t\t\t\t\t \t\n\t \t\t \t\t \t \n \t \t \t\t\t "}, {"source_code": "Red\n\t \t \t\t \n\t\t \t\t \t\t\t\n\t \t \t\n\t \t\t\t\t"}, {"source_code": "Red\n \t\t \t \t\n\t\t \t \t\t\t \n\t \t \t\t\t\t\t\n\t\t\t \t\t\t "}, {"source_code": "Red\n\t \t \t \n\t \t \t \n\t \t \t \t\t \n \t\t\t \t\t "}, {"source_code": "red\n \t \t\t\t \n\t\t\t \t \t \n \t \t \t\n\t \t \t\t\t\t "}, {"source_code": "red\n\t \t \t \t \n\t \t\t \t\t \t\n \t\t\t\n\t \t \t"}, {"source_code": "Red\n \t\t\t\t \t\t \n\t \t \t \n \t\t\t\t \n\t \t"}, {"source_code": "even\n \t\t\t\t\t\t \t\n \t \t \t \t\t\n\t\t\t \t \n\t\t \t\t\t \t\t"}, {"source_code": "Black\n \t\t \t\t \t\n\t\t \t \t \t\t \n \t\t \t\t \t\t\n \t \t\t "}, {"source_code": "even\n\t\t\t \t \t\n\t\t\t\t \t \t\n \t \t \t \t\n \t\t\t\t \t "}, {"source_code": "red\n\t \t\t\t\t\t\t\n\t\t\t\t\t \t \t\t\n\t \t\t\t\t \t\t\n\t\t \t \t \t\t"}, {"source_code": "1 to 18\n \t\t \t\t\t \t \n\t \t \t\t \t\t \n\t\t\t\t\t \t\n\t\t\t\t \t\t "}, {"source_code": "Red\n \t\t \t\t\t \t\n \t\t\t\t\t \t\t \n \t \t \t\t\t \t\n\t\t\t\t \t\t \t"}, {"source_code": "black\n\n\n\n\t\t\t \t\t \t \n\t\t \t\t \t\t\n \t\t \t \t\t\n \t \t\t\t \t "}, {"source_code": "Odd\n \t\t \t\t\n\t\t \t\t\t \n \t \t \t\n \t\t\t\t \t\t "}, {"source_code": "odd\n\t\t\t \t \t \t\n \t \t \t \n\t\t\t \t \t \n\t \t \t \t \t"}, {"source_code": "odd\n\t\t \t\t\t \t\t\n\t\t \t \t \n\t \t\t\t\t \t\t\n\t\t \t \t\t "}, {"source_code": "Odd\n \t\t \t\n\t \t\t\t\t \n\t\t \t\t \t\t \n \t \t\t \t"}, {"source_code": "black\n\t \t\t\t\t\t \t\n \t \t\t \t \t\n\t \t \t \n \t\t\t\t \t"}, {"source_code": "Red\n\n\t \t \t\t \n\t\t\t\t\t\t \t\t\t\n \t \t \t \n\t\t \t\t \t "}, {"source_code": "Red\n\n\t\t \t \t\t \t\n\t\t\t \t \t\t \n \t\t \t\t \t\n \t\t\t\t \t"}, {"source_code": "odd\n\t \t \t\t \t\t\t\n \t \t \n\t \t\n\t \t\t \t\t\t"}, {"source_code": "odd\n\t \t \t\t \t\n \t\t \t \t\t\n\t \t\t\t\t\t\t\t\t\n\t\t \t \t \t \t"}, {"source_code": "odd\n \t \t \t\t\t\n \t \t \n \t \t\t\t \n \t\t\t \t \t"}, {"source_code": "Red\n\t\t\t \t\t \t\n\t\t \t\t\t\t\t \n\t\t \t\t\t\t\n\t\t\t\t\t\t\t \t"}, {"source_code": "Red\n \t \t\t \t\n\t\t \t \t\t\t\n\t \t\t\t\t\t\t \n \t \t \t "}, {"source_code": "RED\n \t\t \t \n\t\t\t \t \t\t \n\t\t\t \t \t\t\n \t\t\t \t\t"}, {"source_code": "odd\n\t \t\t \t \t\n \t\t \t\t\t \n \t \n \t \t \t \t\t\t"}, {"source_code": "red\n\t \t \t \t \n\t \t \t\n\t \t\t \t\t\t\t\t\n \t\t\t "}, {"source_code": "red\n \t\t \t \n \t\t \t\n \t \t\t \n\t\t\t \t \t"}, {"source_code": "red\n \t\t\t \t \t \n\t \t \t\t\t \n \t\t \t\n\t\t\t \t\t\t \t "}, {"source_code": "odd\n\t\t \t\t \t \n \t \t\t\n\t\t \t \n \t\t \t \t\t"}, {"source_code": "Red\n \t\t\t \t \t \n \t\t\t \n\t \t \t \t \t\n \t\t\t \t \t\t "}, {"source_code": "red\n \t\t\t \t \n\t \t\t \t\t\t\t\n \t \t \t\t\t\t\n\t \t \t\t"}, {"source_code": "red\n \t\t \t \t \n \t \t \n \t \t\n\t \t\t \t"}, {"source_code": "Red\n \t \t \t \n \t\t\t\t \t \t\n \t \t \t\t\n \t\t\t\t \t\t"}, {"source_code": "Odd\n\t\t\t\t \t\t \t\n \t\t\t\t \t \n \t\t \t\t\t\t\t\t\n \t \t "}, {"source_code": "red\n \t \n \t\t\t\t \t\t \n \t \t\t \n\t \t\t \t \t"}, {"source_code": "odd\n\t\t\t\t\t \t\t\t \n \t\t \t\t\n \t \t\t\t\t\t\n\t \t \t\t\t\t "}, {"source_code": "black\n\t \t\t \t \n\t \t\t\t \t \t\n \t \t\t \t\n \t \t \t\t "}, {"source_code": "Red\n \t\t\t \t\t\t \t\n \t\t \t \t\n \t \t\t\t \t\n \t \t\t\t \t\t"}, {"source_code": "red\n\t\t\t \t\t \t \t\n \t \t \n \t \t\t \t\t\n\t \t \t \t \t"}, {"source_code": "even\n \t\t\t\t\t \t\t\n \t\t \t \t \t \n\t\t \t\t\t\t \n\t \t \t\t "}, {"source_code": "1 to 18\n \t\t \t \t \n\t\t \t \t \n \t\t\t\t\t\t \t\t\n \t\t"}, {"source_code": "red\n \t\n \t \t \n \t \n \t\t\t\t \t "}, {"source_code": "Even\n \t \t \t\t\t \n\t\t \t\t \n \t\t\t\t \t\t\n \t \t "}, {"source_code": "Odd\n \t \t \n \t \t \t\t \t\t\n \t \t \n\t \t\t\t\t \t\t"}, {"source_code": "even\n \t\t \t\t \t \n\t\t\t \t \t\t\n\t\t\t\t\t \t\t\t \n \t\t \t\t "}, {"source_code": "1 to 18\n \t \t\t \n\t\t\t\t \n\t\t\t \t \t \n \t\t \t \t"}, {"source_code": "Red\n \t \t\t \n\t \t\t\t \t\n \t\t\t\t \t\t \n\t\t\t \t\t\t\t"}, {"source_code": "black\n\t\t\t\t \t \t\n\t\t \t \t\n\t\t \t \t\n \t \t\t\t \t "}, {"source_code": "red\n \t \t\t\t \n\t\t\t\t\t \t\t\t \n \t \t\t\t \t \n\t \t\t\t \t "}, {"source_code": "even\n\t\t\t \t\t\t\t \t\n \t \t \t \t\t\n \t\t \t \t\t\t\n\t \t\t\t\t\t \t"}, {"source_code": "1 to 18\n\t\t\t \t\t\t\t\t\n\t\t \t\t\t \t\t\t\n \t\t \t \t \n\t \t\t\t\t "}, {"source_code": "Odd\n \t \t\t \n\t\t \t \t \n \t \t\t \t\t\t\t\n\t\t\t \t \t\t\t\t"}, {"source_code": "Red\n\t\t \t \n\t \t\t\t\t \t \n \t\t \t\t\t \n\t \t\t\t\t\t\t "}, {"source_code": "red\n\t \t \t \t \t \n \t\t \t\n \t \t\t \t\t\t \n \t\t \t\t\t "}], "negative_code": [{"source_code": "16\n \t \t \t \n \t \t \t \n \t\t \t\t \n\t \t\t\t\t\t\t\t"}, {"source_code": "Odd\n \t\t\t\t \t\t\t\t\n\t\t\t \t \t\t\n \t\t \t \t\t\n \t\t \t \t\t "}, {"source_code": "odd\n \t \t\t \t \n\t\t \t \t\t\n \t \t\t\n \t\t \t "}, {"source_code": "even\n\t\t\t\t \t\t \n \t \t\t \n\t\t \t \n\t \t\t \t\t\t"}, {"source_code": "odd\n \t\t \t \n\t\t\t\t \t \t \n \t \t\t\t\t\n\t\t \t\t\t\t "}, {"source_code": "red\n\t \t \t\n \t\t\n \t\t\t\n\t \t\t \t \t\t"}, {"source_code": "odd\n\t \t \t\t \n\t\t \t \t \t \t\n\t \t \t\t \t \n\t\t\t\t\t \t\t\t\t"}, {"source_code": "13\n \t \t \t \t\t\t\n\t\t \t \t\t\t \t\n\t \t\t \t \t \n\t\t\t \t \t \t\t"}, {"source_code": "27\n \t \t \n\t \t\t\t\t\t \t\t\n\t \t \t\t \t\n\t \t \t\t\t \t"}, {"source_code": "18\n\t\t \t \t \t\t\t\n\t\t\t\t\t \t\t \n\t \t\t\t \t \t\n \t \t \t \t"}, {"source_code": "Red\n \t\t \t\t\t\t\n \t \t \t\t \t\n\t\t \t\t \t\n\t \t\t\t\t \t"}, {"source_code": "Black\n \t \t\t\t\t \n\t\t \t \t\t\n\t \t\t\t\t\t\t \n \t\t\t \t \t\t"}, {"source_code": "18\n\t\t \t \t \t\t\t\n\t\t\t\t\t \t\t \n\t \t\t\t \t \t\n \t \t \t \t"}, {"source_code": "odd\n \t\t \n\t \t \t\t\n \t \t\t \n\t \t\t\t\t\t\t \t"}, {"source_code": "Red\n \t\t\t \t\t \t\n\t\t \t\t\t \n\t \t\t\t\t \t \t\n \t \t \t\t"}, {"source_code": "28\n\t \t\t \t\t\t\n\t\t \t\t\t\t \t\t\n\t\t\t\t\t \t\t \n \t\t \t\t"}, {"source_code": "18\n \t \t \t\t\t \n\t\t\t \t \t\t\t\n \t\t \t \t\n\t \t\t\t \t "}, {"source_code": "Odd\n\t\t\t\t\t \t \t\n\t \t\t \t\t\n\t\t \t \t\t\t\n \t \t \t"}, {"source_code": "34\n\t\t\t \t \t \t \n\t\t\t\t \t \t\n \t\t \t\t \n\t \t \t \t "}, {"source_code": "0\n \t\t\t\t\t \t\n\t \t\t\t \n \t \t \t \t\t\n\t\t\t \t\t\t\t\t "}, {"source_code": "Red\n \t\t \t \n\t\t\t\t \t\t\t \n \t\t \t \t\n \t \t \t\t\t"}, {"source_code": "8\n\t \t\t \n\t\t\t\t \t \t\t\n\t \t\t\t\t\t\t\n \t\t\t \t "}, {"source_code": "31\n\t\t \t \t \n\t\t \t \t \n \t\t \t\t\n\t \t \t"}, {"source_code": "2nd 12\n \t\t \t \t\n\t\t \t \t\n \t \t\t\n \t \t\t\t\t \t "}, {"source_code": "Odd\n\t\t\t\t \t\t\t\t\t\n\t\t \t \t\t \t\n \t \t\t \t \n\t \t \t\t\t\t\t\t"}, {"source_code": "10\n\t \t \t\n \t \t\t \t \t\n \t \t \t\t\n \t\t \t \t\t "}, {"source_code": "1\n \t\t\t \t \n \t \t \t\t\t\t\n\t \t \t \n \t\t \t\t \t"}, {"source_code": "32\n\t \t\t\t\n \t\t\t\t \n\t \t \t\t\t\n\t\t \t\t\t"}, {"source_code": "24\n\t \t \t\t\t\n \t\t \t \n \t\t \t\t \n \t\t \t "}, {"source_code": "odd\n\t\t\t\t \t\t\t\t\t\n \t\t\t \t \t\t\n \t\t \t \t\t\t \n \t\t\t \t \t"}, {"source_code": "27\n\t \t\t \n \t \t\t\t\t\t \n\t \t\t\t\t\t\t\n \t\t \t\t\t "}, {"source_code": "odd\n \t\t \n\t \t \t\t\n \t \t\t \n\t \t\t\t\t\t\t \t"}, {"source_code": "00\n\t\t\t\t\t \t \n \t \t\t \t\t \n\t \t \t\t\n\t \t\t \t\t \t\t"}, {"source_code": "28\n\t \t\t\t \t\n\t\t\t\t \t\t \t \n\t\t \t \t\t \t\n\t \t \t\t"}, {"source_code": "Odd\n\t\t\t\t\t \t \t\n\t \t\t \t\t\n\t\t \t \t\t\t\n \t \t \t"}, {"source_code": "2nd 12\n \t\t \t \t\n\t\t \t \t\n \t \t\t\n \t \t\t\t\t \t "}, {"source_code": "Red\n\n\t\t \t\t\t\t \t\n\t \t \t \t\n\t\t \t \t \t\n\t \t \t\t\t \t"}, {"source_code": "2\n\t \t\t\t\t \t\t\t\n \t\t \t \n \t\t \t \t\n \t \t\t\t "}, {"source_code": "\u00a31\n \t \t\t\t\t \n \t \t \t\n\t \t \t \t \t\n\t\t \t\t\t \t"}, {"source_code": "Red\n\n\t\t \t\t\t\t \t\n\t \t \t \t\n\t\t \t \t \t\n\t \t \t\t\t \t"}, {"source_code": "8\n\t \t\t \n\t\t\t\t \t \t\t\n\t \t\t\t\t\t\t\n \t\t\t \t "}, {"source_code": "000\n \t\t\t \t\t\n \t\t \t \t\n \t\t \t\t \n\t \t \t\t\t "}, {"source_code": "Kemot\n\t\t \t \t\t\n \t \t \t \n\t\t \t\t\t\t\n \t\t"}, {"source_code": "red\n \t \t\t\t\t \t \n \t\t \t \t \n\t\t\t\t \t\t\t\t \n \t\t \t\t\t\t\t\t"}, {"source_code": "Red\n\n\t \t\n \t \t \n \t \t \t \t \n \t \t\t\t "}, {"source_code": "1 to 36\n \t \t\t \n \t\t \t\t\n \t \t \n\t\t\t \t\t\t\t "}, {"source_code": "34\n\t\t\t \t \t \t \n\t\t\t\t \t \t\n \t\t \t\t \n\t \t \t \t "}, {"source_code": "0\n \t \t \t\t\n \t\t\t\t\t\t \n\t\t \t \t\t\t\n \t\t \t\t \t"}, {"source_code": "2\n\t \t \t \t \n\t\t \t\t \t\t \n\t\t \t \t \t\n \t \t"}, {"source_code": "Odd\n\t\t\t \t\t\t \t\n \t \t\n \t \t\t \n \t\t \t\t\t"}, {"source_code": "number\n \t \t\t \t\t \n \t \t\t \t \t\n\t\t\t\t\t\t \t \t\n\t\t \t \t "}, {"source_code": "Red\n \t \t \t \t \n \t\t \t\t \t\n\t \t\t\t \n\t \t \t\t "}, {"source_code": "odd\n\t\t\t\t \t\t \t\n \t \t\t\t\t\t \n\t \t\t \t\t\t\t\n\t \t\t\t\t\t "}, {"source_code": "1\n\t \t\t\t \t\n\t\t \t\t \t \t\n\t\t \t\t \t \t\n \t \t\t \t\t"}, {"source_code": "red\n\t\t\t \t \t\t\t\n \t \n \t \t\t\t \n \t\t\t\t\t\t"}, {"source_code": "even\n\t\t\t\t \t\t \n \t \t\t \n\t\t \t \n\t \t\t \t\t\t"}, {"source_code": "Even\n \t\t \t \t\n\t \t \t\t\t \n\t\t \t\t\t\t\t\t\t\n \t \t\t \t "}, {"source_code": "0.2\n \t\t\t \t \t\t\n\t \t\t \t \t\t \n \t \t\n\t \t\t \t"}, {"source_code": "2nd 12\n \t\t \t \t\n\t\t \t \t\n \t \t\t\n \t \t\t\t\t \t "}, {"source_code": "Black\n \t\t\t \t\t\t\t\t\n \t \t\t \t\t\n\t \t \t\t\t\t \n \t\t "}, {"source_code": "15\n\t\t \t\t\t\t\t\t\t\n\t \t\t\t \t\t\t\n\t \t\t \t\t\n\t\t \t \t\t\t\t"}, {"source_code": "33\n\t \t\t \t\t\t\n \t \t \n\t \t\t\t \t\t \n\t \t \t \t\t "}, {"source_code": "odd\n \t\t \n\t \t \t\t\n \t \t\t \n\t \t\t\t\t\t\t \t"}, {"source_code": "Red\n \t\t \t\t\n \t\t\t\t \t \n \t \t\t \t \t\t\n\t \t \t\t \t\t"}, {"source_code": "0\n \t \t\t\t \t\n \t \t\t \t\n\t\t\t \t\t \t\n \t \t\t \t"}, {"source_code": "Odd\n\t \t\t \t\t \n\t \t\t\t \n\t\t \t\n\t \t\t \t\t "}, {"source_code": "Odd\n\t \t\t\t\t \n\t\t \t \t \t\n\t \t \t\t\t \n\t \t \t "}, {"source_code": "odd\n \t\t\t\t\t \n\t \t \t\t\t \n \t \t\t\t \n\t\t \t\t \t \t"}, {"source_code": "Red\n\t\t\t\t\t \t\t \t\n \t\t \t\t\t \t \n \t \t\t\t \n \t\t \t \t\t"}, {"source_code": "Red\n\n \t\t\t\t \t\t \t\n \t\t \t\t \t\n\t\t \t \t\t\t\t\n \t\t \t \t "}, {"source_code": "Red\n\t \t \t \t\n \t\t \t\t\t \n \t\t\t \t\t \t\t\n\t \t \t\t \t\t"}, {"source_code": "12\n\t\t \t\t \t\t\n \t \t \t\t\t\t\t\n \t\t \t \t \n \t\t\t\t\t "}, {"source_code": "27\n\t \t\t \n \t \t\t\t\t\t \n\t \t\t\t\t\t\t\n \t\t \t\t\t "}, {"source_code": "Red\n \t\t\t\t \t \t\n \t\t\t\t \t\t\t\n\t \t\t \t\t\t\n \t\t \t "}, {"source_code": "odd\n \t \t\t\t \t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t \t\t\t \n\t\t \t\t "}, {"source_code": "Even\n \t \t\t\t\t \t\t\n\t \t \t\n \t\t \t \t\t \n \t \t\t\t "}, {"source_code": "Red\n\t\t\t\t \t \t\t\n\t\t\t\t\t \t \t\t\n\t \t\t\t\t\t \t\t\n \t\t "}, {"source_code": "2 to 1\n\t\t\t\t\t\t\t \n\t\t\t \t\t\t\t \n\t \t \t\t \n\t\t \t \t\t\t\t"}, {"source_code": "1\n\t\t\t \t \n \t\t\t \t\t\t\t\n \t \t\t \t\n\t \t \t \t"}, {"source_code": "odd\n \t \t\t \t \n\t\t \t \t\t\n \t \t\t\n \t\t \t "}, {"source_code": "Red\n \t \t \t \t\n \t\t \t \t \n \t \t\t\t\t\t\n \t\t \t\t\t\t"}, {"source_code": "odd\n\t \t\t\t\t \t \n \t \t \t \t\t\t\n \t\t\t \n \t \t \t\t\t"}, {"source_code": "even\n\t\t\t\t \t\t \t\n \t\t\t \t\n\t \t\t\t \n \t\t\t\t \t\t\t"}, {"source_code": "red\n \t \t\t\t \t\n \t\t \t\t \n\t \t\t\t \t\t\n\t \t \t \t "}, {"source_code": "Red\n\t \t \t\t\t\t\t\n \t\t\t \t\t\t \n\t\t\t\t\t\t\t\t\t\t\n \t \t \t\t\t "}, {"source_code": "1 to 35\n\t \t \t \t\t\n\t \t \t\t\t\t \n \t \t \n\t \t \t \t\t\t\t"}, {"source_code": "Positive\n\t \t \t\t \t\t\n\t\t \t \t \t \n \t\t\t\t \t \t\t\n\t\t \t\t\t\t "}, {"source_code": "31\n\t\t\t \t\t\t\n \t \t\t\t \t\t\n\t\t\t\t\t\t \t \n \t\t\t \t\t\t "}, {"source_code": "Red\n\n\t \t\t \t\n \t \t \t\n\t \t \t\t \t\n \t\t \t\t\t\t "}, {"source_code": "13\n \t\t\t \t \t\n\t\t \t \t\t\t \n \t \t \t\n\t \t \t \t "}, {"source_code": "2\n \t\t\t \t \t\n\t \t\t\t \t \n\t\t\t\t\t \t \t\t\n \t\t\t\t\t "}, {"source_code": "Even\n \t \t\t\t\t \t\t\n\t \t \t\n \t\t \t \t\t \n \t \t\t\t "}, {"source_code": "black\n \t \t \t \t\n\t \t\t\t\t\t \t\t\n \t\t \t \n\t\t\t \t\t \t"}, {"source_code": "27\n\t \t\t \n \t \t\t\t\t\t \n\t \t\t\t\t\t\t\n \t\t \t\t\t "}, {"source_code": "Black\n \t\t\t \t\t\t\t\t\n \t \t\t \t\t\n\t \t \t\t\t\t \n \t\t "}, {"source_code": "red\n\t\t\t \t \t\t \t\n \t \t\t\t \t \n\t\t\t \t \t \t\n\t\t \t\t \t \t"}, {"source_code": "Red\n \t \t \t \t\n \t \t \t\t\t\n\t \t \n\t \t\t\t \t"}, {"source_code": "12\n\t \t \t\t\n \t \t\t \n\t \t\t \t \n\t \t \t\t \t "}, {"source_code": "even\n \t\t \n \t\t\t \n \t \t \n\t\t\t \t \t \t"}, {"source_code": "red\n \t\t \t \t\t \n \t \t\t \t\n \t\t \n\t\t \t \t \t"}], "src_uid": "f2a71cb9706b76317f2f442a9129055f"} {"nl": {"description": "This is an interactive problem.I want to play a game with you...We hid from you a cyclic graph of $$$n$$$ vertices ($$$3 \\le n \\le 10^{18}$$$). A cyclic graph is an undirected graph of $$$n$$$ vertices that form one cycle. Each vertex belongs to the cycle, i.e. the length of the cycle (the number of edges in it) is exactly $$$n$$$. The order of the vertices in the cycle is arbitrary.You can make queries in the following way: \"? a b\" where $$$1 \\le a, b \\le 10^{18}$$$ and $$$a \\neq b$$$. In response to the query, the interactor outputs on a separate line the length of random of two paths from vertex $$$a$$$ to vertex $$$b$$$, or -1 if $$$\\max(a, b) > n$$$. The interactor chooses one of the two paths with equal probability. The length of the path\u00a0\u2014is the number of edges in it.You win if you guess the number of vertices in the hidden graph (number $$$n$$$) by making no more than $$$50$$$ queries.Note that the interactor is implemented in such a way that for any ordered pair $$$(a, b)$$$, it always returns the same value for query \"? a b\", no matter how many such queries. Note that the \"? b a\" query may be answered differently by the interactor.The vertices in the graph are randomly placed, and their positions are fixed in advance.Hacks are forbidden in this problem. The number of tests the jury has is $$$50$$$.", "input_spec": null, "output_spec": null, "sample_inputs": ["1\n\n2\n\n-1"], "sample_outputs": ["? 1 2\n\n? 1 3\n\n? 1 4\n\n! 3"], "notes": "NoteIn the first example, the graph could look like this The lengths of the simple paths between all pairs of vertices in this case are $$$1$$$ or $$$2$$$. The first query finds out that one of the simple paths from vertex $$$1$$$ to vertex $$$2$$$ has a length of $$$1$$$. With the second query, we find out that one of the simple paths from vertex $$$1$$$ to vertex $$$3$$$ has length $$$2$$$. In the third query, we find out that vertex $$$4$$$ is not in the graph. Consequently, the size of the graph is $$$3$$$. "}, "positive_code": [{"source_code": ""}, {"source_code": "0; $j--){\n $count += 1/$j;\n}\necho $count;"}], "negative_code": [], "src_uid": "260666df22ee510fcce3ebdfbb8b71a2"} {"nl": {"description": "You are given three strings $$$a$$$, $$$b$$$ and $$$c$$$ of the same length $$$n$$$. The strings consist of lowercase English letters only. The $$$i$$$-th letter of $$$a$$$ is $$$a_i$$$, the $$$i$$$-th letter of $$$b$$$ is $$$b_i$$$, the $$$i$$$-th letter of $$$c$$$ is $$$c_i$$$.For every $$$i$$$ ($$$1 \\leq i \\leq n$$$) you must swap (i.e. exchange) $$$c_i$$$ with either $$$a_i$$$ or $$$b_i$$$. So in total you'll perform exactly $$$n$$$ swap operations, each of them either $$$c_i \\leftrightarrow a_i$$$ or $$$c_i \\leftrightarrow b_i$$$ ($$$i$$$ iterates over all integers between $$$1$$$ and $$$n$$$, inclusive).For example, if $$$a$$$ is \"code\", $$$b$$$ is \"true\", and $$$c$$$ is \"help\", you can make $$$c$$$ equal to \"crue\" taking the $$$1$$$-st and the $$$4$$$-th letters from $$$a$$$ and the others from $$$b$$$. In this way $$$a$$$ becomes \"hodp\" and $$$b$$$ becomes \"tele\".Is it possible that after these swaps the string $$$a$$$ becomes exactly the same as the string $$$b$$$?", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$) \u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains a string of lowercase English letters $$$a$$$. The second line of each test case contains a string of lowercase English letters $$$b$$$. The third line of each test case contains a string of lowercase English letters $$$c$$$. It is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding $$$100$$$.", "output_spec": "Print $$$t$$$ lines with answers for all test cases. For each test case: If it is possible to make string $$$a$$$ equal to string $$$b$$$ print \"YES\" (without quotes), otherwise print \"NO\" (without quotes). You can print either lowercase or uppercase letters in the answers.", "sample_inputs": ["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim"], "sample_outputs": ["NO\nYES\nYES\nNO"], "notes": "NoteIn the first test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$.In the second test case, you should swap $$$c_i$$$ with $$$a_i$$$ for all possible $$$i$$$. After the swaps $$$a$$$ becomes \"bca\", $$$b$$$ becomes \"bca\" and $$$c$$$ becomes \"abc\". Here the strings $$$a$$$ and $$$b$$$ are equal.In the third test case, you should swap $$$c_1$$$ with $$$a_1$$$, $$$c_2$$$ with $$$b_2$$$, $$$c_3$$$ with $$$b_3$$$ and $$$c_4$$$ with $$$a_4$$$. Then string $$$a$$$ becomes \"baba\", string $$$b$$$ becomes \"baba\" and string $$$c$$$ becomes \"abab\". Here the strings $$$a$$$ and $$$b$$$ are equal.In the fourth test case, it is impossible to do the swaps so that string $$$a$$$ becomes exactly the same as string $$$b$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " $v){\n if($v != $a[$k] && $v != $b[$k]){\n $bool = false;\n }\n }\n if($bool){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n}\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": " 0; $t --){\n //print pow(2, intval(fgets(STDIN)) - 1).\"\\n\";\n list($n, $a, $b, $c, $d) = explode(\" \", trim(fgets(STDIN)));\n\n\n\n if($n * ($a - $b) > $c + $d || $n * ($a + $b) < $c - $d)\n print(\"NO\\n\");\n\n else\n print(\"YES\\n\");\n\n\n\n\n}\n\n\n"}, {"source_code": " $tmp_d) echo \"NO\" . \"\\n\" ;\n else if($tmp_c > $tmp_b) echo \"NO\".\"\\n\" ;\n else echo \"YES\".\"\\n\" ;\n }\n?>"}, {"source_code": "\n"}], "negative_code": [{"source_code": " 0; $t --){\n //print pow(2, intval(fgets(STDIN)) - 1).\"\\n\";\n list($n, $a, $b, $c, $d) = explode(\" \", trim(fgets(STDIN)));\n $flag = 0;\n\n for($i = $a - $b; $i <= $a + $b; $i++){\n if($n * $i >= $c - $d && $n * $i <= $c + $d)\n $flag = 1;\n }\n\n if($flag)\n print(\"YES\\n\");\n\n else\n print(\"NO\\n\");\n\n\n\n\n}\n\n\n"}, {"source_code": " $tmp_d) echo \"NO\" . \"\\n\" ;\n else if($tmp_c > $tmp_b) echo \"NO\".\"\\n\" ;\n else echo \"YES\".\"\\n\" ;\n }\n?>"}, {"source_code": "\n"}, {"source_code": "\n"}], "src_uid": "30cfce44a7a0922929fbe54446986748"} {"nl": {"description": "To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the buying and the selling are made only once. To carry out his plan, Qwerty is going to take a bank loan that covers all expenses and to return the loaned money at the end of the operation (the money is returned without the interest). At the same time, Querty wants to get as much profit as possible.The system has n planets in total. On each of them Qwerty can buy or sell items of m types (such as food, medicine, weapons, alcohol, and so on). For each planet i and each type of items j Qwerty knows the following: aij \u2014 the cost of buying an item; bij \u2014 the cost of selling an item; cij \u2014 the number of remaining items.It is not allowed to buy more than cij items of type j on planet i, but it is allowed to sell any number of items of any kind.Knowing that the hold of Qwerty's ship has room for no more than k items, determine the maximum profit which Qwerty can get.", "input_spec": "The first line contains three space-separated integers n, m and k (2\u2009\u2264\u2009n\u2009\u2264\u200910, 1\u2009\u2264\u2009m,\u2009k\u2009\u2264\u2009100) \u2014 the number of planets, the number of question types and the capacity of Qwerty's ship hold, correspondingly. Then follow n blocks describing each planet. The first line of the i-th block has the planet's name as a string with length from 1 to 10 Latin letters. The first letter of the name is uppercase, the rest are lowercase. Then in the i-th block follow m lines, the j-th of them contains three integers aij, bij and cij (1\u2009\u2264\u2009bij\u2009<\u2009aij\u2009\u2264\u20091000, 0\u2009\u2264\u2009cij\u2009\u2264\u2009100) \u2014 the numbers that describe money operations with the j-th item on the i-th planet. The numbers in the lines are separated by spaces. It is guaranteed that the names of all planets are different.", "output_spec": "Print a single number \u2014 the maximum profit Qwerty can get.", "sample_inputs": ["3 3 10\nVenus\n6 5 3\n7 6 5\n8 6 10\nEarth\n10 9 0\n8 6 4\n10 9 3\nMars\n4 3 0\n8 4 12\n7 2 5"], "sample_outputs": ["16"], "notes": "NoteIn the first test case you should fly to planet Venus, take a loan on 74 units of money and buy three items of the first type and 7 items of the third type (3\u00b76\u2009+\u20097\u00b78\u2009=\u200974). Then the ranger should fly to planet Earth and sell there all the items he has bought. He gets 3\u00b79\u2009+\u20097\u00b79\u2009=\u200990 units of money for the items, he should give 74 of them for the loan. The resulting profit equals 16 units of money. We cannot get more profit in this case."}, "positive_code": [{"source_code": " 0)\n {\n $o -= $k[$n[$z]][2];\n if($o < 0)\n {\n $o += $k[$n[$z]][2];\n $p += $l[$z] * $o;\n break;\n }\n elseif($o == 0)\n {\n $p += $l[$z] * $k[$n[$z]][2];\n break;\n }\n elseif($o > 0)\n {\n $p += $l[$z] * $k[$n[$z]][2];\n }\n }\n else\n {\n break;\n }\n }\n array_push($j, $p);\n }\n }\n}\nprint max($j);\n?>"}], "negative_code": [{"source_code": " 0)\n {\n $o -= $k[$n[$z]][2];\n if($o < 0)\n {\n $o += $k[$n[$z]][2];\n $p += $l[$z] * $o;\n break;\n }\n elseif($o == 0)\n {\n break;\n }\n elseif($o > 0)\n {\n $p += $l[$z] * $k[$n[$z]][2];\n }\n }\n else\n {\n break;\n }\n }\n array_push($j, $p);\n }\n }\n}\nprint max($j);\n?>"}, {"source_code": " 0)\n {\n $o -= $k[$n[$z]][2];\n if($o < 0)\n {\n $o += $k[$n[$z]][2];\n $p += $l[$z] * $o;\n break;\n }\n elseif($o == 0)\n {\n break;\n }\n elseif($o > 0)\n {\n $p += $l[$z] * $k[$n[$z]][2];\n }\n }\n else\n {\n break;\n }\n }\n array_push($j, $p);\n }\n }\n}\nprint max($j);\n?>"}], "src_uid": "7419c4268a9815282fadca6581f28ec1"} {"nl": {"description": "An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons \u2014 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct record of a IPv6 address: \"0124:5678:90ab:cdef:0124:5678:90ab:cdef\". We'll call such format of recording an IPv6-address full.Besides the full record of an IPv6 address there is a short record format. The record of an IPv6 address can be shortened by removing one or more leading zeroes at the beginning of each block. However, each block should contain at least one digit in the short format. For example, the leading zeroes can be removed like that: \"a56f:00d3:0000:0124:0001:f19a:1000:0000\" \u2009\u2192\u2009 \"a56f:d3:0:0124:01:f19a:1000:00\". There are more ways to shorten zeroes in this IPv6 address.Some IPv6 addresses contain long sequences of zeroes. Continuous sequences of 16-bit zero blocks can be shortened to \"::\". A sequence can consist of one or several consecutive blocks, with all 16 bits equal to 0. You can see examples of zero block shortenings below: \"a56f:00d3:0000:0124:0001:0000:0000:0000\" \u2009\u2192\u2009 \"a56f:00d3:0000:0124:0001::\"; \"a56f:0000:0000:0124:0001:0000:1234:0ff0\" \u2009\u2192\u2009 \"a56f::0124:0001:0000:1234:0ff0\"; \"a56f:0000:0000:0000:0001:0000:1234:0ff0\" \u2009\u2192\u2009 \"a56f:0000::0000:0001:0000:1234:0ff0\"; \"a56f:00d3:0000:0124:0001:0000:0000:0000\" \u2009\u2192\u2009 \"a56f:00d3:0000:0124:0001::0000\"; \"0000:0000:0000:0000:0000:0000:0000:0000\" \u2009\u2192\u2009 \"::\". It is not allowed to shorten zero blocks in the address more than once. This means that the short record can't contain the sequence of characters \"::\" more than once. Otherwise, it will sometimes be impossible to determine the number of zero blocks, each represented by a double colon.The format of the record of the IPv6 address after removing the leading zeroes and shortening the zero blocks is called short.You've got several short records of IPv6 addresses. Restore their full record.", "input_spec": "The first line contains a single integer n \u2014 the number of records to restore (1\u2009\u2264\u2009n\u2009\u2264\u2009100). Each of the following n lines contains a string \u2014 the short IPv6 addresses. Each string only consists of string characters \"0123456789abcdef:\". It is guaranteed that each short address is obtained by the way that is described in the statement from some full IPv6 address.", "output_spec": "For each short IPv6 address from the input print its full record on a separate line. Print the full records for the short IPv6 addresses in the order, in which the short records follow in the input.", "sample_inputs": ["6\na56f:d3:0:0124:01:f19a:1000:00\na56f:00d3:0000:0124:0001::\na56f::0124:0001:0000:1234:0ff0\na56f:0000::0000:0001:0000:1234:0ff0\n::\n0ea::4d:f4:6:0"], "sample_outputs": ["a56f:00d3:0000:0124:0001:f19a:1000:0000\na56f:00d3:0000:0124:0001:0000:0000:0000\na56f:0000:0000:0124:0001:0000:1234:0ff0\na56f:0000:0000:0000:0001:0000:1234:0ff0\n0000:0000:0000:0000:0000:0000:0000:0000\n00ea:0000:0000:0000:004d:00f4:0006:0000"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "20f69ee5f04c8cbb769be3ab646031ab"} {"nl": {"description": "Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told \"no genome, no degree\". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.Dwarf Misha has already chosen the subject for his thesis: determining by two dwarven genomes, whether they belong to the same race. Two dwarves belong to the same race if we can swap two characters in the first dwarf's genome and get the second dwarf's genome as a result. Help Dwarf Misha and find out whether two gnomes belong to the same race or not.", "input_spec": "The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters. The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters. The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that correspond to the genomes are different. The given genomes may have different length.", "output_spec": "Print \"YES\", if the dwarves belong to the same race. Otherwise, print \"NO\".", "sample_inputs": ["ab\nba", "aa\nab"], "sample_outputs": ["YES", "NO"], "notes": "Note First example: you can simply swap two letters in string \"ab\". So we get \"ba\". Second example: we can't change string \"aa\" into string \"ab\", because \"aa\" does not contain letter \"b\". "}, "positive_code": [{"source_code": ""}, {"source_code": " $v)\n{\n\tif($v !== $rb[$i])\n\t{\n\t\t$cnt++;\n\t\t$difs[] = $i;\n\t}\n}\n\nif($cnt === 0)\n\tdie(\"YES\\n\");\n\nif($cnt === 2)\n{\n\tif($ra[$difs[0]] === $rb[$difs[1]] && $rb[$difs[0]] === $ra[$difs[1]])\n\t\tdie(\"YES\\n\");\n}\n\ndie(\"NO\\n\");\n\n?>\n"}, {"source_code": "2)\n {\n \t//$flag=1;\n \t//echo \"NO\";\n \tbreak;\n }\n } \n}\n\n\n\nif($count==2&&$a[1]==$b[0]&&$a[0]==$b[1])\n\techo \"YES\\n\";\nelse\n\techo \"NO\";\n\n\n}\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n /* for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n\n?>"}], "negative_code": [{"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n "}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n"}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>"}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>"}, {"source_code": "(strlen($max_substring))) {\n $max_substring = $current_substr;\n }\n $number_correct++;\n }\n // if(($flag_correct==0)&&($start_string{$i}==\")\")) {\n // $str_end = $i+1;\n // $current_substr = substr($start_string, $str_begin, $str_end-$str_begin);\n // // echo $current_substr.\"\\n\";\n // // echo $str_begin.\"\\n\";\n // // echo $str_end.\"\\n\";\n // // echo \"---------------\\n\";\n // if(strlen($current_substr)>strlen($max_substring)) {\n // $max_substring = $current_substr;\n // }\n // //echo $max_substring.\"\\n\";\n // $str_begin = $i;\n // $number_correct++;\n // }\n // // // elseif(($flag_correct==1)&&($i==0)) {\n // // // $str_begin = $i;\n // // // }\n // elseif($flag_correct==0) {\n // $str_begin = $i;\n // }\n // elseif($flag_correct<0) {\n // $flag_correct=0;\n // //continue;\n // }\n }\n \n if($number_correct>0) {\n echo $max_substring.\" \".$number_correct.\"\\n\";\n }\n else {\n echo \"0 1\\n\";\n }\n fclose($stdin);\n?>"}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n"}, {"source_code": "$cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n"}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>"}, {"source_code": "$cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) {\n $cur_max_len = $cur_len-1;\n $numb_such=1;\n }\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n"}, {"source_code": "$cur_max_len) $cur_max_len = $cur_len-1;\n if(($cur_len-1)>0) $numb_correct++;\n $cur_len = 0;\n $open=0;\n }\n }\n if($cur_max_len==0) $numb_correct=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_correct);\n?>\n"}, {"source_code": "$cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if(($cur_max_len!=0)&&($numb_such==0)) $numb_such=1;\n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>"}, {"source_code": "$cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n \n if($open>0){\n for($i=0;$i $cur_max_len) $cur_max_len = $cur_len-1;\n else if(($cur_len-1) == $cur_max_len) $numb_such++;\n $cur_len = 0;\n $open=0;\n }\n }\n }\n \n if($cur_max_len==0) $numb_such=1;\n fputs($stdout, $cur_max_len . \" \" . $numb_such);\n?>\n"}], "src_uid": "91c3af92731cd7d406674598c0dcbbbc"} {"nl": {"description": "A bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For example, bracket sequences \"()()\" and \"(())\" are regular (the resulting expressions are: \"(1)+(1)\" and \"((1+1)+1)\"), and \")(\", \"(\" and \")\" are not.You are given an integer $$$n$$$. Your goal is to construct and print exactly $$$n$$$ different regular bracket sequences of length $$$2n$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 50$$$) \u2014 the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \\le n \\le 50$$$).", "output_spec": "For each test case, print $$$n$$$ lines, each containing a regular bracket sequence of length exactly $$$2n$$$. All bracket sequences you output for a testcase should be different (though they may repeat in different test cases). If there are multiple answers, print any of them. It can be shown that it's always possible.", "sample_inputs": ["3\n3\n1\n3"], "sample_outputs": ["()()()\n((()))\n(()())\n()\n((()))\n(())()\n()(())"], "notes": null}, "positive_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function factorial($number)\r\n {\r\n $factorial = 1;\r\n for ($i = 1; $i <= $number; $i++){\r\n $factorial = $factorial * $i;\r\n }\r\n return $factorial;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n for ($i = 1; $i <= $n; $i++) {\r\n $str = $str2 = '';\r\n for ($j = 0; $j < $i; $j++) {\r\n $str .= '(';\r\n $str2 .= ')';\r\n }\r\n $r = $str . $str2;\r\n for ($x = 0; $x < $n - $i; $x++) {\r\n $r .= '()';\r\n }\r\n IO::line($r);\r\n }\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [], "src_uid": "27b73a87fc30c77abb55784e2e1fde38"} {"nl": {"description": "A permutation p of size n is the sequence p1,\u2009p2,\u2009...,\u2009pn, consisting of n distinct integers, each of them is from 1 to n (1\u2009\u2264\u2009pi\u2009\u2264\u2009n).A lucky permutation is such permutation p, that any integer i (1\u2009\u2264\u2009i\u2009\u2264\u2009n) meets this condition ppi\u2009=\u2009n\u2009-\u2009i\u2009+\u20091.You have integer n. Find some lucky permutation p of size n.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the required permutation size.", "output_spec": "Print \"-1\" (without the quotes) if the lucky permutation p of size n doesn't exist. Otherwise, print n distinct integers p1,\u2009p2,\u2009...,\u2009pn (1\u2009\u2264\u2009pi\u2009\u2264\u2009n) after a space \u2014 the required permutation. If there are multiple answers, you can print any of them.", "sample_inputs": ["1", "2", "4", "5"], "sample_outputs": ["1", "-1", "2 4 1 3", "2 5 3 1 4"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " 1){\n\t\techo -1; die;\n\t}\n\tif($n % 2 == 1)\n\t\t$a[floor($n / 2)] = floor($n / 2);\t \n\tfor($i = 0; $i < floor($n / 2); $i += 2){\n\t\t$a[$i] = $i + 1;\n\t\t$a[$i + 1] = $n - $i - 1;\n\t\t$a[$n - $i - 1] = $n - $i - 2;\n\t\t$a[$n - $i - 2] = $i;\n\t}\n\tfor($i = 0; $i < $n; $i++) echo ($a[$i] + 1).' ';\n?>\n"}], "negative_code": [], "src_uid": "dfca19b36c1d682ee83224a317e495e9"} {"nl": {"description": "This is an easy version of the problem. The only difference between an easy and a hard version is the constraints on $$$a$$$, $$$b$$$, $$$c$$$ and $$$d$$$.You are given $$$4$$$ positive integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ with $$$a < c$$$ and $$$b < d$$$. Find any pair of numbers $$$x$$$ and $$$y$$$ that satisfies the following conditions: $$$a < x \\leq c$$$, $$$b < y \\leq d$$$, $$$x \\cdot y$$$ is divisible by $$$a \\cdot b$$$.Note that required $$$x$$$ and $$$y$$$ may not exist.", "input_spec": "The first line of the input contains a single integer $$$t$$$ $$$(1 \\leq t \\leq 10$$$), the number of test cases. The descriptions of the test cases follow. The only line of each test case contains four integers $$$a$$$, $$$b$$$, $$$c$$$ and $$$d$$$ ($$$1 \\leq a < c \\leq 10^5$$$, $$$1 \\leq b < d \\leq 10^5$$$).", "output_spec": "For each test case print a pair of numbers $$$a < x \\leq c$$$ and $$$b < y \\leq d$$$ such that $$$x \\cdot y$$$ is divisible by $$$a \\cdot b$$$. If there are multiple answers, print any of them. If there is no such pair of numbers, then print -1 -1.", "sample_inputs": ["5\n\n1 1 2 2\n\n3 4 5 7\n\n8 9 15 18\n\n12 21 14 24\n\n36 60 48 66"], "sample_outputs": ["2 2\n4 6\n12 12\n-1 -1\n-1 -1"], "notes": null}, "positive_code": [{"source_code": " $v){\r\n if(isset($primesum[$k])){\r\n $primesum[$k] += $v;\r\n }else {\r\n $primesum[$k] = $v;\r\n }\r\n }\r\n $gp = [];\r\n foreach($primesum as $k => $v){\r\n $gp[] = [$k,$v];\r\n }\r\n $ptn = [];\r\n func(1,1,0);\r\n $ok = false;\r\n for($j=0;$j >\".$x.\" \".$y.PHP_EOL;\r\n if($x <= $a){\r\n $e = intdiv($a+$x, $x);\r\n $x *= $e;\r\n }\r\n if($y <= $b){\r\n $e = intdiv($b+$y, $y);\r\n $y *= $e;\r\n }\r\n //echo \">\".$x.\" \".$y.PHP_EOL;\r\n if($x > $c) continue;\r\n if($y > $d) continue;\r\n $ans[] = $x.\" \".$y;\r\n $ok=true;\r\n break;\r\n }\r\n if(!$ok) $ans[] = \"-1 -1\";\r\n}\r\n\r\necho implode(PHP_EOL,$ans);\r\n\r\nfunction func($x, $y, $i){\r\n global $gp, $ptn;\r\n if($i == count($gp)){\r\n $ptn[] = [$x,$y];\r\n return;\r\n }\r\n $p = $gp[$i][0];\r\n $cnt = $gp[$i][1];\r\n for($j=0;$j<=$cnt;$j++){\r\n func($x*pow($p,$j),$y*pow($p,$cnt-$j),$i+1);\r\n }\r\n}\r\n\r\n//--------------------------------\r\n// $n \u306b\u3064\u3044\u3066\u7d20\u56e0\u6570\u5206\u89e3\u3092\u3059\u308b\r\n// \u623b\u308a\u5024\uff1a\u9023\u60f3\u914d\u5217\uff08\u30ad\u30fc\u306f\u7d20\u6570\u3001\u5024\u306f\u500b\u6570\uff09\r\n// --\u4f8b1--------------------------\r\n// $n = 16\r\n// $return = [2 => 4]\r\n// --\u4f8b2--------------------------\r\n// $n = 24\r\n// $return = [2 => 3, 3 => 1]\r\n//--------------------------------\r\nfunction factorize($n){\r\n $res = [];\r\n for($i=2; $i*$i<=$n; $i++){\r\n if($n % $i != 0) continue;\r\n $res[$i]=0;\r\n while($n % $i == 0){ \r\n $res[$i]++;\r\n $n /= $i;\r\n }\r\n }\r\n if($n != 1){\r\n $res[$n]=1;\r\n }\r\n return $res;\r\n }\r\n "}], "negative_code": [], "src_uid": "84c60293d487e2c2ecee38a2fcf63b10"} {"nl": {"description": "Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sending it to the magazine 2Char, he needs to adapt the text to the format of the journal. To do so, he removes some words from the chosen article, in such a way that the remaining text can be written using no more than two distinct letters.Since the payment depends from the number of non-space characters in the article, Andrew wants to keep the words with the maximum total length.", "input_spec": "The first line of the input contains number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of words in the article chosen by Andrew. Following are n lines, each of them contains one word. All the words consist only of small English letters and their total length doesn't exceed 1000. The words are not guaranteed to be distinct, in this case you are allowed to use a word in the article as many times as it appears in the input.", "output_spec": "Print a single integer\u00a0\u2014 the maximum possible total length of words in Andrew's article.", "sample_inputs": ["4\nabb\ncacc\naaa\nbbb", "5\na\na\nbcbcb\ncdecdecdecdecdecde\naaaa"], "sample_outputs": ["9", "6"], "notes": "NoteIn the first sample the optimal way to choose words is {'abb', 'aaa', 'bbb'}.In the second sample the word 'cdecdecdecdecdecde' consists of three distinct letters, and thus cannot be used in the article. The optimal answer is {'a', 'a', 'aaaa'}."}, "positive_code": [{"source_code": " 2)\n {\n unset($b[$x]);\n }\n}\nsort($b);\n$f = array(\"a\" => 0, \"b\" => 0, \"c\" => 0, \"d\" => 0, \"e\" => 0, \"f\" => 0, \"g\" => 0, \"h\" => 0, \"i\" => 0, \"j\" => 0, \"k\" => 0, \"l\" => 0, \"m\" => 0, \"n\" => 0, \"o\" => 0, \"p\" => 0, \"q\" => 0, \"r\" => 0, \"s\" => 0, \"t\" => 0, \"u\" => 0, \"v\" => 0, \"w\" => 0, \"x\" => 0, \"y\" => 0, \"z\" => 0, \"ab\" => 0, \"ac\" => 0, \"ad\" => 0, \"ae\" => 0, \"af\" => 0, \"ag\" => 0, \"ah\" => 0, \"ai\" => 0, \"aj\" => 0, \"ak\" => 0, \"al\" => 0, \"am\" => 0, \"an\" => 0, \"ao\" => 0, \"ap\" => 0, \"aq\" => 0, \"ar\" => 0, \"as\" => 0, \"at\" => 0, \"au\" => 0, \"av\" => 0, \"aw\" => 0, \"ax\" => 0, \"ay\" => 0, \"az\" => 0, \"bc\" => 0, \"bd\" => 0, \"be\" => 0, \"bf\" => 0, \"bg\" => 0, \"bh\" => 0, \"bi\" => 0, \"bj\" => 0, \"bk\" => 0, \"bl\" => 0, \"bm\" => 0, \"bn\" => 0, \"bo\" => 0, \"bp\" => 0, \"bq\" => 0, \"br\" => 0, \"bs\" => 0, \"bt\" => 0, \"bu\" => 0, \"bv\" => 0, \"bw\" => 0, \"bx\" => 0, \"by\" => 0, \"bz\" => 0, \"cd\" => 0, \"ce\" => 0, \"cf\" => 0, \"cg\" => 0, \"ch\" => 0, \"ci\" => 0, \"cj\" => 0, \"ck\" => 0, \"cl\" => 0, \"cm\" => 0, \"cn\" => 0, \"co\" => 0, \"cp\" => 0, \"cq\" => 0, \"cr\" => 0, \"cs\" => 0, \"ct\" => 0, \"cu\" => 0, \"cv\" => 0, \"cw\" => 0, \"cx\" => 0, \"cy\" => 0, \"cz\" => 0, \"de\" => 0, \"df\" => 0, \"dg\" => 0, \"dh\" => 0, \"di\" => 0, \"dj\" => 0, \"dk\" => 0, \"dl\" => 0, \"dm\" => 0, \"dn\" => 0, \"do\" => 0, \"dp\" => 0, \"dq\" => 0, \"dr\" => 0, \"ds\" => 0, \"dt\" => 0, \"du\" => 0, \"dv\" => 0, \"dw\" => 0, \"dx\" => 0, \"dy\" => 0, \"dz\" => 0, \"ef\" => 0, \"eg\" => 0, \"eh\" => 0, \"ei\" => 0, \"ej\" => 0, \"ek\" => 0, \"el\" => 0, \"em\" => 0, \"en\" => 0, \"eo\" => 0, \"ep\" => 0, \"eq\" => 0, \"er\" => 0, \"es\" => 0, \"et\" => 0, \"eu\" => 0, \"ev\" => 0, \"ew\" => 0, \"ex\" => 0, \"ey\" => 0, \"ez\" => 0, \"fg\" => 0, \"fh\" => 0, \"fi\" => 0, \"fj\" => 0, \"fk\" => 0, \"fl\" => 0, \"fm\" => 0, \"fn\" => 0, \"fo\" => 0, \"fp\" => 0, \"fq\" => 0, \"fr\" => 0, \"fs\" => 0, \"ft\" => 0, \"fu\" => 0, \"fv\" => 0, \"fw\" => 0, \"fx\" => 0, \"fy\" => 0, \"fz\" => 0, \"gh\" => 0, \"gi\" => 0, \"gj\" => 0, \"gk\" => 0, \"gl\" => 0, \"gm\" => 0, \"gn\" => 0, \"go\" => 0, \"gp\" => 0, \"gq\" => 0, \"gr\" => 0, \"gs\" => 0, \"gt\" => 0, \"gu\" => 0, \"gv\" => 0, \"gw\" => 0, \"gx\" => 0, \"gy\" => 0, \"gz\" => 0, \"hi\" => 0, \"hj\" => 0, \"hk\" => 0, \"hl\" => 0, \"hm\" => 0, \"hn\" => 0, \"ho\" => 0, \"hp\" => 0, \"hq\" => 0, \"hr\" => 0, \"hs\" => 0, \"ht\" => 0, \"hu\" => 0, \"hv\" => 0, \"hw\" => 0, \"hx\" => 0, \"hy\" => 0, \"hz\" => 0, \"ij\" => 0, \"ik\" => 0, \"il\" => 0, \"im\" => 0, \"in\" => 0, \"io\" => 0, \"ip\" => 0, \"iq\" => 0, \"ir\" => 0, \"is\" => 0, \"it\" => 0, \"iu\" => 0, \"iv\" => 0, \"iw\" => 0, \"ix\" => 0, \"iy\" => 0, \"iz\" => 0, \"jk\" => 0, \"jl\" => 0, \"jm\" => 0, \"jn\" => 0, \"jo\" => 0, \"jp\" => 0, \"jq\" => 0, \"jr\" => 0, \"js\" => 0, \"jt\" => 0, \"ju\" => 0, \"jv\" => 0, \"jw\" => 0, \"jx\" => 0, \"jy\" => 0, \"jz\" => 0, \"kl\" => 0, \"km\" => 0, \"kn\" => 0, \"ko\" => 0, \"kp\" => 0, \"kq\" => 0, \"kr\" => 0, \"ks\" => 0, \"kt\" => 0, \"ku\" => 0, \"kv\" => 0, \"kw\" => 0, \"kx\" => 0, \"ky\" => 0, \"kz\" => 0, \"lm\" => 0, \"ln\" => 0, \"lo\" => 0, \"lp\" => 0, \"lq\" => 0, \"lr\" => 0, \"ls\" => 0, \"lt\" => 0, \"lu\" => 0, \"lv\" => 0, \"lw\" => 0, \"lx\" => 0, \"ly\" => 0, \"lz\" => 0, \"mn\" => 0, \"mo\" => 0, \"mp\" => 0, \"mq\" => 0, \"mr\" => 0, \"ms\" => 0, \"mt\" => 0, \"mu\" => 0, \"mv\" => 0, \"mw\" => 0, \"mx\" => 0, \"my\" => 0, \"mz\" => 0, \"no\" => 0, \"np\" => 0, \"nq\" => 0, \"nr\" => 0, \"ns\" => 0, \"nt\" => 0, \"nu\" => 0, \"nv\" => 0, \"nw\" => 0, \"nx\" => 0, \"ny\" => 0, \"nz\" => 0, \"op\" => 0, \"oq\" => 0, \"or\" => 0, \"os\" => 0, \"ot\" => 0, \"ou\" => 0, \"ov\" => 0, \"ow\" => 0, \"ox\" => 0, \"oy\" => 0, \"oz\" => 0, \"pq\" => 0, \"pr\" => 0, \"ps\" => 0, \"pt\" => 0, \"pu\" => 0, \"pv\" => 0, \"pw\" => 0, \"px\" => 0, \"py\" => 0, \"pz\" => 0, \"qr\" => 0, \"qs\" => 0, \"qt\" => 0, \"qu\" => 0, \"qv\" => 0, \"qw\" => 0, \"qx\" => 0, \"qy\" => 0, \"qz\" => 0, \"rs\" => 0, \"rt\" => 0, \"ru\" => 0, \"rv\" => 0, \"rw\" => 0, \"rx\" => 0, \"ry\" => 0, \"rz\" => 0, \"st\" => 0, \"su\" => 0, \"sv\" => 0, \"sw\" => 0, \"sx\" => 0, \"sy\" => 0, \"sz\" => 0, \"uv\" => 0, \"uw\" => 0, \"ux\" => 0, \"uy\" => 0, \"uz\" => 0, \"vw\" => 0, \"vx\" => 0, \"vy\" => 0, \"vz\" => 0, \"wx\" => 0, \"wy\" => 0, \"wz\" => 0, \"xy\" => 0, \"xz\" => 0, \"yz\" => 0);\nfor($x = 0; $x < count($b); $x++)\n{\n $g = str_split($b[$x]);\n $r = array_unique($g);\n sort($r);\n $s = implode($r);\n $f[$s] += count($g);\n}\n$t = array_slice($f, 0, 26);\n$u = array_slice($f, 26);\n$v = array_keys($u);\n$w = array_keys($t);\nfor($x = 0; $x < count($u); $x++)\n{\n for($y = 0; $y < count($t); $y++)\n {\n if(($v[$x][0] == $w[$y]) || ($v[$x][1] == $w[$y]))\n {\n $f[$v[$x]] += $f[$w[$y]];\n }\n }\n}\nprint max($f);\n?>"}, {"source_code": " 2) {\n continue;\n } elseif ($c == 2) {\n $temp = array();\n $f = 0;\n foreach ($s as $l => $t) {\n $temp[] = $l - 97;\n $f += $t;\n }\n $bArray[$temp[0]][$temp[1]] += $f;\n $bArray[$temp[1]][$temp[0]] += $f;\n\n } else {\n foreach ($s as $l => $t) {\n $aArray[$l - 97] += $t;\n }\n }\n}\n$max = 0;\nfor ($i = 0; $i < 26; $i++) {\n for ($j = 0; $j < 26; $j++) {\n if ($i==$j) {\n continue;\n }\n $max = max($max, $bArray[$i][$j] + $aArray[$i] + $aArray[$j]);\n }\n}\necho $max;"}, {"source_code": " main();\n?>\n\n\n"}], "negative_code": [], "src_uid": "d8a93129cb5e7f05a5d6bbeedbd9ef1a"} {"nl": {"description": "You are given a set $$$S$$$, which contains the first $$$n$$$ positive integers: $$$1, 2, \\ldots, n$$$.You can perform the following operation on $$$S$$$ any number of times (possibly zero): Choose a positive integer $$$k$$$ where $$$1 \\le k \\le n$$$, such that there exists a multiple of $$$k$$$ in $$$S$$$. Then, delete the smallest multiple of $$$k$$$ from $$$S$$$. This operation requires a cost of $$$k$$$. You are given a set $$$T$$$, which is a subset of $$$S$$$. Find the minimum possible total cost of operations such that $$$S$$$ would be transformed into $$$T$$$. We can show that such a transformation is always possible.", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\le t \\le 10\\,000$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line contains a single positive integer $$$n$$$ ($$$1 \\le n \\le 10^6$$$). The second line of each test case contains a binary string of length $$$n$$$, describing the set $$$T$$$. The $$$i$$$-th character of the string is '1' if and only if $$$i$$$ is an element of $$$T$$$, and '0' otherwise. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$. ", "output_spec": "For each test case, output one non-negative integer\u00a0\u2014 the minimum possible total cost of operations such that $$$S$$$ would be transformed into $$$T$$$.", "sample_inputs": ["6\n\n6\n\n111111\n\n7\n\n1101001\n\n4\n\n0000\n\n4\n\n0010\n\n8\n\n10010101\n\n15\n\n110011100101100"], "sample_outputs": ["0\n11\n4\n4\n17\n60"], "notes": "NoteIn the first test case, we shall not perform any operations as $$$S$$$ is already equal to $$$T$$$, which is the set $$$\\{1, 2, 3, 4, 5, 6\\}$$$.In the second test case, initially, $$$S = \\{1, 2, 3, 4, 5, 6, 7\\}$$$, and $$$T = \\{1, 2, 4, 7\\}$$$. We shall perform the following operations: Choose $$$k=3$$$, then delete $$$3$$$ from $$$S$$$. Choose $$$k=3$$$, then delete $$$6$$$ from $$$S$$$. Choose $$$k=5$$$, then delete $$$5$$$ from $$$S$$$. The total cost is $$$3+3+5 = 11$$$. It can be shown that this is the smallest cost possible.In the third test case, initially, $$$S = \\{1, 2, 3, 4\\}$$$ and $$$T = \\{\\}$$$ (empty set). We shall perform $$$4$$$ operations of $$$k=1$$$ to delete $$$1$$$, $$$2$$$, $$$3$$$, and $$$4$$$.In the fourth test case, initially, $$$S = \\{1, 2, 3, 4\\}$$$ and $$$T = \\{3\\}$$$. We shall perform two operations with $$$k=1$$$ to delete $$$1$$$ and $$$2$$$, then perform one operation with $$$k=2$$$ to delete $$$4$$$."}, "positive_code": [{"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [{"source_code": " 0) {\r\n $size = count($t);\r\n for($i=0; $i < count($t); $i++) {\r\n if(isset($t[$i])) {\r\n $temp = $t[$i];\r\n $ans += $temp;\r\n for($j=$i+1; $j < $size; $j++) {\r\n \r\n if(isset($t[$j]) && $t[$j] % $temp == 0) {\r\n // IO::pr($j . ' => ' . $t[$j] . ' ' . $temp);\r\n $ans += $temp;\r\n unset($t[$j]);\r\n $t = array_values($t);\r\n }\r\n }\r\n // if(count($t) == $i+1) {\r\n // break;\r\n // }\r\n }\r\n \r\n } \r\n }\r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 0) {\r\n $size = count($t);\r\n for($i=0; $i < count($t); $i++) {\r\n if(isset($t[$i])) {\r\n $temp = $t[$i];\r\n $ans += $temp;\r\n for($j=$i+1; $j < $size; $j++) {\r\n \r\n if(isset($t[$j]) && $t[$j] % $temp == 0) {\r\n // IO::pr($j . ' => ' . $t[$j] . ' ' . $temp);\r\n $ans += $temp;\r\n unset($t[$j]);\r\n $t = array_values($t);\r\n }\r\n }\r\n // if(count($t) == $i+1) {\r\n // break;\r\n // }\r\n }\r\n \r\n } \r\n }\r\n \r\n IO::pr($ans);\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "src_uid": "28277036765f76f20c327ab2fda6c43b"} {"nl": {"description": "Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.There are n cashiers at the exit from the supermarket. At the moment the queue for the i-th cashier already has ki people. The j-th person standing in the queue to the i-th cashier has mi,\u2009j items in the basket. Vasya knows that: the cashier needs 5 seconds to scan one item; after the cashier scans each item of some customer, he needs 15 seconds to take the customer's money and give him the change. Of course, Vasya wants to select a queue so that he can leave the supermarket as soon as possible. Help him write a program that displays the minimum number of seconds after which Vasya can get to one of the cashiers.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of cashes in the shop. The second line contains n space-separated integers: k1,\u2009k2,\u2009...,\u2009kn (1\u2009\u2264\u2009ki\u2009\u2264\u2009100), where ki is the number of people in the queue to the i-th cashier. The i-th of the next n lines contains ki space-separated integers: mi,\u20091,\u2009mi,\u20092,\u2009...,\u2009mi,\u2009ki (1\u2009\u2264\u2009mi,\u2009j\u2009\u2264\u2009100)\u00a0\u2014 the number of products the j-th person in the queue for the i-th cash has.", "output_spec": "Print a single integer \u2014 the minimum number of seconds Vasya needs to get to the cashier.", "sample_inputs": ["1\n1\n1", "4\n1 4 3 2\n100\n1 2 2 3\n1 9 1\n7 8"], "sample_outputs": ["20", "100"], "notes": "NoteIn the second test sample, if Vasya goes to the first queue, he gets to the cashier in 100\u00b75\u2009+\u200915\u2009=\u2009515 seconds. But if he chooses the second queue, he will need 1\u00b75\u2009+\u20092\u00b75\u2009+\u20092\u00b75\u2009+\u20093\u00b75\u2009+\u20094\u00b715\u2009=\u2009100 seconds. He will need 1\u00b75\u2009+\u20099\u00b75\u2009+\u20091\u00b75\u2009+\u20093\u00b715\u2009=\u2009100 seconds for the third one and 7\u00b75\u2009+\u20098\u00b75\u2009+\u20092\u00b715\u2009=\u2009105 seconds for the fourth one. Thus, Vasya gets to the cashier quicker if he chooses the second or the third queue."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "0ea79b2a7ddf3d4da9c7a348e61933a7"} {"nl": {"description": "Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integers from 1 to n was encountered in his array exactly once). If there are multiple ways to do it he wants to find the lexicographically minimal permutation among them.Thus minimizing the number of changes has the first priority, lexicographical minimizing has the second priority.In order to determine which of the two permutations is lexicographically smaller, we compare their first elements. If they are equal \u2014 compare the second, and so on. If we have two permutations x and y, then x is lexicographically smaller if xi\u2009<\u2009yi, where i is the first index in which the permutations x and y differ.Determine the array Ivan will obtain after performing all the changes.", "input_spec": "The first line contains an single integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009200\u2009000) \u2014 the number of elements in Ivan's array. The second line contains a sequence of integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n) \u2014 the description of Ivan's array.", "output_spec": "In the first line print q \u2014 the minimum number of elements that need to be changed in Ivan's array in order to make his array a permutation. In the second line, print the lexicographically minimal permutation which can be obtained from array with q changes.", "sample_inputs": ["4\n3 2 2 3", "6\n4 5 6 3 2 1", "10\n6 8 4 6 7 1 6 3 4 5"], "sample_outputs": ["2\n1 2 4 3", "0\n4 5 6 3 2 1", "3\n2 8 4 6 7 1 9 3 10 5"], "notes": "NoteIn the first example Ivan needs to replace number three in position 1 with number one, and number two in position 3 with number four. Then he will get a permutation [1, 2, 4, 3] with only two changed numbers \u2014 this permutation is lexicographically minimal among all suitable. In the second example Ivan does not need to change anything because his array already is a permutation."}, "positive_code": [{"source_code": " 1)\n {\n if(($b[$x] < $d[$g]) && ($h[$b[$x]] == FALSE))\n {\n $f .= $b[$x] . \" \";\n $h[$b[$x]] = TRUE;\n }\n else\n {\n $f .= $d[$g] . \" \";\n $e[$b[$x]]--;\n $g++;\n }\n }\n else\n {\n $f .= $b[$x] . \" \";\n }\n}\nprint $f;\n?>"}], "negative_code": [], "src_uid": "0560658d84cbf91c0d86eea4be92a4d9"} {"nl": {"description": "There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,\u2009y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,\u2009y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x0,\u2009y0).Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. ", "input_spec": "The first line contains three integers n, x0 \u0438 y0 (1\u2009\u2264\u2009n\u2009\u2264\u20091000, \u2009-\u2009104\u2009\u2264\u2009x0,\u2009y0\u2009\u2264\u2009104) \u2014 the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (\u2009-\u2009104\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009104) \u2014 the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.", "output_spec": "Print a single integer \u2014 the minimum number of shots Han Solo needs to destroy all the stormtroopers. ", "sample_inputs": ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"], "sample_outputs": ["2", "1"], "notes": "NoteExplanation to the first and second samples from the statement, respectively: "}, "positive_code": [{"source_code": ""}, {"source_code": " $xy2) {\n list ($x2, $y2) = $xy2;\n if (abs($y1my0 * ($x2 - $x0) - $x1mx0 * ($y2 - $y0)) < 1e-8) {\n unset($xy[$i2]);\n }\n }\n\n $count++;\n}\n\necho \"$count\\n\";\n"}, {"source_code": ""}, {"source_code": " $xy2) {\n list ($x2, $y2) = $xy2;\n if (($y1my0 * ($x2 - $x0) - $x1mx0 * ($y2 - $y0)) < 1e-8) {\n unset($xy[$i2]);\n }\n }\n\n $count++;\n}\n\necho \"$count\\n\";\n"}], "src_uid": "8d2845c33645ac45d4d37f9493b0c380"} {"nl": {"description": "Valentin participates in a show called \"Shockers\". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014 the number of actions Valentin did. The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types: Valentin pronounced some word and didn't get an electric shock. This action is described by the string \". w\" (without quotes), in which \".\" is a dot (ASCII-code 46), and w is the word that Valentin said. Valentin pronounced some word and got an electric shock. This action is described by the string \"! w\" (without quotes), in which \"!\" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said. Valentin made a guess about the selected letter. This action is described by the string \"? s\" (without quotes), in which \"?\" is a question mark (ASCII-code 63), and s is the guess\u00a0\u2014 a lowercase English letter. All words consist only of lowercase English letters. The total length of all words does not exceed 105. It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.", "output_spec": "Output a single integer\u00a0\u2014 the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.", "sample_inputs": ["5\n! abc\n. ad\n. b\n! cd\n? c", "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e", "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h"], "sample_outputs": ["1", "2", "0"], "notes": "NoteIn the first test case after the first action it becomes clear that the selected letter is one of the following: a,\u2009b,\u2009c. After the second action we can note that the selected letter is not a. Valentin tells word \"b\" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock. In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n{\n print \"0\";\n}\nelse\n{\n print ($b - 1) - g;\n}\n?>"}, {"source_code": ""}, {"source_code": " 1)\n{\n print \"0\";\n}\nelse\n{\n print ($b - 1) - g;\n}\n?>"}, {"source_code": ""}], "src_uid": "3583a9762191ee8f8c3c2a287cb1ec1d"} {"nl": {"description": "\u0412 \u0441\u0430\u043c\u043e\u043b\u0451\u0442\u0435 \u0435\u0441\u0442\u044c n \u0440\u044f\u0434\u043e\u0432 \u043c\u0435\u0441\u0442. \u0415\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u044f\u0434\u044b \u0441\u0432\u0435\u0440\u0445\u0443, \u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u044f\u0434\u0443 \u0435\u0441\u0442\u044c 3 \u043c\u0435\u0441\u0442\u0430 \u0441\u043b\u0435\u0432\u0430, \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0440\u044f\u0434\u0430\u043c\u0438, \u0437\u0430\u0442\u0435\u043c 4 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430, \u0437\u0430\u0442\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0440\u044f\u0434\u0430\u043c\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0435\u0449\u0451 3 \u043c\u0435\u0441\u0442\u0430 \u0441\u043f\u0440\u0430\u0432\u0430.\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0443\u0436\u0435 \u0437\u0430\u043d\u044f\u0442\u044b \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430\u043c\u0438. \u0412\u0441\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u2014 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0435 (\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043b\u0435\u0442\u0430\u044e\u0442) \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435. \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0430\u0441\u0441\u0430\u0434\u0438\u0442\u044c \u0435\u0449\u0451 k \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u0431\u044b\u043b\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0414\u0432\u0430 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0441\u0438\u0434\u044f\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u0440\u044f\u0434\u0443 \u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442 \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u044f\u0434\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u043c \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u0442\u043e \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0432 \u0441\u0443\u043c\u043c\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0434\u0432\u0430\u0436\u0434\u044b.", "input_spec": "\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 n \u0438 k (1\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009k\u2009\u2264\u200910\u00b7n) \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u044f\u0434\u043e\u0432 \u043c\u0435\u0441\u0442 \u0432 \u0441\u0430\u043c\u043e\u043b\u0451\u0442\u0435 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0430\u0434\u0438\u0442\u044c. \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u044f\u0434\u043e\u0432 \u043c\u0435\u0441\u0442 \u0441\u0430\u043c\u043e\u043b\u0451\u0442\u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u044f\u0434\u0443 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d '-', \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0440\u044f\u0434\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d '.', \u0442\u043e \u044d\u0442\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d 'S', \u0442\u043e \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0439 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0432\u0435\u043d 'P', \u0442\u043e \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u0434\u0435\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440. \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u043c\u0435\u0441\u0442 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 k. \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u044f\u0434\u044b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0443.", "output_spec": "\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u043b\u0430\u043d \u0440\u0430\u0441\u0441\u0430\u0434\u043a\u0438 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u0432 \u0442\u043e\u043c \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0447\u0442\u043e \u0438 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0430\u0434\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 k \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0447\u043d\u0443\u044e \u0431\u0443\u043a\u0432\u0443 'x' \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '.'. ", "sample_inputs": ["1 2\nSP.-SS.S-S.S", "4 9\nPP.-PPPS-S.S\nPSP-PPSP-.S.\n.S.-S..P-SS.\nP.S-P.PP-PSP"], "sample_outputs": ["5\nSPx-SSxS-S.S", "15\nPPx-PPPS-S.S\nPSP-PPSP-xSx\nxSx-SxxP-SSx\nP.S-PxPP-PSP"], "notes": "\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0430\u0434\u0438\u0442\u044c \u0435\u0449\u0451 \u0434\u0432\u0443\u0445 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432. \u0414\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0430\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0441\u043b\u0435\u0432\u0430 \u043c\u0435\u0441\u0442\u043e, \u0430 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u043c\u0435\u0441\u0442\u0430 \u043e\u043d \u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043e\u0441\u0435\u0434\u043e\u043c \u0434\u0432\u0443\u0445 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u043e\u0433\u043e \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0438\u0434\u0438\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043b\u0435\u0432\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u043c \u0438 \u043f\u044f\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0430\u0445 \u0441\u043b\u0435\u0432\u0430 \u0441\u0438\u0434\u044f\u0442 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0435 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u044b, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438 \u0434\u0440\u0443\u0433 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0430 (\u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0441\u0443\u043c\u043c\u0435 2).\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u0430\u0434\u043a\u0438 \u0435\u0449\u0451 \u0434\u0432\u0443\u0445 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432, \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u043d\u044b\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043f\u044f\u0442\u0438."}, "positive_code": [{"source_code": " 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n}\nif($b > 0)\n{\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") && ($b > 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n }\n if($b > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"2\") && ($b > 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n }\n }\n else\n {\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") || ($e[$y] == \"2\"))\n {\n $e[$y] = \".\";\n }\n }\n $c[$x] = $e;\n }\n }\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") || ($e[$y] == \"2\"))\n {\n $e[$y] = \".\";\n }\n }\n $c[$x] = $e;\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") || ($e[$y] == \"2\"))\n {\n $e[$y] = \".\";\n }\n }\n $c[$x] = $e;\n}\n$f = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if($e[$y] == \"S\")\n {\n if($e[$y - 1] != NULL)\n {\n if(($e[$y - 1] == \"P\") || ($e[$y - 1] == \"x\") || ($e[$y - 1] == \"S\"))\n {\n $f++;\n }\n }\n if($e[$y + 1] != NULL)\n {\n if(($e[$y + 1] == \"P\") || ($e[$y + 1] == \"x\") || ($e[$y + 1] == \"S\"))\n {\n $f++;\n }\n }\n }\n }\n $c[$x] = $e;\n}\nprint $f . \"\\n\";\nfor($x = 0; $x < $a; $x++)\n{\n print $c[$x] . \"\\n\";\n}\n?>"}, {"source_code": " $row){\n $arrStr = str_split($row);\n $srt_return = '';\n foreach ($arrStr as $k => $char){\n if($char == \".\") {\n if ($people_count > 0) {\n if ($k >=1 && $k < 11) {\n if ($arrStr[$k - 1] != \"S\" && $arrStr[$k + 1] != \"S\") {\n $char = \"x\";\n $people_count = $people_count - 1;\n }\n\n }\n elseif($k == 0 && $arrStr[$k + 1] != \"S\") {\n $char = \"x\";\n $people_count = $people_count - 1;\n }\n elseif($k == 11 && $arrStr[$k - 1] != \"S\") {\n $char = \"x\";\n $people_count = $people_count - 1;\n }\n }\n }\n\n $srt_return = $srt_return.$char;\n }\n $arRows[$key] = $srt_return;\n\n}\n\n\nforeach ($arRows as $key => $row){\n $arrStr = str_split($row);\n $srt_return = '';\n foreach ($arrStr as $k => $char){\n if($char == \".\") {\n if ($people_count > 0) {\n if ($k >=1 && $k < 11) {\n $sos = $arrStr[$k - 1] . $arrStr[$k + 1];\n if ($sos != \"SS\") {\n $char = \"x\";\n $people_count = $people_count - 1;\n }\n\n }\n else {\n $char = \"x\";\n $people_count = $people_count - 1;\n }\n }\n }\n\n $srt_return = $srt_return.$char;\n }\n $arRows[$key] = $srt_return;\n\n}\n\nforeach ($arRows as $k => $row){\n\n if($people_count >= 1){\n $arRows[$k] = preg_replace(\"/\\./\",\"x\",$arRows[$k],$people_count,$count);\n $people_count = $people_count - $count;\n }\n else{\n break;\n }\n\n}\nglobal $count_result;\n$count_result = 0;\nfunction counter($f){\n global $count_result;\n if($f != \"\"){\n if($f != \"-\" && $f != \".\"){\n $count_result++;\n }\n }\n\n}\n\nforeach ($arRows as $key => $row){\n $arrStr = str_split($row);\n foreach ($arrStr as $k => $char){\n if($char == \"S\"){\n if($k > 0){\n counter($arrStr[$k-1]);\n }\n if($k < 11){\n counter($arrStr[$k+1]);\n }\n }\n }\n}\n\necho $count_result.\"\\n\";\nforeach ($arRows as $row){\n echo $row;\n}\n\n?>"}, {"source_code": " 0 && $str[$i-1] != \".\"){\n \t\t\t$neighbors++;\n \t\t}\n \t\tif($i< strlen($str)-1 && $str[$i+1]!=\".\"){\n \t\t\t$neighbors++;\n \t\t}\n \t}\n \tif($str[$i] == \".\"){\n \t\t$c = 0;\n \t\tif($i>0 && $str[$i-1]==\"S\"){\n \t\t\t$c++;\n \t\t}\n \t\tif($i+1 < strlen($str) && $str[$i+1]==\"S\"){\n \t\t\t$c++;\n \t\t}\n \t\tswitch ($c) {\n \t\t\tcase 0:\n \t\t\t\t$best_place[] = [$row, $i+$colomn];\n \t\t\t\tbreak;\n \t\t\tcase 1:\n \t\t\t\t$mid_place[] = [$row, $i+$colomn];\n \t\t\t\tbreak;\n \t\t\tcase 2:\n \t\t\t\t$bad_place[] = [$row, $i+$colomn];\n \t\t}\n \t}\n }\n}\n$list = explode(\" \", fgets(STDIN));\n$n = $list[0]; \n$passangers = $list[1];\n$best_place = [];\n$mid_place = [];\n$bad_place = [];\n$need_place = [];\n$neighbors = 0;\n$rows = [];\nfor($i = 0; $i < $n; $i++){\n\t$row = trim(fgets(STDIN));\n\t$rows[] = $row;\n\t$rows_in_row = explode(\"-\", $row);\n\t$r1 = $rows_in_row[0];\n\t$r2 = $rows_in_row[1];\n\t$r3 = $rows_in_row[2];\n sorting($r1, $i, 0);\n sorting($r2, $i, 4);\n sorting($r3, $i, 9);\n}\n$best = count($best_place);\n$mid = count($mid_place);\n$bad = count($bad_place);\nif($best >= $passangers){\n\t$need_place = array_slice($best_place, 0, $passangers);\n}\nelse{\n $need_place = $best_place;\n $passangers -= $best;\n if($passangers <= $mid){\n \t$need_place = array_merge($need_place, array_slice($mid_place, 0, $passangers));\n $neighbors += $passangers;\n }\n else{\n \t$neighbors += $mid;\n \t$passangers-=$mid;\n \t$need_place = array_merge($need_place, $mid_place, array_slice($bad_place, 0, $passangers));\n \t$neighbors += 2*$passangers;\n }\n}\nforeach ($need_place as $place) {\n\t$rows[$place[0]][$place[1]] = \"x\";\n}\necho $neighbors;\nforeach ($rows as $row) {\n\techo \"\\n\".$row;\n}\n?>"}], "negative_code": [{"source_code": " 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n}\nif($b > 0)\n{\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") && ($b > 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n }\n if($b > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"2\") && ($b > 0))\n {\n $e[$y] = \"x\";\n $b--;\n }\n }\n $c[$x] = $e;\n }\n }\n else\n {\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") || ($e[$y] == \"2\"))\n {\n $e[$y] = \".\";\n }\n }\n $c[$x] = $e;\n }\n }\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if(($e[$y] == \"1\") || ($e[$y] == \"2\"))\n {\n $e[$y] = \".\";\n }\n }\n $c[$x] = $e;\n }\n}\n$f = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < 12; $y++)\n {\n if($e[$y] == \"S\")\n {\n if($e[$y - 1] != NULL)\n {\n if(($e[$y - 1] == \"P\") || ($e[$y - 1] == \"x\") || ($e[$y - 1] == \"S\"))\n {\n $f++;\n }\n }\n if($e[$y + 1] != NULL)\n {\n if(($e[$y + 1] == \"P\") || ($e[$y + 1] == \"x\") || ($e[$y + 1] == \"S\"))\n {\n $f++;\n }\n }\n }\n }\n $c[$x] = $e;\n}\nprint $f . \"\\n\";\nfor($x = 0; $x < $a; $x++)\n{\n print $c[$x] . \"\\n\";\n}\n?>"}, {"source_code": " \"Px-S\",\n \"/S-\\.P/\" => \"S-xP\",\n \"/P\\.-/\" => \"Px-\",\n \"/P\\.P/\" => \"PxP\",\n \"/\\.\\.P/\" => \".xP\",\n \"/P\\.\\./\" => \"Px.\",\n \"/^\\.P/\" => \"xP\",\n \"/P\\.$/\" => \"Px\"\n);\n\n$arSecondPaterns = array(\n \"/\\.\\.S/\" =>\".xS\",\n \"/S\\.\\./\" =>\"Sx.\",\n \"/-\\.S/\"=> \"-xS\",\n \"/S\\.-/\"=> \"Sx-\",\n \"/S\\.$/\" =>\"Sx\",\n \"/^\\.S/\" =>\"xS\",\n \"/P\\.S/\"=> \"PxS\",\n \"/S\\.P/\"=> \"SxP\",\n);\n\n$count = 0;\nforeach ($arRows as $k => $row){\n if($people_count >= 2){\n $maxDuble = intval($people_count / 2);\n $arRows[$k] = preg_replace(\"/P\\.\\.P/\",\"PxxP\",$arRows[$k]);\n $people_count -= ($count * 2);\n }\n else{\n break;\n }\n\n}\n\n$count = 0;\nforeach ($arRows as $k => $row){\n foreach ($arFirstPaterns as $search => $replace){\n if($people_count >= 1){\n $arRows[$k] = preg_replace($search,$replace,$arRows[$k],$people_count,$count);\n $people_count -= $count;\n }\n else{\n break 2;\n }\n }\n}\n$count = 0;\nforeach ($arRows as $k => $row){\n foreach ($arSecondPaterns as $search => $replace){\n if($people_count >= 1){\n $arRows[$k] = preg_replace($search,$replace,$arRows[$k],$people_count,$count);\n $people_count -= $count;\n }\n else{\n break 2;\n }\n }\n}\n\nforeach ($arRows as $key => $row){\n $arrStr = str_split($row);\n $srt_return = '';\n foreach ($arrStr as $k => $char){\n if($char == \".\") {\n if ($people_count > 0) {\n if ($k >=1 && $k < 11) {\n $sos = $arrStr[$k - 1] . $arrStr[$k + 1];\n if ($sos != \"SS\") {\n $char = \"x\";\n $people_count--;\n }\n\n }\n else {\n $char = \"x\";\n $people_count--;\n }\n }\n }\n\n $srt_return = $srt_return.$char;\n }\n $arRows[$key] = $srt_return;\n\n}\n\nforeach ($arRows as $k => $row){\n\n if($people_count >= 1){\n $arRows[$k] = preg_replace(\"/\\./\",\"x\",$arRows[$k],$people_count,$count);\n $people_count -= $count;\n }\n else{\n break;\n }\n\n}\nglobal $count_result;\n$count_result = 0;\nfunction counter($f){\n global $count_result;\n if($f != \"\"){\n if($f != \"-\" && $f != \".\"){\n $count_result++;\n }\n }\n\n}\n\nforeach ($arRows as $key => $row){\n $arrStr = str_split($row);\n foreach ($arrStr as $k => $char){\n if($char == \"S\"){\n if($k > 0){\n counter($arrStr[$k-1]);\n }\n if($k < 11){\n counter($arrStr[$k+1]);\n }\n }\n }\n}\n\necho $count_result.\"\\n\";\nforeach ($arRows as $row){\n echo $row;\n}\n\n\n?>"}, {"source_code": " $pos){\n \t$pos = $arr[$i-1] + $range;\n\t\tif($arr[$i] > $pos){\n\t\t\t$velo = -1;\n\t\t\tbreak;\n\t\t} else {$velo ++;}\n }\n}\necho $velo.\" \";"}, {"source_code": " 0 && $str[$i-1] != \".\"){\n \t\t\t$neighbors++;\n \t\t}\n \t\tif($i< strlen($str)-1 && $str[$i+1]!=\".\"){\n \t\t\t$neighbors++;\n \t\t}\n \t}\n \tif($str[$i] == \".\"){\n \t\t$c = 0;\n \t\tif($i>0 && $str[$i-1]==\"S\"){\n \t\t\t$c++;\n \t\t}\n \t\tif($i+1 < strlen($str) && $str[$i+1]==\"S\"){\n \t\t\t$c++;\n \t\t}\n \t\tswitch ($c) {\n \t\t\tcase 0:\n \t\t\t\t$best_place[] = [$row, $i+$colomn];\n \t\t\t\tbreak;\n \t\t\tcase 1:\n \t\t\t\t$mid_place[] = [$row, $i+$colomn];\n \t\t\t\tbreak;\n \t\t\tcase 2:\n \t\t\t\t$bad_place[] = [$row, $i+$colomn];\n \t\t}\n \t}\n }\n}\n$list = explode(\" \", fgets(STDIN));\n$n = $list[0]; \n$passangers = $list[1];\n$best_place = [];\n$mid_place = [];\n$bad_place = [];\n$need_place = [];\n$neighbors = 0;\n$rows = [];\nfor($i = 0; $i < $n; $i++){\n\t$row = trim(fgets(STDIN));\n\t$rows[] = $row;\n\t$rows_in_row = explode(\"-\", $row);\n\t$r1 = $rows_in_row[0];\n\t$r2 = $rows_in_row[1];\n\t$r3 = $rows_in_row[2];\n sorting($r1, $i, 0);\n sorting($r2, $i, 4);\n sorting($r3, $i, 9);\n}\n$best = count($best_place);\n$mid = count($mid_place);\n$bad = count($bad_place);\necho \"neig $neighbors \\n\";\nif($best >= $passangers){\n\t$need_place = array_slice($best_place, 0, $passangers);\n}\nelse{\n $need_place = $best_place;\n $passangers -= $best;\n if($passangers <= $mid){\n \t$need_place = array_merge($need_place, array_slice($mid_place, 0, $passangers));\n $neighbors += $passangers;\n }\n else{\n \t$neighbors += $mid;\n \t$passangers-=$mid;\n \t$need_place = array_merge($need_place, $mid_place, array_slice($bad_place, 0, $passangers));\n \t$neighbors += 2*$passangers;\n }\n}\nforeach ($need_place as $place) {\n\t$rows[$place[0]][$place[1]] = \"x\";\n}\necho $neighbors.\"\\n\";\nforeach ($rows as $row) {\n\techo $row.\"\\n\";\n}\n//echo \"best\";\n//var_dump($best_place);\n//echo \"\\n mid\";\n//var_dump($mid_place);\n//echo \"\\n bad\";\n//var_dump($bad_place);\n?>"}], "src_uid": "4f45c5fd31e500c1128cf6cb5e41e3d6"} {"nl": {"description": "A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a\u2009\u2264\u2009b, he or she likes it if and only if he can climb into this car and 2a\u2009\u2265\u2009b.You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.", "input_spec": "You are given four integers V1, V2, V3, Vm(1\u2009\u2264\u2009Vi\u2009\u2264\u2009100)\u00a0\u2014 sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1\u2009>\u2009V2\u2009>\u2009V3.", "output_spec": "Output three integers\u00a0\u2014 sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print \"-1\" (without quotes).", "sample_inputs": ["50 30 10 10", "100 50 10 21"], "sample_outputs": ["50\n30\n10", "-1"], "notes": "NoteIn first test case all conditions for cars' sizes are satisfied.In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20."}, "positive_code": [{"source_code": "= $d) && (($d * 2) < ($b * 2)))\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n else\n {\n print \"-1\";\n }\n}\nelse\n{\n $f = $d * 2;\n if($c <= $f)\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n else\n {\n print \"-1\";\n }\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " $c))\n{\n print \"-1\";\n}\nelse\n{\n print $a . \"\\n\";\n print $b . \"\\n\";\n print $c . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d)\n {\n $g = max($c, $d);\n if($c < $g)\n {\n print \"-1\";\n }\n else\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n }\n else\n {\n print \"-1\";\n }\n}\nelse\n{\n $f = $d * 2;\n if($c <= $f)\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n else\n {\n print \"-1\";\n }\n}\n?>"}, {"source_code": " $e) || ($d > $c))\n{\n print \"-1\";\n}\nelse\n{\n print $a . \"\\n\";\n print $b . \"\\n\";\n print $c . \"\\n\";\n}\n?>"}, {"source_code": " $c))\n{\n print \"-1\";\n}\nelse\n{\n print $a . \"\\n\";\n print $b . \"\\n\";\n print $c . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": "= $d)\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n else\n {\n print \"-1\";\n }\n}\nelse\n{\n $f = $d * 2;\n if($c <= $f)\n {\n print ($a * 2) . \"\\n\";\n print ($b * 2) . \"\\n\";\n print max($c, $d);\n }\n else\n {\n print \"-1\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "56535017d012fdfcc13695dfd5b33084"} {"nl": {"description": "You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \\le x \\le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal elements.If there is no such $$$x$$$, print \"-1\" (without quotes).", "input_spec": "The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$, $$$0 \\le k \\le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u2014 the sequence itself.", "output_spec": "Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print \"-1\" (without quotes).", "sample_inputs": ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"], "sample_outputs": ["6", "-1"], "notes": "NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this number because $$$3$$$ elements of the given sequence will be also less than or equal to this number."}, "positive_code": [{"source_code": " $b)\n {\n print \"-1\";\n break;\n }\n }\n}\n?>"}, {"source_code": " $b)\n {\n print \"-1\";\n break;\n }\n}\n?>"}, {"source_code": " $b)\n {\n print \"-1\";\n break;\n }\n }\n}\n?>"}, {"source_code": " 4, Cube => 6, Octahedron => 8, Dodecahedron => 12, Icosahedron => 20);\n$b = trim(fgets(STDIN));\n$c = 0;\nfor($x = 0; $x < $b; $x++)\n{\n $d = trim(fgets(STDIN));\n $c += $a[$d];\n}\nprint $c;\n?>"}, {"source_code": "solution($data1, $data2);\n\n// End of interface\n\n\nclass MainClass {\n\tpublic $problemLink = 'https://codeforces.com/problemset/problem/785/A';\n\tpublic $submissionLink = '';\n\n\tpublic function solution($n, $s)\n\t{\n\t\t$res = 0;\n\t\t\tfor($i = 0; $i < $n; $i++){\n\t\t\t\tswitch ($s[$i]) {\n\t\t\t\t\tcase 'Tetrahedron':\n\t\t\t\t\t\t$res = $res + 4;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Cube':\n\t\t\t\t\t\t$res = $res + 6;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Octahedron':\n\t\t\t\t\t\t$res = $res + 8;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Dodecahedron':\n\t\t\t\t\t\t$res = $res + 12;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Icosahedron':\n\t\t\t\t\t\t$res = $res + 20;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn $res;\n\t}\n\n}"}, {"source_code": ""}, {"source_code": " 4,\n 'Cube' => 6,\n 'Octahedron' => 8,\n 'Dodecahedron' => 12,\n 'Icosahedron' => 20,\n];\n$sum = 0;\nfor ($i = 1; $i <= $count; $i++) {\n $sum += $array[trim(fgets(STDIN))];\n}\n\necho $sum;"}, {"source_code": ""}, {"source_code": " 4, \"Cube\" => 6, \"Octahedron\" => 8, \"Dodecahedron\" => 12, \"Icosahedron\" => 20];\n\n$total = 0;\nfor ($k=0; $k<$n; $k++) {\n $total += $const[$i[$k][0]];\n}\n\necho $total;\n\n?>"}, {"source_code": ""}, {"source_code": "4,\"Cube\"=>6,\"Dodecahedron\"=>12,\"Icosahedron\"=>20,\"Octahedron\"=>8];\nfor ($i=0;$i<$n;$i++) { \n $a=trim(fgets(STDIN));\n $result+=$shekl[$a];\n}\necho $result;"}, {"source_code": " $line) {\n $input[$index] = explode(\" \", trim($line));\n}\n\n// Solve past this line\n$shapeLibrary = [\n 'Tetrahedron' => 4,\n 'Cube' => 6,\n 'Octahedron' => 8,\n 'Dodecahedron' => 12,\n 'Icosahedron' => 20\n];\n$shapes = array_slice($input, 1);\n$output = 0;\n\nforeach ($shapes as $shape) {\n $output += $shapeLibrary[$shape[0]];\n}\n\necho $output;\n "}, {"source_code": "4, \"C\"=>6, \"O\"=>8, \"D\"=>12, \"I\"=>20);\n$sum = 0;\nfor ($i=0;$i<$n;$i++){\n\t$sum += $a[substr(trim(fgets(STDIN)), 0, 1)];\n}\necho $sum; \n?>"}, {"source_code": " 0){$line = str_replace($del,'',$line);$dataex[] = $line;$text = explode(\" \",$line);\n foreach($text as $txt){$arr_txt[] = $txt;$this->linex[$id] = $il;$this->liney[$il] = $id;$id++;}}$il++;}$this->arr_line = $dataex;$this->arr_txt = $arr_txt;}\n function G(){$ret = $this->arr_txt[$this->ntxt++];$this->nline = $this->linex[$this->ntxt];return $ret;}\n function GL(){$this->ntxt = $this->liney[$this->nline]+1;return $this->arr_line[$this->nline++];}} /*init*/\n\n$inp = new stdIn(false);\n$n = $inp->arr_line[0];\n$gran = 0;\nfor ($i=1;$i<$n+1;$i++){\n $str = $inp->arr_line[$i];\n switch ($str){\n case \"Tetrahedron\":\n $gran = $gran + 4 ;\n break;\n case \"Cube\":\n $gran = $gran + 6 ;\n break;\n case \"Octahedron\":\n $gran = $gran + 8 ;\n break;\n case \"Dodecahedron\":\n $gran = $gran + 12 ;\n break;\n case \"Icosahedron\":\n $gran = $gran + 20 ;\n break;\n\n }\n}\necho $gran;"}], "negative_code": [], "src_uid": "e6689123fefea251555e0e096f58f6d1"} {"nl": {"description": "There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot10^5$$$)\u00a0\u2014 the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively\u00a0\u2014 the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).", "output_spec": "For each test case, output $$$n$$$ space-separated non-negative integers\u00a0\u2014 the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.", "sample_inputs": ["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"], "sample_outputs": ["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"], "notes": "NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL)."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}], "negative_code": [], "src_uid": "296552dc2df23b3920baef7d47d0a591"} {"nl": {"description": "Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.For example, the following matrices are palindromic: The following matrices are not palindromic because they change after the order of rows is reversed: The following matrices are not palindromic because they change after the order of columns is reversed: You are given $$$n^2$$$ integers. Put them into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic. If there are multiple answers, print any. If there is no solution, print \"NO\".", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\le n \\le 20$$$). The second line contains $$$n^2$$$ integers $$$a_1, a_2, \\dots, a_{n^2}$$$ ($$$1 \\le a_i \\le 1000$$$) \u2014 the numbers to put into a matrix of $$$n$$$ rows and $$$n$$$ columns.", "output_spec": "If it is possible to put all of the $$$n^2$$$ numbers into a matrix of $$$n$$$ rows and $$$n$$$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print \"YES\". Then print $$$n$$$ lines with $$$n$$$ space-separated numbers \u2014 the resulting matrix. If it's impossible to construct any matrix, then print \"NO\". You can print each letter in any case (upper or lower). For example, \"YeS\", \"no\" and \"yES\" are all acceptable.", "sample_inputs": ["4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1", "3\n1 1 1 1 1 3 3 3 3", "4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1", "1\n10"], "sample_outputs": ["YES\n1 2 2 1\n8 2 2 8\n8 2 2 8\n1 2 2 1", "YES\n1 3 1\n3 1 3\n1 3 1", "NO", "YES\n10"], "notes": "NoteNote that there exist multiple answers for the first two examples."}, "positive_code": [{"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n $d[$e[$x]] -= $h4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n }\n sort($b);\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n if(count($b2) > $a + $a - 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}], "negative_code": [{"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n $b3 = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n $b3[$e[$x]]++;\n }\n }\n }\n sort($b);\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n $b3 = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n $b3[$e[$x]]++;\n }\n }\n }\n sort($b);\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n if($a != 19)\n {\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n if($a == 19)\n {\n print_r($d);\n }\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n }\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n }\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n $d[$e[$x]] -= $h4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n }\n sort($b);\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n $h = 1;\n break;\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == $a / 2)\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == $a / 2 - 1)\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == $a / 2)\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == $a / 2 - 1)\n {\n $p = $a - 1;\n $q--;\n }\n }\n $s++;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n $d = array();\n for($x = 0; $x < count($b); $x++)\n {\n $d[$b[$x]]++;\n }\n asort($d);\n $e = array_keys($d);\n $f = array();\n $g = 0;\n while(TRUE)\n {\n if($g > 400)\n {\n break;\n }\n else\n {\n $f[$g] = TRUE;\n $g += 4;\n }\n }\n $h = 0;\n $b2 = array();\n for($x = 0; $x < count($d); $x++)\n {\n if($f[$d[$e[$x]]] == FALSE)\n {\n if($d[$e[$x]] % 2 == 1)\n {\n $h++;\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n $h3 = $e[$x];\n $d[$e[$x]]--;\n $f[$d[$e[$x]]] = TRUE;\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n }\n else\n {\n $h4 = $d[$e[$x]] % 4;\n for($y = 0; $y < $h4; $y++)\n {\n $b2[count($b2)] = $e[$x];\n $h2 = array_search($e[$x], $b);\n array_splice($b, $h2, 1);\n }\n $d[$e[$x]] -= 2;\n $f[$d[$e[$x]]] = TRUE;\n }\n }\n }\n if($h == 1)\n {\n print \"YES\\n\";\n $i = array();\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $i[$x][$y] = 0;\n }\n }\n $i[floor($a / 2)][floor($a / 2)] = $h3;\n $j = 0;\n $k = 0;\n $l = $a - 1;\n $m = 0;\n $n = 0;\n $o = $a - 1;\n $p = $a - 1;\n $q = $a - 1;\n $r = 1;\n $s = 0;\n $u = array();\n $b = array();\n $b3 = array();\n for($x = 0; $x < count($d); $x++)\n {\n $v = $d[$e[$x]];\n if(($v % 2 != 1) || ($f[$d[$e[$x]]] == TRUE))\n {\n for($y = 0; $y < $v; $y++)\n {\n $b[count($b)] = $e[$x];\n $b3[$e[$x]]++;\n }\n }\n }\n if($a == 19)\n {\n print_r($b3);\n }\n if(count($b) > 0)\n {\n for($x = 0; $x < $a; $x++)\n {\n for($y = 0; $y < $a; $y++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b[$s];\n $j++;\n if($j == floor($a / 2))\n {\n $j = 0;\n $k++;\n }\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b[$s];\n $l--;\n if($l == floor($a / 2))\n {\n $l = $a - 1;\n $m++;\n }\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b[$s];\n $n++;\n if($n == floor($a / 2))\n {\n $n = 0;\n $o--;\n }\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b[$s];\n $p--;\n if($p == floor($a / 2))\n {\n $p = $a - 1;\n $q--;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $s++;\n }\n if($q == floor($a / 2))\n {\n break;\n }\n }\n $b = array_slice($b, $s + 1);\n $b2 = array_merge($b, $b2);\n }\n sort($b2);\n $j = floor($a / 2);\n $k = 0;\n $l = floor($a / 2);\n $m = $a - 1;\n $n = 0;\n $o = floor($a / 2);\n $p = $a - 1;\n $q = floor($a / 2);\n $r = 1;\n for($x = 0; $x < count($b2); $x++)\n {\n $t = $r % 5;\n $r++;\n if($r == 5)\n {\n $r = 1;\n }\n if($t == 1)\n {\n $i[$j][$k] = $b2[$x];\n $k++;\n }\n elseif($t == 2)\n {\n $i[$l][$m] = $b2[$x];\n $m--;\n }\n elseif($t == 3)\n {\n $i[$n][$o] = $b2[$x];\n $n++;\n }\n elseif($t == 4)\n {\n $i[$p][$q] = $b2[$x];\n $p--;\n }\n }\n for($x = 0; $x < $a; $x++)\n {\n print implode(\" \", $i[$x]) . \"\\n\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}], "src_uid": "20928dd8e512bee2d86c6611c5e76390"} {"nl": {"description": "Codeforces user' handle color depends on his rating\u00a0\u2014 it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.Anton wants the color of his handle to become red. He considers his performance in the rated contest to be good if he outscored some participant, whose handle was colored red before the contest and his rating has increased after it.Anton has written a program that analyses contest results and determines whether he performed good or not. Are you able to do the same?", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of participants Anton has outscored in this contest . The next n lines describe participants results: the i-th of them consists of a participant handle namei and two integers beforei and afteri (\u2009-\u20094000\u2009\u2264\u2009beforei,\u2009afteri\u2009\u2264\u20094000)\u00a0\u2014 participant's rating before and after the contest, respectively. Each handle is a non-empty string, consisting of no more than 10 characters, which might be lowercase and uppercase English letters, digits, characters \u00ab_\u00bb and \u00ab-\u00bb characters. It is guaranteed that all handles are distinct.", "output_spec": "Print \u00abYES\u00bb (quotes for clarity), if Anton has performed good in the contest and \u00abNO\u00bb (quotes for clarity) otherwise.", "sample_inputs": ["3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749", "3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.In the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before the contest."}, "positive_code": [{"source_code": "= 2400) && ($e > $d))\n {\n $b = 1;\n break;\n }\n}\nif($b == 0)\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\";\n}\n?>"}, {"source_code": "= 2400 && intval($x[2]) > intval($x[1])){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "= 2400) and ($s[2] > $s[1])) {\n $g = true;\n }\n}\nif ($g) {\n print \"YES\";\n} else {\n print \"NO\";\n}\n?>\n\n\n"}, {"source_code": " $pieces[1] && $pieces[1] > 2399) {\n echo 'YES';\n die();\n }\n}\necho 'NO';\n"}, {"source_code": "=2400&&($after>2400&&$after>$before)){\n\t\t$answ=\"YES\";\n\t\t\n\t\tbreak;\n\t\t\n\t}\n\t\n}\necho $answ;\n\n\n"}, {"source_code": " $before && $before >= 2400) {\n\t\tdie('YES');\n\t}\n}\ndie('NO');"}], "negative_code": [{"source_code": "= 2400 && $x[2] > $x[1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "= 2400 && $a[$i][2] > $a[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": " 2400 && $a[$i][2] > $a[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "$handle = fopen (\"php://stdin\",\"r\");\nfscanf($handle,\"%d\",$n);\n$a = array();\nfor($a_i = 0; $a_i < $n; $a_i++) {\n $a_temp = fgets($handle);\n $a[] = explode(\" \",$a_temp);\n array_walk($a[$a_i],'intval');\n}\n\n//$n=3;\n/*\n$handles = [\n\t['Burunduk1', 2526, 2537],\n\t['BudAlNik', 2084, 2214],\n\t['subscriber', 2833, 2749]\n];*/\n$good = false;\nfor($i=0; $i<3 ;$i++){\n\tif($a[$i][1] > 2400 && $a[$i][2] > $a[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\techo \"YES\";\n}else{\n\techo \"NO\";\n}"}, {"source_code": "= 2400 && intval($x[2]) > intval($x[1])){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "$handle = fopen (\"php://stdin\",\"r\");\nfscanf($handle,\"%d\",$n);\n$arr_temp = fgets($handle);\n$arr = explode(\" \",$arr_temp);\narray_walk($handles,'intval');\n\n$n=3;\n$handles = [\n\t['Burunduk1', 2526, 2537],\n\t['BudAlNik', 2084, 2214],\n\t['subscriber', 2833, 2749]\n];\n$good = false;\nfor($i=0; $i<3 ;$i++){\n\tif($handles[$i][1] > 2400 && $handles[$i][2] > $handles[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\techo \"YES\";\n}else{\n\techo \"NO\";\n}"}, {"source_code": "$handle = fopen (\"php://stdin\",\"r\");\nfscanf($handle,\"%d\",$n);\n$a = array();\nfor($a_i = 0; $a_i < $n; $a_i++) {\n $a_temp = fgets($handle);\n $a[] = explode(\" \",$a_temp);\n array_walk($a[$a_i],'intval');\n}\n\n//$n=3;\n/*\n$handles = [\n\t['Burunduk1', 2526, 2537],\n\t['BudAlNik', 2084, 2214],\n\t['subscriber', 2833, 2749]\n];*/\n$good = false;\nfor($i=0; $i<3 ;$i++){\n\tif($a[$i][1] > 2400 && $a[$i][2] > $a[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "= 2400 && $a[$i][2] > $a[$i][1]){\n\t\t$good = true;\n\t\tbreak;\n\t}\n}\nif($good){\n\tprint \"YES\";\n}else{\n\tprint \"NO\";\n}"}, {"source_code": "\n\n$stdin = fopen('php://stdin', 'r');\n$s = trim(fgets($stdin));\n$answ=\"NO\";\nwhile (!feof($stdin)) {\n\tlist($name,$before,$after)=explode(\" \",trim(fgets($stdin)));\n\tif($before>=2400&&$after>2400){\n\t\t$answ=\"YES\";\n\t}\n\t\n}\n\necho $answ;\n"}, {"source_code": "\n\n$stdin = fopen('php://stdin', 'r');\n$s = trim(fgets($stdin));\n$answ=\"NO\";\n$i=0;\nwhile ($i<(int)$s) {\n\t$i++;\n\tlist($name,$before,$after)=explode(\" \",trim(fgets($stdin)));\n\tif($before>=2400&&$after>2400){\n\t\t$answ=\"YES\";\n\t\t\n\t\tbreak;\n\t\t\n\t}\n\t\n}\necho $answ;\n\n\n"}, {"source_code": " $before && $before > 2400) {\n\t\tdie('YES');\n\t}\n}\ndie('NO');"}, {"source_code": " $before && $before >= 2400) {\n\t\tdie('YES');\n\t}\n}\ndie('NO');"}], "src_uid": "3bff9b69423cf6c8425e347a4beef96b"} {"nl": {"description": "According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1,\u2009a2,\u2009...,\u2009an centimeters. Some soldiers are of the same height. Bob wants to know, how many ways exist to form a reconnaissance unit of two soldiers from his detachment.Ways (1,\u20092) and (2,\u20091) should be regarded as different.", "input_spec": "The first line contains two integers n and d (1\u2009\u2264\u2009n\u2009\u2264\u20091000,\u20091\u2009\u2264\u2009d\u2009\u2264\u2009109) \u2014 amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers \u2014 heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.", "output_spec": "Output one number \u2014 amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.", "sample_inputs": ["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"], "sample_outputs": ["6", "6"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "=1 && $n<=1000)&&(is_integer($d) && $d>=1 && $d<=exp(9*log(10))))\n{ //\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0438\u0430\u043f\u043e\u0437\u043e\u043d\u0430 \u0434\u043b\u044f n\n $f=true;\n for ($i=0; $i<=$n-1; $i++)\n {// \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0441\u043e\u043b\u0434\u0430\u0442\n if (($otryad[$i]<1)||($otryad[$i]>exp(9*log(10))))\n {$f=false;}\n }\n if ($f)\n {\n $count=0;\n for ($i=0; $i<$n-1; $i++)\n {\n for ($j=$i+1; $j<$n; $j++)\n {\n $h=abs($otryad[$i]-$otryad[$j]);\n if ($h<=$d) {$count++;}\n }\n }\n $count=$count*2;\n fputs(STDOUT, \"$count\");\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $a)\n foreach($h as $j => $b)\n if($i!=$j && abs($a-$b)<=$d) $ans++;\n\necho $ans;\n"}, {"source_code": " $a)\n foreach($height as $j => $b)\n if($i!=$j && abs($a-$b)<=$d) $ans++;\n\necho $ans;\n"}, {"source_code": ""}, {"source_code": "=1 && $n<=1000)&&($d>=1 && $d<=exp(9*log(10))))\n\t{\nfor ($i=1; $i<=$n-1; $i++)\n{\n\t$r=stripos($s,' ');\n\t$mas[$i]=substr($s, 0, $r);\n\t$s=substr($s, $r+1, $len-$r-1);\n\t}\n\t$mas[$n]=$s;\nfputs(STDOUT, \"Vihodnie dannie: \");\n\t$count=0;\n\tfor ($i=1; $i<=$n-1; $i++)\n\t{\n\t\tfor ($j=$i+1; $j<=$n; $j++)\n\t\t{\n\t\t\t$h=abs($mas[$i]-$mas[$j]);\n\t\t\tif ($h<=$d) {$count++;}\n\t\t\t}\n\t\t}\n\t\t$count=$count*2;\n\t\tfputs(STDOUT, \"$count\");\n\t}\n\telse\n\t{fputs(STDOUT, \"Nevernii diapazon\");\n\t\t}\n?>"}, {"source_code": "=1 && $n<=1000)&&($d>=1 && $d<=exp(9*log(10))))\n {\nfor ($i=1; $i<=$n-1; $i++)\n{\n $r=stripos($s,' ');\n $mas[$i]=substr($s, 0, $r);\n if (($mas[$i]<1)||($mas[$i]>exp(9*log(10))))\n {$f=false;}\n $s=substr($s, $r+1, $len-$r-1);\n }\n $mas[$n]=$s;\n if (($mas[$n]<1)||($mas[$n]>exp(9*log(10))))\n {$f=false;}\n if ($f)\n {\nfputs(STDOUT, \"Vihodnie dannie: \");\n $count=0;\n for ($i=1; $i<=$n-1; $i++)\n {\n for ($j=$i+1; $j<=$n; $j++)\n {\n $h=abs($mas[$i]-$mas[$j]);\n if ($h<=$d) {$count++;}\n }\n }\n $count=$count*2;\n fputs(STDOUT, \"$count\");\n }\n else\n {fputs(STDOUT, \"Nevernii diapazon\");\n }\n }\n?>"}, {"source_code": ""}, {"source_code": " /* BismiLahi Rahmani Rahim */ ?>\n\n\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "290d9779a6be44ce6a2e62989aee0dbd"} {"nl": {"description": "You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s|\u2009-\u20091 with exactly one pivot. We will assume that the bar is a segment on the Ox axis between points 0 and |s|\u2009-\u20091.The decoding of the lever description is given below. If the i-th character of the string equals \"^\", that means that at coordinate i there is the pivot under the bar. If the i-th character of the string equals \"=\", that means that at coordinate i there is nothing lying on the bar. If the i-th character of the string equals digit c (1-9), that means that at coordinate i there is a weight of mass c on the bar. Your task is, given the lever description, print if it will be in balance or not. Assume that the bar doesn't weight anything. Assume that the bar initially is in balance then all weights are simultaneously put on it. After that the bar either tilts to the left, or tilts to the right, or is in balance.", "input_spec": "The first line contains the lever description as a non-empty string s (3\u2009\u2264\u2009|s|\u2009\u2264\u2009106), consisting of digits (1-9) and characters \"^\" and \"=\". It is guaranteed that the line contains exactly one character \"^\". It is guaranteed that the pivot of the lever isn't located in any end of the lever bar. To solve the problem you may need 64-bit integer numbers. Please, do not forget to use them in your programs.", "output_spec": "Print \"left\" if the given lever tilts to the left, \"right\" if it tilts to the right and \"balance\", if it is in balance.", "sample_inputs": ["=^==", "9===^==1", "2==^7==", "41^52=="], "sample_outputs": ["balance", "left", "right", "balance"], "notes": "NoteAs you solve the problem, you may find the following link useful to better understand how a lever functions: http://en.wikipedia.org/wiki/Lever.The pictures to the examples: "}, "positive_code": [{"source_code": "0)\n{\n if($a[$j] == '=')\n $temp = 0;\n else\n $temp = $a[$j];\n \n $totalL = $totalL +($temp * $i);\n \n $i--;\n $j++;\n}\n$right++;\nwhile($a[$right])\n{\n if($a[$right] == '=')\n $temp = 0;\n else\n $temp = $a[$right];\n \n $totalR = $totalR +($temp * ($right-$right2));\n \n $right++;\n}\n\nif($totalR > $totalL)\n echo\"right\";\nelse if($totalR < $totalL)\n echo\"left\";\nelse\n echo\"balance\";\n ?>"}, {"source_code": "$right) echo \"left\";\nelse echo \"right\";\n?>"}, {"source_code": "=0;$i--)\n{\n if($left[$i] != \"=\")\n $sl+=$left[$i]*$ctmp;\n\n$ctmp++;\n}\n$ctmp=1;\nfor($i=0;$i $sl)\necho 'right';\nelse\necho 'left';\n\n?>"}, {"source_code": " $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $leftweight += $value * $pos;\n }\n}\nforeach ($right as $key => $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $rightweight += $value * $pos;\n }\n}\n\nif ($leftweight == $rightweight) {\n echo \"balance\";\n} elseif ($leftweight > $rightweight) {\n echo \"left\";\n} else {\n echo \"right\";\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $leftweight += $value * $pos;\n }\n}\nforeach ($right as $key => $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $rightweight += $value * $pos;\n }\n}\n\nif ($left == $right) {\n echo \"balance\";\n} elseif ($left > $right) {\n echo \"left\";\n} else {\n echo \"right\";\n}\n?>"}, {"source_code": " $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $leftweight += $value * $pos;\n }\n}\nforeach ($right as $key => $value) {\n if ($value !== \"=\") {\n $pos = $key + 1;\n $rightweight += $value * $pos;\n }\n}\n\nif ($left == $right) {\n echo \"balance\";\n} elseif ($left > $right) {\n echo \"left\";\n} else {\n echo \"right\";\n}\n?>"}], "src_uid": "19f2c21b18e84f50e251b1dfd557d32f"} {"nl": {"description": "Acingel is a small town. There was only one doctor here\u00a0\u2014 Miss Ada. She was very friendly and nobody has ever said something bad about her, so who could've expected that Ada will be found dead in her house? Mr Gawry, world-famous detective, is appointed to find the criminal. He asked $$$m$$$ neighbours of Ada about clients who have visited her in that unlucky day. Let's number the clients from $$$1$$$ to $$$n$$$. Each neighbour's testimony is a permutation of these numbers, which describes the order in which clients have been seen by the asked neighbour.However, some facts are very suspicious\u00a0\u2013 how it is that, according to some of given permutations, some client has been seen in the morning, while in others he has been seen in the evening? \"In the morning some of neighbours must have been sleeping!\"\u00a0\u2014 thinks Gawry\u00a0\u2014 \"and in the evening there's been too dark to see somebody's face...\". Now he wants to delete some prefix and some suffix (both prefix and suffix can be empty) in each permutation, so that they'll be non-empty and equal to each other after that\u00a0\u2014 some of the potential criminals may disappear, but the testimony won't stand in contradiction to each other.In how many ways he can do it? Two ways are called different if the remaining common part is different.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 100\\,000$$$, $$$1 \\le m \\le 10$$$)\u00a0\u2014 the number of suspects and the number of asked neighbors. Each of the next $$$m$$$ lines contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le n$$$). It is guaranteed that these integers form a correct permutation (that is, each number from $$$1$$$ to $$$n$$$ appears exactly once).", "output_spec": "Output a single integer denoting the number of ways to delete some prefix and some suffix of each permutation (possibly empty), such that the remaining parts will be equal and non-empty.", "sample_inputs": ["3 2\n1 2 3\n2 3 1", "5 6\n1 2 3 4 5\n2 3 1 4 5\n3 4 5 1 2\n3 5 4 2 1\n2 3 5 4 1\n1 2 3 4 5", "2 2\n1 2\n2 1"], "sample_outputs": ["4", "5", "2"], "notes": "NoteIn the first example, all possible common parts are $$$[1]$$$, $$$[2]$$$, $$$[3]$$$ and $$$[2, 3]$$$.In the second and third examples, you can only leave common parts of length $$$1$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "7733551cffde2a78826e9cd53f3a7c9d"} {"nl": {"description": "A positive integer $$$x$$$ is called a power of two if it can be represented as $$$x = 2^y$$$, where $$$y$$$ is a non-negative integer. So, the powers of two are $$$1, 2, 4, 8, 16, \\dots$$$.You are given two positive integers $$$n$$$ and $$$k$$$. Your task is to represent $$$n$$$ as the sum of exactly $$$k$$$ powers of two.", "input_spec": "The only line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 10^9$$$, $$$1 \\le k \\le 2 \\cdot 10^5$$$).", "output_spec": "If it is impossible to represent $$$n$$$ as the sum of $$$k$$$ powers of two, print NO. Otherwise, print YES, and then print $$$k$$$ positive integers $$$b_1, b_2, \\dots, b_k$$$ such that each of $$$b_i$$$ is a power of two, and $$$\\sum \\limits_{i = 1}^{k} b_i = n$$$. If there are multiple answers, you may print any of them.", "sample_inputs": ["9 4", "8 1", "5 1", "3 7"], "sample_outputs": ["YES\n1 2 2 4", "YES\n8", "NO", "NO"], "notes": null}, "positive_code": [{"source_code": " $b)\n{\n $c = array_fill(0, $b, 1);\n $d = 0;\n $e = 1;\n $f = 0;\n $g = 0;\n while(TRUE)\n {\n $h = pow(2, $e) + ($b - 1) + $f;\n if($h < $a)\n {\n $e++;\n }\n elseif($h == $a)\n {\n $c[$d] = pow(2, $e);\n $g = 1;\n break;\n }\n elseif($h > $a)\n {\n $b--;\n if($b == 0)\n {\n break;\n }\n $c[$d] = pow(2, $e - 1);\n $d++;\n $f += pow(2, $e - 1);\n $e = 1;\n }\n }\n if($g == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n print implode(\" \", $c);\n }\n}\n?>"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n\n$bc = Utils::bitCount($n);\nif ($bc > $k || $n<$k) {\n\techo \"NO\";\n\texit();\n} else {\n\t$stack = str_split(strrev(decbin($n)), 1);\n\n\t$d = $k - $bc;\n\twhile ($d > 0) {\n\t\t$top = array_pop($stack);\n\t\tif ($top === null) {echo \"NO\";exit();}\n\t\tif ($top <= $d) {\n\t\t\t$d -= $top;\n\t\t\t$x = array_pop($stack);\n\t\t\tif ($x === null) {echo \"NO\";exit();}\n\t\t\t$x+= $top*2;\n\t\t\tarray_push($stack, $x);\n\t\t} else {\n\t\t\t$x = array_pop($stack);\n\t\t\tif ($x === null) {echo \"NO\";exit();}\n\t\t\t$x+= $d*2;\n\t\t\tarray_push($stack, $x);\n\t\t\tarray_push($stack, $top-$d);\n\t\t\t$d -= $d;\n\t\t}\n\n\t}\n\t$s = '';\n\tforeach ($stack as $degree=>$count) {\n\t\t$s .= str_repeat(' ' . (1<<$degree), $count);\n\t}\n\techo \"YES\\n\";\n\techo trim($s);\n}\n\n"}], "negative_code": [{"source_code": " $b)\n{\n $c = array_fill(0, $b, 1);\n $d = 0;\n $e = 1;\n $f = 0;\n while(TRUE)\n {\n $h = pow(2, $e) + ($b - 1) + $f;\n if($h < $a)\n {\n $e++;\n }\n elseif($h == $a)\n {\n $c[$d] = pow(2, $e);\n $f = 1;\n break;\n }\n elseif($h > $a)\n {\n $b--;\n if($b == 0)\n {\n break;\n }\n $c[$d] = pow(2, $e - 1);\n $d++;\n $f += pow(2, $e - 1);\n $e = 1;\n }\n }\n if($f == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n print implode(\" \", $c);\n }\n}\n?>"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n\n$bc = Utils::bitCount($n);\nif ($bc > $k) {\n\techo \"NO\";\n\texit();\n} else {\n\t$stack = str_split(strrev(decbin($n)), 1);\n\t\n\t$d = $k - $bc;\n\twhile ($d > 0) {\n\t\t$top = array_pop($stack);\n\t\tif ($top <= $d) {\n\t\t\t$d -= $top;\n\t\t\t$x = array_pop($stack);\n\t\t\t$x+= $top*2;\n\t\t\tarray_push($stack, $x);\n\t\t} else {\n\t\t\t$x = array_pop($stack);\n\t\t\t$x+= $d*2;\n\t\t\tarray_push($stack, $x);\n\t\t\tarray_push($stack, $top-$d);\n\t\t\t$d -= $d;\n\t\t}\n\t}\n\t$s = '';\n\tforeach ($stack as $degree=>$count) {\n\t\t$s .= str_repeat(' ' . (1<<$degree), $count);\n\t}\n\techo \"YES\\n\";\n\techo trim($s);\n}\n\n"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n\n$bc = Utils::bitCount($n);\nif ($bc > $k || $n<$k) {\n\techo \"NO\";\n\texit();\n} else {\n\t$stack = str_split(strrev(decbin($n)), 1);\n\tvar_dump($stack);\n\n\t$d = $k - $bc;\n\twhile ($d > 0) {\n\t\t$top = array_pop($stack);\n\t\tif ($top === null) {echo \"NO\";exit();}\n\t\tif ($top <= $d) {\n\t\t\t$d -= $top;\n\t\t\t$x = array_pop($stack);\n\t\t\tif ($x === null) {echo \"NO\";exit();}\n\t\t\t$x+= $top*2;\n\t\t\tarray_push($stack, $x);\n\t\t} else {\n\t\t\t$x = array_pop($stack);\n\t\t\tif ($x === null) {echo \"NO\";exit();}\n\t\t\t$x+= $d*2;\n\t\t\tarray_push($stack, $x);\n\t\t\tarray_push($stack, $top-$d);\n\t\t\t$d -= $d;\n\t\t}\n\t\tvar_dump($stack);\n\t}\n\t$s = '';\n\tforeach ($stack as $degree=>$count) {\n\t\t$s .= str_repeat(' ' . (1<<$degree), $count);\n\t}\n\techo \"YES\\n\";\n\techo trim($s);\n}\n\n"}], "src_uid": "10d6179b479e1238a51154a9a6fc13cb"} {"nl": {"description": "You have $$$n$$$ rectangular wooden blocks, which are numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th block is $$$1$$$ unit high and $$$\\lceil \\frac{i}{2} \\rceil$$$ units long.Here, $$$\\lceil \\frac{x}{2} \\rceil$$$ denotes the result of division of $$$x$$$ by $$$2$$$, rounded up. For example, $$$\\lceil \\frac{4}{2} \\rceil = 2$$$ and $$$\\lceil \\frac{5}{2} \\rceil = \\lceil 2.5 \\rceil = 3$$$.For example, if $$$n=5$$$, then the blocks have the following sizes: $$$1 \\times 1$$$, $$$1 \\times 1$$$, $$$1 \\times 2$$$, $$$1 \\times 2$$$, $$$1 \\times 3$$$. The available blocks for $$$n=5$$$ Find the maximum possible side length of a square you can create using these blocks, without rotating any of them. Note that you don't have to use all of the blocks. One of the ways to create $$$3 \\times 3$$$ square using blocks $$$1$$$ through $$$5$$$ ", "input_spec": "Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$)\u00a0\u2014 the number of blocks.", "output_spec": "For each test case, print one integer\u00a0\u2014 the maximum possible side length of a square you can create.", "sample_inputs": ["3\n\n2\n\n5\n\n197654321"], "sample_outputs": ["1\n3\n98827161"], "notes": "NoteIn the first test case, you can create a $$$1 \\times 1$$$ square using only one of the blocks.In the second test case, one of the possible ways to create a $$$3 \\times 3$$$ square is shown in the statement. It is impossible to create a $$$4 \\times 4$$$ or larger square, so the answer is $$$3$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "';\n\n if (is_array($data)) {\n print_r($data);\n } else {\n var_dump($data);\n }\n\n if ($die) {\n die();\n }\n\n echo ' "}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $c = strlen($data);\n if ($c<2 || $c>200000) print 0;\n else{\n $sc = substr_count($data, 'I');\n \tif ($sc>0) print $sc;\n \telse print substr_count($data, 'A');\n }\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $arr = array();\n $c = strlen($data);\n for ($i=0;$i<$c;$i++)\n \t$arr[$data{$i}]++;\n \n if (isset($arr['I'])) print $arr['I'];\n elseif (isset($arr['A'])) print $arr['A'];\n else print 0;\n ?>"}, {"source_code": "\n $a = fgets(STDIN);\n $data = trim(fgets(STDIN));\n $arr = array();\n for ($i=0;$i<$a;$i++){\n \t$arr[$data{$i}]++;\n }\n if (isset($arr['I'])) print $arr['I'];\n elseif (isset($arr['A'])) print $arr['A'];\n else print 0;\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $a = substr_count($data, 'I');\n if ($a == 1){\n \tprint 1;\n }elseif ($a > 1){\n \tprint $a - 1;\n }else print substr_count($data, 'A');\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $sc = substr_count($data, 'I');\n if ($sc>0) print $sc;\n else print substr_count($data, 'A');\n ?>"}, {"source_code": "\n fgets(STDIN);\n $data = trim(fgets(STDIN));\n $arr = array();\n for ($i=0;$i "}], "src_uid": "5e4defe52832cc0d36e7ea5d9f86f895"} {"nl": {"description": "Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).The key in football is to divide into teams fairly before the game begins. There are n boys playing football in the yard (including Petya), each boy's football playing skill is expressed with a non-negative characteristic ai (the larger it is, the better the boy plays). Let's denote the number of players in the first team as x, the number of players in the second team as y, the individual numbers of boys who play for the first team as pi and the individual numbers of boys who play for the second team as qi. Division n boys into two teams is considered fair if three conditions are fulfilled: Each boy plays for exactly one team (x\u2009+\u2009y\u2009=\u2009n). The sizes of teams differ in no more than one (|x\u2009-\u2009y|\u2009\u2264\u20091). The total football playing skills for two teams differ in no more than by the value of skill the best player in the yard has. More formally: Your task is to help guys divide into two teams fairly. It is guaranteed that a fair division into two teams always exists.", "input_spec": "The first line contains the only integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009105) which represents the number of guys in the yard. The next line contains n positive space-separated integers, ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009104), the i-th number represents the i-th boy's playing skills. ", "output_spec": "On the first line print an integer x \u2014 the number of boys playing for the first team. On the second line print x integers \u2014 the individual numbers of boys playing for the first team. On the third line print an integer y \u2014 the number of boys playing for the second team, on the fourth line print y integers \u2014 the individual numbers of boys playing for the second team. Don't forget that you should fulfil all three conditions: x\u2009+\u2009y\u2009=\u2009n, |x\u2009-\u2009y|\u2009\u2264\u20091, and the condition that limits the total skills. If there are multiple ways to solve the problem, print any of them. The boys are numbered starting from one in the order in which their skills are given in the input data. You are allowed to print individual numbers of boys who belong to the same team in any order.", "sample_inputs": ["3\n1 2 1", "5\n2 3 3 1 1"], "sample_outputs": ["2\n1 2 \n1\n3", "3\n4 1 3 \n2\n5 2"], "notes": "NoteLet's consider the first sample test. There we send the first and the second boy to the first team and the third boy to the second team. Let's check all three conditions of a fair division. The first limitation is fulfilled (all boys play), the second limitation on the sizes of groups (|2\u2009-\u20091|\u2009=\u20091\u2009\u2264\u20091) is fulfilled, the third limitation on the difference in skills ((2\u2009+\u20091)\u2009-\u2009(1)\u2009=\u20092\u2009\u2264\u20092) is fulfilled."}, "positive_code": [{"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n\t\n/*\tanother way roop numbers is half.\n\t$len = count($arr_key);\n\tfor ($i = 0; $i < $len / 2; $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$len - $i - 1] + 1;\n\t}\n\tif ($len % 2 === 1) $temp_arr_1[] = $arr_key[$len % 2 + 1] + 1;\n\t}\n*/\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) % 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\tif ($temp_len % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[(int)($temp_len / 2) - 1] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[(int)($temp_len / 2) + 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_1[] = $arr_key[(int)($temp_len / 2) - 1] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\t\t}\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}], "negative_code": [{"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray(12);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\tforeach ($arr_key as $as_i) {\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\t$temp_c++;\n\t}\n\t\tarray_printf($temp_arr_1);\n\t\tprint(\"\\n\");\n\t\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) / 2 === 1){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[(int)($temp_len / 2) - 1];\n\t\t$temp_arr_2[(int)($temp_len / 2)];\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) % 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[] = $arr_key[(int)($temp_len / 2) - 1] + 1;\n\t\t$temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t}\n\t\t$temp_c++;\n\t}\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2) + 1] + 1;\n\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) % 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[] = $arr_key[(int)($temp_len / 2) - 1];\n\t\t$temp_arr_2[] = $arr_key[(int)($temp_len / 2)];\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) / 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[(int)($temp_len / 2) - 1];\n\t\t$temp_arr_2[(int)($temp_len / 2)];\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\tforeach ($arr_key as $as_i) {\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\t$temp_c++;\n\t}\n\t\n/*\tanother way roop numbers is half.\n\t$len = count($arr_key);\n\tfor ($i = 0; $i < $len / 2; $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i];\n\t\t\t$temp_arr_1[] = $arr_key[$len - $i - 1];\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i];\n\t\t\t$temp_arr_2[] = $arr_key[$len - $i - 1];\n\t}\n\tif ($len % 2 === 1) $temp_arr_1[] = $arr_key[$len % 2 + 1];\n\t}\n*/\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) / 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[(int)($temp_len / 2) - 1];\n\t\t$temp_arr_2[(int)($temp_len / 2)];\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\n/*\t$temp_c = 1;\n\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\tfor ($i = 0; $i < $temp_len / 2; $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t}\n\tif ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len % 2 + 1] + 1;\n\t}\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t}\n\t\t$temp_c++;\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tfor ($i = 0; $i < (int)$temp_len / 2; $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t}\n\t\t$temp_c++;\n\t}\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[$temp_len / 2 + 1] + 1;\n\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\t//for ($i = 0; $i < $temp_len / 2; $i++) {\n\tif ((int)($temp_len / 2) % 2 === 1 && $temp_len !== 3){ \n\t\tfor ($i = 0; $i < (int)($temp_len / 2) - 1; $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t\t$temp_arr_1[(int)($temp_len / 2) - 1];\n\t\t$temp_arr_2[(int)($temp_len / 2)];\n\t} else {\n\t\tfor ($i = 0; $i < (int)($temp_len / 2); $i++) {\n\t\t\tif ($temp_c % 2 === 1) {\n\t\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t} else {\n\t\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t\t}\n\t\t\t$temp_c++;\n\t\t}\n\t}\n\t//if ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len / 2 + 1] + 1;\n\tif ($temp_len % 2 === 1) $temp_arr_2[] = $arr_key[(int)($temp_len / 2)] + 1;\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.\u30eb\u30fc\u30d7\u306e\u30ad\u30e3\u30b9\u30c8\n2.\u6b8b\u3063\u305f1\u3064\u3092\u5165\u308c\u308b\u914d\u5217\n3.index\u306e\u30ad\u30e3\u30b9\u30c8\n*/\n?>"}, {"source_code": "_tok = $tok;\n\t\t$this->_token = strtok($str_line, $this->_tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->_token;\n\t\t$this->_token = strtok($this->_tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n\t\n\tpublic function nextIntArray($num) {\n\t\t$temp_arr = array();\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$temp_arr[] = (int)$this->nextToken();\n\t\t}\n\t\treturn $temp_arr;\n\t}\n}\n\nfunction array_printf(array $array) {\n\t\t$message = \"\";\n\t\tforeach ($array as $value) {\n\t\t\t$message .= \"$value\" . \" \";\n\t\t}\n\t\t$message = rtrim($message);\n\t\tprintf('%s', $message);\n}\n\nfunction solve(){\n\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_k = $Token->nextInt();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$inp_arr = $Token->nextIntArray($inp_k);\n\t\n\tif (arsort(&$inp_arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$arr_key = array_keys($inp_arr); \n\t$temp_arr_1 = array();\n\t$temp_arr_2 = array();\n\t$temp_c = 1;\n\n/*\tforeach ($arr_key as $as_i) {\n\t\t//if ($temp_c % 2 === 1) $temp_arr_1[] = $as_i;\n\t\tif ($temp_c % 2 === 1) $temp_arr_1[] = $as_i + 1;\n\t\t//else if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i;\n\t\telse if ($temp_c % 2 === 0) $temp_arr_2[] = $as_i + 1;\n\t\t$temp_c++;\n\t}\n*/\t\n\t//another way roop numbers is half.\n\t$temp_len = count($arr_key);\n\tfor ($i = 0; $i < $temp_len / 2; $i++) {\n\t\tif ($temp_c % 2 === 1) {\n\t\t\t$temp_arr_1[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_1[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t} else {\n\t\t\t$temp_arr_2[] = $arr_key[$i] + 1;\n\t\t\t$temp_arr_2[] = $arr_key[$temp_len - $i - 1] + 1;\n\t\t}\n\t\t$temp_c++;\n\t}\n\tif ($temp_len % 2 === 1) $temp_arr_1[] = $arr_key[$temp_len % 2 + 1] + 1;\n\n\n\t$len_arr1 = count($temp_arr_1);\n\t$len_arr2 = count($temp_arr_2);\n\tprintf(\"%d\\n\", $len_arr1);\n\tarray_printf($temp_arr_1);\n\tprintf(\"\\n%d\\n\", $len_arr2);\n\tarray_printf($temp_arr_2);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n/*\n1.runtime err \u30af\u30e9\u30b9\u306e\u540d\u79f0\n2.output 01\n*/\n?>"}], "src_uid": "0937a7e2f912fc094cc4275fd47cd457"} {"nl": {"description": "Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.We know that the i-th star on the pedal axle has ai (0\u2009<\u2009a1\u2009<\u2009a2\u2009<\u2009...\u2009<\u2009an) teeth, and the j-th star on the rear wheel axle has bj (0\u2009<\u2009b1\u2009<\u2009b2\u2009<\u2009...\u2009<\u2009bm) teeth. Any pair (i,\u2009j) (1\u2009\u2264\u2009i\u2009\u2264\u2009n;\u00a01\u2009\u2264\u2009j\u2009\u2264\u2009m) is called a gear and sets the indexes of stars to which the chain is currently attached. Gear (i,\u2009j) has a gear ratio, equal to the value .Since Vasya likes integers, he wants to find such gears (i,\u2009j), that their ratios are integers. On the other hand, Vasya likes fast driving, so among all \"integer\" gears (i,\u2009j) he wants to choose a gear with the maximum ratio. Help him to find the number of such gears.In the problem, fraction denotes division in real numbers, that is, no rounding is performed.", "input_spec": "The first input line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u200950) \u2014 the number of stars on the bicycle's pedal axle. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009104) in the order of strict increasing. The third input line contains integer m (1\u2009\u2264\u2009m\u2009\u2264\u200950) \u2014 the number of stars on the rear wheel axle. The fourth line contains m integers b1,\u2009b2,\u2009...,\u2009bm (1\u2009\u2264\u2009bi\u2009\u2264\u2009104) in the order of strict increasing. It is guaranteed that there exists at least one gear (i,\u2009j), that its gear ratio is an integer. The numbers on the lines are separated by spaces.", "output_spec": "Print the number of \"integer\" gears with the maximum ratio among all \"integer\" gears.", "sample_inputs": ["2\n4 5\n3\n12 13 15", "4\n1 2 3 4\n5\n10 11 12 13 14"], "sample_outputs": ["2", "1"], "notes": "NoteIn the first sample the maximum \"integer\" gear ratio equals 3. There are two gears that have such gear ratio. For one of them a1\u2009=\u20094,\u2009b1\u2009=\u200912, and for the other a2\u2009=\u20095,\u2009b3\u2009=\u200915."}, "positive_code": [{"source_code": ""}, {"source_code": "in();\n\n\tfor ($i = 0; $i < $N; $i++)\n\t{\n\t\t$A[] = (int)$Input->in();\n\t}\n\n\t$M = (int)$Input->in();\n\n\t$max = -1;\n\t$c = 0;\n\n\tfor ($i = 0; $i < $M; $i++)\n\t{\n\t\t$B = (int)$Input->in();\n\n\t\tforeach ($A as $a)\n\t\t{\n\t\t\tif ($B % $a === 0)\n\t\t\t{\n\t\t\t\tif ($max < intval($B / $a))\n\t\t\t\t{\n\t\t\t\t\t$max = intval($B / $a);\n\t\t\t\t\t$c = 1;\n\t\t\t\t}\n\t\t\t\telse if ($max === intval($B / $a))\n\t\t\t\t{\n\t\t\t\t\t$c++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tprint($c);\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}, {"source_code": " $ff) {\n $res=1;\n $ff = $ss;\n }\n elseif ($ss == $ff) {\n $res++;\n }\n }\n }\n}\necho $res;\n?>"}, {"source_code": " $max) {$max = $b[$j]/$a[$i]; $r = 1;}\n\nprint $r;\n?>"}], "negative_code": [{"source_code": ""}], "src_uid": "102667eaa3aee012fef70f4192464674"} {"nl": {"description": "Polycarp has to solve exactly $$$n$$$ problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in $$$k$$$ days. It means that Polycarp has exactly $$$k$$$ days for training!Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of $$$k$$$ days. He also doesn't want to overwork, so if he solves $$$x$$$ problems during some day, he should solve no more than $$$2x$$$ problems during the next day. And, at last, he wants to improve his skill, so if he solves $$$x$$$ problems during some day, he should solve at least $$$x+1$$$ problem during the next day.More formally: let $$$[a_1, a_2, \\dots, a_k]$$$ be the array of numbers of problems solved by Polycarp. The $$$i$$$-th element of this array is the number of problems Polycarp solves during the $$$i$$$-th day of his training. Then the following conditions must be satisfied: sum of all $$$a_i$$$ for $$$i$$$ from $$$1$$$ to $$$k$$$ should be $$$n$$$; $$$a_i$$$ should be greater than zero for each $$$i$$$ from $$$1$$$ to $$$k$$$; the condition $$$a_i < a_{i + 1} \\le 2 a_i$$$ should be satisfied for each $$$i$$$ from $$$1$$$ to $$$k-1$$$. Your problem is to find any array $$$a$$$ of length $$$k$$$ satisfying the conditions above or say that it is impossible to do it.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 10^9, 1 \\le k \\le 10^5$$$) \u2014 the number of problems Polycarp wants to solve and the number of days Polycarp wants to train.", "output_spec": "If it is impossible to find any array $$$a$$$ of length $$$k$$$ satisfying Polycarp's rules of training, print \"NO\" in the first line. Otherwise print \"YES\" in the first line, then print $$$k$$$ integers $$$a_1, a_2, \\dots, a_k$$$ in the second line, where $$$a_i$$$ should be the number of problems Polycarp should solve during the $$$i$$$-th day. If there are multiple answers, you can print any.", "sample_inputs": ["26 6", "8 3", "1 1", "9 4"], "sample_outputs": ["YES\n1 2 4 5 6 8", "NO", "YES\n1", "NO"], "notes": null}, "positive_code": [{"source_code": " $n) {\n die('NO');\n}\n\n$arr = [];\n\nfor ($i = 0; $i < $k; $i++) {\n $arr[$i] = $i + 1;\n}\n\n$delta = (int)floor(($n - $summ) / $k);\nif ($delta) {\n for ($i = 0; $i < $k; $i++) {\n $arr[$i] = $i + $delta;\n }\n}\n\n$n -= array_sum($arr);\n\n$lastIndex = $k - 1;\nwhile($n > 0) {\n $i = $lastIndex;\n while ($n > 0 && $i >= 0 && $arr[$i] < ($delta + $arr[0] * 2 ** $i)) {\n $arr[$i]++;\n $n--;\n $i--;\n }\n if ($arr[$lastIndex] === (int)($delta + $arr[0] * 2 ** $lastIndex)) {\n break;\n }\n}\nif ($n !== 0) {\n echo 'NO';\n} else {\n echo 'YES' . PHP_EOL . implode(' ', $arr);\n}\n"}], "negative_code": [{"source_code": " 0 && $n !== $tmp) {\n $tmp = $n;\n for ($i = $k - 1; $i > 0 && $n > 0; $i--) {\n if (($arr[$i] / $arr[$i - 1]) < 2) {\n $arr[$i]++;\n $n--;\n }\n }\n}\nif ($n !== 0) {\n echo 'NO';\n} else {\n echo 'YES' . PHP_EOL . implode(' ', $arr);\n}\n"}], "src_uid": "df801ebbe05c17bb1d157108d523d1f8"} {"nl": {"description": "DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s\u2009=\u2009s1s2... s|s| (|s| is the length of the string) he represents its value with a function f(s), where Now DZY has a string s. He wants to insert k lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get? ", "input_spec": "The first line contains a single string s\u00a0(1\u2009\u2264\u2009|s|\u2009\u2264\u2009103). The second line contains a single integer k\u00a0(0\u2009\u2264\u2009k\u2009\u2264\u2009103). The third line contains twenty-six integers from wa to wz. Each such number is non-negative and doesn't exceed 1000.", "output_spec": "Print a single integer \u2014 the largest possible value of the resulting string DZY could get.", "sample_inputs": ["abc\n3\n1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"], "sample_outputs": ["41"], "notes": "NoteIn the test sample DZY can obtain \"abcbbc\", value\u2009=\u20091\u00b71\u2009+\u20092\u00b72\u2009+\u20093\u00b72\u2009+\u20094\u00b72\u2009+\u20095\u00b72\u2009+\u20096\u00b72\u2009=\u200941."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "85f90533a9840e944deef9f3b4229cb8"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ integers.Let's call a pair of indices $$$i$$$, $$$j$$$ good if $$$1 \\le i < j \\le n$$$ and $$$\\gcd(a_i, 2a_j) > 1$$$ (where $$$\\gcd(x, y)$$$ is the greatest common divisor of $$$x$$$ and $$$y$$$).Find the maximum number of good index pairs if you can reorder the array $$$a$$$ in an arbitrary way.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of the test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 2000$$$)\u00a0\u2014 the number of elements in the array. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^5$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the maximum number of good index pairs if you can reorder the array $$$a$$$ in an arbitrary way.", "sample_inputs": ["3\n4\n3 6 5 3\n2\n1 7\n5\n1 4 2 4 1"], "sample_outputs": ["4\n0\n9"], "notes": "NoteIn the first example, the array elements can be rearranged as follows: $$$[6, 3, 5, 3]$$$.In the third example, the array elements can be rearranged as follows: $$$[4, 4, 2, 1, 1]$$$."}, "positive_code": [{"source_code": " 1) { $ans++; }\r\n }\r\n }\r\n echo $ans.PHP_EOL;\r\n}\r\n\r\n?>"}], "negative_code": [], "src_uid": "d638f524fe07cb8e822b5c6ec3fe8216"} {"nl": {"description": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with the task.", "input_spec": "The single line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009106) \u2014 the sum of digits of the required lucky number.", "output_spec": "Print on the single line the result \u2014 the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.", "sample_inputs": ["11", "10"], "sample_outputs": ["47", "-1"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "2584fa8c1adb1aa8cd5c28a8610ff72d"} {"nl": {"description": "$$$n$$$ students are taking an exam. The highest possible score at this exam is $$$m$$$. Let $$$a_{i}$$$ be the score of the $$$i$$$-th student. You have access to the school database which stores the results of all students.You can change each student's score as long as the following conditions are satisfied: All scores are integers $$$0 \\leq a_{i} \\leq m$$$ The average score of the class doesn't change. You are student $$$1$$$ and you would like to maximize your own score.Find the highest possible score you can assign to yourself such that all conditions are satisfied.", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 200$$$). The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\leq 10^{3}$$$, $$$1 \\leq m \\leq 10^{5}$$$) \u00a0\u2014 the number of students and the highest possible score respectively. The second line of each testcase contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$ 0 \\leq a_{i} \\leq m$$$) \u00a0\u2014 scores of the students.", "output_spec": "For each testcase, output one integer \u00a0\u2014 the highest possible score you can assign to yourself such that both conditions are satisfied._", "sample_inputs": ["2\n4 10\n1 2 3 4\n4 5\n1 2 3 4"], "sample_outputs": ["10\n5"], "notes": "NoteIn the first case, $$$a = [1,2,3,4] $$$, with average of $$$2.5$$$. You can change array $$$a$$$ to $$$[10,0,0,0]$$$. Average remains $$$2.5$$$, and all conditions are satisfied.In the second case, $$$0 \\leq a_{i} \\leq 5$$$. You can change $$$a$$$ to $$$[5,1,1,3]$$$. You cannot increase $$$a_{1}$$$ further as it will violate condition $$$0\\le a_i\\le m$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $b)\n {\n $f = floor($d / $b);\n $g = $d % $b;\n $d = $g;\n print ($e + $f) . \" \";\n $e = 0;\n }\n}\n?>"}], "negative_code": [], "src_uid": "a2085c2d21b2dbe4cc27a15fa4a1ec4f"} {"nl": {"description": "Cowboy Vlad has a birthday today! There are $$$n$$$ children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a circle arbitrarily, it may turn out, that there is a tall and low child standing next to each other, and it will be difficult for them to hold hands. Therefore, children want to stand in a circle so that the maximum difference between the growth of two neighboring children would be minimal possible.Formally, let's number children from $$$1$$$ to $$$n$$$ in a circle order, that is, for every $$$i$$$ child with number $$$i$$$ will stand next to the child with number $$$i+1$$$, also the child with number $$$1$$$ stands next to the child with number $$$n$$$. Then we will call the discomfort of the circle the maximum absolute difference of heights of the children, who stand next to each other.Please help children to find out how they should reorder themselves, so that the resulting discomfort is smallest possible.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$2 \\leq n \\leq 100$$$)\u00a0\u2014 the number of the children who came to the cowboy Vlad's birthday. The second line contains integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$) denoting heights of every child.", "output_spec": "Print exactly $$$n$$$ integers\u00a0\u2014 heights of the children in the order in which they should stand in a circle. You can start printing a circle with any child. If there are multiple possible answers, print any of them.", "sample_inputs": ["5\n2 1 1 3 2", "3\n30 10 20"], "sample_outputs": ["1 2 3 2 1", "10 20 30"], "notes": "NoteIn the first example, the discomfort of the circle is equal to $$$1$$$, since the corresponding absolute differences are $$$1$$$, $$$1$$$, $$$1$$$ and $$$0$$$. Note, that sequences $$$[2, 3, 2, 1, 1]$$$ and $$$[3, 2, 1, 1, 2]$$$ form the same circles and differ only by the selection of the starting point.In the second example, the discomfort of the circle is equal to $$$20$$$, since the absolute difference of $$$10$$$ and $$$30$$$ is equal to $$$20$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "205b2332c176b758e843473e8d357475"} {"nl": {"description": "Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is:Given an undirected tree consisting of n nodes, find the minimum number of vertices that cover all the edges. Formally, we need to find a set of vertices such that for each edge (u,\u2009v) that belongs to the tree, either u is in the set, or v is in the set, or both are in the set. Mahmoud has found the following algorithm: Root the tree at node 1. Count the number of nodes at an even depth. Let it be evenCnt. Count the number of nodes at an odd depth. Let it be oddCnt. The answer is the minimum between evenCnt and oddCnt. The depth of a node in a tree is the number of edges in the shortest path between this node and the root. The depth of the root is 0.Ehab told Mahmoud that this algorithm is wrong, but he didn't believe because he had tested his algorithm against many trees and it worked, so Ehab asked you to find 2 trees consisting of n nodes. The algorithm should find an incorrect answer for the first tree and a correct answer for the second one.", "input_spec": "The only line contains an integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009105), the number of nodes in the desired trees.", "output_spec": "The output should consist of 2 independent sections, each containing a tree. The algorithm should find an incorrect answer for the tree in the first section and a correct answer for the tree in the second. If a tree doesn't exist for some section, output \"-1\" (without quotes) for that section only. If the answer for a section exists, it should contain n\u2009-\u20091 lines, each containing 2 space-separated integers u and v (1\u2009\u2264\u2009u,\u2009v\u2009\u2264\u2009n), which means that there's an undirected edge between node u and node v. If the given graph isn't a tree or it doesn't follow the format, you'll receive wrong answer verdict. If there are multiple answers, you can print any of them.", "sample_inputs": ["2", "8"], "sample_outputs": ["-1\n1 2", "1 2\n1 3\n2 4\n2 5\n3 6\n4 7\n4 8\n1 2\n1 3\n2 4\n2 5\n2 6\n3 7\n6 8"], "notes": "NoteIn the first sample, there is only 1 tree with 2 nodes (node 1 connected to node 2). The algorithm will produce a correct answer in it so we printed \u2009-\u20091 in the first section, but notice that we printed this tree in the second section.In the second sample:In the first tree, the algorithm will find an answer with 4 nodes, while there exists an answer with 3 nodes like this: In the second tree, the algorithm will find an answer with 3 nodes which is correct: "}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}], "negative_code": [], "src_uid": "b1959af75dfdf8281e70ae66375caa14"} {"nl": {"description": "You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.You know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English characters, each language consists of several words. For each language, all words are distinct, i.e. they are spelled differently. Moreover, the words of these languages have a one-to-one correspondence, that is, for each word in each language, there exists exactly one word in the other language having has the same meaning.You can write down every word the professor says in either the first language or the second language. Of course, during the lecture you write down each word in the language in which the word is shorter. In case of equal lengths of the corresponding words you prefer the word of the first language.You are given the text of the lecture the professor is going to read. Find out how the lecture will be recorded in your notes.", "input_spec": "The first line contains two integers, n and m (1\u2009\u2264\u2009n\u2009\u2264\u20093000, 1\u2009\u2264\u2009m\u2009\u2264\u20093000) \u2014 the number of words in the professor's lecture and the number of words in each of these languages. The following m lines contain the words. The i-th line contains two strings ai, bi meaning that the word ai belongs to the first language, the word bi belongs to the second language, and these two words have the same meaning. It is guaranteed that no word occurs in both languages, and each word occurs in its language exactly once. The next line contains n space-separated strings c1,\u2009c2,\u2009...,\u2009cn \u2014 the text of the lecture. It is guaranteed that each of the strings ci belongs to the set of strings {a1,\u2009a2,\u2009... am}. All the strings in the input are non-empty, each consisting of no more than 10 lowercase English letters.", "output_spec": "Output exactly n words: how you will record the lecture in your notebook. Output the words of the lecture in the same order as in the input.", "sample_inputs": ["4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest", "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll"], "sample_outputs": ["codeforces round letter round", "hbnyiyc joll joll un joll"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "0)\n\t{\nlist($c, $d) = explode(\" \", trim(fgets(STDIN)));\n\t\tif(strlen($c)>strlen($d))\n\t\t\t$mp[$c]=$d;\n\t\telse\n\t\t\t$mp[$c]=$c;\n\t$b--;}\n\n$qw = explode(\" \", trim(fgets(STDIN)));\n\tfor ($i=0;$i<$a;$i++)\n\t{\n\t\tif ($i != $a-1)\n\t\techo $mp[$qw[$i]].\" \";\nelse echo $mp[$qw[$i]].PHP_EOL;\n\t}\n\t\n\n?>"}, {"source_code": " strlen($data[1])){\n $short_sting = $data[1];\n }\n else{\n $short_sting = $data[0];\n }\n \n $voc[$data[0]] = $short_sting;\n\n}\n\n$lection = readline();\n\n$lection_array = explode(' ', $lection);\n$new_lect = [];\nfor($a = 0;$a < $lection_size; $a++){\n $new_lect[] = $voc[$lection_array[$a]];\n}\n\n$return = implode(' ', $new_lect);\n\nprint_r($return);\n\nreturn 0;\n\n?>"}, {"source_code": " $kalame) {\n if(strlen($array[$kalame]) < strlen($kalame)){\n $jomle[$key]=$array[$kalame];\n }\n}\necho join(' ',$jomle);"}, {"source_code": "$item){\n $s = str_replace($k.\" \",$item.\" \",$s);\n}\n\necho $s;"}, {"source_code": "$item){\n $s = str_replace(\" \".$k.\" \",\" \".$item.\" \",$s);\n}\n\necho trim($s);"}], "src_uid": "edd556d60de89587f1b8daa893538530"} {"nl": {"description": "You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Ox axis, equals w, the length of the side that is parallel to the Oy axis, equals h. The second rectangle can be obtained by rotating the first rectangle relative to the origin of coordinates by angle \u03b1. Your task is to find the area of the region which belongs to both given rectangles. This region is shaded in the picture.", "input_spec": "The first line contains three integers w,\u2009h,\u2009\u03b1 (1\u2009\u2264\u2009w,\u2009h\u2009\u2264\u2009106;\u00a00\u2009\u2264\u2009\u03b1\u2009\u2264\u2009180). Angle \u03b1 is given in degrees.", "output_spec": "In a single line print a real number \u2014 the area of the region which belongs to both given rectangles. The answer will be considered correct if its relative or absolute error doesn't exceed 10\u2009-\u20096.", "sample_inputs": ["1 1 45", "6 4 30"], "sample_outputs": ["0.828427125", "19.668384925"], "notes": "NoteThe second sample has been drawn on the picture above."}, "positive_code": [{"source_code": " 90) $a = 180- $a;\n $a = $a * pi() / 180;\n $t = 2* atan($h / $w);\n \n $ret = 0;\n if ($a == 0)\n $ret = $w * $h;\n elseif ($a < $t)\n {\n $sina = sin($a);\n $cosa = cos($a);\n $ret = ($w * $h - (1 - $cosa) * ($h * $h + $w * $w - 2 * $h * $w * $sina) / (2 * $sina * $cosa));\n }\n else\n $ret = $h * $h / sin($a);\n \n echo $ret;\n \n?>\n"}], "negative_code": [], "src_uid": "21432a74b063b008cf9f04d2804c1c3f"} {"nl": {"description": "You are given a string $$$s$$$ consisting only of lowercase Latin letters.You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossible to do it.Let's call a string good if it is not a palindrome. Palindrome is a string which is read from left to right the same as from right to left. For example, strings \"abacaba\", \"aa\" and \"z\" are palindromes and strings \"bba\", \"xd\" are not.You have to answer $$$t$$$ independent queries.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 number of queries. Each of the next $$$t$$$ lines contains one string. The $$$i$$$-th line contains a string $$$s_i$$$ consisting only of lowercase Latin letter. It is guaranteed that the length of $$$s_i$$$ is from $$$1$$$ to $$$1000$$$ (inclusive).", "output_spec": "Print $$$t$$$ lines. In the $$$i$$$-th line print the answer to the $$$i$$$-th query: -1 if it is impossible to obtain a good string by rearranging the letters of $$$s_i$$$ and any good string which can be obtained from the given one (by rearranging the letters) otherwise.", "sample_inputs": ["3\naa\nabacaba\nxdd"], "sample_outputs": ["-1\nabaacba\nxdd"], "notes": "NoteIn the first query we cannot rearrange letters to obtain a good string.Other examples (not all) of correct answers to the second query: \"ababaca\", \"abcabaa\", \"baacaba\".In the third query we can do nothing to obtain a good string."}, "positive_code": [{"source_code": ""}, {"source_code": "0){\n // echo \"1\";\n echo $array[$i];\n echo \"\\n\";\n }\n else{\n $check=0;\n // echo \"2\";\n for ($l=0;$l<$len;$l++){\n // echo \"3\";\n if($var[0]!=$var[$l]){\n // echo \"4\";\n $swap=$var[0];\n $var[0]=$var[$l];\n $var[$l]=$swap;\n for($m=0;$m<$len;$m++){\n echo $var[$m];\n }\n echo \"\\n\";\n $check=-1;\n break;\n\n\n }\n }\n if($check!=-1){\n echo -1;\n echo \"\\n\";\n }\n }\n\n }\n\n // }\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " $r1) {\n $r2 = max($r2, $dist[$j][1]);\n }\n }\n $result = min($result,$r1+$r2);\n }\n fprintf(STDOUT,\"%.0f\",$result);\n exit();\n}"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 0) {\n if(strcmp($dist[$j][1],$r2) > 0){\n $r2 = $dist[$j][1];\n }\n\n }\n }\n // var_dump($r1);\n // var_dump($r2);\n if(strcmp($result,bcadd($r1,$r2))) {\n $result = bcadd($r1, $r2);\n }\n }\n fprintf(STDOUT,\"%s\",$result);\n\n exit();\n}\n"}, {"source_code": " 0) {\n if(strcmp($dist[$j][1],$r2) > 0){\n $r2 = $dist[$j][1];\n }\n\n }\n }\n // var_dump($r1);\n // var_dump($r2);\n if(strcmp($result,bcadd($r1,$r2)) > 0) {\n $result = bcadd($r1, $r2);\n }\n }\n fprintf(STDOUT,\"%s\",$result);\n\n exit();\n}\n"}, {"source_code": " $r1) {\n $r2 = max($r2, $dist[$j][1]);\n }\n }\n $result = min($result,$r1+$r2);\n }\n fprintf(STDOUT,\"%.0f\",$result);\n exit();\n}\n"}], "src_uid": "5db9c5673a04256c52f180dbfca2a52f"} {"nl": {"description": "A bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For example, bracket sequences \"()()\" and \"(())\" are regular (the resulting expressions are: \"(1)+(1)\" and \"((1+1)+1)\"), and \")(\", \"(\" and \")\" are not.Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given a regular bracket sequence $$$s$$$ and an integer number $$$k$$$. Your task is to find a regular bracket sequence of length exactly $$$k$$$ such that it is also a subsequence of $$$s$$$.It is guaranteed that such sequence always exists.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\le k \\le n \\le 2 \\cdot 10^5$$$, both $$$n$$$ and $$$k$$$ are even) \u2014 the length of $$$s$$$ and the length of the sequence you are asked to find. The second line is a string $$$s$$$ \u2014 regular bracket sequence of length $$$n$$$.", "output_spec": "Print a single string \u2014 a regular bracket sequence of length exactly $$$k$$$ such that it is also a subsequence of $$$s$$$. It is guaranteed that such sequence always exists.", "sample_inputs": ["6 4\n()(())", "8 8\n(()(()))"], "sample_outputs": ["()()", "(()(()))"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "c783434bb17819344fb9a49de1f63708"} {"nl": {"description": "There are $$$n$$$ athletes in front of you. Athletes are numbered from $$$1$$$ to $$$n$$$ from left to right. You know the strength of each athlete\u00a0\u2014 the athlete number $$$i$$$ has the strength $$$s_i$$$.You want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must be exactly in one team.You want the strongest athlete from the first team to differ as little as possible from the weakest athlete from the second team. Formally, you want to split the athletes into two teams $$$A$$$ and $$$B$$$ so that the value $$$|\\max(A) - \\min(B)|$$$ is as small as possible, where $$$\\max(A)$$$ is the maximum strength of an athlete from team $$$A$$$, and $$$\\min(B)$$$ is the minimum strength of an athlete from team $$$B$$$.For example, if $$$n=5$$$ and the strength of the athletes is $$$s=[3, 1, 2, 6, 4]$$$, then one of the possible split into teams is: first team: $$$A = [1, 2, 4]$$$, second team: $$$B = [3, 6]$$$. In this case, the value $$$|\\max(A) - \\min(B)|$$$ will be equal to $$$|4-3|=1$$$. This example illustrates one of the ways of optimal split into two teams.Print the minimum value $$$|\\max(A) - \\min(B)|$$$.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case consists of two lines. The first line contains positive integer $$$n$$$ ($$$2 \\le n \\le 50$$$)\u00a0\u2014 number of athletes. The second line contains $$$n$$$ positive integers $$$s_1, s_2, \\ldots, s_n$$$ ($$$1 \\le s_i \\le 1000$$$), where $$$s_i$$$\u00a0\u2014 is the strength of the $$$i$$$-th athlete. Please note that $$$s$$$ values may not be distinct.", "output_spec": "For each test case print one integer\u00a0\u2014 the minimum value of $$$|\\max(A) - \\min(B)|$$$ with the optimal split of all athletes into two teams. Each of the athletes must be a member of exactly one of the two teams.", "sample_inputs": ["5\n5\n3 1 2 6 4\n6\n2 1 3 2 4 3\n4\n7 9 3 1\n2\n1 1000\n3\n100 150 200"], "sample_outputs": ["1\n0\n2\n999\n50"], "notes": "NoteThe first test case was explained in the statement. In the second test case, one of the optimal splits is $$$A=[2, 1]$$$, $$$B=[3, 2, 4, 3]$$$, so the answer is $$$|2-2|=0$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n $f = trim(fgets(STDIN));\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if($c[$f[$y]][$e[$f[$y]]] > $g)\n {\n $g = $c[$f[$y]][$e[$f[$y]]];\n }\n $e[$f[$y]]++;\n }\n print $g . \"\\n\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n $f = trim(fgets(STDIN));\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if($c[$f[$y]][$e[$f[$y]]] > $g)\n {\n $g = $c[$f[$y]][$e[$f[$y]]];\n $e[$y]++;\n }\n }\n print $g . \"\\n\";\n}\n?>"}, {"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n if(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n if(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($v) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}], "negative_code": [{"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n if(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n if(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n if(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n if(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n if(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n if(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n elseif(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n elseif(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n elseif(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n elseif(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n elseif(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n elseif(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 2)\n{\n $c = array();\n $d = array();\n for($x = 1; $x <= $a; $x++)\n {\n $e = trim(fgets(STDIN));\n if(($e[0] == 0) && ($e[2] == 0))\n {\n $c[0] = 1;\n }\n elseif(($e[0] == 0) && ($e[2] == 1))\n {\n $d[0] = 1;\n }\n elseif(($e[0] == 1) && ($e[2] == 0))\n {\n $d[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 3)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $i = array();\n for($x = 1; $x <= $a; $x++)\n {\n $h = trim(fgets(STDIN));\n if($x == 1)\n {\n $i[0] = $h;\n if(($a == 10000) && ($b == 3))\n {\n if($i[0] == \"1 1 1\")\n {\n $d = array($i[0]);\n for($x = 1; $x < $a; $x++)\n {\n $e = trim(fgets(STDIN));\n $d[$x] = $e;\n }\n $d = array_unique($d);\n sort($d);\n print_r($d);\n }\n }\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 0))\n {\n $c[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $d[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $d[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $d[2] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 1) && ($h[4] == 0))\n {\n $e[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 0) && ($h[4] == 1))\n {\n $e[1] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 1))\n {\n $f[0] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 0))\n {\n $f[1] = 1;\n }\n elseif(($h[0] == 0) && ($h[2] == 1) && ($h[4] == 1))\n {\n $g[0] = 1;\n }\n elseif(($h[0] == 1) && ($h[2] == 0) && ($h[4] == 0))\n {\n $g[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelseif($b == 4)\n{\n $c = array();\n $d = array();\n $e = array();\n $f = array();\n $g = array();\n $h = array();\n $i = array();\n $j = array();\n $k = array();\n $l = array();\n $m = array();\n $n = array();\n $o = array();\n $p = array();\n $q = array();\n $r = array();\n $s = array();\n $t = array();\n $u = array();\n $v = array();\n $w = array();\n for($x = 1; $x <= $a; $x++)\n {\n $y = trim(fgets(STDIN));\n if(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $c[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $d[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $d[2] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $d[3] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $e[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $e[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $f[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $f[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $g[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $g[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $h[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $h[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $i[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $i[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $j[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $j[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 1))\n {\n $k[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $k[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $l[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $l[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $m[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $m[1] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 0))\n {\n $n[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $n[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $o[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $o[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $p[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $p[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $q[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 1))\n {\n $q[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $r[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $r[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $s[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $s[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $t[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 1))\n {\n $t[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $u[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 1) && ($y[4] == 0) && ($y[6] == 0))\n {\n $u[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $v[0] = 1;\n }\n elseif(($y[0] == 1) && ($y[2] == 0) && ($y[4] == 1) && ($y[6] == 0))\n {\n $v[1] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 0) && ($y[4] == 0) && ($y[6] == 1))\n {\n $w[0] = 1;\n }\n elseif(($y[0] == 0) && ($y[2] == 1) && ($y[4] == 1) && ($y[6] == 0))\n {\n $w[1] = 1;\n }\n }\n if((count($c) > 0) || (count($d) > 1) || (count($e) > 1) || (count($f) > 1) || (count($g) > 1) || (count($h) > 1) || (count($i) > 1) || (count($j) > 1) || (count($k) > 1) || (count($l) > 1) || (count($m) > 1) || (count($n) > 1) || (count($o) > 1) || (count($p) > 1) || (count($q) > 1) || (count($r) > 1) || (count($s) > 1) || (count($t) > 1) || (count($u) > 1) || (count($w) > 1))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}], "src_uid": "0928e12caeb71d631a26912c5606b568"} {"nl": {"description": "You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the display one position to the right (the last digit becomes the first one). For example, if the display is currently showing number 579, then if we push the first button, the display will show 680, and if after that we push the second button, the display will show 068.You know that the lock will open if the display is showing the smallest possible number that can be obtained by pushing the buttons in some order. The leading zeros are ignored while comparing numbers. Now your task is to find the desired number.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the number of digits on the display. The second line contains n digits\u00a0\u2014 the initial state of the display.", "output_spec": "Print a single line containing n digits\u00a0\u2014 the desired state of the display containing the smallest possible number.", "sample_inputs": ["3\n579", "4\n2014"], "sample_outputs": ["024", "0142"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "6ee356f2b3a4bb88087ed76b251afec2"} {"nl": {"description": "You find yourself on an unusual crossroad with a weird traffic light. That traffic light has three possible colors: red (r), yellow (y), green (g). It is known that the traffic light repeats its colors every $$$n$$$ seconds and at the $$$i$$$-th second the color $$$s_i$$$ is on.That way, the order of the colors is described by a string. For example, if $$$s=$$$\"rggry\", then the traffic light works as the following: red-green-green-red-yellow-red-green-green-red-yellow- ... and so on.More formally, you are given a string $$$s_1, s_2, \\ldots, s_n$$$ of length $$$n$$$. At the first second the color $$$s_1$$$ is on, at the second \u2014 $$$s_2$$$, ..., at the $$$n$$$-th second the color $$$s_n$$$ is on, at the $$$n + 1$$$-st second the color $$$s_1$$$ is on and so on.You need to cross the road and that can only be done when the green color is on. You know which color is on the traffic light at the moment, but you don't know the current moment of time. You need to find the minimum amount of time in which you are guaranteed to cross the road.You can assume that you cross the road immediately. For example, with $$$s=$$$\"rggry\" and the current color r there are two options: either the green color will be on after $$$1$$$ second, or after $$$3$$$. That way, the answer is equal to $$$3$$$ \u2014 that is the number of seconds that we are guaranteed to cross the road, if the current color is r.", "input_spec": "The first line contains a single integer $$$t$$$ $$$(1 \\leq t \\leq 10^4$$$) \u2014 the number of test cases. Then the description of the test cases follows. The first line of each test case contains an integer $$$n$$$ and a symbol $$$c$$$ ($$$1 \\leq n \\leq 2 \\cdot 10^5$$$, $$$c$$$ is one of allowed traffic light colors r, y or g)\u2014 the length of the string $$$s$$$ and the current color of the traffic light. The second line of each test case contains a string $$$s$$$ of the length $$$n$$$, consisting of the letters r, y and g. It is guaranteed that the symbol g is in the string $$$s$$$ and the symbol $$$c$$$ is in the string $$$s$$$. It is guaranteed, that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each test case output the minimal number of second in which you are guaranteed to cross the road.", "sample_inputs": ["6\n\n5 r\n\nrggry\n\n1 g\n\ng\n\n3 r\n\nrrg\n\n5 y\n\nyrrgy\n\n7 r\n\nrgrgyrg\n\n9 y\n\nrrrgyyygy"], "sample_outputs": ["3\n0\n2\n4\n1\n4"], "notes": "NoteThe first test case is explained in the statement.In the second test case the green color is on so you can cross the road immediately. In the third test case, if the red color was on at the second second, then we would wait for the green color for one second, and if the red light was on at the first second, then we would wait for the green light for two seconds.In the fourth test case the longest we would wait for the green color is if we wait for it starting from the fifth second."}, "positive_code": [{"source_code": ">\". ($gpos[$o]-$p);\r\n //echo PHP_EOL;\r\n $ptn = max($ptn, $gpos[$o]-$p);\r\n }\r\n //echo \"--\".PHP_EOL;\r\n $ans[] = $ptn;\r\n}\r\necho implode(PHP_EOL,$ans);\r\n\r\n // $array\u306e\u4e2d\u3067$x\u3088\u308a\u5927\u304d\u3044\u5024\u3092\u6301\u3064\u6700\u521d\u306e\u4f4d\u7f6e\u3092\u8fd4\u3059\r\n // \u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f-1\r\n // $array\u306f\u6607\u9806\u306b\u30bd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u524d\u63d0\r\n function searchPosGT(&$a, $x){\r\n $ok=count($a);\r\n $ng=-1;\r\n if($ng === 0) return -1;\r\n while($ok-$ng > 1){\r\n $m=($ng+$ok)>>1;\r\n //echo \"m:\".$m.\" ok:\".$ok.\" ng:\".$ng.\" a:\".$a[$m].\" x:\".$x.PHP_EOL;\r\n if($a[$m] > $x) $ok = $m;\r\n else $ng = $m;\r\n }\r\n if($ok === count($a)) return -1;\r\n return $ok;\r\n }\r\n\r\n\r\n\r\n"}], "negative_code": [], "src_uid": "9d3ee1b292a2402bb2204ab85dcab587"} {"nl": {"description": "Gildong is playing a video game called Block Adventure. In Block Adventure, there are $$$n$$$ columns of blocks in a row, and the columns are numbered from $$$1$$$ to $$$n$$$. All blocks have equal heights. The height of the $$$i$$$-th column is represented as $$$h_i$$$, which is the number of blocks stacked in the $$$i$$$-th column.Gildong plays the game as a character that can stand only on the top of the columns. At the beginning, the character is standing on the top of the $$$1$$$-st column. The goal of the game is to move the character to the top of the $$$n$$$-th column.The character also has a bag that can hold infinitely many blocks. When the character is on the top of the $$$i$$$-th column, Gildong can take one of the following three actions as many times as he wants: if there is at least one block on the column, remove one block from the top of the $$$i$$$-th column and put it in the bag; if there is at least one block in the bag, take one block out of the bag and place it on the top of the $$$i$$$-th column; if $$$i < n$$$ and $$$|h_i - h_{i+1}| \\le k$$$, move the character to the top of the $$$i+1$$$-st column. $$$k$$$ is a non-negative integer given at the beginning of the game. Note that it is only possible to move to the next column. In actions of the first two types the character remains in the $$$i$$$-th column, and the value $$$h_i$$$ changes.The character initially has $$$m$$$ blocks in the bag. Gildong wants to know if it is possible to win the game. Help Gildong find the answer to his question.", "input_spec": "Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 1000$$$). Description of the test cases follows. The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1 \\le n \\le 100$$$, $$$0 \\le m \\le 10^6$$$, $$$0 \\le k \\le 10^6$$$) \u2014 the number of columns in the game, the number of blocks in the character's bag at the beginning, and the non-negative integer $$$k$$$ described in the statement. The second line of each test case contains $$$n$$$ integers. The $$$i$$$-th integer is $$$h_i$$$ ($$$0 \\le h_i \\le 10^6$$$), the initial height of the $$$i$$$-th column.", "output_spec": "For each test case, print \"YES\" if it is possible to win the game. Otherwise, print \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["5\n3 0 1\n4 3 5\n3 1 2\n1 4 7\n4 10 0\n10 20 10 20\n2 5 5\n0 11\n1 9 9\n99"], "sample_outputs": ["YES\nNO\nYES\nNO\nYES"], "notes": "NoteIn the first case, Gildong can take one block from the $$$1$$$-st column, move to the $$$2$$$-nd column, put the block on the $$$2$$$-nd column, then move to the $$$3$$$-rd column.In the second case, Gildong has to put the block in his bag on the $$$1$$$-st column to get to the $$$2$$$-nd column. But it is impossible to get to the $$$3$$$-rd column because $$$|h_2 - h_3| = 3 > k$$$ and there is no way to decrease the gap.In the fifth case, the character is already on the $$$n$$$-th column from the start so the game is won instantly."}, "positive_code": [{"source_code": "= $e[$y + 1])\n {\n $f = $e[$y + 1] - $d;\n if($f < 0)\n {\n $f = 0;\n }\n $c += $e[$y] - $f;\n }\n elseif($e[$y] < $e[$y + 1])\n {\n $f = $e[$y + 1] - $d;\n if($f < 0)\n {\n $f = 0;\n }\n if($e[$y] >= $f)\n {\n $c += $e[$y] - $f;\n }\n else\n {\n $c -= $f - $e[$y];\n if($c < 0)\n {\n $g = 1;\n break;\n }\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": "= $e[$y + 1])\n {\n $c += $e[$y] - ($e[$y + 1] - $d);\n }\n elseif($c >= ($e[$y + 1] - $d) - $e[$y])\n {\n $c -= ($e[$y + 1] - $d) - $e[$y];\n }\n else\n {\n $f = 1;\n break;\n }\n }\n if($f == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}], "src_uid": "3f60e740d9a3ec14223b2b1f62c52f61"} {"nl": {"description": "After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $$$n$$$. Let's call them $$$a$$$ and $$$b$$$.Note that a permutation of $$$n$$$ elements is a sequence of numbers $$$a_1, a_2, \\ldots, a_n$$$, in which every number from $$$1$$$ to $$$n$$$ appears exactly once. The message can be decoded by an arrangement of sequence $$$a$$$ and $$$b$$$, such that the number of matching pairs of elements between them is maximum. A pair of elements $$$a_i$$$ and $$$b_j$$$ is said to match if: $$$i = j$$$, that is, they are at the same index. $$$a_i = b_j$$$ His two disciples are allowed to perform the following operation any number of times: choose a number $$$k$$$ and cyclically shift one of the permutations to the left or right $$$k$$$ times. A single cyclic shift to the left on any permutation $$$c$$$ is an operation that sets $$$c_1:=c_2, c_2:=c_3, \\ldots, c_n:=c_1$$$ simultaneously. Likewise, a single cyclic shift to the right on any permutation $$$c$$$ is an operation that sets $$$c_1:=c_n, c_2:=c_1, \\ldots, c_n:=c_{n-1}$$$ simultaneously.Help Ishika and Hriday find the maximum number of pairs of elements that match after performing the operation any (possibly zero) number of times.", "input_spec": "The first line of the input contains a single integer $$$n$$$ $$$(1 \\le n \\le 2 \\cdot 10^5)$$$\u00a0\u2014 the size of the arrays. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ $$$(1 \\le a_i \\le n)$$$ \u2014 the elements of the first permutation. The third line contains $$$n$$$ integers $$$b_1$$$, $$$b_2$$$, ..., $$$b_n$$$ $$$(1 \\le b_i \\le n)$$$ \u2014 the elements of the second permutation.", "output_spec": "Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times.", "sample_inputs": ["5\n1 2 3 4 5\n2 3 4 5 1", "5\n5 4 3 2 1\n1 2 3 4 5", "4\n1 3 2 4\n4 2 3 1"], "sample_outputs": ["5", "1", "2"], "notes": "NoteFor the first case: $$$b$$$ can be shifted to the right by $$$k = 1$$$. The resulting permutations will be $$$\\{1, 2, 3, 4, 5\\}$$$ and $$$\\{1, 2, 3, 4, 5\\}$$$.For the second case: The operation is not required. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$1$$$.For the third case: $$$b$$$ can be shifted to the left by $$$k = 1$$$. The resulting permutations will be $$$\\{1, 3, 2, 4\\}$$$ and $$$\\{2, 3, 1, 4\\}$$$. Positions $$$2$$$ and $$$4$$$ have matching pairs of elements. For all possible rotations of $$$a$$$ and $$$b$$$, the number of matching pairs won't exceed $$$2$$$."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "eb1bb862dc2b0094383192f6998891c5"} {"nl": {"description": "Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $$$n$$$ last days: $$$a_1, a_2, \\dots, a_n$$$, where $$$a_i$$$ is the price of berPhone on the day $$$i$$$.Polycarp considers the price on the day $$$i$$$ to be bad if later (that is, a day with a greater number) berPhone was sold at a lower price. For example, if $$$n=6$$$ and $$$a=[3, 9, 4, 6, 7, 5]$$$, then the number of days with a bad price is $$$3$$$ \u2014 these are days $$$2$$$ ($$$a_2=9$$$), $$$4$$$ ($$$a_4=6$$$) and $$$5$$$ ($$$a_5=7$$$).Print the number of days with a bad price.You have to answer $$$t$$$ independent data sets.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 10000$$$) \u2014 the number of sets of input data in the test. Input data sets must be processed independently, one after another. Each input data set consists of two lines. The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 150000$$$) \u2014 the number of days. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^6$$$), where $$$a_i$$$ is the price on the $$$i$$$-th day. It is guaranteed that the sum of $$$n$$$ over all data sets in the test does not exceed $$$150000$$$.", "output_spec": "Print $$$t$$$ integers, the $$$j$$$-th of which should be equal to the number of days with a bad price in the $$$j$$$-th input data set.", "sample_inputs": ["5\n6\n3 9 4 6 7 5\n1\n1000000\n2\n2 1\n10\n31 41 59 26 53 58 97 93 23 84\n7\n3 2 1 2 3 4 5"], "sample_outputs": ["3\n0\n1\n8\n2"], "notes": null}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if($c[$y] > $d)\n {\n $e++;\n }\n else\n {\n $d = $c[$y];\n }\n }\n print $e . \"\\n\";\n}\n?>"}, {"source_code": " $s){\n $z++;\n }\n $s = min($s, $arr[$j]);\n }\n printf(\"%d\\n\", $z);\n}\n?>"}], "negative_code": [], "src_uid": "09faf19627d2ff00c3821d4bc2644b63"} {"nl": {"description": "The map of Berland is a rectangle of the size n\u2009\u00d7\u2009m, which consists of cells of size 1\u2009\u00d7\u20091. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are not connected with the ocean. Formally, lake is a set of water cells, such that it's possible to get from any cell of the set to any other without leaving the set and moving only to cells adjacent by the side, none of them is located on the border of the rectangle, and it's impossible to add one more water cell to the set such that it will be connected with any other cell.You task is to fill up with the earth the minimum number of water cells so that there will be exactly k lakes in Berland. Note that the initial number of lakes on the map is not less than k. ", "input_spec": "The first line of the input contains three integers n, m and k (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u200950, 0\u2009\u2264\u2009k\u2009\u2264\u200950)\u00a0\u2014 the sizes of the map and the number of lakes which should be left on the map. The next n lines contain m characters each \u2014 the description of the map. Each of the characters is either '.' (it means that the corresponding cell is water) or '*' (it means that the corresponding cell is land). It is guaranteed that the map contain at least k lakes.", "output_spec": "In the first line print the minimum number of cells which should be transformed from water to land. In the next n lines print m symbols \u2014 the map after the changes. The format must strictly follow the format of the map in the input data (there is no need to print the size of the map). If there are several answers, print any of them. It is guaranteed that the answer exists on the given data.", "sample_inputs": ["5 4 1\n****\n*..*\n****\n**.*\n..**", "3 3 0\n***\n*.*\n***"], "sample_outputs": ["1\n****\n*..*\n****\n****\n..**", "1\n***\n***\n***"], "notes": "NoteIn the first example there are only two lakes \u2014 the first consists of the cells (2,\u20092) and (2,\u20093), the second consists of the cell (4,\u20093). It is profitable to cover the second lake because it is smaller. Pay attention that the area of water in the lower left corner is not a lake because this area share a border with the ocean. "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "e514d949e7837c603a9ee032f83b90d2"} {"nl": {"description": "The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number appears. It consists of the remaining binary digits, written in the corresponding order (possible, with leading zeroes).The Little Elephant wants the number he is going to write on the paper to be as large as possible. Help him find the maximum number that he can obtain after deleting exactly one binary digit and print it in the binary notation.", "input_spec": "The single line contains integer a, written in the binary notation without leading zeroes. This number contains more than 1 and at most 105 digits.", "output_spec": "In the single line print the number that is written without leading zeroes in the binary notation \u2014 the answer to the problem.", "sample_inputs": ["101", "110010"], "sample_outputs": ["11", "11010"], "notes": "NoteIn the first sample the best strategy is to delete the second digit. That results in number 112\u2009=\u2009310.In the second sample the best strategy is to delete the third or fourth digits \u2014 that results in number 110102\u2009=\u20092610."}, "positive_code": [{"source_code": ""}, {"source_code": "0)\n{\n $b = strpos($a, '0');\n $c = substr_replace($a, '', $b, 1);\n echo $c;\n}else{\n $b = strpos($a, '1');\n $c = substr_replace($a, '', $b, 1);\n echo $c;\n}\n?>"}, {"source_code": " 1)) {\n\t$res = substr($res, 1, strlen($res) - 1);\n}\n\necho $res;\n\n// End of submission file\n// Submission by chaotic_iak\n?>"}, {"source_code": ""}, {"source_code": "0)\n{\n $b = strpos($a, '0');\n $c = substr_replace($a, '', $b, 1);\n echo $c;\n}else{\n $b = strpos($a, '1');\n $c = substr_replace($a, '', $b, 1);\n echo $c;\n}\n?>"}], "negative_code": [{"source_code": "$v) {\n if ($v == '0') $p=$k;\n}\n$o='';\nfor ($i=0;$i "}, {"source_code": "$v) {\n if ($v == '0') $p=$k;\n}\n$o='';\nfor ($i=0;$i "}, {"source_code": "$v) {\n if ($v == '0') $p=$k;\n}\n$o='';\nfor ($i=0;$i "}], "src_uid": "133eaf241bb1557ba9a3f59c733d34bf"} {"nl": {"description": "A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the length of i-th segment. No two segments touch or intersect.For example: If x\u2009=\u20096 and the crossword is 111011, then its encoding is an array {3,\u20092}; If x\u2009=\u20098 and the crossword is 01101010, then its encoding is an array {2,\u20091,\u20091}; If x\u2009=\u20095 and the crossword is 11111, then its encoding is an array {5}; If x\u2009=\u20095 and the crossword is 00000, then its encoding is an empty array. Mishka wants to create a new one-dimensional Japanese crossword. He has already picked the length and the encoding for this crossword. And now he needs to check if there is exactly one crossword such that its length and encoding are equal to the length and encoding he picked. Help him to check it!", "input_spec": "The first line contains two integer numbers n and x (1\u2009\u2264\u2009n\u2009\u2264\u2009100000, 1\u2009\u2264\u2009x\u2009\u2264\u2009109) \u2014 the number of elements in the encoding and the length of the crossword Mishka picked. The second line contains n integer numbers a1, a2, ..., an (1\u2009\u2264\u2009ai\u2009\u2264\u200910000) \u2014 the encoding.", "output_spec": "Print YES if there exists exaclty one crossword with chosen length and encoding. Otherwise, print NO.", "sample_inputs": ["2 4\n1 3", "3 10\n3 3 2", "2 10\n1 3"], "sample_outputs": ["NO", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "= 0; $x--)\n{\n $d[$c[$x]] += $d[$x + 2];\n}\n$e = array();\nfor($x = 0; $x < $a; $x++)\n{\n $e[$c[$x]][count($e[$c[$x]])] = $x + 2;\n}\n$f = array(1 => 1);\n$g = array(1 => 1);\n$h = array(1);\n$i = array(0);\n$k = 2;\nwhile(TRUE)\n{\n $j = $e[$h[count($h) - 1]][$i[count($i) - 1]];\n if($j == NULL)\n {\n unset($h[count($h) - 1]);\n unset($i[count($i) - 1]);\n $i[count($i) - 1] += 1;\n if(count($h) == 0)\n {\n break;\n }\n }\n else\n {\n $f[$k] = $j;\n $g[$j] = $k;\n $k++;\n if($e[$j] == TRUE)\n {\n $h[count($h)] = $j;\n $i[count($i)] = 0;\n }\n else\n {\n $i[count($i) - 1] += 1;\n }\n }\n}\nfor($x = 0; $x < $b; $x++)\n{\n list($l, $m) = explode(\" \", trim(fgets(STDIN)));\n if($m > $d[$l])\n {\n print \"-1\\n\";\n }\n else\n {\n print $f[$g[$l] + $m - 1] . \"\\n\";\n }\n}\n?>"}, {"source_code": " $right_id[$u])\n echo \"-1\\n\";\n else echo \"$value_map[$id]\\n\";\n}\nfunction dfs($node){\n global $dfs_id;\n global $edge;\n global $left_id;\n global $right_id;\n global $value_map;\n $left_id[$node] = ++$dfs_id;\n $value_map[$dfs_id] = $node;\n //var_dump($node);\n if(isset($edge[$node])){\n $child_count = count($edge[$node]); \n for($i = 0;$i < $child_count;$i++){\n dfs($edge[$node][$i]);\n }\n }\n $right_id[$node] = $dfs_id; \n}"}], "negative_code": [], "src_uid": "4dffa25857c7719a43817e0ad01ef759"} {"nl": {"description": "Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100\u2009\u00d7\u2009100 square with the lower left corner at point (0,\u20090) and with the upper right corner at point (100,\u2009100). Then the alarm clocks are points with integer coordinates in this square.The morning has come. All n alarm clocks in Inna's room are ringing, so Inna wants to turn them off. For that Inna has come up with an amusing game: First Inna chooses a type of segments that she will use throughout the game. The segments can be either vertical or horizontal. Then Inna makes multiple moves. In a single move, Inna can paint a segment of any length on the plane, she chooses its type at the beginning of the game (either vertical or horizontal), then all alarm clocks that are on this segment switch off. The game ends when all the alarm clocks are switched off. Inna is very sleepy, so she wants to get through the alarm clocks as soon as possible. Help her, find the minimum number of moves in the game that she needs to turn off all the alarm clocks!", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of the alarm clocks. The next n lines describe the clocks: the i-th line contains two integers xi, yi \u2014 the coordinates of the i-th alarm clock (0\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009100). Note that a single point in the room can contain any number of alarm clocks and the alarm clocks can lie on the sides of the square that represents the room.", "output_spec": "In a single line print a single integer \u2014 the minimum number of segments Inna will have to draw if she acts optimally.", "sample_inputs": ["4\n0 0\n0 1\n0 2\n1 0", "4\n0 0\n0 1\n1 0\n1 1", "4\n1 1\n1 2\n2 3\n3 3"], "sample_outputs": ["2", "2", "3"], "notes": "NoteIn the first sample, Inna first chooses type \"vertical segments\", and then she makes segments with ends at : (0,\u20090), (0,\u20092); and, for example, (1,\u20090), (1,\u20091). If she paints horizontal segments, she will need at least 3 segments.In the third sample it is important to note that Inna doesn't have the right to change the type of the segments during the game. That's why she will need 3 horizontal or 3 vertical segments to end the game."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": " $c[$y])\r\n {\r\n $d = 1;\r\n break;\r\n }\r\n }\r\n if($d == 0)\r\n {\r\n print \"NO\\n\";\r\n }\r\n else\r\n {\r\n print \"YES\\n\";\r\n }\r\n}\r\n?>"}], "negative_code": [], "src_uid": "ef1448a744f67347183479c697aa87e1"} {"nl": {"description": "There are $$$n$$$ boxers, the weight of the $$$i$$$-th boxer is $$$a_i$$$. Each of them can change the weight by no more than $$$1$$$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.It is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).Write a program that for given current values \u200b$$$a_i$$$ will find the maximum possible number of boxers in a team.It is possible that after some change the weight of some boxer is $$$150001$$$ (but no more).", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 150000$$$) \u2014 the number of boxers. The next line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$, where $$$a_i$$$ ($$$1 \\le a_i \\le 150000$$$) is the weight of the $$$i$$$-th boxer.", "output_spec": "Print a single integer \u2014 the maximum possible number of people in a team.", "sample_inputs": ["4\n3 2 4 1", "6\n1 1 1 4 4 4"], "sample_outputs": ["4", "5"], "notes": "NoteIn the first example, boxers should not change their weights \u2014 you can just make a team out of all of them.In the second example, one boxer with a weight of $$$1$$$ can be increased by one (get the weight of $$$2$$$), one boxer with a weight of $$$4$$$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $$$3$$$ and $$$5$$$, respectively). Thus, you can get a team consisting of boxers with weights of $$$5, 4, 3, 2, 1$$$."}, "positive_code": [{"source_code": " 0)\n{\n $c[count($c)] = $d;\n}\n$g[0] = TRUE;\nfor($x = 0; $x < count($c); $x++)\n{\n $e = $c[$x];\n $f = array();\n for($y = 0; $y < count($e); $y++)\n {\n $f[$e[$y]]++;\n }\n rsort($f);\n if(($f[0] > 2) || (($f[0] > 1) && ($f[1] > 1)))\n {\n $g[$e[0] - 1] = TRUE;\n $g[$e[count($e) - 1] + 1] = TRUE;\n }\n elseif($f[0] > 1)\n {\n if($g[$e[0] - 1] == FALSE)\n {\n $g[$e[0] - 1] = TRUE;\n }\n elseif($g[$e[count($e) - 1] + 1] == FALSE)\n {\n $g[$e[count($e) - 1] + 1] = TRUE;\n }\n }\n}\nunset($g[0]);\n$h = array_unique($b);\nprint count($g) + count($h);\n?>"}], "negative_code": [{"source_code": " 1) && ($c[2] == NULL))\n {\n $c[2] = 1;\n }\n }\n else\n {\n if(($d[1] > 1) && ($c[$d[0] - 1] == NULL))\n {\n $c[$d[0] - 1] = 1;\n $d[1]--;\n }\n if(($d[1] > 1) && ($c[$d[0] + 1] == NULL))\n {\n $c[$d[0] + 1] = 1;\n $d[1]--;\n }\n }\n $d = each($c);\n}\nprint count($c);\n?>"}], "src_uid": "41215d764f10c025bf18a70b6215aecf"} {"nl": {"description": "\"Hey, it's homework time\" \u2014 thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him.The sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.You are given an arbitrary sequence a1,\u2009a2,\u2009...,\u2009an containing n integers. Each integer is not less than 1 and not greater than 5000. Determine what minimum number of elements Polycarpus needs to change to get a permutation (he should not delete or add numbers). In a single change he can modify any single sequence element (i. e. replace it with another integer).", "input_spec": "The first line of the input data contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u20095000) which represents how many numbers are in the sequence. The second line contains a sequence of integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u20095000,\u20091\u2009\u2264\u2009i\u2009\u2264\u2009n).", "output_spec": "Print the only number \u2014 the minimum number of changes needed to get the permutation.", "sample_inputs": ["3\n3 1 2", "2\n2 2", "5\n5 3 3 3 1"], "sample_outputs": ["0", "1", "2"], "notes": "NoteThe first sample contains the permutation, which is why no replacements are required.In the second sample it is enough to replace the first element with the number 1 and that will make the sequence the needed permutation.In the third sample we can replace the second element with number 4 and the fourth element with number 2."}, "positive_code": [{"source_code": ""}, {"source_code": "h = $h;\n// $this->len = 2 * ($a + $b);\n// }\n//\n//}\n//\n//class Page {\n//\n// public $a, $b, $p;\n//\n// public function __construct($a, $b, $p) {\n// $this->a = $a;\n// $this->b = $b;\n// $this->p = $p;\n// }\n//\n//}\n//\n//function getPrice($room, $page) {\n// $piece = (int)($page -> a / $room->h);\n// if($piece<=0)\n// return 99999999;\n// $wide = $piece * $page -> b;\n//\n// $yu_len = $room->len % $wide;\n// $rolls = (int)($room->len / $wide) + ($yu_len != 0 ? 1 : 0);\n// return $rolls * $page->p;\n//}\n//\n//$room = array();\n//$page = array();\n$fr = fopen(\"php://stdin\", \"r\");\n$n = (int) fgets($fr);\n$arr = fgets($fr);\nfclose($fr);\n$arr = explode(' ', $arr);\n$ary = array();\n\nforeach ($arr as $value) {\n $value2=(int)$value;\n $ary[$value2] = 1;\n}\n$cnt = 0;\nfor ($i = 1; $i <= $n; ++$i) {\n if ($ary[$i] == 1){\n// echo \"haha\";\n $cnt++;\n }\n}\necho $n-$cnt;\n\n//\n//for ($i = 0; $i < $rooms; ++$i) {\n// fscanf(STDIN, \"%d%d%d\", $a, $b, $h);\n// array_push($room, new Room($a, $b, $h));\n//}\n//\n//fscanf(STDIN, \"%d\", $pages);\n//for ($i = 0; $i < $pages; ++$i) {\n// fscanf(STDIN, \"%d%d%d\", $a, $b, $p);\n// array_push($page, new Page($a, $b, $p));\n//}\n//\n//$sum=0;\n//\n//foreach ($room as $rm) {\n// $min=99999999;\n// foreach ($page as $pg) {\n// $price=getPrice($rm, $pg);\n// if($price<$min)\n// $min=$price;\n// }\n// $sum+=$min;\n//}\n//echo $sum;\n//\n//usort($a, 'cmp');\n//$b = Array();\n//foreach ($a as $ai) {\n// $l = 0;\n// $r = count($b);\n// while ($l < $r) {\n// $m = ($l + $r) / 2;\n// if ($ai->h > $b[$m]->h) {\n// $l = $m + 1;\n// } else {\n// $r = $m;\n// }\n// }\n// $ai->p = ($r == 0 ? NULL : $b[$r - 1]);\n// $b[$r] = $ai;\n//}\n//\n//echo count($b) . \"\\n\";\n//if (count($b) > 0) {\n// $c = Array();\n// for ($p = array_pop($b); $p != NULL; $p = $p->p) {\n// array_unshift($c, $p->i);\n// }\n// print implode($c, ' ') . \"\\n\";\n//}\n?>"}, {"source_code": "\n"}], "negative_code": [{"source_code": "h = $h;\n// $this->len = 2 * ($a + $b);\n// }\n//\n//}\n//\n//class Page {\n//\n// public $a, $b, $p;\n//\n// public function __construct($a, $b, $p) {\n// $this->a = $a;\n// $this->b = $b;\n// $this->p = $p;\n// }\n//\n//}\n//\n//function getPrice($room, $page) {\n// $piece = (int)($page -> a / $room->h);\n// if($piece<=0)\n// return 99999999;\n// $wide = $piece * $page -> b;\n//\n// $yu_len = $room->len % $wide;\n// $rolls = (int)($room->len / $wide) + ($yu_len != 0 ? 1 : 0);\n// return $rolls * $page->p;\n//}\n//\n//$room = array();\n//$page = array();\n$fr = fopen(\"php://stdin\", \"r\");\n$n = (int) fgets($fr);\n$arr = fgets($fr);\nfclose($fr);\n$arr = explode(' ', $arr);\n$ary = array();\n\nforeach ($arr as $value) {\n $value=(int)$value;\n $ary[$value2] = 1;\n}\n$cnt = 0;\nfor ($i = 1; $i <= $n; ++$i) {\n if ($ary[$i] == NULL){\n// echo \"haha\";\n $cnt++;\n }\n}\necho $cnt;\n\n//\n//for ($i = 0; $i < $rooms; ++$i) {\n// fscanf(STDIN, \"%d%d%d\", $a, $b, $h);\n// array_push($room, new Room($a, $b, $h));\n//}\n//\n//fscanf(STDIN, \"%d\", $pages);\n//for ($i = 0; $i < $pages; ++$i) {\n// fscanf(STDIN, \"%d%d%d\", $a, $b, $p);\n// array_push($page, new Page($a, $b, $p));\n//}\n//\n//$sum=0;\n//\n//foreach ($room as $rm) {\n// $min=99999999;\n// foreach ($page as $pg) {\n// $price=getPrice($rm, $pg);\n// if($price<$min)\n// $min=$price;\n// }\n// $sum+=$min;\n//}\n//echo $sum;\n//\n//usort($a, 'cmp');\n//$b = Array();\n//foreach ($a as $ai) {\n// $l = 0;\n// $r = count($b);\n// while ($l < $r) {\n// $m = ($l + $r) / 2;\n// if ($ai->h > $b[$m]->h) {\n// $l = $m + 1;\n// } else {\n// $r = $m;\n// }\n// }\n// $ai->p = ($r == 0 ? NULL : $b[$r - 1]);\n// $b[$r] = $ai;\n//}\n//\n//echo count($b) . \"\\n\";\n//if (count($b) > 0) {\n// $c = Array();\n// for ($p = array_pop($b); $p != NULL; $p = $p->p) {\n// array_unshift($c, $p->i);\n// }\n// print implode($c, ' ') . \"\\n\";\n//}"}, {"source_code": "h > $b[$m]->h) {\n// $l = $m + 1;\n// } else {\n// $r = $m;\n// }\n// }\n// $ai->p = ($r == 0 ? NULL : $b[$r - 1]);\n// $b[$r] = $ai;\n//}\n//\n//echo count($b) . \"\\n\";\n//if (count($b) > 0) {\n// $c = Array();\n// for ($p = array_pop($b); $p != NULL; $p = $p->p) {\n// array_unshift($c, $p->i);\n// }\n// print implode($c, ' ') . \"\\n\";\n//}"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "bdd86c8bc54bbac6e2bb5a9d68b6eb1c"} {"nl": {"description": "Sasha and Dima want to buy two $$$n$$$-tier cakes. Each cake should consist of $$$n$$$ different tiers: from the size of $$$1$$$ to the size of $$$n$$$. Tiers should go in order from the smallest to the biggest (from top to bottom).They live on the same street, there are $$$2 \\cdot n$$$ houses in a row from left to right. Each house has a pastry shop where you can buy a cake tier. Unfortunately, in each pastry shop you can buy only one tier of only one specific size: in the $$$i$$$-th house you can buy a tier of the size $$$a_i$$$ ($$$1 \\le a_i \\le n$$$).Since the guys carry already purchased tiers, and it is impossible to insert a new tier in the middle of the cake, they agreed to buy tiers from the smallest to the biggest. That is, each of them buys tiers in order: $$$1$$$, then $$$2$$$, then $$$3$$$ and so on up to $$$n$$$.Initially, Sasha and Dima are located near the first (leftmost) house. Output the minimum distance that they will have to walk in total to buy both cakes. The distance between any two neighboring houses is exactly $$$1$$$.", "input_spec": "The first line of the input contains an integer number $$$n$$$ \u2014 the number of tiers in each cake ($$$1 \\le n \\le 10^5$$$). The second line contains $$$2 \\cdot n$$$ integers $$$a_1, a_2, \\dots, a_{2n}$$$ ($$$1 \\le a_i \\le n$$$), where $$$a_i$$$ is equal to the size of the tier, which can be bought in the $$$i$$$-th house. Remember that in each house you can buy only one tier. It is guaranteed that every number from $$$1$$$ to $$$n$$$ occurs in $$$a$$$ exactly two times.", "output_spec": "Print one number \u00a0\u2014 the minimum distance that the guys have to walk in total to buy both cakes. Guys can be near same house at the same time. They begin near the first (leftmost) house. Each of the guys should buy $$$n$$$ tiers in ascending order of their sizes.", "sample_inputs": ["3\n1 1 2 2 3 3", "2\n2 1 1 2", "4\n4 1 3 2 2 3 1 4"], "sample_outputs": ["9", "5", "17"], "notes": "NoteIn the first example, the possible optimal sequence of actions is: Sasha buys a tier of size $$$1$$$ near the $$$1$$$-st house ($$$a_1=1$$$); Dima goes to the house $$$2$$$; Dima buys a tier of size $$$1$$$ near the $$$2$$$-nd house ($$$a_2=1$$$); Sasha goes to the house $$$4$$$; Sasha buys a tier of size $$$2$$$ near the $$$4$$$-th house ($$$a_4=2$$$); Sasha goes to the house $$$5$$$; Sasha buys a tier of size $$$3$$$ near the $$$5$$$-th house ($$$a_5=3$$$); Dima goes to the house $$$3$$$; Dima buys a tier of size $$$2$$$ near the $$$3$$$-rd house ($$$a_3=2$$$); Dima goes to the house $$$6$$$; Dima buys a tier of size $$$3$$$ near the $$$6$$$-th house ($$$a_6=3$$$). So, Sasha goes the distance $$$3+1=4$$$, and Dima goes the distance $$$1+1+3=5$$$. In total, they cover a distance of $$$4+5=9$$$. You can make sure that with any other sequence of actions they will walk no less distance."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "dc9c2703aa7aaf1d254211cf06030329"} {"nl": {"description": "Polycarp is reading a book consisting of $$$n$$$ pages numbered from $$$1$$$ to $$$n$$$. Every time he finishes the page with the number divisible by $$$m$$$, he writes down the last digit of this page number. For example, if $$$n=15$$$ and $$$m=5$$$, pages divisible by $$$m$$$ are $$$5, 10, 15$$$. Their last digits are $$$5, 0, 5$$$ correspondingly, their sum is $$$10$$$.Your task is to calculate the sum of all digits Polycarp has written down.You have to answer $$$q$$$ independent queries.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 1000$$$) \u2014 the number of queries. The following $$$q$$$ lines contain queries, one per line. Each query is given as two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 10^{16}$$$) \u2014 the number of pages in the book and required divisor, respectively.", "output_spec": "For each query print the answer for it \u2014 the sum of digits written down by Polycarp.", "sample_inputs": ["7\n1 1\n10 1\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13"], "sample_outputs": ["1\n45\n153\n294\n3359835\n0\n427262129093995"], "notes": null}, "positive_code": [{"source_code": " $b)\n {\n break;\n }\n else\n {\n $f = strval($f);\n if($e[$f[strlen($f) - 1]] == 1)\n {\n break;\n }\n else\n {\n $d[count($d)] = $f[strlen($f) - 1];\n $e[$f[strlen($f) - 1]] = 1;\n $f = bcadd($f, $c);\n }\n }\n }\n $g = floor(bcdiv($b, $c));\n $g = number_format($g, 0, \".\", \"\");\n $h = array_sum($d);\n $i = bcdiv($g, count($d));\n $j = bcmod($g, count($d));\n $k = bcmul($h, $i);\n $l = array_sum(array_slice($d, 0, $j));\n $m = bcadd($k, $l);\n print $m . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": " $b)\n {\n break;\n }\n else\n {\n $f = strval($f);\n if($e[$f[strlen($f) - 1]] == 1)\n {\n break;\n }\n else\n {\n $d[count($d)] = $f[strlen($f) - 1];\n $e[$f[strlen($f) - 1]] = 1;\n $f = bcadd($f, $c);\n }\n }\n }\n $g = floor(bcdiv($b, $c));\n $h = array_sum($d);\n $i = floor(bcdiv($g, count($d)));\n $j = bcmod($g, count($d));\n $k = bcmul($h, $i);\n $l = array_sum(array_slice($d, 0, $j));\n $m = bcadd($k, $l);\n print $m . \"\\n\";\n}\n?>"}, {"source_code": " $b)\n {\n break;\n }\n else\n {\n $f = strval($f);\n if($e[$f[strlen($f) - 1]] == 1)\n {\n break;\n }\n else\n {\n $d[count($d)] = $f[strlen($f) - 1];\n $e[$f[strlen($f) - 1]] = 1;\n $f += $c;\n }\n }\n }\n $g = floor(bcdiv($b, $c));\n $h = array_sum($d);\n $i = floor(bcdiv($g, count($d)));\n $j = bcmod($g, count($d));\n $k = bcmul($h, $i);\n $l = array_sum(array_slice($d, 0, $j));\n $m = bcadd($k, $l);\n print $m . \"\\n\";\n}\n?>"}], "src_uid": "9964bfdcfdd041b839ce120019e8220f"} {"nl": {"description": "Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring \"..\" (two consecutive periods) in string s, of all occurrences of the substring let's choose the first one, and replace this substring with string \".\". In other words, during the replacement operation, the first two consecutive periods are replaced by one. If string s contains no two consecutive periods, then nothing happens.Let's define f(s) as the minimum number of operations of replacement to perform, so that the string does not have any two consecutive periods left.You need to process m queries, the i-th results in that the character at position xi (1\u2009\u2264\u2009xi\u2009\u2264\u2009n) of string s is assigned value ci. After each operation you have to calculate and output the value of f(s).Help Daniel to process all queries.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009300\u2009000) the length of the string and the number of queries. The second line contains string s, consisting of n lowercase English letters and period signs. The following m lines contain the descriptions of queries. The i-th line contains integer xi and ci (1\u2009\u2264\u2009xi\u2009\u2264\u2009n, ci \u2014 a lowercas English letter or a period sign), describing the query of assigning symbol ci to position xi.", "output_spec": "Print m numbers, one per line, the i-th of these numbers must be equal to the value of f(s) after performing the i-th assignment.", "sample_inputs": ["10 3\n.b..bz....\n1 h\n3 c\n9 f", "4 4\n.cc.\n2 .\n3 .\n2 a\n1 a"], "sample_outputs": ["4\n3\n1", "1\n3\n1\n1"], "notes": "NoteNote to the first sample test (replaced periods are enclosed in square brackets).The original string is \".b..bz....\". after the first query f(hb..bz....) = 4\u00a0\u00a0\u00a0\u00a0(\"hb[..]bz....\" \u2009\u2192\u2009 \"hb.bz[..]..\" \u2009\u2192\u2009 \"hb.bz[..].\" \u2009\u2192\u2009 \"hb.bz[..]\" \u2009\u2192\u2009 \"hb.bz.\") after the second query f(hb\u0441.bz....) = 3\u00a0\u00a0\u00a0\u00a0(\"hb\u0441.bz[..]..\" \u2009\u2192\u2009 \"hb\u0441.bz[..].\" \u2009\u2192\u2009 \"hb\u0441.bz[..]\" \u2009\u2192\u2009 \"hb\u0441.bz.\") after the third query f(hb\u0441.bz..f.) = 1\u00a0\u00a0\u00a0\u00a0(\"hb\u0441.bz[..]f.\" \u2009\u2192\u2009 \"hb\u0441.bz.f.\")Note to the second sample test.The original string is \".cc.\". after the first query: f(..c.) = 1\u00a0\u00a0\u00a0\u00a0(\"[..]c.\" \u2009\u2192\u2009 \".c.\") after the second query: f(....) = 3\u00a0\u00a0\u00a0\u00a0(\"[..]..\" \u2009\u2192\u2009 \"[..].\" \u2009\u2192\u2009 \"[..]\" \u2009\u2192\u2009 \".\") after the third query: f(.a..) = 1\u00a0\u00a0\u00a0\u00a0(\".a[..]\" \u2009\u2192\u2009 \".a.\") after the fourth query: f(aa..) = 1\u00a0\u00a0\u00a0\u00a0(\"aa[..]\" \u2009\u2192\u2009 \"aa.\")"}, "positive_code": [{"source_code": " 1) {\n $x += $tempDotNumber - 1;\n }\n\n return $x;\n}\n"}], "negative_code": [], "src_uid": "68883ab115882de5cf77d0848b80b422"} {"nl": {"description": "Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the end of the game. If boys have the same number of points, the game finishes with a draw.At some point, Valera lost his count, and so he can not say exactly what the score is at the end of the game. But there are things he remembers for sure. He remembers that the entire game Vasya got heads at least a times, and Petya got heads at least b times. Moreover, he knows that the winner of the game was Vasya. Valera wants to use this information to know every possible outcome of the game, which do not contradict his memories.", "input_spec": "The single line contains four integers x,\u2009y,\u2009a,\u2009b (1\u2009\u2264\u2009a\u2009\u2264\u2009x\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009b\u2009\u2264\u2009y\u2009\u2264\u2009100). The numbers on the line are separated by a space.", "output_spec": "In the first line print integer n \u2014 the number of possible outcomes of the game. Then on n lines print the outcomes. On the i-th line print a space-separated pair of integers ci, di \u2014 the number of heads Vasya and Petya got in the i-th outcome of the game, correspondingly. Print pairs of integers (ci,\u2009di) in the strictly increasing order. Let us remind you that the pair of numbers (p1,\u2009q1) is less than the pair of numbers (p2,\u2009q2), if p1\u2009<\u2009p2, or p1\u2009=\u2009p2 and also q1\u2009<\u2009q2.", "sample_inputs": ["3 2 1 1", "2 4 2 2"], "sample_outputs": ["3\n2 1\n3 1\n3 2", "0"], "notes": null}, "positive_code": [{"source_code": " $f[$x])\n {\n array_push($g, $e[$x] . \" \" . $f[$x]);\n }\n}\nif(count($g) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($g) . \"\\n\";\n for($x = 0; $x < count($g) - 1; $x++)\n {\n print $g[$x] . \"\\n\";\n }\n print $g[$x];\n}\n?>"}, {"source_code": ""}, {"source_code": " /* BismiLahi Rahmani Rahim */ ?>\n\n= $a ? $j+1 : $a; $i <= $x; $i ++) {\n $answer[] = array($i, $j);\n }\n}\nsort($answer);\n\nprintf(\"%d\\n\", count($answer));\n\nforeach ($answer as $val) {\n printf(\"%d %d\\n\", $val[0], $val[1]);\n}\n\n\n?>\n"}], "negative_code": [{"source_code": " $a)\n{\n $b = $a;\n}\n$e = array();\n$f = array();\n$g = $a;\n$h = $b;\n$i = $c;\n$j = $d;\n$k = 0;\n$l = array();\n$n = array();\n$o = array();\nfor($x = 1; $x <= 10000; $x++)\n{\n if($c > $d)\n {\n $k++;\n array_push($e, $c);\n array_push($f, $d);\n $p = $d;\n if(strlen($p) == 1)\n {\n $p = 0 . $p;\n }\n array_push($l, $c . \".\" . $p);\n }\n if($c == $a)\n {\n $c = $i;\n $d++;\n if($d == $b + 1)\n {\n break;\n }\n }\n $c++;\n}\nasort($l);\n$m = array_keys($l);\nfor($x = 0; $x < count($e); $x++)\n{\n array_push($n, $e[$m[$x]]);\n array_push($o, $f[$m[$x]]);\n}\nif($k > 0)\n{\n print $k . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n if($x == count($e) - 1)\n {\n print $n[$x] . \" \" . $o[$x];\n }\n else\n {\n print $n[$x] . \" \" . $o[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": " $a)\n{\n $b = $a;\n}\n$e = array();\n$f = array();\n$g = $a;\n$h = $b;\n$i = $c;\n$j = $d;\n$k = 0;\nfor($x = 1; $x <= ($g - $i + 1) + ($h - $j + 1); $x++)\n{\n if($c > $d)\n {\n $k++;\n array_push($e, $c);\n array_push($f, $d);\n }\n if($c == $a)\n {\n $c = $i;\n $d++;\n }\n $c++;\n}\nif($k > 0)\n{\n print $k . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n if($x == count($e) - 1)\n {\n print $e[$x] . \" \" . $f[$x];\n }\n else\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": " $a)\n{\n $b = $a;\n}\n$e = array();\n$f = array();\n$g = $a;\n$h = $b;\n$i = $c;\n$j = $d;\n$k = 0;\n$l = array();\n$n = array();\n$o = array();\nfor($x = 1; $x <= 10000; $x++)\n{\n if($c > $d)\n {\n $k++;\n array_push($e, $c);\n array_push($f, $d);\n array_push($l, $c . $d);\n }\n if($c == $a)\n {\n $c = $i;\n $d++;\n if($d == $b + 1)\n {\n break;\n }\n }\n $c++;\n}\nasort($l);\n$m = array_keys($l);\nfor($x = 0; $x < count($e); $x++)\n{\n array_push($n, $e[$m[$x]]);\n array_push($o, $f[$m[$x]]);\n}\nif($k > 0)\n{\n print $k . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n if($x == count($e) - 1)\n {\n print $n[$x] . \" \" . $o[$x];\n }\n else\n {\n print $n[$x] . \" \" . $o[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": " $a)\n{\n $b = $a;\n}\n$e = array();\n$f = array();\n$g = $a;\n$h = $b;\n$i = $c;\n$j = $d;\n$k = 0;\nfor($x = 1; $x <= 10000; $x++)\n{\n if($c > $d)\n {\n $k++;\n array_push($e, $c);\n array_push($f, $d);\n }\n if($c == $a)\n {\n $c = $i;\n $d++;\n if($d == $b + 1)\n {\n break;\n }\n }\n $c++;\n}\nif($k > 0)\n{\n print $k . \"\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n if($x == count($e) - 1)\n {\n print $e[$x] . \" \" . $f[$x];\n }\n else\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\nelse\n{\n print \"0\";\n}\n?>"}, {"source_code": " /* BismiLahi Rahmani Rahim */ ?>\n\n $x) {\n printf(\"0\");\n exit;\n}\n\nfor ($j = $b; $j <= $y; $j ++) {\n for ($i = $j + 1 >= $a ? $j+1 : $a; $i <= $x; $i ++) {\n $answer[] = array($i, $j);\n }\n}\nsort($answer);\n\nprintf(\"%d\\n\", count($answer));\n\nforeach ($answer as $val) {\n printf(\"%d %d\\n\", $val[0], $val[1]);\n}\n\n\n?>\n"}], "src_uid": "bb3e3b51a4eda8fef503952a00777910"} {"nl": {"description": "An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it either to the beginning of the train, or to the end of the train, at his desire. What is the minimum number of actions David Blaine needs to perform in order to sort the train?", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the number of cars in the train. The second line contains n integers pi (1\u2009\u2264\u2009pi\u2009\u2264\u2009n, pi\u2009\u2260\u2009pj if i\u2009\u2260\u2009j)\u00a0\u2014 the sequence of the numbers of the cars in the train.", "output_spec": "Print a single integer\u00a0\u2014 the minimum number of actions needed to sort the railway cars.", "sample_inputs": ["5\n4 1 2 5 3", "4\n4 1 3 2"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train."}, "positive_code": [{"source_code": " $c[$x])\n {\n $e++;\n }\n else\n {\n $d = max($d, $e);\n $e = 1;\n }\n}\n$d = max($d, $e);\nprint $a - $d;\n?>"}], "negative_code": [{"source_code": " $c[$x])\n {\n $e++;\n }\n else\n {\n $d = max($d, $e);\n $e = 0;\n }\n}\n$d = max($d, $e);\nprint $a - $d;\n?>"}, {"source_code": " $c[$x])\n {\n $e++;\n }\n else\n {\n $d = max($d, $e);\n $e = 0;\n }\n}\nprint $a - $d;\n?>"}], "src_uid": "277948a70c75840445e1826f2b23a897"} {"nl": {"description": "Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from $$$1$$$, starting from the topmost one. The columns are numbered from $$$1$$$, starting from the leftmost one.Initially, the table hasn't been filled and Polycarp wants to fix it. He writes integers from $$$1$$$ and so on to the table as follows. The figure shows the placement of the numbers from $$$1$$$ to $$$10$$$. The following actions are denoted by the arrows. The leftmost topmost cell of the table is filled with the number $$$1$$$. Then he writes in the table all positive integers beginning from $$$2$$$ sequentially using the following algorithm.First, Polycarp selects the leftmost non-filled cell in the first row and fills it. Then, while the left neighbor of the last filled cell is filled, he goes down and fills the next cell. So he goes down until the last filled cell has a non-filled neighbor to the left (look at the vertical arrow going down in the figure above).After that, he fills the cells from the right to the left until he stops at the first column (look at the horizontal row in the figure above). Then Polycarp selects the leftmost non-filled cell in the first row, goes down, and so on.A friend of Polycarp has a favorite number $$$k$$$. He wants to know which cell will contain the number. Help him to find the indices of the row and the column, such that the intersection of the row and the column is the cell containing the number $$$k$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line containing one integer $$$k$$$ ($$$1 \\le k \\le 10^9$$$) which location must be found.", "output_spec": "For each test case, output in a separate line two integers $$$r$$$ and $$$c$$$ ($$$r, c \\ge 1$$$) separated by spaces \u2014 the indices of the row and the column containing the cell filled by the number $$$k$$$, respectively.", "sample_inputs": ["7\n11\n14\n5\n4\n1\n2\n1000000000"], "sample_outputs": ["2 4\n4 3\n1 3\n2 1\n1 1\n1 2\n31623 14130"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "f8335c59cd05988c8053f138c4df06aa"} {"nl": {"description": "You are given a picture consisting of $$$n$$$ rows and $$$m$$$ columns. Rows are numbered from $$$1$$$ to $$$n$$$ from the top to the bottom, columns are numbered from $$$1$$$ to $$$m$$$ from the left to the right. Each cell is painted either black or white. You think that this picture is not interesting enough. You consider a picture to be interesting if there is at least one cross in it. A cross is represented by a pair of numbers $$$x$$$ and $$$y$$$, where $$$1 \\le x \\le n$$$ and $$$1 \\le y \\le m$$$, such that all cells in row $$$x$$$ and all cells in column $$$y$$$ are painted black.For examples, each of these pictures contain crosses: The fourth picture contains 4 crosses: at $$$(1, 3)$$$, $$$(1, 5)$$$, $$$(3, 3)$$$ and $$$(3, 5)$$$.Following images don't contain crosses: You have a brush and a can of black paint, so you can make this picture interesting. Each minute you may choose a white cell and paint it black.What is the minimum number of minutes you have to spend so the resulting picture contains at least one cross?You are also asked to answer multiple independent queries.", "input_spec": "The first line contains an integer $$$q$$$ ($$$1 \\le q \\le 5 \\cdot 10^4$$$) \u2014 the number of queries. The first line of each query contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 5 \\cdot 10^4$$$, $$$n \\cdot m \\le 4 \\cdot 10^5$$$) \u2014 the number of rows and the number of columns in the picture. Each of the next $$$n$$$ lines contains $$$m$$$ characters \u2014 '.' if the cell is painted white and '*' if the cell is painted black. It is guaranteed that $$$\\sum n \\le 5 \\cdot 10^4$$$ and $$$\\sum n \\cdot m \\le 4 \\cdot 10^5$$$.", "output_spec": "Print $$$q$$$ lines, the $$$i$$$-th line should contain a single integer \u2014 the answer to the $$$i$$$-th query, which is the minimum number of minutes you have to spend so the resulting picture contains at least one cross.", "sample_inputs": ["9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**"], "sample_outputs": ["0\n0\n0\n0\n0\n4\n1\n1\n2"], "notes": "NoteThe example contains all the pictures from above in the same order.The first 5 pictures already contain a cross, thus you don't have to paint anything.You can paint $$$(1, 3)$$$, $$$(3, 1)$$$, $$$(5, 3)$$$ and $$$(3, 5)$$$ on the $$$6$$$-th picture to get a cross in $$$(3, 3)$$$. That'll take you $$$4$$$ minutes.You can paint $$$(1, 2)$$$ on the $$$7$$$-th picture to get a cross in $$$(4, 2)$$$.You can paint $$$(2, 2)$$$ on the $$$8$$$-th picture to get a cross in $$$(2, 2)$$$. You can, for example, paint $$$(1, 3)$$$, $$$(3, 1)$$$ and $$$(3, 3)$$$ to get a cross in $$$(3, 3)$$$ but that will take you $$$3$$$ minutes instead of $$$1$$$.There are 9 possible crosses you can get in minimum time on the $$$9$$$-th picture. One of them is in $$$(1, 1)$$$: paint $$$(1, 2)$$$ and $$$(2, 1)$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " $max_row) {\n\n $max_row = $current_row;\n $row = $j;\n $rows = [$j];\n } elseif ($current_row == $max_row) {\n $rows[] = $j;\n }\n }\n\n if ($cols) {\n $max_col = max($cols);\n $col = array_search($max_col, $cols);\n }\n\n $res = ($x - $max_col) + ($y - $max_row);\n if ($res == 0) {\n return 0;\n }\n\n foreach ($cols as $_c => $val) {\n if ($val == $max_col) {\n foreach ($rows as $_r) {\n\n if ($matrix[$_c][$_r] != '*') {\n return $res - 1;\n }\n }\n }\n }\n\n return $res;\n}\n\n\n$n = intval(fgets($__fp));\n$res1 = [];\nfor ($i = 0; $i < $n; $i++) {\n list($x, $y) = array_map('intval', explode(' ', trim(fgets($__fp))));\n $matrix = [];\n for ($j = 0; $j < $x; $j++) {\n $matrix[] = str_split(trim(fgets($__fp)));\n }\n\n $res1[] = calcTime($x, $y, $matrix);\n}\n\nfclose($__fp);\n\necho join(PHP_EOL, $res1);"}], "negative_code": [{"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x == 149))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $e5 = max($e4);\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if($e5 == $c)\n {\n $i = $b - $h;\n }\n elseif($h == $b)\n {\n $i = $c - $e;\n }\n elseif(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if($d[$y] == $h)\n {\n $d2 = $y;\n break;\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x >= 147))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n if(($a == 16433) && ($x == 148))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3) . \"\\n\";\n }\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n $d3 = array_unique($d);\n if((count($e5) == 1) && ($e5[0] != \".\"))\n {\n $i = $b - $h;\n }\n elseif((count($d3) == 1) && ($d3[0] != \".\"))\n {\n $i = $c - $e;\n }\n elseif(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x >= 147))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3[$y]) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x == 148))\n {\n print_r($e3);\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n $d3 = array_unique($d);\n if(count($e5) == 1)\n {\n $i = $b - $h;\n }\n elseif(count($d3) == 1)\n {\n $i = $c - $e;\n }\n elseif(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x == 148))\n {\n for($y = 0; $y < $b; $y++)\n {\n $e4 = $e3[$y];\n print implode(\" \", $e4) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x == 150))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if($d[$y] == $h)\n {\n $d2 = $y;\n break;\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if(($e3[$e2][$d2] == \"*\") && ($e2 != $d2))\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $e)\n {\n $e = $g;\n $e2 = $y;\n }\n $e3[$y] = $f;\n }\n $h = max($d);\n for($y = 0; $y < $c; $y++)\n {\n if(($d[$y] == $h) && ($e3[$e2][$y] == \".\"))\n {\n $d2 = $y;\n break;\n }\n elseif($d[$y] == $h)\n {\n $d2 = $y;\n }\n }\n if(($a == 16433) && ($x == 147))\n {\n for($y = 0; $y < $b; $y++)\n {\n print implode(\" \", $e3) . \"\\n\";\n }\n }\n if(($e == $c) && ($h == $b))\n {\n $i = 0;\n }\n else\n {\n if($e3[$e2][$d2] == \"*\")\n {\n $i = ($b - $h) + ($c - $e);\n }\n else\n {\n $i = ($b - $h) + ($c - $e) - 1;\n }\n }\n print $i . \"\\n\";\n}\n?>"}, {"source_code": " $max_row) {\n $max_row = $current_row;\n $row = $j;\n }\n }\n\n if ($cols) {\n $max_col = max($cols);\n $col = array_search($max_col, $cols);\n }\n $res = ($x - $max_col) + ($y - $max_row);\n\n//if(!isset($matrix[$row][$col] ))\n//{\n// var_dump($matrix, $row, $col);exit;\n//}\n\n\n if($res != 0 && $matrix[$col][$row] != '*')\n {\n $res -= 1;\n }\n\n return $res;\n\n}\n\n\n$n = intval(fgets($__fp));\n$res1 = [];\nfor ($i = 0; $i < $n; $i++) {\n list($x, $y) = array_map('intval', explode(' ', trim(fgets($__fp))));\n $matrix = [];\n for ($j = 0; $j < $x; $j++)\n {\n $matrix[] = str_split(trim(fgets($__fp)));\n }\n\n $res1[] = calcTime($x, $y, $matrix);\n}\n\nfclose($__fp);\n\necho join(PHP_EOL, $res1);"}, {"source_code": " $max_row) {\n $max_row = $current_row;\n $row = $j;\n }\n }\n\n if ($cols) {\n $max_col = max($cols);\n $col = array_search($max_col, $cols);\n }\n\n return ($x - $max_col) + ($y - $max_row);\n\n}\n\n\n$n = intval(fgets($__fp));\n$res1 = [];\nfor ($i = 0; $i < $n; $i++) {\n list($x, $y) = array_map('intval', explode(' ', trim(fgets($__fp))));\n $matrix = [];\n for ($j = 0; $j < $x; $j++)\n {\n $matrix[] = str_split(trim(fgets($__fp)));\n }\n\n $res1[] = calcTime($x, $y, $matrix);\n}\n\nfclose($__fp);\n\necho join(PHP_EOL, $res1);"}, {"source_code": " $max_row) {\n $max_row = $current_row;\n $row = $j;\n }\n }\n\n if ($cols) {\n $max_col = max($cols);\n $col = array_search($max_col, $cols);\n }\n\n return ($x - $max_col) + ($y - $max_row) - 1;\n\n}\n\n\n$n = intval(fgets($__fp));\n$res1 = [];\nfor ($i = 0; $i < $n; $i++) {\n list($x, $y) = array_map('intval', explode(' ', trim(fgets($__fp))));\n $matrix = [];\n for ($j = 0; $j < $x; $j++)\n {\n $matrix[] = str_split(trim(fgets($__fp)));\n }\n\n $res1[] = calcTime($x, $y, $matrix);\n}\n\nfclose($__fp);\n\necho join(PHP_EOL, $res1);"}, {"source_code": " $max_row) {\n $max_row = $current_row;\n $row = $j;\n }\n }\n\n if ($cols) {\n $max_col = max($cols);\n $col = array_search($max_col, $cols);\n }\n\n $res = ($x - $max_col) + ($y - $max_row);\n return $res == 0 ? $res : $res - 1;\n\n}\n\n\n$n = intval(fgets($__fp));\n$res1 = [];\nfor ($i = 0; $i < $n; $i++) {\n list($x, $y) = array_map('intval', explode(' ', trim(fgets($__fp))));\n $matrix = [];\n for ($j = 0; $j < $x; $j++)\n {\n $matrix[] = str_split(trim(fgets($__fp)));\n }\n\n $res1[] = calcTime($x, $y, $matrix);\n}\n\nfclose($__fp);\n\necho join(PHP_EOL, $res1);"}], "src_uid": "a1b6a2f4659169e0e818bbdee6d36e76"} {"nl": {"description": "Little Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test they will get a mark from 1 to p. Vova is very smart and he can write every test for any mark, but he doesn't want to stand out from the crowd too much. If the sum of his marks for all tests exceeds value x, then his classmates notice how smart he is and start distracting him asking to let them copy his homework. And if the median of his marks will be lower than y points (the definition of a median is given in the notes), then his mom will decide that he gets too many bad marks and forbid him to play computer games.Vova has already wrote k tests and got marks a1,\u2009...,\u2009ak. He doesn't want to get into the first or the second situation described above and now he needs to determine which marks he needs to get for the remaining tests. Help him do that.", "input_spec": "The first line contains 5 space-separated integers: n, k, p, x and y (1\u2009\u2264\u2009n\u2009\u2264\u2009999, n is odd, 0\u2009\u2264\u2009k\u2009<\u2009n, 1\u2009\u2264\u2009p\u2009\u2264\u20091000, n\u2009\u2264\u2009x\u2009\u2264\u2009n\u00b7p, 1\u2009\u2264\u2009y\u2009\u2264\u2009p). Here n is the number of tests that Vova is planned to write, k is the number of tests he has already written, p is the maximum possible mark for a test, x is the maximum total number of points so that the classmates don't yet disturb Vova, y is the minimum median point so that mom still lets him play computer games. The second line contains k space-separated integers: a1,\u2009...,\u2009ak (1\u2009\u2264\u2009ai\u2009\u2264\u2009p)\u00a0\u2014 the marks that Vova got for the tests he has already written.", "output_spec": "If Vova cannot achieve the desired result, print \"-1\". Otherwise, print n\u2009-\u2009k space-separated integers\u00a0\u2014 the marks that Vova should get for the remaining tests. If there are multiple possible solutions, print any of them.", "sample_inputs": ["5 3 5 18 4\n3 5 4", "5 3 5 16 4\n5 5 5"], "sample_outputs": ["4 1", "-1"], "notes": "NoteThe median of sequence a1,\u00a0...,\u00a0an where n is odd (in this problem n is always odd) is the element staying on (n\u2009+\u20091)\u2009/\u20092 position in the sorted list of ai.In the first sample the sum of marks equals 3 + 5 + 4 + 4 + 1 = 17, what doesn't exceed 18, that means that Vova won't be disturbed by his classmates. And the median point of the sequence {1, 3, 4, 4, 5} equals to 4, that isn't less than 4, so his mom lets him play computer games.Please note that you do not have to maximize the sum of marks or the median mark. Any of the answers: \"4\u00a02\", \"2\u00a04\", \"5\u00a01\", \"1\u00a05\", \"4\u00a01\", \"1\u00a04\" for the first test is correct.In the second sample Vova got three '5' marks, so even if he gets two '1' marks, the sum of marks will be 17, that is more than the required value of 16. So, the answer to this test is \"-1\"."}, "positive_code": [{"source_code": " $d)\n{\n print \"-1\";\n}\nelse\n{\n $i = $d - $g;\n $i -= $a - $b;\n $j = array_fill(0, $a - $b, 1);\n if($f[0] == 0)\n {\n $k = $j;\n }\n else\n {\n $k = array_merge($f, $j);\n }\n sort($k);\n $l = (($a + 1) / 2) - 1;\n if($k[$l] >= $e)\n {\n print implode(\" \", $j);\n }\n else\n {\n if(($b > ($a - $b)) && ($k[$a - 1] < $e))\n {\n print \"-1\";\n }\n else\n {\n $m = $e - 1;\n $n = 0;\n for($x = 0; $x < $a - $b; $x++)\n {\n $i -= $m;\n if($i >= 0)\n {\n $j[$x] = $e;\n $k[0] = $e;\n sort($k);\n if($k[$l] >= $e)\n {\n $n = 1;\n print implode(\" \", $j);\n break;\n }\n }\n else\n {\n $n = 1;\n print \"-1\";\n break;\n }\n }\n if($n == 0)\n {\n print \"-1\";\n }\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " $d)\n{\n print \"-1\";\n}\nelse\n{\n $i = $d - $g;\n $i -= $a - $b;\n $j = array_fill(0, $a - $b, 1);\n if($f[0] == 0)\n {\n $k = $j;\n }\n else\n {\n $k = array_merge($f, $j);\n }\n sort($k);\n $l = (($a + 1) / 2) - 1;\n if($k[$l] >= $e)\n {\n print implode(\" \", $j);\n }\n else\n {\n if(($b > ($a - $b)) && ($k[$a - 1] < $e))\n {\n print \"-1\";\n }\n else\n {\n $m = $e - 1;\n for($x = 0; $x < $a - $b; $x++)\n {\n $i -= $m;\n if($i >= 0)\n {\n $j[$x] = $e;\n $k[0] = $e;\n sort($k);\n if($k[$l] >= $e)\n {\n print implode(\" \", $j);\n break;\n }\n }\n else\n {\n print \"-1\";\n break;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n print \"-1\";\n}\nelse\n{\n $i = $d - $g;\n $i -= $a - $b;\n $j = array_fill(0, $a - $b, 1);\n $k = array_merge($f, $j);\n sort($k);\n $l = (($a + 1) / 2) - 1;\n if($k[$l] >= $e)\n {\n print implode(\" \", $j);\n }\n else\n {\n if(($b > ($a - $b)) && ($k[$a - 1] < $e))\n {\n print \"-1\";\n }\n else\n {\n $m = $e - 1;\n for($x = 0; $x < $a - $b; $x++)\n {\n $i -= $m;\n if($i >= 0)\n {\n $j[$x] = $e;\n $k[0] = $e;\n sort($k);\n if($k[$l] >= $e)\n {\n print implode(\" \", $j);\n break;\n }\n }\n else\n {\n print \"-1\";\n break;\n }\n }\n }\n }\n}\n?>"}], "src_uid": "f01d11bd231a7b2e7ca56de1df0f1272"} {"nl": {"description": "A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line, where the i-th safe from the left is called safe i. There are n banknotes left in all the safes in total. The i-th banknote is in safe xi. Oleg is now at safe a. There are two security guards, one of which guards the safe b such that b\u2009<\u2009a, i.e. the first guard is to the left of Oleg. The other guard guards the safe c so that c\u2009>\u2009a, i.e. he is to the right of Oleg.The two guards are very lazy, so they do not move. In every second, Oleg can either take all the banknotes from the current safe or move to any of the neighboring safes. However, he cannot visit any safe that is guarded by security guards at any time, becaues he might be charged for stealing. Determine the maximum amount of banknotes Oleg can gather.", "input_spec": "The first line of input contains three space-separated integers, a, b and c (1\u2009\u2264\u2009b\u2009<\u2009a\u2009<\u2009c\u2009\u2264\u2009109), denoting the positions of Oleg, the first security guard and the second security guard, respectively. The next line of input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105), denoting the number of banknotes. The next line of input contains n space-separated integers x1,\u2009x2,\u2009...,\u2009xn (1\u2009\u2264\u2009xi\u2009\u2264\u2009109), denoting that the i-th banknote is located in the xi-th safe. Note that xi are not guaranteed to be distinct.", "output_spec": "Output a single integer: the maximum number of banknotes Oleg can take.", "sample_inputs": ["5 3 7\n8\n4 7 5 5 3 6 2 8", "6 5 7\n5\n1 5 7 92 3"], "sample_outputs": ["4", "0"], "notes": "NoteIn the first example Oleg can take the banknotes in positions 4, 5, 6 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7 and 8 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 3 and 2 because he can't run into the first security guard. Thus, he can take a maximum of 4 banknotes.For the second sample, Oleg can't take any banknotes without bumping into any of the security guards."}, "positive_code": [{"source_code": " $b) && ($e[$x] < $c))\n {\n $f++;\n }\n}\nprint $f;\n?>"}], "negative_code": [], "src_uid": "aceadc8eadf6d5efd7c5a9fbc0396423"} {"nl": {"description": "\u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u043b\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0448\u0442\u0430\u0431 \u0432 \u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433\u0435! \u0412\u044b \u043d\u0435 \u043f\u0440\u0435\u043c\u0438\u043d\u0443\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0431\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u0442\u044c \u0438\u0437 \u043e\u0444\u0438\u0441\u0430 \u0432 \u0414\u043e\u043c\u0435 \u0417\u0438\u043d\u0433\u0435\u0440\u0430 \u0432 \u043e\u0444\u0438\u0441 \u043d\u0430 \u041a\u0440\u0430\u0441\u043d\u043e\u043c \u043c\u043e\u0441\u0442\u0443.\u0414\u043b\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0438\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0435\u0434\u0438\u043d\u044b\u043c \u0446\u0435\u043b\u044b\u043c. \u041d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435 \u043e\u0444\u0438\u0441\u0430 \u043d\u0430 \u041a\u0440\u0430\u0441\u043d\u043e\u043c \u043c\u043e\u0441\u0442\u0443 \u0435\u0441\u0442\u044c $$$n$$$ \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432, $$$i$$$-\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043c\u0435\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 $$$w_i$$$ \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 $$$h_i$$$. \u041b\u044e\u0431\u043e\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0448\u0438\u0440\u0438\u043d\u0443 $$$h_i$$$ \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 $$$w_i$$$.\u041d\u0430\u0437\u043e\u0432\u0451\u043c \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0438\u043c\u0435\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0432\u044b\u0441\u043e\u0442\u0443. \u041b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u0432 \u043f\u0430\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c.\u041f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432.", "input_spec": "\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $$$n$$$\u00a0\u2014 \u0447\u0438\u0441\u043b\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u043d\u0430 \u0441\u043a\u043b\u0430\u0434\u0435. \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 $$$n$$$ \u0441\u0442\u0440\u043e\u043a \u0437\u0430\u0434\u0430\u043d\u044b \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $$$w_i$$$ \u0438 $$$h_i$$$\u00a0($$$1 \\le w_i, h_i \\le 10^9$$$)\u00a0\u2014 \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 $$$i$$$-\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u043c\u0438 ($$$w_i = h_i$$$), \u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c. \u0412 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 $$$2 \\le n \\le 10^3$$$.", "output_spec": "\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u0430\u0440 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432.", "sample_inputs": ["5\n3 2\n2 2\n5 5\n3 5\n4 3", "7\n10 10\n10 20\n20 10\n10 20\n10 20\n10 10\n20 10"], "sample_outputs": ["5", "21"], "notes": "\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432 \u0441 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 $$$(1, 2)$$$, $$$(1, 4)$$$, $$$(1, 5)$$$, $$$(3, 4)$$$, $$$(4, 5)$$$.\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0441\u0435 \u043f\u0430\u0440\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u0432\u00a0\u2014 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435."}, "positive_code": [{"source_code": " $el[1] ? $el[1].' '.$el[0] : $buf;\r\n $el = $el[0] > $el[1] ? [$el[1],$el[0]] : $el;\r\n\r\n\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n $arr[] = $buf;\r\n\r\n $arrCommon[] = $el;\r\n }else{\r\n $elCount = $buf;\r\n }\r\n $i = true;\r\n}\r\n\r\n$lineMap = array_count_values($sizes);\r\n$multiMap = array_count_values($arr);\r\n\r\nforeach($arr as $k => $size){\r\n\r\n $pExpl = explode(' ', $size);\r\n if($pExpl[0] == $pExpl[1]){\r\n\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 2;\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $lineMap[$pExpl[0]] - $multiMap[$size];\r\n\r\n $step = $pCountAdd;\r\n\r\n }else{\r\n //remove itself\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 1;\r\n $lineMap[$pExpl[1]] = $lineMap[$pExpl[1]] - 1;\r\n\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $multiMap[$size];\r\n\r\n $sameLeft = $multiMap[$pExpl[0].' '.$pExpl[0]] ? $multiMap[$pExpl[0].' '.$pExpl[0]] : 0;\r\n $sameRight = $multiMap[$pExpl[1].' '.$pExpl[1]] ? $multiMap[$pExpl[1].' '.$pExpl[1]] : 0;\r\n $pCountAdd = ($lineMap[$pExpl[0]] + $lineMap[$pExpl[1]]) - $sameLeft - $sameRight - $pCountAdd;\r\n\r\n $step = $pCountAdd;\r\n\r\n }\r\n\r\n $count += $step;\r\n\r\n}\r\n\r\necho $count;\r\n?>"}, {"source_code": " $el[1] ? $el[1].' '.$el[0] : $buf;\r\n $el = $el[0] > $el[1] ? [$el[1],$el[0]] : $el;\r\n\r\n\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n $arr[] = $buf;\r\n\r\n $arrCommon[] = $el;\r\n }else{\r\n $elCount = $buf;\r\n }\r\n $i = true;\r\n}\r\n\r\n$lineMap = array_count_values($sizes);\r\n$multiMap = array_count_values($arr);\r\n\r\nforeach($arr as $k => $size){\r\n\r\n $pExpl = explode(' ', $size);\r\n if($pExpl[0] == $pExpl[1]){\r\n\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 2;\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $lineMap[$pExpl[0]] - $multiMap[$size];\r\n\r\n $step = $pCountAdd;\r\n\r\n }else{\r\n //remove itself\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 1;\r\n $lineMap[$pExpl[1]] = $lineMap[$pExpl[1]] - 1;\r\n\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $multiMap[$size];\r\n\r\n $sameLeft = $multiMap[$pExpl[0].' '.$pExpl[0]] ? $multiMap[$pExpl[0].' '.$pExpl[0]] : 0;\r\n $sameRight = $multiMap[$pExpl[1].' '.$pExpl[1]] ? $multiMap[$pExpl[1].' '.$pExpl[1]] : 0;\r\n $pCountAdd = ($lineMap[$pExpl[0]] + $lineMap[$pExpl[1]]) - $sameLeft - $sameRight - $pCountAdd;\r\n\r\n $step = $pCountAdd;\r\n\r\n }\r\n\r\n $count += $step;\r\n\r\n}\r\n\r\necho $count;\r\n?>"}, {"source_code": " $el[1] ? $el[1].' '.$el[0] : $buf;\r\n $el = $el[0] > $el[1] ? [$el[1],$el[0]] : $el;\r\n\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n $arr[] = $buf;\r\n\r\n $arrCommon[] = $el;\r\n}\r\n\r\n$lineMap = array_count_values($sizes);\r\n$multiMap = array_count_values($arr);\r\n\r\nforeach($arr as $k => $size){\r\n $pExpl = explode(' ', $size);\r\n\r\n if($pExpl[0] == $pExpl[1]){\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 2;\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $lineMap[$pExpl[0]] - $multiMap[$size];\r\n\r\n $step = $pCountAdd;\r\n } else {\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 1;\r\n $lineMap[$pExpl[1]] = $lineMap[$pExpl[1]] - 1;\r\n\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n $pCountAdd = $multiMap[$size];\r\n\r\n foreach ($multiMap as $code => $map){\r\n if($code != $size && $map > 0){\r\n $exCode = explode(' ', $code);\r\n if($exCode[0] == $pExpl[0] || $exCode[0] == $pExpl[1] || $exCode[1] == $pExpl[0] || $exCode[1] == $pExpl[1]){\r\n $pCountAdd += $map;\r\n \r\n }\r\n }\r\n }\r\n\r\n $step = $pCountAdd;\r\n }\r\n\r\n $count += $step;\r\n}\r\n\r\necho $count;\r\n?>"}, {"source_code": " 1000){\r\n echo 0;\r\n }else{\r\n function checkPair($size, $arr){\r\n $c = 0;\r\n foreach($arr as $k => $r){\r\n if($size[0] == $r[0] || $size[0] == $r[1] || $size[1] == $r[0] || $size[1] == $r[1]){\r\n $c++;\r\n }\r\n }\r\n \r\n return $c;\r\n }\r\n \r\n \r\n $tmpSizes = $sizes;\r\n foreach($sizes as $k => $size){\r\n unset($tmpSizes[$k]);\r\n $count += checkPair($size, $tmpSizes);\r\n }\r\n echo $count;\r\n }\r\n \r\n?>"}, {"source_code": " $el[1] ? $el[1].' '.$el[0] : $buf;\r\n $el = $el[0] > $el[1] ? [$el[1],$el[0]] : $el;\r\n\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n $arr[] = $buf;\r\n\r\n $arrCommon[] = $el;\r\n}\r\n\r\n$lineMap = array_count_values($sizes);\r\n$multiMap = array_count_values($arr);\r\n\r\nforeach($arr as $k => $size){\r\n $pExpl = explode(' ', $size);\r\n\r\n if($pExpl[0] == $pExpl[1]){\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 2;\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $lineMap[$pExpl[0]] - $multiMap[$size];\r\n\r\n $step = $pCountAdd;\r\n } else {\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 1;\r\n $lineMap[$pExpl[1]] = $lineMap[$pExpl[1]] - 1;\r\n\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n $pCountAdd = $multiMap[$size];\r\n\r\n foreach ($multiMap as $code => $map){\r\n if($code != $size && $map > 0){\r\n $exCode = explode(' ', $code);\r\n if($exCode[0] == $pExpl[0] || $exCode[0] == $pExpl[1] || $exCode[1] == $pExpl[0] || $exCode[1] == $pExpl[1]){\r\n $pCountAdd += 1;\r\n \r\n }\r\n }\r\n }\r\n\r\n $step = $pCountAdd;\r\n }\r\n\r\n $count += $step;\r\n}\r\n\r\necho $count;\r\n?>"}, {"source_code": " $el[1] ? $el[1].' '.$el[0] : $buf;\r\n $el = $el[0] > $el[1] ? [$el[1],$el[0]] : $el;\r\n /*if($el[0] == $el[1]){\r\n $sizes[] = $el[0];\r\n }else{\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n }*/\r\n\r\n $sizes[] = $el[0];\r\n $sizes[] = $el[1];\r\n\r\n $arr[] = $buf;\r\n\r\n $arrCommon[] = $el;\r\n }else{\r\n $elCount = $buf;\r\n }\r\n $i = true;\r\n}\r\n\r\n$lineMap = array_count_values($sizes);\r\n$multiMap = array_count_values($arr);\r\n\r\nforeach($arr as $k => $size){\r\n // $pCountW = $lineMap[$size[0]];\r\n // $pCountH = $lineMap[$size[1]];\r\n $pExpl = explode(' ', $size);\r\n if($pExpl[0] == $pExpl[1]){\r\n\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 2;\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $lineMap[$pExpl[0]] - $multiMap[$size];\r\n\r\n $step = $pCountAdd;\r\n\r\n }else{\r\n //remove itself\r\n $lineMap[$pExpl[0]] = $lineMap[$pExpl[0]] - 1;\r\n $lineMap[$pExpl[1]] = $lineMap[$pExpl[1]] - 1;\r\n\r\n $multiMap[$size] = $multiMap[$size] - 1;\r\n\r\n $pCountAdd = $multiMap[$size];\r\n\r\n foreach ($multiMap as $code => $map){\r\n if($code != $size && $map > 0){\r\n $exCode = explode(' ', $code);\r\n if($exCode[0] == $pExpl[0] || $exCode[0] == $pExpl[1] || $exCode[1] == $pExpl[0] || $exCode[1] == $pExpl[1]){\r\n $pCountAdd += 1;\r\n \r\n }\r\n }\r\n\r\n }\r\n\r\n $step = $pCountAdd;\r\n\r\n }\r\n\r\n $count += $step;\r\n\r\n}\r\n\r\necho $count;\r\n?>"}, {"source_code": " 100000){\r\n echo 0;\r\n}else{\r\n\r\n function cmp($a, $b) {\r\n if ($a == $b) {\r\n return 0;\r\n }\r\n return ($a < $b) ? -1 : 1;\r\n }\r\n\r\n uasort($sizes, 'cmp');\r\n\r\n\r\n /*echo ' ';\r\n print_r($sizes);\r\n echo '';*/\r\n\r\n $i = 1;\r\n foreach($sizes as $k => $size){\r\n if($size[0] == $size[1]) {\r\n $pair[] = $size[0];\r\n }else{\r\n $single[] = $size[0];\r\n $single[] = $size[1];\r\n }\r\n\r\n $i++;\r\n }\r\n\r\n $count = count($pair);\r\n\r\n foreach ($single as $k => $s){\r\n if(in_array($s, $pair)){\r\n // unset($single[$k]);\r\n $count++;\r\n }\r\n }\r\n\r\n\r\n/* echo '';\r\n print_r($hash);\r\n echo '';*/\r\n\r\n\r\n/* echo '';\r\n print_r($pair);\r\n echo '';\r\n\r\n echo '';\r\n print_r($single);\r\n echo '';*/\r\n\r\n foreach(array_count_values($single) as $value){\r\n $count+=intdiv($value,2);\r\n }\r\n\r\n echo $count;\r\n}"}, {"source_code": "width = $width;\r\n $this->height = $height;\r\n }\r\n\r\n public function width(): int\r\n {\r\n return $this->width;\r\n }\r\n\r\n public function height(): int\r\n {\r\n return $this->height;\r\n }\r\n\r\n public function mark(): void\r\n {\r\n $this->isMarked = true;\r\n }\r\n\r\n public function isMarked(): bool\r\n {\r\n return $this->isMarked;\r\n }\r\n}\r\n\r\n/**\r\n * @param Monitor[] $monitors\r\n * @return int\r\n */\r\nfunction findSuitablePairs(array $monitors): int\r\n{\r\n $groups = [];\r\n foreach ($monitors as $monitor) {\r\n $width = $monitor->width();\r\n\r\n if (!isset($groups[$width])) {\r\n $groups[$width] = [];\r\n }\r\n $groups[$width][] = $monitor;\r\n\r\n $height = $monitor->height();\r\n if ($width === $height) {\r\n continue;\r\n }\r\n\r\n if (!isset($groups[$height])) {\r\n $groups[$height] = [];\r\n }\r\n $groups[$height][] = $monitor;\r\n }\r\n\r\n $result = 0;\r\n\r\n foreach ($groups as $key => $monitors) {\r\n $countToCalc = 0;\r\n /** @var Monitor $monitor */\r\n foreach ($monitors as $monitor) {\r\n if ($monitor->isMarked()) {\r\n continue;\r\n }\r\n $countToCalc++;\r\n $monitor->mark();\r\n }\r\n $result += $countToCalc * ($countToCalc - 1) / 2;\r\n }\r\n\r\n return $result;\r\n}\r\n\r\nfunction readInput()\r\n{\r\n $commandsCount = trim(fgets(STDIN));\r\n if (empty($commandsCount)) {\r\n return [];\r\n }\r\n\r\n $result = [];\r\n\r\n for ($i = 0; $i < $commandsCount; $i++) {\r\n $result[] = explode(' ', trim(fgets(STDIN)));\r\n }\r\n\r\n return $result;\r\n}\r\n"}], "src_uid": "32c99f64fdf69b9fd87b07dbd14ceffa"} {"nl": {"description": "One day Prof. Slim decided to leave the kingdom of the GUC to join the kingdom of the GIU. He was given an easy online assessment to solve before joining the GIU. Citizens of the GUC were happy sad to see the prof leaving, so they decided to hack into the system and change the online assessment into a harder one so that he stays at the GUC. After a long argument, they decided to change it into the following problem.Given an array of $$$n$$$ integers $$$a_1,a_2,\\ldots,a_n$$$, where $$$a_{i} \\neq 0$$$, check if you can make this array sorted by using the following operation any number of times (possibly zero). An array is sorted if its elements are arranged in a non-decreasing order. select two indices $$$i$$$ and $$$j$$$ ($$$1 \\le i,j \\le n$$$) such that $$$a_i$$$ and $$$a_j$$$ have different signs. In other words, one must be positive and one must be negative. swap the signs of $$$a_{i}$$$ and $$$a_{j}$$$. For example if you select $$$a_i=3$$$ and $$$a_j=-2$$$, then they will change to $$$a_i=-3$$$ and $$$a_j=2$$$. Prof. Slim saw that the problem is still too easy and isn't worth his time, so he decided to give it to you to solve.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^{5}$$$) \u2014 the length of the array $$$a$$$. The next line contain $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$-10^9 \\le a_{i} \\le 10^9$$$, $$$a_{i} \\neq 0$$$) separated by spaces describing elements of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case, print \"YES\" if the array can be sorted in the non-decreasing order, otherwise print \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["4\n\n7\n\n7 3 2 -11 -13 -17 -23\n\n6\n\n4 10 25 47 71 96\n\n6\n\n71 -35 7 -4 -11 -25\n\n6\n\n-45 9 -48 -67 -55 7"], "sample_outputs": ["NO\nYES\nYES\nNO"], "notes": "NoteIn the first test case, there is no way to make the array sorted using the operation any number of times.In the second test case, the array is already sorted.In the third test case, we can swap the sign of the $$$1$$$-st element with the sign of the $$$5$$$-th element, and the sign of the $$$3$$$-rd element with the sign of the $$$6$$$-th element, this way the array will be sorted.In the fourth test case, there is no way to make the array sorted using the operation any number of times."}, "positive_code": [{"source_code": " 0 ? (int)$a[$i] : -$a[$i];\r\n } \r\n \r\n for($i=0; $i<$n; $i++) {\r\n if($i < $otr) {\r\n $a[$i] *= -1;\r\n } \r\n }\r\n for($i=1; $i<$n; $i++) {\r\n if($a[$i] < $a[$i-1]) {\r\n $ans = false;\r\n break;\r\n } \r\n } \r\n pr($ans ? $yes : $no);\r\n\r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\n function ComandR($aCordinate) {\r\n return [$aCordinate[0] + 1, $aCordinate[1]];\r\n }\r\n function ComandL($aCordinate) {\r\n return [$aCordinate[0] - 1, $aCordinate[1]];\r\n }\r\n function ComandU($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] + 1];\r\n }\r\n function ComandD($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] - 1];\r\n }\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo explode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }"}], "negative_code": [], "src_uid": "430f34fe715b8dcbcadf3b2c3e1e0381"} {"nl": {"description": "The bear has a string s\u2009=\u2009s1s2... s|s| (record |s| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i,\u2009j (1\u2009\u2264\u2009i\u2009\u2264\u2009j\u2009\u2264\u2009|s|), that string x(i,\u2009j)\u2009=\u2009sisi\u2009+\u20091... sj contains at least one string \"bear\" as a substring.String x(i,\u2009j) contains string \"bear\", if there is such index k (i\u2009\u2264\u2009k\u2009\u2264\u2009j\u2009-\u20093), that sk\u2009=\u2009b, sk\u2009+\u20091\u2009=\u2009e, sk\u2009+\u20092\u2009=\u2009a, sk\u2009+\u20093\u2009=\u2009r.Help the bear cope with the given problem.", "input_spec": "The first line contains a non-empty string s (1\u2009\u2264\u2009|s|\u2009\u2264\u20095000). It is guaranteed that the string only consists of lowercase English letters.", "output_spec": "Print a single number \u2014 the answer to the problem.", "sample_inputs": ["bearbtear", "bearaabearc"], "sample_outputs": ["6", "20"], "notes": "NoteIn the first sample, the following pairs (i,\u2009j) match: (1,\u20094),\u2009(1,\u20095),\u2009(1,\u20096),\u2009(1,\u20097),\u2009(1,\u20098),\u2009(1,\u20099).In the second sample, the following pairs (i,\u2009j) match: (1,\u2009\u20094),\u2009(1,\u2009\u20095),\u2009(1,\u2009\u20096),\u2009(1,\u2009\u20097),\u2009(1,\u2009\u20098),\u2009(1,\u2009\u20099),\u2009(1,\u2009\u200910),\u2009(1,\u2009\u200911),\u2009(2,\u2009\u200910),\u2009(2,\u2009\u200911),\u2009(3,\u2009\u200910),\u2009(3,\u2009\u200911),\u2009(4,\u2009\u200910),\u2009(4,\u2009\u200911),\u2009(5,\u2009\u200910),\u2009(5,\u2009\u200911),\u2009(6,\u2009\u200910),\u2009(6,\u2009\u200911),\u2009(7,\u2009\u200910),\u2009(7,\u2009\u200911)."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "240a2b88ded6016d0fd7157d0ee2beea"} {"nl": {"description": "You are given a sorted array $$$a_1, a_2, \\dots, a_n$$$ (for each index $$$i > 1$$$ condition $$$a_i \\ge a_{i-1}$$$ holds) and an integer $$$k$$$.You are asked to divide this array into $$$k$$$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $$$max(i)$$$ be equal to the maximum in the $$$i$$$-th subarray, and $$$min(i)$$$ be equal to the minimum in the $$$i$$$-th subarray. The cost of division is equal to $$$\\sum\\limits_{i=1}^{k} (max(i) - min(i))$$$. For example, if $$$a = [2, 4, 5, 5, 8, 11, 19]$$$ and we divide it into $$$3$$$ subarrays in the following way: $$$[2, 4], [5, 5], [8, 11, 19]$$$, then the cost of division is equal to $$$(4 - 2) + (5 - 5) + (19 - 8) = 13$$$.Calculate the minimum cost you can obtain by dividing the array $$$a$$$ into $$$k$$$ non-empty consecutive subarrays. ", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 3 \\cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$ 1 \\le a_i \\le 10^9$$$, $$$a_i \\ge a_{i-1}$$$). ", "output_spec": "Print the minimum cost you can obtain by dividing the array $$$a$$$ into $$$k$$$ nonempty consecutive subarrays. ", "sample_inputs": ["6 3\n4 8 15 16 23 42", "4 4\n1 3 3 7", "8 1\n1 1 2 3 5 8 13 21"], "sample_outputs": ["12", "0", "20"], "notes": "NoteIn the first test we can divide array $$$a$$$ in the following way: $$$[4, 8, 15, 16], [23], [42]$$$. "}, "positive_code": [{"source_code": " 0; $x--)\n {\n $f = $c[$x] - $c[$x - 1];\n if($e[$f] > 0)\n {\n $e[$f]--;\n $h += $g - $c[$x];\n $g = $c[$x - 1];\n }\n }\n $h += $g - $c[0];\n print $h;\n}\n?>"}, {"source_code": " $v) {\n if (isset($arr[$i + 1])) {\n $diff[] = $arr[$i + 1] - $v;\n }\n}\nsort($diff);\nwhile (--$k) {\n $result -= array_pop($diff);\n}\necho $result;\n"}, {"source_code": " $v) {\n if (isset($arr[$i + 1])) {\n $diff[] = $arr[$i + 1] - $v;\n }\n}\nsort($diff);\necho array_sum(array_slice($diff, 0, $n - $k));\n"}], "negative_code": [{"source_code": ""}, {"source_code": " 0; $x--)\n {\n $f = $c[$x] - $c[$x - 1];\n if($e[$f] > 0)\n {\n $b--;\n $e[$f]--;\n unset($c[$x]);\n if($b == 0)\n {\n break;\n }\n }\n }\n print max($c) - min($c);\n}\n?>"}, {"source_code": " $v) {\n $pairDiff[] = (int)($arr[$i + 1] ?? $v) - (int)$v;\n}\nif ($n ==='44721' && $k ==='44000') {\n rsort($arr);\n die(implode(' ', $arr));\n}\nunset($arr);\n\nwhile ($k--) {\n $result -= $pairDiff[--$n];\n}\necho $result;\n"}, {"source_code": " $v) {\n $diff[] = ($arr[$i + 1] ?? $v) - $v;\n}\nsort($diff);\necho array_sum($n - $k);\n//15502462 1301009\n"}, {"source_code": " $v) {\n $diff[] = ($arr[$i + 1] ?? $v) - $v;\n}\nsort($diff);\necho array_sum(array_slice($diff, 0, $n - $k));\n//15502462 1301009\n"}, {"source_code": " $v) {\n if (isset($arr[$i + 1])) {\n $pairDiff[] = $arr[$i + 1] - $arr[$i];\n }\n}\n$result = $v - $arr[0];\nwhile (--$k && count($pairDiff) > 0) {\n $result -= array_pop($pairDiff);\n}\necho $result;\n"}, {"source_code": " $v) {\n $pairDiff[] = (int)($arr[$i + 1] ?? $v) - (int)$v;\n}\n$result = (int)$v - (int)$arr[0];\nunset($arr);\nwhile ($k--) {\n $result -= $pairDiff[$n - $k - 1];\n}\necho $result;\n"}, {"source_code": " $v) {\n $pairDiff[] = (int)($arr[$i + 1] ?? $v) - (int)$v;\n}\nunset($arr);\nwhile ($k--) {\n $result -= $pairDiff[--$n];\n}\necho $result;\n"}, {"source_code": " $v) {\n $pairDiff[] = ($arr[$i + 1] ?? $arr[$i]) - $arr[$i];\n}\n$result = (int)$v - (int)$arr[0];\nwhile ($k--) {\n $result -= $pairDiff[$n - $k - 1];\n}\necho $result;\n"}, {"source_code": " $v) {\n if (isset($arr[$i + 1])) {\n $pairDiff[] = $arr[$i + 1] - $arr[$i];\n }\n}\nif ($k === '1') {\n die(array_sum($pairDiff));\n}\n$limit = $n - $k;\n$result = 0;\nfor ($i = 0; $i < $limit; $i++) {\n $result += $pairDiff[$i];\n}\necho $result;\n"}, {"source_code": " $v) {\n $diff[] = ($arr[$i + 1] ?? $v) - $v;\n}\necho array_sum(array_slice($diff, 0, $n - $k));\n//15502462 1301009\n"}], "src_uid": "2895624e708159bc2a6f3e91140a6c45"} {"nl": {"description": "Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: on this day the gym is closed and the contest is not carried out; on this day the gym is closed and the contest is carried out; on this day the gym is open and the contest is not carried out; on this day the gym is open and the contest is carried out. On each of days Vasya can either have a rest or write the contest (if it is carried out on this day), or do sport (if the gym is open on this day).Find the minimum number of days on which Vasya will have a rest (it means, he will not do sport and write the contest at the same time). The only limitation that Vasya has \u2014 he does not want to do the same activity on two consecutive days: it means, he will not do sport on two consecutive days, and write the contest on two consecutive days.", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of days of Vasya's vacations. The second line contains the sequence of integers a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u20093) separated by space, where: ai equals 0, if on the i-th day of vacations the gym is closed and the contest is not carried out; ai equals 1, if on the i-th day of vacations the gym is closed, but the contest is carried out; ai equals 2, if on the i-th day of vacations the gym is open and the contest is not carried out; ai equals 3, if on the i-th day of vacations the gym is open and the contest is carried out.", "output_spec": "Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses: to do sport on any two consecutive days, to write the contest on any two consecutive days. ", "sample_inputs": ["4\n1 3 2 0", "7\n1 3 3 2 1 2 3", "2\n2 2"], "sample_outputs": ["2", "0", "1"], "notes": "NoteIn the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.In the third test Vasya can do sport either on a day number 1 or number 2. He can not do sport in two days, because it will be contrary to the his limitation. Thus, he will have a rest for only one day."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "08f1ba79ced688958695a7cfcfdda035"} {"nl": {"description": "There is a pyramid which consists of $$$n$$$ floors. The floors are numbered from top to bottom in increasing order. In the pyramid, the $$$i$$$-th floor consists of $$$i$$$ rooms.Denote the $$$j$$$-th room on the $$$i$$$-th floor as $$$(i,j)$$$. For all positive integers $$$i$$$ and $$$j$$$ such that $$$1 \\le j \\le i < n$$$, there are $$$2$$$ one-way staircases which lead from $$$(i,j)$$$ to $$$(i+1,j)$$$ and from $$$(i,j)$$$ to $$$(i+1,j+1)$$$ respectively.In each room you can either put a torch or leave it empty. Define the brightness of a room $$$(i, j)$$$ to be the number of rooms with a torch from which you can reach the room $$$(i, j)$$$ through a non-negative number of staircases.For example, when $$$n=5$$$ and torches are placed in the rooms $$$(1,1)$$$, $$$(2,1)$$$, $$$(3,2)$$$, $$$(4,1)$$$, $$$(4,3)$$$, and $$$(5,3)$$$, the pyramid can be illustrated as follows: In the above picture, rooms with torches are colored in yellow, and empty rooms are white. The blue numbers in the bottom-right corner indicate the brightness of the rooms.The room $$$(4,2)$$$ (the room with a star) has brightness $$$3$$$. In the picture below, the rooms from where you can reach $$$(4,2)$$$ have red border. The brightness is $$$3$$$ since there are three torches among these rooms. The pyramid is called nice if and only if for all floors, all rooms in the floor have the same brightness.Define the brilliance of a nice pyramid to be the sum of brightness over the rooms $$$(1,1)$$$, $$$(2,1)$$$, $$$(3,1)$$$, ..., $$$(n,1)$$$.Find an arrangement of torches in the pyramid, such that the resulting pyramid is nice and its brilliance is maximized.We can show that an answer always exists. If there are multiple answers, output any one of them.", "input_spec": "The first line of the input contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The only line of each test case contains a single positive integer $$$n$$$ ($$$1 \\le n \\le 500$$$)\u00a0\u2014 the number of floors in the pyramid. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$500$$$.", "output_spec": "For each test case, output $$$n$$$ lines, the arrangement of torches in the pyramid. The $$$i$$$-th line should contain $$$i$$$ integers, each separated with a space. The $$$j$$$-th integer on the $$$i$$$-th line should be $$$1$$$ if room $$$(i,j)$$$ has a torch, and $$$0$$$ otherwise. We can show that an answer always exists. If there are multiple answers, output any one of them.", "sample_inputs": ["3\n\n1\n\n2\n\n3"], "sample_outputs": ["1 \n1 \n1 1 \n1 \n1 1 \n1 0 1"], "notes": "NoteIn the third test case, torches are placed in $$$(1,1)$$$, $$$(2,1)$$$, $$$(2,2)$$$, $$$(3,1)$$$, and $$$(3,3)$$$. The pyramid is nice as rooms on each floor have the same brightness. For example, all rooms on the third floor have brightness $$$3$$$.The brilliance of the pyramid is $$$1+2+3 = 6$$$. It can be shown that no arrangements with $$$n=3$$$ will have a greater brilliance."}, "positive_code": [{"source_code": " 1) {\r\n for($j=1; $j < $i; $j++) {\r\n $temp .= '0 '; \r\n }\r\n }\r\n if($i > 0) {\r\n $temp .= '1'; \r\n }\r\n \r\n IO::pr($temp); \r\n }\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 1) {\r\n for($j=1; $j < $i-1; $j++) {\r\n $temp .= '0 '; \r\n }\r\n }\r\n if($i > 0) {\r\n $temp .= '1'; \r\n }\r\n \r\n IO::pr($temp); \r\n }\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 1) {\r\n for($j=1; $j < $n-1; $j++) {\r\n $temp .= '0 '; \r\n }\r\n }\r\n if($i > 0) {\r\n $temp .= '1'; \r\n }\r\n \r\n IO::pr($temp); \r\n }\r\n}\r\n \r\n \r\nclass IO {\r\n public static function get()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "src_uid": "4a473e34f2be18a19c306d80d4693199"} {"nl": {"description": "Vasya has got three integers $$$n$$$, $$$m$$$ and $$$k$$$. He'd like to find three integer points $$$(x_1, y_1)$$$, $$$(x_2, y_2)$$$, $$$(x_3, y_3)$$$, such that $$$0 \\le x_1, x_2, x_3 \\le n$$$, $$$0 \\le y_1, y_2, y_3 \\le m$$$ and the area of the triangle formed by these points is equal to $$$\\frac{nm}{k}$$$.Help Vasya! Find such points (if it's possible). If there are multiple solutions, print any of them.", "input_spec": "The single line contains three integers $$$n$$$, $$$m$$$, $$$k$$$ ($$$1\\le n, m \\le 10^9$$$, $$$2 \\le k \\le 10^9$$$).", "output_spec": "If there are no such points, print \"NO\". Otherwise print \"YES\" in the first line. The next three lines should contain integers $$$x_i, y_i$$$ \u2014 coordinates of the points, one point per line. If there are multiple solutions, print any of them. You can print each letter in any case (upper or lower).", "sample_inputs": ["4 3 3", "4 4 7"], "sample_outputs": ["YES\n1 0\n2 3\n4 1", "NO"], "notes": "NoteIn the first example area of the triangle should be equal to $$$\\frac{nm}{k} = 4$$$. The triangle mentioned in the output is pictured below: In the second example there is no triangle with area $$$\\frac{nm}{k} = \\frac{16}{7}$$$."}, "positive_code": [{"source_code": " $div) {\n $found = array_search($div, $arrN);\n if ($found !== false) {\n if (DEBUG) echo \"unset N\\n\";\n unset($arrN[$found]);\n } else {\n $found = array_search($div, $arrM);\n if ($found !== false) {\n if (DEBUG) echo \"unset M\\n\";\n unset($arrM[$found]);\n } else {\n $flgNO = true;\n }\n }\n}\n$nn = 1;\n$mm = 1;\nforeach ($arrN as $v) {\n $nn *= $v;\n}\nforeach ($arrM as $v) {\n $mm *= $v;\n}\nif ($flgNO === true) {\n} elseif ($nn <= $n && $mm <= $m) {\n echo \"YES\\n\";\n echo \"0 0\\n\";\n echo \"0 {$mm}\\n\";\n echo \"{$nn} 0\\n\";\n exit;\n} else {\n if (DEBUG) echo \"AREA OUT\\n\";\n if (DEBUG) echo \"NO\\n\";\n}\nif (DEBUG) {\n var_dump($arrN);\n var_dump($arrM);\n // exit;\n var_dump($arrN);\n var_dump($arrM);\n var_dump($arrK);\n echo \"-------------------\\n\";\n}\n\n$arrN = bunkai($n);\n$arrM = bunkai($m * 2);\n$arrK = bunkai($k);\n\nif (DEBUG) {\n var_dump($arrN);\n var_dump($arrM);\n var_dump($arrK);\n // exit;\n}\n\n$flgNO = false;\nforeach ($arrK as $kkk => $div) {\n $found = array_search($div, $arrM);\n if ($found !== false) {\n if (DEBUG) echo \"unset M\\n\";\n unset($arrM[$found]);\n } else {\n $found = array_search($div, $arrN);\n if ($found !== false) {\n if (DEBUG) echo \"unset N\\n\";\n unset($arrN[$found]);\n } else {\n $flgNO = true;\n }\n }\n}\nif (DEBUG) {\n var_dump($arrN);\n var_dump($arrM);\n var_dump($arrK);\n // exit;\n}\n\n$nn = 1;\n$mm = 1;\nforeach ($arrN as $v) {\n $nn *= $v;\n}\nforeach ($arrM as $v) {\n $mm *= $v;\n}\nif ($flgNO === true) {\n echo \"NO\\n\";\n} elseif ($nn <= $n && $mm <= $m) {\n echo \"YES\\n\";\n echo \"0 0\\n\";\n echo \"0 {$mm}\\n\";\n echo \"{$nn} 0\\n\";\n} else {\n if (DEBUG) echo \"AREA OUT\\n\";\n echo \"NO\\n\";\n}\n\nfunction bunkai($num) {\n $ret = array();\n $div = 2;\n while(true) {\n if ($num % $div === 0) {\n $ret[] = $div;\n $num /= $div;\n $div = 2;\n } else {\n $div++;\n }\n if ($div > sqrt($num)) {\n if ($num >= 2) {\n $ret[] = $num;\n }\n return $ret;\n }\n }\n}\n"}], "negative_code": [{"source_code": " $div) {\n $found = array_search($div, $arrN);\n if ($found !== false) {\n // echo \"unset N\\n\";\n unset($arrN[$found]);\n } else {\n $found = array_search($div, $arrM);\n if ($found !== false) {\n // echo \"unset M\\n\";\n unset($arrM[$found]);\n } else {\n $flgNO = true;\n }\n }\n}\n$nn = 1;\n$mm = 1;\nforeach ($arrN as $v) {\n $nn *= $v;\n}\nforeach ($arrM as $v) {\n $mm *= $v;\n}\nif ($flgNO === true) {\n} elseif ($nn <= $n && $mm <= $m) {\n echo \"YES\\n\";\n echo \"0 0\\n\";\n echo \"0 {$mm}\\n\";\n echo \"{$nn} 0\\n\";\n exit;\n} else {\n // echo \"NO\\n\";\n}\n// var_dump($arrN);\n// var_dump($arrM);\n// exit;\n// var_dump($arrN);\n// var_dump($arrM);\n// var_dump($arrK);\n// echo \"-------------------\\n\";\n\n$arrN = bunkai($n);\n$arrM = bunkai($m * 2);\n$arrK = bunkai($k);\n\n// var_dump($arrN);\n// var_dump($arrM);\n// var_dump($arrK);\n// exit;\n\n$flgNO = false;\nforeach ($arrK as $kkk => $div) {\n $found = array_search($div, $arrM);\n if ($found !== false) {\n // echo \"unset M\\n\";\n unset($arrM[$found]);\n } else {\n $found = array_search($div, $arrN);\n if ($found !== false) {\n // echo \"unset N\\n\";\n unset($arrN[$found]);\n } else {\n $flgNO = true;\n }\n }\n}\n// var_dump($arrN);\n// var_dump($arrM);\n// var_dump($arrK);\n// exit;\n$nn = 1;\n$mm = 1;\nforeach ($arrN as $v) {\n $nn *= $v;\n}\nforeach ($arrM as $v) {\n $mm *= $v;\n}\nif ($flgNO === true) {\n echo \"NO\\n\";\n} elseif ($nn <= $n && $mm <= $m) {\n echo \"YES\\n\";\n echo \"0 0\\n\";\n echo \"0 {$mm}\\n\";\n echo \"{$nn} 0\\n\";\n} else {\n echo \"NO\\n\";\n}\n\nfunction bunkai($num) {\n $ret = array();\n $div = 2;\n while(true) {\n if ($num % $div === 0) {\n $ret[] = $div;\n $num /= $div;\n $div = 2;\n } else {\n $div++;\n }\n if ($div > sqrt($num)) {\n $ret[] = $num;\n return $ret;\n }\n }\n}\n"}], "src_uid": "5c026adda2ae3d7b707d5054bd84db3f"} {"nl": {"description": "You are given a string $$$a$$$, consisting of $$$n$$$ characters, $$$n$$$ is even. For each $$$i$$$ from $$$1$$$ to $$$n$$$ $$$a_i$$$ is one of 'A', 'B' or 'C'.A bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For example, bracket sequences \"()()\" and \"(())\" are regular (the resulting expressions are: \"(1)+(1)\" and \"((1+1)+1)\"), and \")(\", \"(\" and \")\" are not.You want to find a string $$$b$$$ that consists of $$$n$$$ characters such that: $$$b$$$ is a regular bracket sequence; if for some $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) $$$a_i=a_j$$$, then $$$b_i=b_j$$$. In other words, you want to replace all occurrences of 'A' with the same type of bracket, then all occurrences of 'B' with the same type of bracket and all occurrences of 'C' with the same type of bracket.Your task is to determine if such a string $$$b$$$ exists.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The only line of each testcase contains a string $$$a$$$. $$$a$$$ consists only of uppercase letters 'A', 'B' and 'C'. Let $$$n$$$ be the length of $$$a$$$. It is guaranteed that $$$n$$$ is even and $$$2 \\le n \\le 50$$$.", "output_spec": "For each testcase print \"YES\" if there exists such a string $$$b$$$ that: $$$b$$$ is a regular bracket sequence; if for some $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) $$$a_i=a_j$$$, then $$$b_i=b_j$$$. Otherwise, print \"NO\". You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).", "sample_inputs": ["4\nAABBAC\nCACA\nBBBBAC\nABCA"], "sample_outputs": ["YES\nYES\nNO\nNO"], "notes": "NoteIn the first testcase one of the possible strings $$$b$$$ is \"(())()\".In the second testcase one of the possible strings $$$b$$$ is \"()()\"."}, "positive_code": [{"source_code": " 0,\r\n ')' => 0\r\n ];\r\n $bStatus = true;\r\n for ($i = 0; $i < $count; $i++) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b['('] += 1;\r\n }\r\n if ($b['('] < $b[')']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n $counter = 0;\r\n if ($b['('] == $b[')']) {\r\n $counter += 1;\r\n }\r\n if ($bStatus) {\r\n $b = [\r\n '(' => 0,\r\n ')' => 0\r\n ];\r\n for ($i = $count-1; $i >= 0; $i--) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b[')'] += 1;\r\n }\r\n if ($b[')'] < $b['(']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n if ($b['('] == $b[')']) {\r\n $counter += 1;\r\n }\r\n }\r\n\r\n\r\n echo $a[0] != $a[$count-1] && $count % 2 == 0 && $bStatus && $counter != 0? 'YES' : 'NO';\r\n\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\n"}, {"source_code": " '', $y => '']);\r\n $len = strlen($s);\r\n $d = [$x => 1, $y => -1];\r\n $d[$z] = substr_count($s, $x) * 2 == $len ? -1 : 1;\r\n $sum = 0;\r\n $flg = true;\r\n for ($j = 0; $j < $len && $flg; ++$j) {\r\n $sum += $d[$s[$j]];\r\n $sum < 0 && $flg = false;\r\n }\r\n 0 != $sum && $flg = false;\r\n echo ($flg ? 'YES' : 'NO').PHP_EOL;\r\n }\r\n}\r\n"}, {"source_code": ""}, {"source_code": " '(', 'B' => '(', 'C' => ')'];\r\n $map[] = [$s[0] => '(', 'C' => '(', 'B' => ')'];\r\n $map[] = [$s[0] => '(', 'B' => ')', 'C' => ')'];\r\n } elseif ('B' == $s[0]) {\r\n $map[] = [$s[0] => '(', 'A' => '(', 'C' => ')'];\r\n $map[] = [$s[0] => '(', 'C' => '(', 'A' => ')'];\r\n $map[] = [$s[0] => '(', 'A' => ')', 'C' => ')'];\r\n } elseif ('C' == $s[0]) {\r\n $map[] = [$s[0] => '(', 'B' => '(', 'A' => ')'];\r\n $map[] = [$s[0] => '(', 'A' => '(', 'B' => ')'];\r\n $map[] = [$s[0] => '(', 'B' => ')', 'A' => ')'];\r\n }\r\n for ($i = 0; $i < 3; $i++) {\r\n $s2 = strtr($s, $map[$i]);\r\n $m = 0;\r\n for ($j = 0, $l = strlen($s2); $j < $l; $j++) {\r\n $m += ['(' => 1, ')' => -1][$s2[$j]];\r\n if ($m < 0) break;\r\n }\r\n if (empty($m)) break;\r\n }\r\n echo [true => 'YES', false => 'NO'][$m == 0], \"\\n\";\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $a = str_split(IO::str());\r\n $c = [];\r\n $c[$a[0]] = 1;\r\n $c[$a[count($a) - 1]] = -1;\r\n $res1 = $res2 = [\r\n 'open' => 0, 'close' => 0\r\n ];\r\n $bool = true;\r\n $bool2 = true;\r\n $res = $res0 = 0;\r\n foreach ($a as $k => $b) {\r\n if(isset($c[$b])) {\r\n $res0 += $c[$b];\r\n if ($c[$b] == 1) {\r\n $res1['open'] += 1;\r\n } else {\r\n $res1['close'] += 1;\r\n }\r\n } else {\r\n $res0 -= 1;\r\n $res1['close'] += 1;\r\n }\r\n if ($res0 < 0) {\r\n $bool = false;\r\n }\r\n }\r\n foreach ($a as $k => $b) {\r\n if(isset($c[$b])) {\r\n $res += $c[$b];\r\n if ($c[$b] == 1) {\r\n $res2['open'] += 1;\r\n } else {\r\n $res2['close'] += 1;\r\n }\r\n } else {\r\n $res += 1;\r\n $res2['open'] += 1;\r\n }\r\n if ($res < 0) {\r\n $bool2 = false;\r\n }\r\n }\r\n\r\n if (($bool && $res1['close'] == $res1['open']) || ($bool2 && $res2['close'] == $res2['open'])) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n}"}], "negative_code": [{"source_code": " $U,\r\n 'R' => $R,\r\n 'D' => $D,\r\n 'L' => $L\r\n ];\r\n if ($U >= $n) {\r\n $R -= 1;\r\n $L -= 1;\r\n }\r\n if ($D >= $n) {\r\n $R -= 1;\r\n $L -= 1;\r\n }\r\n if ($R >= $n) {\r\n $U -= 1;\r\n $D -= 1;\r\n }\r\n if ($L >= $n) {\r\n $U -= 1;\r\n $D -= 1;\r\n }\r\n\r\n\r\n echo max($a) <= $n && $U >= 0 && $R >= 0 && $D >= 0 && $L >= 0 ? 'YES' : 'NO';\r\n\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n 0,\r\n ')' => 0\r\n ];\r\n $bStatus = true;\r\n for ($i = 0; $i < $count; $i++) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b['('] += 1;\r\n }\r\n if ($b['('] < $b[')']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n if ($b['('] != $b[')']) {\r\n $bStatus = false;\r\n }\r\n if ($bStatus) {\r\n $b = [\r\n '(' => 0,\r\n ')' => 0\r\n ];\r\n for ($i = $count-1; $i >= 0; $i--) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b[')'] += 1;\r\n }\r\n if ($b[')'] < $b['(']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n if ($b['('] != $b[')']) {\r\n $bStatus = false;\r\n }\r\n }\r\n\r\n\r\n echo $a[0] != $a[$count-1] && $count % 2 == 0 && $bStatus ? 'YES' : 'NO';\r\n\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n 0,\r\n ')' => 0\r\n ];\r\n $bStatus = true;\r\n for ($i = 0; $i < $count; $i++) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b['('] += 1;\r\n }\r\n if ($b['('] < $b[')']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n if ($bStatus) {\r\n $b = [\r\n '(' => 0,\r\n ')' => 0\r\n ];\r\n for ($i = $count-1; $i >= 0; $i--) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b[')'] += 1;\r\n }\r\n if ($b[')'] < $b['(']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n\r\n echo $a[0] != $a[$count-1] && $count % 2 == 0 && $bStatus ? 'YES' : 'NO';\r\n\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n 0,\r\n ')' => 0\r\n ];\r\n $bStatus = true;\r\n for ($i = 0; $i < $count; $i++) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b['('] += 1;\r\n }\r\n if ($b['('] < $b[')']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n if ($bStatus) {\r\n $b = [\r\n '(' => 0,\r\n ')' => 0\r\n ];\r\n for ($i = $count-1; $i >= 0; $i--) {\r\n if ($a[0] == $a[$i]) {\r\n $b['('] += 1;\r\n } elseif ($a[$count-1] == $a[$i]) {\r\n $b[')'] += 1;\r\n } else {\r\n $b[')'] += 1;\r\n }\r\n if ($b[')'] < $b['(']) {\r\n $bStatus = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n\r\n echo $a[0] != $a[$count-1] && $bStatus ? 'YES' : 'NO';\r\n\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2)\r\n {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '')\r\n {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": ""}], "src_uid": "4d24aaf5ebf70265b027a6af86e09250"} {"nl": {"description": "Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. A player is given a non-negative integer number of points in each round of the Plane of Tanks. Vasya wrote results for each round of the last year. He has n records in total.In order to determine a player's category consider the best result obtained by the player and the best results of other players. The player belongs to category: \"noob\" \u2014 if more than 50% of players have better results; \"random\" \u2014 if his result is not worse than the result that 50% of players have, but more than 20% of players have better results; \"average\" \u2014 if his result is not worse than the result that 80% of players have, but more than 10% of players have better results; \"hardcore\" \u2014 if his result is not worse than the result that 90% of players have, but more than 1% of players have better results; \"pro\" \u2014 if his result is not worse than the result that 99% of players have. When the percentage is calculated the player himself is taken into account. That means that if two players played the game and the first one gained 100 points and the second one 1000 points, then the first player's result is not worse than the result that 50% of players have, and the second one is not worse than the result that 100% of players have.Vasya gave you the last year Plane of Tanks results. Help Vasya determine each player's category.", "input_spec": "The first line contains the only integer number n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 a number of records with the players' results. Each of the next n lines contains a player's name and the amount of points, obtained by the player for the round, separated with a space. The name contains not less than 1 and no more than 10 characters. The name consists of lowercase Latin letters only. It is guaranteed that any two different players have different names. The amount of points, obtained by the player for the round, is a non-negative integer number and does not exceed 1000.", "output_spec": "Print on the first line the number m \u2014 the number of players, who participated in one round at least. Each one of the next m lines should contain a player name and a category he belongs to, separated with space. Category can be one of the following: \"noob\", \"random\", \"average\", \"hardcore\" or \"pro\" (without quotes). The name of each player should be printed only once. Player names with respective categories can be printed in an arbitrary order.", "sample_inputs": ["5\nvasya 100\nvasya 200\nartem 100\nkolya 200\nigor 250", "3\nvasya 200\nkolya 1000\nvasya 1000"], "sample_outputs": ["4\nartem noob\nigor pro\nkolya random\nvasya random", "2\nkolya pro\nvasya pro"], "notes": "NoteIn the first example the best result, obtained by artem is not worse than the result that 25% of players have (his own result), so he belongs to category \"noob\". vasya and kolya have best results not worse than the results that 75% players have (both of them and artem), so they belong to category \"random\". igor has best result not worse than the result that 100% of players have (all other players and himself), so he belongs to category \"pro\".In the second example both players have the same amount of points, so they have results not worse than 100% players have, so they belong to category \"pro\"."}, "positive_code": [{"source_code": " $b[$h])\n {\n $k++;\n }\n }\n $g[$f[$x]] = array($i / count($b) * 100, $j / count($b) * 100, $k / count($b) * 100);\n}\nfor($x = 0; $x < count($b); $x++)\n{\n $l = $g[$f[$x]];\n if($l[2] > 50)\n {\n print $f[$x] . \" noob\\n\"; \n }\n elseif($l[2] <= 1)\n {\n print $f[$x] . \" pro\\n\";\n }\n elseif(($l[2] > 1) && ($l[2] <= 10))\n {\n print $f[$x] . \" hardcore\\n\";\n }\n elseif(($l[2] > 10) && ($l[2] <= 20))\n {\n print $f[$x] . \" average\\n\";\n }\n elseif(($l[2] > 20) && ($l[2] <= 50))\n {\n print $f[$x] . \" random\\n\";\n }\n}\n?>"}], "negative_code": [{"source_code": "= 99)\n {\n $m = $f[$x] . \" pro\";\n array_push($l, $m);\n }\n elseif(($j >= 90) && ($k > 1))\n {\n $m = $f[$x] . \" hardcore\";\n array_push($l, $m);\n }\n elseif(($j >= 80) && ($k > 10))\n {\n $m = $f[$x] . \" average\";\n array_push($l, $m);\n }\n elseif(($j >= 50) && ($k > 20))\n {\n $m = $f[$x] . \" random\";\n array_push($l, $m);\n }\n elseif($k > 50)\n {\n $m = $f[$x] . \" noob\";\n array_push($l, $m);\n }\n else\n {\n $m = $f[$x] . \" \" . $j . \" \" . $k;\n array_push($n, $m);\n }\n break;\n }\n }\n}\nif(count($n) != 0)\n{\n print_r($n);\n}\nfor($x = 0; $x < count($l) - 1; $x++)\n{\n print $l[$x] . \"\\n\";\n}\nprint $l[$x];\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * count($f) - $y;\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n $m = $f[$x] . \" pro\";\n array_push($l, $m);\n }\n elseif(($j >= 90) && ($k > 1))\n {\n $m = $f[$x] . \" hardcore\";\n array_push($l, $m);\n }\n elseif(($j >= 80) && ($k > 10))\n {\n $m = $f[$x] . \" average\";\n array_push($l, $m);\n }\n elseif(($j >= 50) && ($k > 20))\n {\n $m = $f[$x] . \" random\";\n array_push($l, $m);\n }\n elseif($k > 50)\n {\n $m = $f[$x] . \" noob\";\n array_push($l, $m);\n }\n break;\n }\n }\n}\nfor($x = 0; $x < count($l) - 1; $x++)\n{\n print $l[$x] . \"\\n\";\n}\nprint $l[$x];\n?>"}, {"source_code": "= 99)\n {\n $m = $f[$x] . \" pro\";\n array_push($l, $m);\n }\n elseif(($j >= 90) && ($k > 1))\n {\n $m = $f[$x] . \" hardcore\";\n array_push($l, $m);\n }\n elseif(($j >= 80) && ($k > 10))\n {\n $m = $f[$x] . \" average\";\n array_push($l, $m);\n }\n elseif(($j >= 50) && ($k > 20))\n {\n $m = $f[$x] . \" random\";\n array_push($l, $m);\n }\n elseif($k > 50)\n {\n $m = $f[$x] . \" noob\";\n array_push($l, $m);\n }\n break;\n }\n }\n}\nfor($x = 0; $x < count($l) - 1; $x++)\n{\n print $l[$x] . \"\\n\";\n}\nprint $l[$x];\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\\n\";\n }\n elseif(($j >= 90) && ($k >= 1))\n {\n print $f[$x] . \" \" . \"hardcore\\n\";\n }\n elseif(($j >= 80) && ($k >= 10))\n {\n print $f[$x] . \" \" . \"average\\n\";\n }\n elseif(($j >= 50) && ($k >= 20))\n {\n print $f[$x] . \" \" . \"random\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\\n\";\n }\n else\n {\n print \"XXX\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\\n\";\n }\n elseif(($j >= 90) && ($k >= 1))\n {\n print $f[$x] . \" \" . \"hardcore\\n\";\n }\n elseif(($j >= 80) && ($k >= 10))\n {\n print $f[$x] . \" \" . \"average\\n\";\n }\n elseif(($j >= 50) && ($k >= 20))\n {\n print $f[$x] . \" \" . \"random\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\" . \"\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\" . \"\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\" . \"\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\" . \"\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\" . \"\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n }\n}\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\" . \"\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\" . \"\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\" . \"\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\" . \"\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\" . \"\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n $m = $f[$x] . \" pro\";\n array_push($l, $m);\n }\n elseif(($j >= 90) && ($k > 1))\n {\n $m = $f[$x] . \" hardcore\";\n array_push($l, $m);\n }\n elseif(($j >= 80) && ($k > 10))\n {\n $m = $f[$x] . \" average\";\n array_push($l, $m);\n }\n elseif(($j >= 50) && ($k > 20))\n {\n $m = $f[$x] . \" random\";\n array_push($l, $m);\n }\n elseif($k > 50)\n {\n $m = $f[$x] . \" noob\";\n array_push($l, $m);\n }\n else\n {\n $m = $f[$x] . \" noob\";\n array_push($n, $m);\n }\n break;\n }\n }\n}\nif(count($n) != 0)\n{\n print_r($n);\n}\nfor($x = 0; $x < count($l) - 1; $x++)\n{\n print $l[$x] . \"\\n\";\n}\nprint $l[$x];\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = round($i * $y);\n $k = round($i * (count($f) - $y));\n if($j >= 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": " 99)\n {\n print $f[$x] . \" \" . \"pro\" . \"\\n\";\n }\n elseif(($j > 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\" . \"\\n\";\n }\n elseif(($j > 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\" . \"\\n\";\n }\n elseif(($j > 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\" . \"\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\" . \"\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j > 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j > 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j > 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j > 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}, {"source_code": "= 99)\n {\n print $f[$x] . \" \" . \"pro\" . \"\\n\";\n }\n elseif(($j >= 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\" . \"\\n\";\n }\n elseif(($j >= 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\" . \"\\n\";\n }\n elseif(($j >= 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\" . \"\\n\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\" . \"\\n\";\n }\n break;\n }\n }\n}\nfor($y = 1; $y <= count($f); $y++)\n{\n if(($d[$x] < $d[$y]) || ($y == (count($f))))\n {\n if($d[$x] < $d[$y])\n {\n $y--;\n }\n $i = 100 / count($f);\n $j = $i * $y;\n $k = $i * (count($f) - $y);\n if($j > 99)\n {\n print $f[$x] . \" \" . \"pro\";\n }\n elseif(($j > 90) && ($k > 1))\n {\n print $f[$x] . \" \" . \"hardcore\";\n }\n elseif(($j > 80) && ($k > 10))\n {\n print $f[$x] . \" \" . \"average\";\n }\n elseif(($j > 50) && ($k > 20))\n {\n print $f[$x] . \" \" . \"random\";\n }\n elseif($k > 50)\n {\n print $f[$x] . \" \" . \"noob\";\n }\n break;\n }\n}\n?>"}], "src_uid": "0430fa56ec7f97efaf9d37096f72bcf8"} {"nl": {"description": "Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.You have to find the minimum number of digits in which these two numbers can differ.", "input_spec": "The first line contains integer k (1\u2009\u2264\u2009k\u2009\u2264\u2009109). The second line contains integer n (1\u2009\u2264\u2009n\u2009<\u200910100000). There are no leading zeros in n. It's guaranteed that this situation is possible.", "output_spec": "Print the minimum number of digits in which the initial number and n can differ.", "sample_inputs": ["3\n11", "3\n99"], "sample_outputs": ["1", "0"], "notes": "NoteIn the first example, the initial number could be 12.In the second example the sum of the digits of n is not less than k. The initial number could be equal to n."}, "positive_code": [{"source_code": " 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $c += $b[$x];\n $d[$b[$x]]++;\n}\nif($c >= $a)\n{\n print \"0\";\n}\nelse\n{\n $e = 0;\n $f = $a - $c;\n $g = 9;\n for($x = 0; $x <= 8; $x++)\n {\n $h = $d[$x];\n $i = $h * $g;\n if($f > $i)\n {\n $e += $d[$x];\n $f -= $i;\n $g--;\n }\n elseif($f == $i)\n {\n $e += $d[$x];\n $f -= $i;\n break;\n }\n elseif($f < $i)\n {\n $e += $d[$x];\n $j = $i - $f;\n $k = floor($j / $g);\n $e -= $k;\n break;\n }\n }\n print $e;\n}\n?>"}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\nfunction readNumArray($f) {\n\treturn readStringExplodeNum($f, ' ', true);\n}\n\nfunction readArray($f) {\n\treturn readStringExplodeNum($f, ' ');\n}\n\nfunction readTrimString($f) {\n\treturn trim(readString($f));\n}\n\n###### /IO ######\n# for($i=0;$i<$n;$i++)\n\nfunction getDiffCount($base, $l) {\n\t$return = 0;\n\tforeach ($base as $i => $v) {\n\t\tif ($base[$i] != $l[$i]) {\n\t\t\t$return++;\n\t\t}\n\t}\n\treturn $return;\n}\n\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test === false) {\n\t\t$f = STDIN;\n\t}\n\t/* begin body */\n\t$k = readNum($f);\n\t$n = readString($f);\n\t$items = str_split($n);\n\t$len = count($items);\n\tsort($items);\n\t$nSum = array_sum($items);\n\t$pos = 0;\n\t$steps = 0;\n\twhile ($nSum < $k && $pos < $len) {\n\t\t$need = $k - $nSum;\n\t\t$canInc = min(9 - $items[$pos], $need);\n\n\t\t$items[$pos] += $canInc;\n\t\t$nSum += $canInc;\n\t\t$steps++;\n\t\t$pos++;\n\t}\n\techo $steps;\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}], "negative_code": [], "src_uid": "d7e6e5042b8860bb2470d5a493b0adf6"} {"nl": {"description": "Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the heading \u2014 he just leaves some blank space to mark them. Help him; find out if he will manage to compose the needed text.", "input_spec": "The first line contains a newspaper heading s1. The second line contains the letter text s2. s1 \u0438 s2 are non-empty lines consisting of spaces, uppercase and lowercase Latin letters, whose lengths do not exceed 200 symbols. The uppercase and lowercase letters should be differentiated. Vasya does not cut spaces out of the heading.", "output_spec": "If Vasya can write the given anonymous letter, print YES, otherwise print NO", "sample_inputs": ["Instead of dogging Your footsteps it disappears but you dont notice anything\nwhere is your dog", "Instead of dogging Your footsteps it disappears but you dont notice anything\nYour dog is upstears", "Instead of dogging your footsteps it disappears but you dont notice anything\nYour dog is upstears", "abcdefg hijk\nk j i h g f e d c b a"], "sample_outputs": ["NO", "YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $alph_in_header[$val]) {\n echo \"NO\";\n die();\n }\n }\n \n echo \"YES\";\n?>"}, {"source_code": "\n$str=str_replace(' ','',trim(fgets(STDIN)));\n$text=str_replace(' ','',trim(fgets(STDIN)));\n$no=0;\n$yes=0;\nfor($i=0;$i"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $alph_in_header[$val]) {\n echo \"NO\";\n die();\n }\n }\n \n echo \"YES\";\n?>"}], "src_uid": "b1ef19d7027dc82d76859d64a6f43439"} {"nl": {"description": "Petya organized a strange birthday party. He invited $$$n$$$ friends and assigned an integer $$$k_i$$$ to the $$$i$$$-th of them. Now Petya would like to give a present to each of them. In the nearby shop there are $$$m$$$ unique presents available, the $$$j$$$-th present costs $$$c_j$$$ dollars ($$$1 \\le c_1 \\le c_2 \\le \\ldots \\le c_m$$$). It's not allowed to buy a single present more than once.For the $$$i$$$-th friend Petya can either buy them a present $$$j \\le k_i$$$, which costs $$$c_j$$$ dollars, or just give them $$$c_{k_i}$$$ dollars directly.Help Petya determine the minimum total cost of hosting his party.", "input_spec": "The first input line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^3$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n, m \\leq 3 \\cdot 10^5$$$)\u00a0\u2014 the number of friends, and the number of unique presents available. The following line contains $$$n$$$ integers $$$k_1, k_2, \\ldots, k_n$$$ ($$$1 \\leq k_i \\leq m$$$), assigned by Petya to his friends. The next line contains $$$m$$$ integers $$$c_1, c_2, \\ldots, c_m$$$ ($$$1 \\le c_1 \\le c_2 \\le \\ldots \\le c_m \\le 10^9$$$)\u00a0\u2014 the prices of the presents. It is guaranteed that sum of values $$$n$$$ over all test cases does not exceed $$$3 \\cdot 10^5$$$, and the sum of values $$$m$$$ over all test cases does not exceed $$$3 \\cdot 10^5$$$.", "output_spec": "For each test case output a single integer\u00a0\u2014 the minimum cost of the party.", "sample_inputs": ["2\n5 4\n2 3 4 3 2\n3 5 12 20\n5 5\n5 4 3 2 1\n10 40 90 160 250", "1\n1 1\n1\n1"], "sample_outputs": ["30\n190", "1"], "notes": "NoteIn the first example, there are two test cases. In the first one, Petya has $$$5$$$ friends and $$$4$$$ available presents. Petya can spend only $$$30$$$ dollars if he gives $$$5$$$ dollars to the first friend. A present that costs $$$12$$$ dollars to the second friend. A present that costs $$$5$$$ dollars to the third friend. A present that costs $$$3$$$ dollars to the fourth friend. $$$5$$$ dollars to the fifth friend. In the second one, Petya has $$$5$$$ and $$$5$$$ available presents. Petya can spend only $$$190$$$ dollars if he gives A present that costs $$$10$$$ dollars to the first friend. A present that costs $$$40$$$ dollars to the second friend. $$$90$$$ dollars to the third friend. $$$40$$$ dollars to the fourth friend. $$$10$$$ dollars to the fifth friend. "}, "positive_code": [{"source_code": "= $i + 1 && $k[$i] = $i + 1;\r\n $sm += $c[$k[$i] - 1];\r\n }\r\n echo nf($sm) . PHP_EOL;\r\n}\r\n\r\n\r\nfunction nf($n)\r\n{\r\n return number_format($n, 0, '', '');\r\n}\r\n"}], "negative_code": [{"source_code": "= $i + 1 && $k[$i] = $i + 1;\r\n $sm += $c[$k[$i] - 1];\r\n }\r\n echo nf($sum) . PHP_EOL;\r\n}\r\n\r\n\r\nfunction nf($n)\r\n{\r\n return number_format($n, 0, '', '');\r\n}\r\n"}, {"source_code": "= $i + 1 && $k[$i] = $i + 1;\r\n $sm += $c[$k[$i] - 1];\r\n }\r\n echo $sm . PHP_EOL;\r\n}\r\n"}], "src_uid": "55962ef2cf88c87873b996dc54cc1bf1"} {"nl": {"description": "This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.Paul and Mary have a favorite string $$$s$$$ which consists of lowercase letters of the Latin alphabet. They want to paint it using pieces of chalk of two colors: red and green. Let's call a coloring of a string wonderful if the following conditions are met: each letter of the string is either painted in exactly one color (red or green) or isn't painted; each two letters which are painted in the same color are different; the number of letters painted in red is equal to the number of letters painted in green; the number of painted letters of this coloring is maximum among all colorings of the string which meet the first three conditions. E.\u2009g. consider a string $$$s$$$ equal to \"kzaaa\". One of the wonderful colorings of the string is shown in the figure. The example of a wonderful coloring of the string \"kzaaa\". Paul and Mary want to learn by themselves how to find a wonderful coloring of the string. But they are very young, so they need a hint. Help them find $$$k$$$ \u2014 the number of red (or green, these numbers are equal) letters in a wonderful coloring.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one non-empty string $$$s$$$ which consists of lowercase letters of the Latin alphabet. The number of characters in the string doesn't exceed $$$50$$$.", "output_spec": "For each test case, output a separate line containing one non-negative integer $$$k$$$ \u2014 the number of letters which will be painted in red in a wonderful coloring.", "sample_inputs": ["5\nkzaaa\ncodeforces\narchive\ny\nxxxxxx"], "sample_outputs": ["2\n5\n3\n0\n1"], "notes": "NoteThe first test case contains the string from the statement. One of the wonderful colorings is shown in the figure. There's no wonderful coloring containing $$$3$$$ or more red letters because the total number of painted symbols will exceed the string's length.The string from the second test case can be painted as follows. Let's paint the first occurrence of each of the letters \"c\", \"o\", \"e\" in red and the second ones in green. Let's paint the letters \"d\", \"f\" in red and \"r\", \"s\" in green. So every letter will be painted in red or green, hence the answer better than $$$5$$$ doesn't exist.The third test case contains the string of distinct letters, so you can paint any set of characters in red, as long as the size of this set doesn't exceed half of the size of the string and is the maximum possible.The fourth test case contains a single letter which cannot be painted in red because there will be no letter able to be painted in green.The fifth test case contains a string of identical letters, so there's no way to paint more than one letter in red."}, "positive_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $a = str_split(IO::str());\r\n $b = [];\r\n $res = 0;\r\n foreach ($a as $v) {\r\n if (isset($b[$v])) {\r\n $b[$v] += 1;\r\n } else {\r\n $b[$v] = 1;\r\n }\r\n }\r\n $t = 0;\r\n foreach ($b as $k => $v) {\r\n if ($v >= 2) {\r\n $res++;\r\n } else {\r\n $t++;\r\n }\r\n }\r\n $res += floor($t / 2);\r\n IO::line($res);\r\n}\r\n\r\n\r\n?>"}, {"source_code": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": " 1) { break; }\r\n }\r\n $k = count($a) - $c;\r\n $c = floor($c / 2);\r\n $ans = $c + $k;\r\n echo $ans.PHP_EOL;\r\n}\r\n\r\n?>"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $a = str_split(IO::str());\r\n $b = [];\r\n $res = 0;\r\n foreach ($a as $v) {\r\n if (isset($b[$v])) {\r\n $b[$v] += 1;\r\n } else {\r\n $b[$v] = 1;\r\n }\r\n }\r\n $res = min(floor(count($a) / 2), count($b));\r\n if (count($b) == 1 && count($a) < 2) {\r\n $res = 0;\r\n }\r\n\r\n IO::line($res);\r\n}\r\n\r\n\r\n?>"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $a = str_split(IO::str());\r\n $b = [];\r\n $res = 0;\r\n foreach ($a as $v) {\r\n if (isset($b[$v])) {\r\n $b[$v] += 1;\r\n } else {\r\n $b[$v] = 1;\r\n }\r\n }\r\n $res = min(floor(count($a) / 2), count($b));\r\n if (count($b) == 1) {\r\n $res = 0;\r\n }\r\n\r\n IO::line($res);\r\n}\r\n\r\n\r\n?>"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $a = str_split(IO::str());\r\n $b = [];\r\n $res = 0;\r\n foreach ($a as $v) {\r\n if (isset($b[$v])) {\r\n $b[$v] += 1;\r\n } else {\r\n $b[$v] = 1;\r\n }\r\n }\r\n $res = min(floor(count($a) / 2), count($b));\r\n if (count($b) == 0) {\r\n $res = 0;\r\n }\r\n\r\n IO::line($res);\r\n}\r\n\r\n\r\n?>"}], "src_uid": "a6b760941ab8be2c32c6dc66c623ea0e"} {"nl": {"description": "A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold: ai\u2009\u2265\u2009ai\u2009-\u20091 for all even i, ai\u2009\u2264\u2009ai\u2009-\u20091 for all odd i\u2009>\u20091. For example the arrays [1,2,1,2] and [1,1,1,1] are z-sorted while the array [1,2,3,4] isn\u2019t z-sorted.Can you make the array z-sorted?", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number of elements in the array a. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109) \u2014 the elements of the array a.", "output_spec": "If it's possible to make the array a z-sorted print n space separated integers ai \u2014 the elements after z-sort. Otherwise print the only word \"Impossible\".", "sample_inputs": ["4\n1 2 2 1", "5\n1 3 2 2 5"], "sample_outputs": ["1 2 1 2", "1 5 2 3 2"], "notes": null}, "positive_code": [{"source_code": " $c[$x + 1])\n {\n $h = 1;\n }\n }\n else\n {\n if($c[$x] < $c[$x + 1])\n {\n $h = 1;\n }\n }\n}\nif($h == 0)\n{\n print implode(\" \", $c);\n}\nelse\n{\n print \"Impossible\";\n}\n?>"}, {"source_code": " '',\n\t\t\"\\n\" => '',\n\t);\n\treturn strtr(fgets($f), $r);\n}\n\nfunction readNumString($f) {\n\treturn trim(fgets($f));\n}\n\nfunction stringToArray($str) {\n\treturn str_split($str);\n}\n\nfunction readNum($f, $is_int = false) {\n\t$v = readNumString($f);\n\treturn $is_int ? intval($v) : floatval($v);\n}\n\nfunction readStringExplode($f, $delimiter = ' ') {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = 'trim';\n\treturn array_map($callf, $return);\n}\n\nfunction readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {\n\t$v = readNumString($f);\n\tif ($delimiter == '') {\n\t\t$return = stringToArray($v);\n\t} else {\n\t\t$return = explode($delimiter, $v);\n\t}\n\t$callf = $is_int ? 'intval' : 'floatval';\n\treturn array_map($callf, $return);\n}\n\n###### /IO ######\n$n = readNum(STDIN);\n\t$nums = readStringExplodeNum(STDIN);\n\tsort($nums);\n\n\t$a = $b = array();\n\t$isError = false;\n\tfor ($i = 0; $i <= $n / 2; $i++) {\n\t\tif (empty($nums)) {\n\t\t\tbreak;\n\t\t}\n\t\t$num = array_shift($nums);\n\t\tif (empty($a)) {\n\t\t\t$a[$i] = $num;\n\t\t} else {\n\t\t\tif ($a[$i - 1] > $num) {\n\t\t\t\t$isError = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t$a[$i] = $num;\n\t\t}\n\n\t\t$num = array_pop($nums);\n\t\tif (empty($b)) {\n\t\t\t$b[$i] = $num;\n\t\t} else {\n\t\t\tif ($b[$i - 1] < $num) {\n\t\t\t\t$isError = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t$b[$i] = $num;\n\t\t}\n\t}\n\tif ($isError) {\n\t\techo 'Impossible';\n\t} else {\n\t\tforeach ($a as $i => $num) {\n\t\t\techo $a[$i] . ' ' . $b[$i] . ' ';\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "2401d34db475853661d6e1e1cb5a8216"} {"nl": {"description": "Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u2009n\u2009-\u2009k\u2009+\u20091,\u2009b\u2009-\u2009a\u2009\u2265\u2009k) and sign all laws with numbers lying in the segments [a;\u00a0a\u2009+\u2009k\u2009-\u20091] and [b;\u00a0b\u2009+\u2009k\u2009-\u20091] (borders are included).As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.", "input_spec": "The first line contains two integers n and k (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105, 0\u2009<\u20092k\u2009\u2264\u2009n) \u2014 the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1,\u2009x2,\u2009...,\u2009xn \u2014 the absurdity of each law (1\u2009\u2264\u2009xi\u2009\u2264\u2009109).", "output_spec": "Print two integers a, b \u2014 the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a;\u00a0a\u2009+\u2009k\u2009-\u20091] and [b;\u00a0b\u2009+\u2009k\u2009-\u20091]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.", "sample_inputs": ["5 2\n3 6 1 1 6", "6 2\n1 1 1 1 1 1"], "sample_outputs": ["1 4", "1 3"], "notes": "NoteIn the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3\u2009+\u20096\u2009+\u20091\u2009+\u20096\u2009=\u200916.In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1\u2009+\u20091\u2009+\u20091\u2009+\u20091\u2009=\u20094."}, "positive_code": [{"source_code": " 0); $right = array(-1 => 0);\n$leftindex = array(); $rightindex = array();\nfor ($i = 0; $i <= $n - (2*$k); $i++) {\n\t$currl = 0;\n\t$currr = 0;\n\tfor ($j = 0; $j < $k; $j++) {\n\t\t$currl += $x[$i+$j];\n\t\t$currr += $x[$n-1-$i-$j];\n\t}\n\tif ($left[$i-1] < $currl) {$left[] = $currl; $leftindex[] = $i;} else {$left[] = $left[$i-1]; $leftindex[] = $leftindex[$i-1];}\n\tif ($right[$i-1] <= $currr) {$right[] = $currr; $rightindex[] = $i;} else {$right[] = $right[$i-1]; $rightindex[] = $rightindex[$i-1];}\n}\n\n$max = 0; $a = 0; $b = $n;\nfor ($i = 0; $i <= $n-(2*$k); $i++) {\n\t$sum = $left[$i] + $right[$n-2*$k-$i];\n\tif ($max < $sum) {$max = $sum; $a = $leftindex[$i]; $b = $rightindex[$n-2*$k-$i];}\n}\necho ($a+1) . \" \" . ($b+1);"}], "src_uid": "74095fe82bd22257eeb97e1caf586499"} {"nl": {"description": "You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.To cyclically shift a table row one cell to the right means to move the value of each cell, except for the last one, to the right neighboring cell, and to move the value of the last cell to the first cell. A cyclical shift of a row to the left is performed similarly, but in the other direction. For example, if we cyclically shift a row \"00110\" one cell to the right, we get a row \"00011\", but if we shift a row \"00110\" one cell to the left, we get a row \"01100\".Determine the minimum number of moves needed to make some table column consist only of numbers 1.", "input_spec": "The first line contains two space-separated integers: n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of rows in the table and m (1\u2009\u2264\u2009m\u2009\u2264\u2009104)\u00a0\u2014 the number of columns in the table. Then n lines follow, each of them contains m characters \"0\" or \"1\": the j-th character of the i-th line describes the contents of the cell in the i-th row and in the j-th column of the table. It is guaranteed that the description of the table contains no other characters besides \"0\" and \"1\".", "output_spec": "Print a single number: the minimum number of moves needed to get only numbers 1 in some column of the table. If this is impossible, print -1.", "sample_inputs": ["3 6\n101010\n000100\n100000", "2 3\n111\n000"], "sample_outputs": ["3", "-1"], "notes": "NoteIn the first sample one way to achieve the goal with the least number of moves is as follows: cyclically shift the second row to the right once, then shift the third row to the left twice. Then the table column before the last one will contain only 1s.In the second sample one can't shift the rows to get a column containing only 1s."}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if($e[$y] == 1)\n {\n $h = 0;\n }\n $f[$y] = min($f[$y], $h);\n $h++;\n }\n for($y = $b - 1; $y >= 0; $y--)\n {\n $f[$y] = min($f[$y], $h);\n $h++;\n }\n for($y = 0; $y < $b; $y++)\n {\n $c[$y] += $f[$y];\n }\n if($g == 0)\n {\n $d = 1;\n break;\n }\n \n}\nif($d == 1)\n{\n print \"-1\";\n}\nelse\n{\n print min($c);\n}\n?>"}], "negative_code": [{"source_code": "= 0; $y--)\n {\n $g += $e[$y];\n if($e[$y] == 1)\n {\n $h = 0;\n }\n $c[$y] += min($f[$y], $h);\n $h++;\n }\n if($g == 0)\n {\n $d = 1;\n break;\n }\n \n}\nif($d == 1)\n{\n print \"-1\";\n}\nelse\n{\n print min($c);\n}\n?>"}], "src_uid": "a491be7d5883d594c3e907a22be607c9"} {"nl": {"description": "Two players play a game.Initially there are $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i.\u00a0e. $$$n - 1$$$ turns are made. The first player makes the first move, then players alternate turns.The first player wants to minimize the last number that would be left on the board, while the second player wants to maximize it.You want to know what number will be left on the board after $$$n - 1$$$ turns if both players make optimal moves.", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\le n \\le 1000$$$)\u00a0\u2014 the number of numbers on the board. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^6$$$).", "output_spec": "Print one number that will be left on the board.", "sample_inputs": ["3\n2 1 3", "3\n2 2 2"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first sample, the first player erases $$$3$$$ and the second erases $$$1$$$. $$$2$$$ is left on the board.In the second sample, $$$2$$$ is left on the board regardless of the actions of the players."}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": " 1)\n{\n if ($p1)\n {\n $p1 = false;\n array_pop ($board);\n }\n else\n {\n $p1 = true;\n array_shift ($board);\n }\n --$n;\n}\n\n/* Output */\necho $board[0];\n"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": " 1) {\n echo $numbers[1];\n} else {\n echo $numbers[0];\n}\n\n"}, {"source_code": " $cols) {\n\n foreach ($cols as $col) {\n\n $numCount = 0;\n\n for ($i = -1; $i < 2; $i++) {\n\n for ($j = -1; $j < 2; $j++) {\n\n if ($i != 0 || $j != 0) {\n\n if (isset($field[$row + $i][$col + $j])) {\n\n $val = $field[$row + $i][$col + $j];\n\n if ($val == '.' || ($val != '*' && $val == 0)) {\n\n $result = 'NO';\n break;\n } elseif ($val != '*') {\n\n $numCount++;\n $field[$row + $i][$col + $j]--;\n $totalSum--;\n }\n }\n }\n }\n }\n }\n\n if ($result == 'NO') {\n break;\n }\n}\n\nif ($totalSum != 0) {\n $result = 'NO';\n}\n\necho $result;\n\n"}], "src_uid": "f93a8bd64a405233342f84542fce314d"} {"nl": {"description": "As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.Let's consider a set of functions of the following form: Let's define a sum of n functions y1(x),\u2009...,\u2009yn(x) of the given type as function s(x)\u2009=\u2009y1(x)\u2009+\u2009...\u2009+\u2009yn(x) for any x. It's easy to show that in this case the graph s(x) is a polyline. You are given n functions of the given type, your task is to find the number of angles that do not equal 180 degrees, in the graph s(x), that is the sum of the given functions.Valeric and Valerko really want to watch the next Euro Championship game, so they asked you to help them.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of functions. Each of the following n lines contains two space-separated integer numbers ki,\u2009bi (\u2009-\u2009109\u2009\u2264\u2009ki,\u2009bi\u2009\u2264\u2009109) that determine the i-th function.", "output_spec": "Print a single number \u2014 the number of angles that do not equal 180 degrees in the graph of the polyline that equals the sum of the given functions.", "sample_inputs": ["1\n1 0", "3\n1 0\n0 2\n-1 1", "3\n-2 -4\n1 7\n-5 1"], "sample_outputs": ["1", "2", "3"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "d436c7a3b7f07c9f026d00bdf677908d"} {"nl": {"description": "Polycarp has n dice d1,\u2009d2,\u2009...,\u2009dn. The i-th dice shows numbers from 1 to di. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d1,\u2009d2,\u2009...,\u2009dn. However, she finds it enough to make a series of statements of the following type: dice i couldn't show number r. For example, if Polycarp had two six-faced dice and the total sum is A\u2009=\u200911, then Agrippina can state that each of the two dice couldn't show a value less than five (otherwise, the remaining dice must have a value of at least seven, which is impossible).For each dice find the number of values for which it can be guaranteed that the dice couldn't show these values if the sum of the shown values is A.", "input_spec": "The first line contains two integers n,\u2009A (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105,\u2009n\u2009\u2264\u2009A\u2009\u2264\u2009s) \u2014 the number of dice and the sum of shown values where s\u2009=\u2009d1\u2009+\u2009d2\u2009+\u2009...\u2009+\u2009dn. The second line contains n integers d1,\u2009d2,\u2009...,\u2009dn (1\u2009\u2264\u2009di\u2009\u2264\u2009106), where di is the maximum value that the i-th dice can show.", "output_spec": "Print n integers b1,\u2009b2,\u2009...,\u2009bn, where bi is the number of values for which it is guaranteed that the i-th dice couldn't show them.", "sample_inputs": ["2 8\n4 4", "1 3\n5", "2 3\n2 3"], "sample_outputs": ["3 3", "4", "0 1"], "notes": "NoteIn the first sample from the statement A equal to 8 could be obtained in the only case when both the first and the second dice show 4. Correspondingly, both dice couldn't show values 1, 2 or 3.In the second sample from the statement A equal to 3 could be obtained when the single dice shows 3. Correspondingly, it couldn't show 1, 2, 4 or 5.In the third sample from the statement A equal to 3 could be obtained when one dice shows 1 and the other dice shows 2. That's why the first dice doesn't have any values it couldn't show and the second dice couldn't show 3."}, "positive_code": [{"source_code": "in();\n $sum = (double) $scn->in();\n for ($i = 0; $i <= $n - 1; $i++) {\n $dice[$i] = (double) $scn->in();\n $grand += $dice[$i];\n }\n for ($i = 0; $i <= $n - 1; $i++) {\n $temp = ($sum - $n) + 1;\n $high = ($temp >= $dice[$i]) ? $dice[$i] : $temp;\n \n $temp = $grand - $dice[$i];\n $low = ($temp >= $sum) ? 1 : $sum - $temp;\n printf(\"%.0lf\\n\", $dice[$i] - (($high - $low) + 1));\n }\n}\n\nclass Scanner {\n private $handle = \"\";\n private $values = array();\n private $index = 0;\n \n public function __construct($localfile){\n if (is_file($localfile)) {\n $this->handle = fopen($localfile, \"r\");\n $contents = stream_get_contents($this->handle);\n }\n else\n $contents = stream_get_contents(STDIN);\n $no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n $this->values = explode(\" \", $no_newlines);\n }\n public function in(){\n return $this->values[$this->index++];\n }\n public function close(){\n if (is_file($localfile) && feof($this->handle))\n fclose($this->handle);\n }\n}\n?>"}], "negative_code": [{"source_code": "= $dice[i]) ? $dice[i] : $temp;\n \n $temp = $grand - $dice[i];\n $low = ($temp >= $sum) ? 1 : $sum - $temp;\n printf(\"%.0lf \", $dice[i] - (($high - $low) + 1));\n }\n?>"}], "src_uid": "2c51414eeb430ad06aac53a99ff95eff"} {"nl": {"description": "Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed to help if Rostislav solves a simple task (and if he doesn't, then why would he need Splay trees anyway?)Given integers l, r and k, you need to print all powers of number k within range from l to r inclusive. However, Rostislav doesn't want to spent time doing this, as he got interested in playing a network game called Agar with Gleb. Help him!", "input_spec": "The first line of the input contains three space-separated integers l, r and k (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u20091018, 2\u2009\u2264\u2009k\u2009\u2264\u2009109).", "output_spec": "Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print \"-1\" (without the quotes).", "sample_inputs": ["1 10 2", "2 4 5"], "sample_outputs": ["1 2 4 8", "-1"], "notes": "NoteNote to the first sample: numbers 20\u2009=\u20091, 21\u2009=\u20092, 22\u2009=\u20094, 23\u2009=\u20098 lie within the specified range. The number 24\u2009=\u200916 is greater then 10, thus it shouldn't be printed."}, "positive_code": [{"source_code": " $b)\n {\n break;\n }\n elseif($f >= $a)\n {\n $d .= $f . \" \";\n }\n }\n if($d == \"\")\n {\n print \"-1\";\n }\n else\n {\n print $d;\n }\n}\n?>"}], "negative_code": [{"source_code": " $b)\n {\n break;\n }\n elseif($f >= $a)\n {\n $d .= $f . \" \";\n }\n}\nif($d == \"\")\n{\n print \"-1\";\n}\nelse\n{\n print $d;\n}\n?>"}, {"source_code": "= $a) && ($g <= $b))\n {\n $d[$f] = $g;\n $e++;\n $f++;\n }\n elseif($g < $a)\n {\n $e++;\n }\n elseif($g > $b)\n {\n break;\n }\n}\nif(count($d) == 0)\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": "= $a) && ($g <= $b))\n {\n $d[$f] = $g;\n $e = bcadd($e, 1);\n $f = bcadd($f, 1);\n }\n elseif($g < $a)\n {\n $e = bcadd($e, 1);\n }\n elseif($g > $b)\n {\n break;\n }\n}\nif(count($d) == 0)\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": " $b)\n {\n break;\n }\n elseif($f >= $a)\n {\n $d .= $f . \" \";\n }\n }\n if($d == \"\")\n {\n print \"-1\";\n }\n else\n {\n print $d;\n }\n}\n?>"}, {"source_code": "= $a) && ($g <= $b))\n {\n $d[$f] = $g;\n $e++;\n $f++;\n }\n elseif($g < $a)\n {\n $e++;\n }\n elseif($g > $b)\n {\n break;\n }\n}\nif(count($d) == 0)\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": " $b)\n {\n break;\n }\n elseif($f >= $a)\n {\n $d .= $f . \" \";\n }\n }\n if($d == \"\")\n {\n print \"-1\";\n }\n else\n {\n print $d;\n }\n}\n?>"}], "src_uid": "8fcec28fb4d165eb58f829c03e6b31d1"} {"nl": {"description": "The robot is placed in the top left corner of a grid, consisting of $$$n$$$ rows and $$$m$$$ columns, in a cell $$$(1, 1)$$$.In one step, it can move into a cell, adjacent by a side to the current one: $$$(x, y) \\rightarrow (x, y + 1)$$$; $$$(x, y) \\rightarrow (x + 1, y)$$$; $$$(x, y) \\rightarrow (x, y - 1)$$$; $$$(x, y) \\rightarrow (x - 1, y)$$$. The robot can't move outside the grid.The cell $$$(s_x, s_y)$$$ contains a deadly laser. If the robot comes into some cell that has distance less than or equal to $$$d$$$ to the laser, it gets evaporated. The distance between two cells $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ is $$$|x_1 - x_2| + |y_1 - y_2|$$$.Print the smallest number of steps that the robot can take to reach the cell $$$(n, m)$$$ without getting evaporated or moving outside the grid. If it's not possible to reach the cell $$$(n, m)$$$, print -1.The laser is neither in the starting cell, nor in the ending cell. The starting cell always has distance greater than $$$d$$$ to the laser.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of testcases. The only line of each testcase contains five integers $$$n, m, s_x, s_y, d$$$ ($$$2 \\le n, m \\le 1000$$$; $$$1 \\le s_x \\le n$$$; $$$1 \\le s_y \\le m$$$; $$$0 \\le d \\le n + m$$$)\u00a0\u2014 the size of the grid, the cell that contains the laser and the evaporating distance of the laser. The laser is neither in the starting cell, nor in the ending cell ($$$(s_x, s_y) \\neq (1, 1)$$$ and $$$(s_x, s_y) \\neq (n, m)$$$). The starting cell $$$(1, 1)$$$ always has distance greater than $$$d$$$ to the laser ($$$|s_x - 1| + |s_y - 1| > d$$$).", "output_spec": "For each testcase, print a single integer. If it's possible to reach the cell $$$(n, m)$$$ from $$$(1, 1)$$$ without getting evaporated or moving outside the grid, then print the smallest amount of steps it can take the robot to reach it. Otherwise, print -1.", "sample_inputs": ["3\n\n2 3 1 3 0\n\n2 3 1 3 1\n\n5 5 3 4 1"], "sample_outputs": ["3\n-1\n8"], "notes": null}, "positive_code": [{"source_code": "= $n && $sx - $d <= 1;\n $noWay |= $sy + $d >= $m && $sy - $d <= 1;\n $noWay |= $sx + $d >= $n && $sy + $d >= $m;\n\n if ($noWay) {\n echo \"-1\\n\";\n } else {\n echo ($n + $m - 2).PHP_EOL;\n }\n}\n/*\n\n1\n11 3 5 2 1\n// -1\n\n1\n11 3 5 1 1\n// 12\n\n1\n11 3 5 3 1\n// 12\n\n1\n11 3 10 2 1\n// -1\n\n1\n11 3 10 2 0\n// 12\n\n1\n3 5 2 3 1\n// -1\n\n1\n10 4 2 2 1\n// -1!\n\n\n */\n"}], "negative_code": [{"source_code": "= $n && $sx - $d <= 1;\n $noWay |= $sy + $d >= $m && $sy - $d <= 1;\n $noWay |= $sx + $d >= $n && $sy + $d >= $m;\n\n if ($noWay) {\n echo \"-1\\n\";\n } else {\n echo ($n + $m - 2).PHP_EOL;\n }\n}\n"}], "src_uid": "fe7186f7d026eb4cd2e1afda75ac9fcd"} {"nl": {"description": "You are given n points on the straight line \u2014 the positions (x-coordinates) of the cities and m points on the same line \u2014 the positions (x-coordinates) of the cellular towers. All towers work in the same way \u2014 they provide cellular network for all cities, which are located at the distance which is no more than r from this tower.Your task is to find minimal r that each city has been provided by cellular network, i.e. for each city there is at least one cellular tower at the distance which is no more than r.If r\u2009=\u20090 then a tower provides cellular network only for the point where it is located. One tower can provide cellular network for any number of cities, but all these cities must be at the distance which is no more than r from this tower.", "input_spec": "The first line contains two positive integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105) \u2014 the number of cities and the number of cellular towers. The second line contains a sequence of n integers a1,\u2009a2,\u2009...,\u2009an (\u2009-\u2009109\u2009\u2264\u2009ai\u2009\u2264\u2009109) \u2014 the coordinates of cities. It is allowed that there are any number of cities in the same point. All coordinates ai are given in non-decreasing order. The third line contains a sequence of m integers b1,\u2009b2,\u2009...,\u2009bm (\u2009-\u2009109\u2009\u2264\u2009bj\u2009\u2264\u2009109) \u2014 the coordinates of cellular towers. It is allowed that there are any number of towers in the same point. All coordinates bj are given in non-decreasing order.", "output_spec": "Print minimal r so that each city will be covered by cellular network.", "sample_inputs": ["3 2\n-2 2 4\n-3 0", "5 3\n1 5 10 14 17\n4 11 15"], "sample_outputs": ["4", "3"], "notes": null}, "positive_code": [{"source_code": "= 0; $w--)\n{\n if($f[$w] == 1)\n {\n $w3 = $w;\n break;\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $d[0] - $g[$x];\n }\n}\nfor($y = $x + 1; $y < count($g); $y++)\n{\n if($y == $w3)\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n $g[$y] = $g[$y] - $h;\n }\n else\n {\n $h = $g[$y];\n }\n}\nfor($x = count($g) - 1; $x >= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($y == $w2)\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}], "negative_code": [{"source_code": "= 0; $x--)\n{\n if($f[$g[$x]] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$g[$y]] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$g[$x]] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\nif(($a == 1000) && ($b == 1000))\n{\n print $c[0] . \" \" . $d[0] . \"\\n\";\n print $c[count($c) - 1] . \" \" . $d[count($d) - 1] . \"\\n\";\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n $g[$x] = \"-1\";\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n $g[$y] = \"-1\";\n }\n}\nif(($a == 1000) && ($b == 1000))\n{\n print implode(\" \", $g) . \"\\n\";\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nif(($a == 1000) && ($b == 1000))\n{\n $w = array_slice($g, 310, 20);\n print implode(\" \", $w) . \"\\n\";\n}\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\nif(($a == 1000) && ($b == 1000))\n{\n print implode(\" \", $g) . \"\\n\";\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$g[$x]] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$g[$y]] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$g[$x]] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n else\n {\n $f[$g[$x]] = 0;\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[count($d) - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n if(($a == 1000) && ($b == 1000))\n {\n if($i == 8)\n {\n print $x . \"\\n\";\n }\n }\n }\n}\nprint $i;\n?>"}, {"source_code": "= 0; $x--)\n{\n if($f[$x] == 1)\n {\n $h = $g[$x];\n break;\n }\n else\n {\n $g[$x] = $g[$x] - $d[$b - 1];\n }\n}\nfor($y = $x - 1; $y >= 0; $y--)\n{\n if($g[$y] == $d[0])\n {\n break;\n }\n elseif($f[$y] == 0)\n {\n if(($h - $g2[$y]) < $g[$y])\n {\n $g[$y] = $h - $g2[$y];\n }\n }\n else\n {\n $h = $g[$y];\n }\n}\n$i = 0;\nfor($x = 0; $x < count($g); $x++)\n{\n if(($f[$x] == 0) && ($g[$x] > $i))\n {\n $i = $g[$x];\n }\n}\nprint $i;\n?>"}], "src_uid": "9fd8e75cb441dc809b1b2c48c4012c76"} {"nl": {"description": "The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts $$$h$$$ hours and each hour lasts $$$m$$$ minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows the number of minutes in decimal; the number of minutes and hours is written with leading zeros if needed to form a two-digit number). Hours are numbered from $$$0$$$ to $$$h-1$$$ and minutes are numbered from $$$0$$$ to $$$m-1$$$. That's how the digits are displayed on the clock. Please note that digit $$$1$$$ is placed in the middle of its position. A standard mirror is in use on the planet Lapituletti. Inhabitants often look at the reflection of the digital clocks in the mirror and feel happy when what you see on the reflected clocks is a valid time (that means that you see valid digits in the reflection and this time can be seen on the normal clocks at some moment of a day).The image of the clocks in the mirror is reflected against a vertical axis. The reflection is not a valid time.The reflection is a valid time with $$$h=24$$$, $$$m = 60$$$. However, for example, if $$$h=10$$$, $$$m=60$$$, then the reflection is not a valid time. An inhabitant of the planet Lapituletti begins to look at a mirrored image of the clocks at some time moment $$$s$$$ and wants to know the nearest future time moment (which can possibly happen on the next day), when the reflected clock time is valid.It can be shown that with any $$$h$$$, $$$m$$$, $$$s$$$ such a moment exists. If the reflected time is correct at the moment the inhabitant began to look at the clock, that moment is considered the nearest.You are asked to solve the problem for several test cases.", "input_spec": "The first line contains a single integer $$$T$$$ ($$$1 \\le T \\le 100$$$) \u2014 the number of test cases. The next $$$2 \\cdot T$$$ lines contain the description of test cases. The description of each test case consists of two lines. The first line of a test case contains two integers $$$h$$$, $$$m$$$ ($$$1 \\le h, m \\le 100$$$). The second line contains the start time $$$s$$$ in the described format HH:MM.", "output_spec": "For each test case output in a separate line the nearest moment in format HH:MM when the reflected time is correct.", "sample_inputs": ["5\n24 60\n12:21\n24 60\n23:59\n90 80\n52:26\n1 100\n00:01\n10 10\n04:04"], "sample_outputs": ["12:21\n00:00\n52:28\n00:00\n00:00"], "notes": "NoteIn the second test case it is not hard to show that the reflection of 23:59 is incorrect, while the reflection of the moment 00:00 on the next day is correct. "}, "positive_code": [{"source_code": "= 0; $i--) {\n\t\t\tif (in_array(intval($str[$i]), $reversable) || $str[$i] == ':') {\n\t\t\t\t$str2 .= (intval($str[$i]) == 2 ? '5' : (intval($str[$i]) == 5 ? '2' : $str[$i]));\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tlist($h2, $m2) = explode(\":\", $str2);\n\t\tif (intval($h2) >= $h || intval($m2) >= $m) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tfunction increment_time_minutes_please($str, $h, $m) {\n\t\tlist($h2, $m2) = explode(\":\", $str);\n\t\t$h2 = intval($h2);\n\t\t$m2 = intval($m2);\n\t\tif ($m2 + 1 == $m) {\n\t\t\t$h2++;\n\t\t\t$m2 = 0;\n\t\t} else {\n\t\t\t$m2++;\n\t\t}\n\t\tif ($h2 == $h) {\n\t\t\t$h2 = 0;\n\t\t}\n\n\t\treturn ($h2 >= 10 ? $h2 : \"0\".$h2).\":\".($m2 >= 10 ? $m2 : \"0\".$m2);\n\t}\n\n\tfor ($o = 0; $o < $t; $o++) {\n\t\tlist($h, $m) = explode(\" \", trim(fgets(STDIN)));\n\t\t$time = trim(fgets(STDIN));\n\t\tfor ($i = 0; $i < $h*$m; $i++)\n\t\t\tif (check_reversed_number_if_valid_please($time, $h, $m)) {\n\t\t\t\tprint $time.\"\\n\";\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t$time = increment_time_minutes_please($time, $h, $m);\n\t\t\t}\n\t\t}\n?>"}], "negative_code": [], "src_uid": "7f28e4dbd199b84bd7885bf7f479cf38"} {"nl": {"description": "Theater stage is a rectangular field of size n\u2009\u00d7\u2009m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.You are to place a spotlight on the stage in some good position. The spotlight will project light in one of the four directions (if you look at the stage from above)\u00a0\u2014 left, right, up or down. Thus, the spotlight's position is a cell it is placed to and a direction it shines.A position is good if two conditions hold: there is no actor in the cell the spotlight is placed to; there is at least one actor in the direction the spotlight projects. Count the number of good positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.", "input_spec": "The first line contains two positive integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091000)\u00a0\u2014 the number of rows and the number of columns in the plan. The next n lines contain m integers, 0 or 1 each\u00a0\u2014 the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.", "output_spec": "Print one integer\u00a0\u2014 the number of good positions for placing the spotlight.", "sample_inputs": ["2 4\n0 1 0 0\n1 0 1 0", "4 4\n0 0 0 0\n1 0 0 1\n0 1 1 0\n0 1 0 0"], "sample_outputs": ["9", "20"], "notes": "NoteIn the first example the following positions are good: the (1, 1) cell and right direction; the (1, 1) cell and down direction; the (1, 3) cell and left direction; the (1, 3) cell and down direction; the (1, 4) cell and left direction; the (2, 2) cell and left direction; the (2, 2) cell and up direction; the (2, 2) and right direction; the (2, 4) cell and left direction. Therefore, there are 9 good positions in this example."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int n, m, k, i, j, count=0;\n cin>>n>>m;\n \n int st[n][m];\n for(i = 0; i < n; i++) \n\t\tfor(j = 0; j < m; j++)\n\t\tcin >> st[i][j];\n\t\t\n\tfor(i=0; i "}, {"source_code": " 0) $x -- ;\n else break ;\n $ans = $i;\n }\n echo $ans + $x . \"\\n\" ;\n }\n?>"}], "negative_code": [{"source_code": " 0) $x -- ;\n else\n {\n $ans = $i - 1 ;\n break ;\n }\n }\n echo $ans + $x . \"\\n\" ;\n }\n?>"}, {"source_code": " 0) $x -- ;\n else break ;\n $ans = $i;\n }\n echo $ans + $x . \"\\n\" ;\n }\n?>"}, {"source_code": " 0) $x -- ;\n else\n {\n $ans = $i - 1 ;\n break ;\n }\n }\n echo $ans . \"\\n\" ;\n }\n?>"}], "src_uid": "e5fac4a1f3a724234990fe758debc33f"} {"nl": {"description": "Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed k hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very light.Vasya has a train lighting schedule for all n hours of the trip \u2014 n numbers from 0 to 100 each (the light level in the first hour, the second hour and so on). During each of those hours he will either read the whole time, or not read at all. He wants to choose k hours to read a book, not necessarily consecutive, so that the minimum level of light among the selected hours were maximum. Vasya is very excited before the upcoming contest, help him choose reading hours.", "input_spec": "The first input line contains two integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u20091000,\u20091\u2009\u2264\u2009k\u2009\u2264\u2009n) \u2014 the number of hours on the train and the number of hours to read, correspondingly. The second line contains n space-separated integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009100), ai is the light level at the i-th hour.", "output_spec": "In the first output line print the minimum light level Vasya will read at. In the second line print k distinct space-separated integers b1,\u2009b2,\u2009...,\u2009bk, \u2014 the indexes of hours Vasya will read at (1\u2009\u2264\u2009bi\u2009\u2264\u2009n). The hours are indexed starting from 1. If there are multiple optimal solutions, print any of them. Print the numbers bi in an arbitrary order.", "sample_inputs": ["5 3\n20 10 30 40 10", "6 5\n90 20 35 40 60 100"], "sample_outputs": ["20\n1 3 4", "35\n1 3 4 5 6"], "notes": "NoteIn the first sample Vasya should read at the first hour (light 20), third hour (light 30) and at the fourth hour (light 40). The minimum light Vasya will have to read at is 20."}, "positive_code": [{"source_code": "= $a[$k-1]) {\n\t$i++;\n\tfputs($f, ($j+1).' ');\n\tif ($i == $k) break;\n}\n\n\nfclose($f);"}, {"source_code": "3){\nfputs($handle, var_export($hList, true).\"\\n\");\nfputs($handle, var_export($newhList, true).\"\\n\");\n}\nfputs($handle, end($newhList).\"\\n\");\nfputs($handle, implode(' ',array_keys($newhList)));\t\nfclose($handle);\n"}, {"source_code": "3){\nfputs($handle, var_export($newhList, true).\"\\n\");\n}\nfputs($handle, end($newhList).\"\\n\");\nfputs($handle, implode(' ',array_keys($newhList)));\t\nfclose($handle);\n"}, {"source_code": "=$i) {\n $t /= $i;\n $c++;\n }\n if ($c>0) {\n $pArray[$i] = $c;\n $c = 0;\n }\n }\n}\nfunction isPrime($x)\n{\n $k = floor(sqrt($x)) + 1;\n $result = true;\n for ($i = 2; $i < $k; $i++) {\n if ($x % $i ==0) {\n $result = false;\n break;\n }\n }\n return $result;\n}\n\n$r = array();\nforeach ($pArray as $p => $q) {\n for ($i = 1; $i <= $q; $i++) {\n $r[] = pow($p, $i);\n }\n}\necho count($r).PHP_EOL;\necho implode(\" \", $r);\n"}, {"source_code": "\n"}], "negative_code": [], "src_uid": "7f61b1d0e8294db74d33a6b6696989ad"} {"nl": {"description": "When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs ai minutes to read the i-th book.Valera decided to choose an arbitrary book with number i and read the books one by one, starting from this book. In other words, he will first read book number i, then book number i\u2009+\u20091, then book number i\u2009+\u20092 and so on. He continues the process until he either runs out of the free time or finishes reading the n-th book. Valera reads each book up to the end, that is, he doesn't start reading the book if he doesn't have enough free time to finish reading it. Print the maximum number of books Valera can read.", "input_spec": "The first line contains two integers n and t (1\u2009\u2264\u2009n\u2009\u2264\u2009105;\u00a01\u2009\u2264\u2009t\u2009\u2264\u2009109) \u2014 the number of books and the number of free minutes Valera's got. The second line contains a sequence of n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009104), where number ai shows the number of minutes that the boy needs to read the i-th book.", "output_spec": "Print a single integer \u2014 the maximum number of books Valera can read.", "sample_inputs": ["4 5\n3 1 2 1", "3 3\n2 2 3"], "sample_outputs": ["3", "1"], "notes": null}, "positive_code": [{"source_code": " $b)\n {\n $f -= $c[$d];\n $d++;\n $e++;\n }\n if($e == $a)\n {\n break;\n } \n}\nprint $h;\n?>"}, {"source_code": ""}, {"source_code": " $time) {\n $max = $max > ($count -1) ? $max : ($count -1);\n $count -= 1;\n $old = $arr[$i - $count];\n $temp -=$old;\n }\n else if($i == $n-1){\n $max = $max > ($count) ? $max : ($count);\n }\n }\n echo $max;\n}\n\ntest($n,$a,$t);"}, {"source_code": " $count ? $cMax : $count;"}, {"source_code": " $maxBooks) {\n $maxBooks = $right - $left + 1;\n }\n } else {\n $sum -= $a[$left];\n $left++;\n $right--;\n }\n $right++;\n}\necho ($maxBooks);"}, {"source_code": " $t) {\n\n $temp = $i - $start;\n\n if ($temp > $maxLength) {\n $maxLength = $temp;\n }\n\n $s -= (int) $a[$start];\n $start++;\n }\n}\n\nif ($s <= $t) {\n $temp = $n - $start;\n\n if ($temp > $maxLength) {\n $maxLength = $temp;\n }\n}\n\necho $maxLength < 0 ? 0 : $maxLength;"}, {"source_code": " /* BismiLahi Rahmani Rahim */ ?>\n\n\n"}], "negative_code": [{"source_code": ""}, {"source_code": " $b)\n {\n $d[$i] = $h;\n $h--;\n $i++;\n $g -= $c[$e];\n $e++;\n }\n}\nprint max($d);\n?>"}, {"source_code": " $b)\n {\n $d[$i] = $h;\n $i++;\n $h--;\n $g -= $c[$e];\n $e++;\n }\n}\nprint max($d);\n?>"}, {"source_code": " $b)\n {\n $d[$i] = $h;\n $h--;\n $i++;\n $g -= $c[$e];\n $e++;\n }\n}\nprint max($d);\n?>"}, {"source_code": " $b)\n {\n $f -= $c[$d];\n $d++;\n $e++;\n $g--;\n if($e == $a)\n {\n break;\n }\n }\n}\nprint max($h, $g);\n?>"}, {"source_code": " $b)\n {\n $d[$i] = $h;\n $i++;\n $h--;\n $g -= $c[$e];\n $e++;\n }\n}\nprint max($d);\n?>"}, {"source_code": ""}, {"source_code": " $b)\n {\n $f -= $c[$d];\n $d++;\n $e++;\n $g--;\n if($e == $a)\n {\n break;\n }\n }\n}\nprint max($h, $g);\n?>"}, {"source_code": ""}, {"source_code": " $t)\n break;\n $total = $temp;\n}\n\necho $count;"}, {"source_code": " $t)\n break;\n $total = $temp;\n}\n\necho $total;"}, {"source_code": " $t)\n break;\n $total = $temp;\n}\n\necho $total;"}, {"source_code": " $t)\n break;\n}\n\necho $total;"}, {"source_code": " $t)\n break;\n $total = $temp;\n $count++;\n}\n\necho $count;"}, {"source_code": " $maxBooks) {\n $maxBooks = $right - $left + 1;\n }\n } else {\n $sum -= $a[$left];\n $left++;\n $right--;\n }\n $right++;\n}\necho ($maxBooks);"}], "src_uid": "ef32a8f37968629673547db574261a9d"} {"nl": {"description": "You are given a non-empty string $$$s=s_1s_2\\dots s_n$$$, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string \"one\" or at least one string \"two\" (or both at the same time) as a substring. In other words, Polycarp does not like the string $$$s$$$ if there is an integer $$$j$$$ ($$$1 \\le j \\le n-2$$$), that $$$s_{j}s_{j+1}s_{j+2}=$$$\"one\" or $$$s_{j}s_{j+1}s_{j+2}=$$$\"two\".For example: Polycarp does not like strings \"oneee\", \"ontwow\", \"twone\" and \"oneonetwo\" (they all have at least one substring \"one\" or \"two\"), Polycarp likes strings \"oonnee\", \"twwwo\" and \"twnoe\" (they have no substrings \"one\" and \"two\"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time.For example, if the string looks like $$$s=$$$\"onetwone\", then if Polycarp selects two indices $$$3$$$ and $$$6$$$, then \"onetwone\" will be selected and the result is \"ontwne\".What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?", "input_spec": "The first line of the input contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string $$$s$$$. Its length does not exceed $$$1.5\\cdot10^5$$$. The string $$$s$$$ consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed $$$1.5\\cdot10^6$$$.", "output_spec": "Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain $$$r$$$ ($$$0 \\le r \\le |s|$$$) \u2014 the required minimum number of positions to be removed, where $$$|s|$$$ is the length of the given line. The second line of each answer should contain $$$r$$$ different integers \u2014 the indices themselves for removal in any order. Indices are numbered from left to right from $$$1$$$ to the length of the string. If $$$r=0$$$, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.", "sample_inputs": ["4\nonetwone\ntestme\noneoneone\ntwotwo", "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\nooone\nonnne\noneeeee\noneeeeeeetwooooo"], "sample_outputs": ["2\n6 3\n0\n\n3\n4 1 7 \n2\n1 4", "6\n18 11 12 1 6 21 \n1\n1 \n1\n3 \n1\n2 \n1\n6 \n0\n\n1\n4 \n0\n\n1\n1 \n2\n1 11"], "notes": "NoteIn the first example, answers are: \"onetwone\", \"testme\" \u2014 Polycarp likes it, there is nothing to remove, \"oneoneone\", \"twotwo\". In the second example, answers are: \"onetwonetwooneooonetwooo\", \"two\", \"one\", \"twooooo\", \"ttttwo\", \"ttwwoo\" \u2014 Polycarp likes it, there is nothing to remove, \"ooone\", \"onnne\" \u2014 Polycarp likes it, there is nothing to remove, \"oneeeee\", \"oneeeeeeetwooooo\". "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "9f8660190134606194cdd8db891a3d46"} {"nl": {"description": "There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monster being eaten, and they stand in the queue next to each other. Monsters eat each other instantly. There are no monsters which are being eaten at the same moment. After the monster A eats the monster B, the weight of the monster A increases by the weight of the eaten monster B. In result of such eating the length of the queue decreases by one, all monsters after the eaten one step forward so that there is no empty places in the queue again. A monster can eat several monsters one after another. Initially there were n monsters in the queue, the i-th of which had weight ai.For example, if weights are [1,\u20092,\u20092,\u20092,\u20091,\u20092] (in order of queue, monsters are numbered from 1 to 6 from left to right) then some of the options are: the first monster can't eat the second monster because a1\u2009=\u20091 is not greater than a2\u2009=\u20092; the second monster can't eat the third monster because a2\u2009=\u20092 is not greater than a3\u2009=\u20092; the second monster can't eat the fifth monster because they are not neighbors; the second monster can eat the first monster, the queue will be transformed to [3,\u20092,\u20092,\u20091,\u20092]. After some time, someone said a good joke and all monsters recovered. At that moment there were k (k\u2009\u2264\u2009n) monsters in the queue, the j-th of which had weight bj. Both sequences (a and b) contain the weights of the monsters in the order from the first to the last.You are required to provide one of the possible orders of eating monsters which led to the current queue, or to determine that this could not happen. Assume that the doctor didn't make any appointments while monsters were eating each other.", "input_spec": "The first line contains single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009500)\u00a0\u2014 the number of monsters in the initial queue. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009106)\u00a0\u2014 the initial weights of the monsters. The third line contains single integer k (1\u2009\u2264\u2009k\u2009\u2264\u2009n)\u00a0\u2014 the number of monsters in the queue after the joke. The fourth line contains k integers b1,\u2009b2,\u2009...,\u2009bk (1\u2009\u2264\u2009bj\u2009\u2264\u20095\u00b7108)\u00a0\u2014 the weights of the monsters after the joke. Monsters are listed in the order from the beginning of the queue to the end.", "output_spec": "In case if no actions could lead to the final queue, print \"NO\" (without quotes) in the only line. Otherwise print \"YES\" (without quotes) in the first line. In the next n\u2009-\u2009k lines print actions in the chronological order. In each line print x\u00a0\u2014 the index number of the monster in the current queue which eats and, separated by space, the symbol 'L' if the monster which stays the x-th in the queue eats the monster in front of him, or 'R' if the monster which stays the x-th in the queue eats the monster behind him. After each eating the queue is enumerated again. When one monster eats another the queue decreases. If there are several answers, print any of them.", "sample_inputs": ["6\n1 2 2 2 1 2\n2\n5 5", "5\n1 2 3 4 5\n1\n15", "5\n1 1 1 3 3\n3\n2 1 6"], "sample_outputs": ["YES\n2 L\n1 R\n4 L\n3 L", "YES\n5 L\n4 L\n3 L\n2 L", "NO"], "notes": "NoteIn the first example, initially there were n\u2009=\u20096 monsters, their weights are [1,\u20092,\u20092,\u20092,\u20091,\u20092] (in order of queue from the first monster to the last monster). The final queue should be [5,\u20095]. The following sequence of eatings leads to the final queue: the second monster eats the monster to the left (i.e. the first monster), queue becomes [3,\u20092,\u20092,\u20091,\u20092]; the first monster (note, it was the second on the previous step) eats the monster to the right (i.e. the second monster), queue becomes [5,\u20092,\u20091,\u20092]; the fourth monster eats the mosnter to the left (i.e. the third monster), queue becomes [5,\u20092,\u20093]; the finally, the third monster eats the monster to the left (i.e. the second monster), queue becomes [5,\u20095]. Note that for each step the output contains numbers of the monsters in their current order in the queue."}, "positive_code": [{"source_code": "= 0))\n {\n while(TRUE)\n {\n if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))\n {\n break;\n }\n elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))\n {\n print ($y + $x + 1) . \" L\\n\";\n $m[$y - 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n $y--;\n }\n elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))\n {\n print ($y + $x + 1) . \" R\\n\";\n $m[$y + 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n }\n }\n break;\n }\n elseif(($m[$y] == $n) && ($m[$y + 1] < $n))\n {\n while(TRUE)\n {\n if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))\n {\n break;\n }\n elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))\n {\n print ($y + $x + 1) . \" L\\n\";\n $m[$y - 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n $y--;\n }\n elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))\n {\n print ($y + $x + 1) . \" R\\n\";\n $m[$y + 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n }\n }\n break;\n }\n }\n \n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n if($i+1 < count($b) && $b[$i]+$b[$i-1] == $b[$i+1]) continue;\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n if($i+2 < count($b) && $b[$i]+$b[$i+1] == $b[$i+2]) continue;\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n if($i+1 < count($b) && $b[$i]+$b[$i-1] == $b[$i+1]) continue;\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n if($i+2 < count($b) && $b[$i]+$b[$i+1] == $b[$i+2]) continue;\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}], "negative_code": [{"source_code": "= 0))\n {\n while(TRUE)\n {\n if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))\n {\n break;\n }\n elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))\n {\n print ($y + $x + 1) . \" L\\n\";\n $m[$y - 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n $y--;\n }\n elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))\n {\n print ($y + $x + 1) . \" R\\n\";\n $m[$y + 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n }\n }\n break;\n }\n elseif(($m[$y] == $n) && ($m[$y + 1] < $n))\n {\n while(TRUE)\n {\n if(($m[$y - 1] == FALSE) && ($m[$y + 1] == FALSE))\n {\n break;\n }\n elseif((($m[$y - 1] < $m[$y]) && ($m[$y + 1] >= $m[$y]) && (($y - 1) >= 0)) || (($m[$y - 1] < $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y - 1) >= 0)) || ($m[$y + 1] == FALSE))\n {\n print ($y + $x + 1) . \" L\\n\";\n $m[$y - 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n $y--;\n }\n elseif((($m[$y - 1] >= $m[$y]) && ($m[$y + 1] < $m[$y]) && (($y + 1) >= 0)) || ($m[$y - 1] == FALSE))\n {\n print ($y + $x + 1) . \" R\\n\";\n $m[$y + 1] += $m[$y];\n $o = array_slice($m, 0, $y);\n $p = array_slice($m, $y + 1);\n $m = array_merge($o, $p);\n }\n }\n break;\n }\n }\n \n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n //$b = array_slice($b, $i);\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n //$b = array_slice($b, $i+1);\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n foreach($b as $bv) print $bv.\" \";\n print \"\\n\";\n foreach($d as $dv) print $dv.\" \";\n print \"\\n------\\n\";\n break(2);\n }\n }\n foreach($b as $bv) print $bv.\" \";\n print \"\\n\";\n foreach($d as $dv) print $dv.\" \";\n print \"\\n------\\n\";\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n \n }\n \n if($c == 1 && $b != $d){\n $b = $cb;\n $d = $cd;\n $who = array();\n $k = 0;\n while(count($d) > 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n for($i = count($b)-1; $i >= 0; $i--){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n //$b = array_slice($b, $i);\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n //$b = array_slice($b, $i+1);\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n continue;\n }\n if ($sd > 1){\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n else{\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i == count($b)-1) {\n break(2);\n }\n }\n }\n }\n \n if($b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}, {"source_code": " 0){\n if($b[0] == $d[0]){\n $b = array_slice($b, 1);\n $d = array_slice($d, 1);\n $k++;\n }\n for($i = 0; $i < count($b); $i++){\n if($i > 0 && $b[$i] > $b[$i-1]){\n $b[$i] += $b[$i-1];\n $who[] = ($i+1+$k).' L';\n //$b = array_slice($b, $i);\n unset($b[$i-1]);\n $b = array_values($b);\n break;\n }\n if($i+1 < count($b) && $b[$i] > $b[$i+1]){\n $b[$i] += $b[$i+1];\n $who[] = ($i+1+$k).' R';\n //$b = array_slice($b, $i+1);\n unset($b[$i+1]);\n $b = array_values($b);\n break;\n } \n if($i == count($b)-1) break(2);\n }\n }\n \n if(count($who) && $b == $d){\n print \"YES\\n\";\n foreach($who as $w){\n print $w.\"\\n\";\n }\n }\n else print \"NO\";\n \n}\n?>"}], "src_uid": "a37f805292e68bc0ad4555fa32d180ef"} {"nl": {"description": "Polycarp has $$$n$$$ coins, the value of the $$$i$$$-th coin is $$$a_i$$$. It is guaranteed that all the values are integer powers of $$$2$$$ (i.e. $$$a_i = 2^d$$$ for some non-negative integer number $$$d$$$).Polycarp wants to know answers on $$$q$$$ queries. The $$$j$$$-th query is described as integer number $$$b_j$$$. The answer to the query is the minimum number of coins that is necessary to obtain the value $$$b_j$$$ using some subset of coins (Polycarp can use only coins he has). If Polycarp can't obtain the value $$$b_j$$$, the answer to the $$$j$$$-th query is -1.The queries are independent (the answer on the query doesn't affect Polycarp's coins).", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$q$$$ ($$$1 \\le n, q \\le 2 \\cdot 10^5$$$) \u2014 the number of coins and the number of queries. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ \u2014 values of coins ($$$1 \\le a_i \\le 2 \\cdot 10^9$$$). It is guaranteed that all $$$a_i$$$ are integer powers of $$$2$$$ (i.e. $$$a_i = 2^d$$$ for some non-negative integer number $$$d$$$). The next $$$q$$$ lines contain one integer each. The $$$j$$$-th line contains one integer $$$b_j$$$ \u2014 the value of the $$$j$$$-th query ($$$1 \\le b_j \\le 10^9$$$).", "output_spec": "Print $$$q$$$ integers $$$ans_j$$$. The $$$j$$$-th integer must be equal to the answer on the $$$j$$$-th query. If Polycarp can't obtain the value $$$b_j$$$ the answer to the $$$j$$$-th query is -1.", "sample_inputs": ["5 4\n2 4 8 2 4\n8\n5\n14\n10"], "sample_outputs": ["1\n-1\n3\n2"], "notes": null}, "positive_code": [{"source_code": " $f)\n {\n $i = floor($f / $e[$y]);\n $j = $f % $e[$y];\n if($j == 0)\n {\n $f = 0;\n $g += $i;\n break;\n }\n else\n {\n $f -= $i * $e[$y];\n $g += $i;\n }\n }\n }\n }\n if($f == 0)\n {\n $k .= $g . \"\\n\";\n }\n else\n {\n $k .= \"-1\\n\";\n }\n}\nprint $k;\n?>"}], "negative_code": [], "src_uid": "a5c38d4842d3d4652cd79dd9715c138d"} {"nl": {"description": "Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like \"1,2\u00a0,3,...,\u00a0\u00a0\u00a010\" will be corrected to \"1,\u00a02,\u00a03,\u00a0...,\u00a010\".In this task you are given a string s, which is composed by a concatination of terms, each of which may be: a positive integer of an arbitrary length (leading zeroes are not allowed), a \"comma\" symbol (\",\"), a \"space\" symbol (\" \"), \"three dots\" (\"...\", that is, exactly three points written one after another, also known as suspension points). Polycarp wants to add and remove spaces in the string s to ensure the following: each comma is followed by exactly one space (if the comma is the last character in the string, this rule does not apply to it), each \"three dots\" term is preceded by exactly one space (if the dots are at the beginning of the string, this rule does not apply to the term), if two consecutive numbers were separated by spaces only (one or more), then exactly one of them should be left, there should not be other spaces. Automate Polycarp's work and write a program that will process the given string s.", "input_spec": "The input data contains a single string s. Its length is from 1 to 255 characters. The string s does not begin and end with a space. Its content matches the description given above.", "output_spec": "Print the string s after it is processed. Your program's output should be exactly the same as the expected answer. It is permissible to end output line with a line-break character, and without it.", "sample_inputs": ["1,2 ,3,..., 10", "1,,,4...5......6", "...,1,2,3,..."], "sample_outputs": ["1, 2, 3, ..., 10", "1, , , 4 ...5 ... ...6", "..., 1, 2, 3, ..."], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " ' ...',\n '/(\\\\s*,\\\\s*)/s' => ', ',\n '/\\\\s{2,}/s' => ' ',\n '/\\\\.\\\\.\\\\. (\\d)/s' => '...$1',\n);\n$str = fgets(STDIN);\n$str = preg_replace(array_keys($rx), array_values($rx), $str);\nfwrite(STDOUT, trim($str));"}, {"source_code": ""}, {"source_code": "\n$input = file_get_contents(\"php://stdin\");\n\n$len = strlen ($input);\n$result = '';\n$prew = '';\nfor($i = 0; $i < $len; $i++){\n if($input[$i] == '.'){\n if($prew){\n $result .= $prew . '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n $prew = '';\n } else if($input[$i] == ','){\n if($prew == ', '){\n $result .= $prew;\n }\n $prew = ', ';\n } else if($input[$i] == ' '){\n if(!$prew){\n $prew = ' ';\n }\n } else {\n if($prew == ', ' || $result[strlen ($result) - 1] != '.'){\n $result .= $prew;\n }\n $result .= $input[$i];\n $prew = '';\n }\n}\necho trim($result);\n?>"}, {"source_code": "= 0; $x--)\n{\n if(($b[$x] == \",\") && (($b[$x - 1] == \" \")))\n {\n array_splice($b, $x - 1, 1);\n $x++;\n }\n}\nfor($x = 0; $x < count($b); $x++)\n{\n if(($b[$x] == \",\") && ($b[$x + 1] == \",\"))\n {\n $b[$x] = \", \";\n }\n}\nprint implode($b);\n?>"}, {"source_code": ""}, {"source_code": "= 0; $x--)\n{\n if(($b[$x] == \",\") && (($b[$x - 1] == \" \")))\n {\n array_splice($b, $x - 1, 1);\n $x++;\n }\n}\nprint implode($b);\n?>"}, {"source_code": "= 0; $x--)\n{\n if(($b[$x] == \",\") && (($b[$x - 1] == \" \")))\n {\n array_splice($b, $x - 1, 1);\n $x++;\n }\n}\nfor($x = 0; $x < count($b); $x++)\n{\n if(($b[$x] == \",\") && ($b[$x + 1] == \",\"))\n {\n $b[$x] = \", \";\n }\n}\nprint implode($b);\n?>"}, {"source_code": "= 0; $x--)\n{\n if(($b[$x] == \",\") && (($b[$x - 1] == \" \")))\n {\n array_splice($b, $x - 1, 1);\n $x++;\n }\n}\nfor($x = 0; $x < count($b); $x++)\n{\n if(($b[$x] == \",\") && ($b[$x + 1] == \",\"))\n {\n $b[$x] = \", \";\n }\n}\nprint implode($b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " ' ...',\n '/(\\\\s*,\\\\s*)/s' => ', ',\n '/\\\\s{2,}/s' => ' ',\n);\n$str = fgets(STDIN);\n$str = preg_replace(array_keys($rx), array_values($rx), $str);\nfwrite(STDOUT, trim($str));"}, {"source_code": " ' ...',\n '/(\\\\s*,\\\\s*)/s' => ', ',\n '/\\\\s\\\\s/s' => ' ',\n);\n$str = fgets(STDIN);\n$str = preg_replace(array_keys($rx), array_values($rx), $str);\nfwrite(STDOUT, trim($str));"}, {"source_code": ""}, {"source_code": "\n$input = file_get_contents(\"php://stdin\");\n\n$len = strlen ($input);\n$result = '';\n$prew = '';\nfor($i = 0; $i < $len; $i++){\n if($input[$i] == '.'){\n if($prew){\n $result .= $prew . '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n $prew = '';\n } else if($input[$i] == ','){\n if($prew == ', '){\n $result .= $prew;\n }\n $prew = ', ';\n } else if($input[$i] == ' '){\n if(!$prew){\n $prew = ' ';\n }\n } else {\n if($prew && $result[strlen ($result) - 1] != '.'){\n $result .= $prew;\n }\n $result .= $input[$i];\n $prew = '';\n }\n}\necho trim($result);\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$input = file_get_contents(\"php://stdin\");\n$input = str_replace(\" \", \"\", $input);\n\n$len = strlen ($input);\n$result = '';\nfor($i = 0; $i < $len; $i++){\n //echo $input[$i];\n if($input[$i] == '.'){\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd';\n if($i < 1 || $input[$i - 1] == ','){\n $result .= '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n } else if($input[$i] == ','){\n $result .= ', ';\n } else {\n $result .= $input[$i];\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd';\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n }\n \n \n //echo \"\\n\";\n}\n\necho $result;\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$input = file_get_contents(\"php://stdin\");\n$input = str_replace(\" \", \"\", $input);\n\n$len = strlen ($input);\n$result = '';\nfor($i = 0; $i < $len; $i++){\n //echo $input[$i];\n if($input[$i] == '.'){\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd';\n if($i < 1 || $input[$i - 1] == ','){\n $result .= '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n } else if($input[$i] == ','){\n if(isset($input[$i + 1])){\n\t\t\t$result .= ', ';\n\t\t} else {\n\t\t\t$result .= ',';\n\t\t}\n } else {\n $result .= $input[$i];\n if($input[$i + 1] == ','){\n $i++;\n $result .= ', ';\n }\n }\n \n \n //echo \"\\n\";\n}\n\necho trim($result);\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$input = file_get_contents(\"php://stdin\");\n$input = str_replace(\" \", \"\", $input);\n\n$len = strlen ($input);\n$result = '';\nfor($i = 0; $i < $len; $i++){\n //echo $input[$i];\n if($input[$i] == '.'){\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd';\n if($i > 1 && $input[$i - 1] == ','){\n $result .= '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n } else if($input[$i] == ','){\n $result .= ', ';\n } else {\n $result .= $input[$i];\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd';\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n }\n \n \n //echo \"\\n\";\n}\n\necho $result;\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}, {"source_code": "\n$input = file_get_contents(\"php://stdin\");\n\n$len = strlen ($input);\n$result = '';\n$prew = '';\nfor($i = 0; $i < $len; $i++){\n if($input[$i] == '.'){\n if($prew){\n $result .= $prew . '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n $prew = '';\n } else if($input[$i] == ','){\n if($prew == ', '){\n $result .= $prew;\n }\n $prew = ', ';\n } else if($input[$i] == ' '){\n if(!$prew){\n $prew = ' ';\n }\n } else {\n $result .= $prew . $input[$i];\n $prew = '';\n }\n}\necho trim($result);\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$input = file_get_contents(\"php://stdin\");\n$input = str_replace(\" \", \"\", $input);\n\n$len = strlen ($input);\n$result = '';\nfor($i = 0; $i < $len; $i++){\n //echo $input[$i];\n if($input[$i] == '.'){\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd';\n if($input[$i - 1] == ','){\n $result .= '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n if($i > 1 && $input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n } else if($input[$i] == ','){\n $result .= ', ';\n } else {\n $result .= $input[$i];\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd';\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n }\n \n \n //echo \"\\n\";\n}\n\necho $result;\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$string = file_get_contents(\"php://stdin\");\n\n$patterns[0] = \"/(\\s+),/\";\n$patterns[1] = \"/,/\";\n$patterns[2] = \"/(\\.\\.\\.)/\";\n$patterns[3] = \"/(\\s+)/\";\n\n\n$replacements[3] = \",\";\n$replacements[2] = \", \";\n$replacements[1] = \" ...\";\n$replacements[0] = \" \";\n\necho trim(preg_replace($patterns, $replacements, $string));\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}, {"source_code": "\n/*\n$start_time = microtime();\n$start_array = explode(\" \",$start_time);\n$time['start'] = $start_array[1] + $start_array[0];*/\n\n$input = file_get_contents(\"php://stdin\");\n$input = str_replace(\" \", \"\", $input);\n\n$len = strlen ($input);\n$result = '';\nfor($i = 0; $i < $len; $i++){\n //echo $input[$i];\n if($input[$i] == '.'){\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd';\n if($i < 1 || $input[$i - 1] == ','){\n $result .= '...';\n } else {\n $result .= ' ...';\n }\n $i += 2;\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n } else if($input[$i] == ','){\n if(isset($input[$i + 1])){\n\t\t\t$result .= ', ';\n\t\t} else {\n\t\t\t$result .= ',';\n\t\t}\n } else {\n $result .= $input[$i];\n //echo ' \ufffd\ufffd\ufffd\ufffd\ufffd';\n if($input[$i + 1] == ','){\n //echo ' \ufffd\ufffd\ufffd';\n $i++;\n $result .= ', ';\n }\n }\n \n \n //echo \"\\n\";\n}\n\necho $result;\n/*\n$end_time = microtime();\n$end_array = explode(\" \",$end_time);\n$time['gener_class'] = $end_array[1] + $end_array[0];\necho $time_gener['class'] = round($time['gener_class']-$time['start'],5);*/\n?>"}], "src_uid": "c7d8c71a1f7e6c7364cce5bddd488a2f"} {"nl": {"description": "Polycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he has recently installed a widget that can display n photos with the scroll option. At each moment of time the widget displays exactly one photograph with the option showing the previous/next one. From the first photo, you can switch to the second one or to the n-th one, from the second photo you can switch to the third one or to the first one, etc. Thus, navigation is performed in a cycle.Polycarp's collection consists of m photo albums, the i-th album contains ai photos. Polycarp wants to choose n photos and put them on a new widget. To make watching the photos interesting to the visitors, he is going to post pictures so that no two photos from one album were neighboring (each photo will have exactly two neighbors, the first photo's neighbors are the second and the n-th one).Help Polycarp compile a photo gallery. Select n photos from his collection and put them in such order that no two photos from one album went one after the other.", "input_spec": "The first line contains two integers n and m (3\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009m\u2009\u2264\u200940), where n is the number of photos on the widget, and m is the number of albums. The second line contains m integers a1,\u2009a2,\u2009...,\u2009am (1\u2009\u2264\u2009ai\u2009\u2264\u20091000), where ai is the number of photos in the i-th album.", "output_spec": "Print the single number -1 if there is no solution. Otherwise, print n numbers t1,\u2009t2,\u2009...,\u2009tn, where ti represents the number of the album of the i-th picture in the widget. The albums are numbered from 1 in the order of their appearance in the input. If there are several solutions, print any of them.", "sample_inputs": ["4 3\n1 3 5", "10 2\n5 5", "10 3\n1 10 3"], "sample_outputs": ["3 1 3 2", "2 1 2 1 2 1 2 1 2 1", "-1"], "notes": null}, "positive_code": [{"source_code": " $a)\n{\n for($x = 0; $x <= count($e) - $a; $x++)\n {\n $i = array_slice($e, $x, $a);\n $j = $i[0];\n $k = $i[$a - 1];\n $l = 0;\n if($j == $k)\n {\n $i = array_slice($i, 1);\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if(($i[$y] != $j) && ($i[$y + 1] != $j))\n {\n $l = 1;\n $m = array_slice($i, 0, $y + 1);\n $n = array_slice($i, $y + 1);\n break;\n }\n }\n array_push($m, $j);\n $o = array_merge($m, $n);\n if($l == 1)\n {\n break;\n }\n }\n else\n {\n $l = 2;\n break;\n }\n }\n if($l == 0)\n {\n print \"-1\";\n }\n elseif($l == 1)\n {\n print implode(\" \", $o);\n }\n elseif($l == 2)\n {\n print implode(\" \", $i);\n }\n}\n?>"}, {"source_code": "\n\n$str1 = trim(fgets(STDIN));\n$str2 = trim(fgets(STDIN));\n//$str1 = '11 5';\n//$str2 = '3 2 3 2 2';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n\n$i=-1;\nforeach($arr as $key=>$value){\n $i++;\n $arr3[$i]=$value;\n $arr4[$i]=$key;\n}\n$arr=$arr3;\n\n$max=$arr[sizeof($arr)-1];\n//print_r($arr); echo '
';\n//print_r($arr3); echo '
';\n//print_r($arr4); echo '
';\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n //echo $k.' ';\n echo $arr4[$k].' ';\n }\n}\n\n?>"}], "negative_code": [{"source_code": " $a)\n{\n for($x = 0; $x <= count($e) - $a; $x++)\n {\n $i = array_slice($e, $x, $a);\n $j = $i[0];\n $k = $i[$a - 1];\n if($j != $k)\n {\n break;\n }\n }\n print implode(\" \", $i);\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $a)\n{\n for($x = 0; $x <= count($e) - $a; $x++)\n {\n $i = array_slice($e, $x, $a);\n $j = $i[0];\n $k = $i[$a - 1];\n $l = 0;\n if($j == $k)\n {\n $i = array_slice($i, 1);\n for($y = 0; $y < count($i) - 1; $y++)\n {\n if(($i[$y] != $j) && ($i[$y + 1] != $j))\n {\n $l = 1;\n $m = array_slice($i, 0, $y + 1);\n $n = array_slice($i, $y + 1);\n break;\n }\n }\n array_push($m, $j);\n $o = array_merge($m, $n);\n if($l == 1)\n {\n break;\n }\n }\n else\n {\n break;\n }\n }\n if($l == 0)\n {\n print \"-1\";\n }\n else\n {\n print implode(\" \", $o);\n }\n}\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\n$max=100;\n/*for ($i=1;$i$max ) { $max=$arr[$i]; }\n}*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=1;\n while ( ($jj<=$kol) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj++;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\n/*\nfor ($i=0;$i $max ) { $max=$arr[$i]; }\n }\n}*/\n$max=50;\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=1;\n while ( ($jj<=$kol) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj++;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol=$ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=9; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=1;\n while ( ($jj<=$kol) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj++;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n$str = fgets(STDIN);\necho $str\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\n\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '6 3';\n//$str2 = '1 2 3';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nsort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n//$str1 = fgets(STDIN);\n//$str2 = fgets(STDIN);\n$str1 = '4 3';\n$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\nprint_r($arr); echo '
';\necho $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = trim(fgets(STDIN));\n$str2 = trim(fgets(STDIN));\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '4 3';\n//$str2 = '1 3 5';\necho $str1.'
';\necho $str2.'
';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\nprint_r($arr); echo '
';\necho $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = trim(fgets(STDIN));\n$str2 = trim(fgets(STDIN));\n//$str1 = '11 5';\n//$str2 = '3 2 3 2 2';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n\n$arr3=array();\nforeach($arr as $key=>$value){\n $arr3[]=$value;\n}\n$arr=$arr3;\n\n$max=$arr[sizeof($arr)-1];\n//print_r($arr3); echo '
';\n//echo 'm:'.$max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nsort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n$arr = explode('0 '.$str2,' ');\n$ak = explode($str1,' ');\n$k = $ak['0'];\n$kol=$ak['1'];\n\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=9; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=1;\n while ( ($jj<=$kol) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj++;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(trim(STDIN));\n$str2 = fgets(trim(STDIN));\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n//$str1 = fgets(STDIN);\n//$str2 = fgets(STDIN);\n$str1 = '4 3';\n$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}, {"source_code": "\n\n$str1 = fgets(STDIN);\n$str2 = fgets(STDIN);\n//$str1 = '4 3';\n//$str2 = '1 3 5';\n\n$ak = explode(' ',$str1);\n$k = $ak['0'];\n$kol = $ak['1'];\n\n$arr = explode(' ','0 '.$str2);\n\n###########################################\nasort($arr);\n$max=$arr[$kol];\n//print_r($arr); echo '
';\n//echo $max; echo '
';\n\n/*\nfor ($i=1;$i$max ) { $max=$arr[$i]; }\n}\n*/\n\n$arr2 = array();\n$possible=1;\n\nfor($i=1;$i<=$k;$i++) {\n\n $j=$max; $e=0;\n while ( ($j>=1) && ($e==0) ) {\n $jj=$kol;\n while ( ($jj>=1) && ($e==0) ) { //\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\n if ( $arr[$jj]==$j ) { //\u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e \u0444\u043e\u0442\u043e\u043a \u0432 \u0442\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\n\n if ( $i==1 ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n } else if ( $i<$k ) {\n if ( $jj != $arr2[$i-1] ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n } else {\n if ( ($jj != $arr2[$i-1]) && ($jj != $arr2[1]) ) {\n $e=1; $arr2[$i]=$jj; $arr[$jj]=$arr[$jj]-1;\n }\n }\n\n }\n $jj--;\n }\n $j--;\n }\n if ( $e==0 ) { $possible=0; }\n\n}\n\nif ( $possible == 0 ) {\n echo '-1';\n} else {\n foreach($arr2 as $v=>$k) {\n echo $k.' ';\n }\n}\n\n?>"}], "src_uid": "2e99f0b671c80da1e768fa9bc7796481"} {"nl": {"description": "The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k\u2009\u00d7\u2009n\u2009\u00d7\u2009m, that is, it has k layers (the first layer is the upper one), each of which is a rectangle n\u2009\u00d7\u2009m with empty squares ('.') and obstacles ('#'). The water can only be present in the empty squares. The tap is positioned above the square (x,\u2009y) of the first layer, it is guaranteed that this square is empty. Every minute a cubical unit of water falls into the plate. Find out in how many minutes the Serial Guy should unglue himself from the soap opera and turn the water off for it not to overfill the plate. That is, you should find the moment of time when the plate is absolutely full and is going to be overfilled in the next moment.Note: the water fills all the area within reach (see sample 4). Water flows in each of the 6 directions, through faces of 1\u2009\u00d7\u20091\u2009\u00d7\u20091 cubes.", "input_spec": "The first line contains three numbers k, n, m (1\u2009\u2264\u2009k,\u2009n,\u2009m\u2009\u2264\u200910) which are the sizes of the plate. Then follow k rectangles consisting of n lines each containing m characters '.' or '#', which represents the \"layers\" of the plate in the order from the top to the bottom. The rectangles are separated by empty lines (see the samples). The last line contains x and y (1\u2009\u2264\u2009x\u2009\u2264\u2009n,\u20091\u2009\u2264\u2009y\u2009\u2264\u2009m) which are the tap's coordinates. x is the number of the line and y is the number of the column. Lines of each layer are numbered from left to right by the integers from 1 to n, columns of each layer are numbered from top to bottom by the integers from 1 to m.", "output_spec": "The answer should contain a single number, showing in how many minutes the plate will be filled.", "sample_inputs": ["1 1 1\n\n.\n\n1 1", "2 1 1\n\n.\n\n#\n\n1 1", "2 2 2\n\n.#\n##\n\n..\n..\n\n1 1", "3 2 2\n\n#.\n##\n\n#.\n.#\n\n..\n..\n\n1 2", "3 3 3\n\n.#.\n###\n##.\n\n.##\n###\n##.\n\n...\n...\n...\n\n1 1"], "sample_outputs": ["1", "1", "5", "7", "13"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "3f6e5f6d9a35c6c9e71a7eeab4acf199"} {"nl": {"description": "You are given a permutation $$$p=[p_1, p_2, \\ldots, p_n]$$$ of integers from $$$1$$$ to $$$n$$$. Let's call the number $$$m$$$ ($$$1 \\le m \\le n$$$) beautiful, if there exists two indices $$$l, r$$$ ($$$1 \\le l \\le r \\le n$$$), such that the numbers $$$[p_l, p_{l+1}, \\ldots, p_r]$$$ is a permutation of numbers $$$1, 2, \\ldots, m$$$.For example, let $$$p = [4, 5, 1, 3, 2, 6]$$$. In this case, the numbers $$$1, 3, 5, 6$$$ are beautiful and $$$2, 4$$$ are not. It is because: if $$$l = 3$$$ and $$$r = 3$$$ we will have a permutation $$$[1]$$$ for $$$m = 1$$$; if $$$l = 3$$$ and $$$r = 5$$$ we will have a permutation $$$[1, 3, 2]$$$ for $$$m = 3$$$; if $$$l = 1$$$ and $$$r = 5$$$ we will have a permutation $$$[4, 5, 1, 3, 2]$$$ for $$$m = 5$$$; if $$$l = 1$$$ and $$$r = 6$$$ we will have a permutation $$$[4, 5, 1, 3, 2, 6]$$$ for $$$m = 6$$$; it is impossible to take some $$$l$$$ and $$$r$$$, such that $$$[p_l, p_{l+1}, \\ldots, p_r]$$$ is a permutation of numbers $$$1, 2, \\ldots, m$$$ for $$$m = 2$$$ and for $$$m = 4$$$. You are given a permutation $$$p=[p_1, p_2, \\ldots, p_n]$$$. For all $$$m$$$ ($$$1 \\le m \\le n$$$) determine if it is a beautiful number or not.", "input_spec": "The first line contains the only integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u00a0\u2014 the number of test cases in the input. The next lines contain the description of test cases. The first line of a test case contains a number $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$)\u00a0\u2014 the length of the given permutation $$$p$$$. The next line contains $$$n$$$ integers $$$p_1, p_2, \\ldots, p_n$$$ ($$$1 \\le p_i \\le n$$$, all $$$p_i$$$ are different)\u00a0\u2014 the given permutation $$$p$$$. It is guaranteed, that the sum of $$$n$$$ from all test cases in the input doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "Print $$$t$$$ lines\u00a0\u2014 the answers to test cases in the order they are given in the input. The answer to a test case is the string of length $$$n$$$, there the $$$i$$$-th character is equal to $$$1$$$ if $$$i$$$ is a beautiful number and is equal to $$$0$$$ if $$$i$$$ is not a beautiful number.", "sample_inputs": ["3\n6\n4 5 1 3 2 6\n5\n5 3 1 2 4\n4\n1 4 3 2"], "sample_outputs": ["101011\n11111\n1001"], "notes": "NoteThe first test case is described in the problem statement.In the second test case all numbers from $$$1$$$ to $$$5$$$ are beautiful: if $$$l = 3$$$ and $$$r = 3$$$ we will have a permutation $$$[1]$$$ for $$$m = 1$$$; if $$$l = 3$$$ and $$$r = 4$$$ we will have a permutation $$$[1, 2]$$$ for $$$m = 2$$$; if $$$l = 2$$$ and $$$r = 4$$$ we will have a permutation $$$[3, 1, 2]$$$ for $$$m = 3$$$; if $$$l = 2$$$ and $$$r = 5$$$ we will have a permutation $$$[3, 1, 2, 4]$$$ for $$$m = 4$$$; if $$$l = 1$$$ and $$$r = 5$$$ we will have a permutation $$$[5, 3, 1, 2, 4]$$$ for $$$m = 5$$$. "}, "positive_code": [{"source_code": " $d)\n {\n $d = $g;\n }\n if($g < $e)\n {\n $e = $g;\n }\n if($d - $e + 1 == $y + 1)\n {\n $h .= \"1\";\n }\n else\n {\n $h .= \"0\";\n }\n $f = next($c);\n }\n print $h . \"\\n\";\n}\n?>"}, {"source_code": "=0 && $r<=$n) {\n if ($a[$l - 1] >$a[$r+1]) {\n $r++;\n if ($max < $a[$r]) {\n $max = $a[$r];\n }\n if ($max == ($r - $l+1)) {\n $vis[$max] = 1;\n }\n } else {\n $l--;\n if ($max < $a[$l]) {\n $max = $a[$l];\n }\n if ($max == ($r - $l + 1)) {\n $vis[$max] = 1;\n }\n\n }\n }\n $vis[$min]=1;\n $vis[$n]=1;\n for($i=0;$i<$n;$i++)\n {\n if(isset($vis[$i+1]))\n {\n echo '1';\n }else\n {\n echo '0';\n }\n }\n echo \"\\n\";\n}\n\n\n\n"}, {"source_code": "=-1 && $r<=$n+1) {\n if ($a[$l - 1] >$a[$r+1]) {\n $r++;\n if ($max < $a[$r]) {\n $max = $a[$r];\n }\n if ($max == ($r - $l+1)) {\n $vis[$max] = 1;\n }\n } else {\n $l--;\n if ($max < $a[$l]) {\n $max = $a[$l];\n }\n if ($max == ($r - $l + 1)) {\n $vis[$max] = 1;\n }\n\n }\n }\n $vis[$min]=1;\n $vis[$n]=1;\n for($i=0;$i<$n;$i++)\n {\n if(isset($vis[$i+1]))\n {\n echo '1';\n }else\n {\n echo '0';\n }\n }\n echo \"\\n\";\n}\n\n\n\n"}, {"source_code": "$a[$r+1]) {\n $r++;\n if ($max < $a[$r]) {\n $max = $a[$r];\n }\n if ($max == ($r - $l + 1)) {\n $vis[$max] = 1;\n }\n } else {\n $l--;\n if ($max < $a[$l]) {\n $max = $a[$l];\n }\n if ($max == ($r - $l + 1)) {\n $vis[$max] = 1;\n }\n\n }\n }\n $vis[$min]=1;\n $vis[$n]=1;\n for($i=0;$i<$n;$i++)\n {\n if(isset($vis[$i+1]))\n {\n echo '1';\n }else\n {\n echo '0';\n }\n }\n echo \"\\n\";\n}\n\n\n\n"}], "src_uid": "ea3ce069895b6fc0f354f0118c7c9fff"} {"nl": {"description": "Polycarp's workday lasts exactly $$$n$$$ minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has $$$k$$$ bars at the beginning of the workday.In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that $$$k$$$ is strictly greater than $$$1$$$.Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.Consider that Polycarp eats a bar in the minute $$$x$$$ and the next bar in the minute $$$y$$$ ($$$x < y$$$). Then the break time is equal to $$$y - x - 1$$$ minutes. It is not necessary for Polycarp to eat all bars he has.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\le n \\le 200\\,000$$$, $$$2 \\le k \\le n$$$) \u2014 the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday. The second line contains the string with length $$$n$$$ consisting of zeros and ones. If the $$$i$$$-th symbol in the string equals to zero, Polycarp has no important things to do in the minute $$$i$$$ and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute $$$i$$$ and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.", "output_spec": "Print the minimum possible break in minutes between eating chocolate bars.", "sample_inputs": ["3 3\n010", "8 3\n01010110"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.In the second example Polycarp will eat bars in the minutes $$$1$$$ and $$$8$$$ anyway, also he needs to eat the chocolate bar in the minute $$$5$$$, so that the time of the maximum break will be equal to $$$3$$$ minutes."}, "positive_code": [{"source_code": "= $N - 1) break;\n if($seq[$i] == '1') {\n if($lim == $i) {\n $cost = $K + 1;\n }\n }\n if($rp[$lim] == $i) {\n ++$cost;\n $prev = $i;\n }\n }\n if($cost <= $K) {\n $ans = $mid;\n $ub = $mid - 1;\n } else {\n $lb = $mid + 1;\n }\n }\n echo $ans;\n?> "}, {"source_code": " $ansl)\n{\n $intv = (int) (($ansl + $ansr) / 2); \n $r = $k - 1;\n \n for($i = 0; $i < $n - 1;)\n {\n $pos = -1;\n \n for($j = min($i + $intv + 1, $n - 1); $j >= $i + 1; --$j)\n if($s[$j] == '0')\n {\n $pos = $j;\n break;\n }\n \n if($pos == -1 || $r == 0)\n {\n $pos = -1;\n break;\n }\n else\n {\n --$r;\n $i = $pos;\n }\n }\n \n if($pos != -1)\n $ansr = $intv;\n else\n $ansl = $intv + 1;\n}\n\necho $ansr;\n\n?>"}, {"source_code": " 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 2 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n $qq = true;\n for ($i = 0; $i < $n; $i++) {\n if ($s[$i] == '1') {\n $qq = false;\n }\n }\n if ($qq && $n == $k) $e = 0;\n echo $e;\n?> "}], "negative_code": [{"source_code": " 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 2 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n $qq = true;\n for ($i = 0; $i < $n; $i++) {\n if ($s[$i] == '1') {\n $qq = false;\n }\n }\n if ($qq && $n == $k) $e = 0;\n echo $e;\n?> "}, {"source_code": " $mm) {\n if ($kk > 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 2 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n echo $e;\n?> "}, {"source_code": " $mm) {\n if ($kk > 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 2 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n $qq = true;\n for ($i = 0; $i < $n; $i++) {\n if ($s[$i] == '1') {\n $qq = false;\n }\n }\n if ($qq && $n == $k) $e = 0;\n echo $e;\n?> "}, {"source_code": " $mm) {\n if ($kk > 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 1 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n $qq = true;\n for ($i = 0; $i < $n; $i++) {\n if ($s[$i] == '1') {\n $qq = false;\n }\n }\n if ($qq && $n == $k) $e = 0;\n echo $e;\n?> "}, {"source_code": " $mm) {\n if ($kk > 0 && $possible != -1) {\n $kk--;\n $lastq = $possible;\n $possible = -1;\n } else {\n $q = false;\n break;\n }\n }\n }\n if ($q && $n - $lastq - 2 > $mm) $q = false;\n if ($q) $e = $mm; else $b = $mm;\n }\n $qq = true;\n for ($i = 0; $i < $n; $i++) {\n if ($s[$i] == '1') {\n $qq = false;\n }\n }\n if ($qq && $n == $k) $e = 0;\n echo $e;\n?> "}], "src_uid": "e33b0a752dc1aba25da21e20435e3fe2"} {"nl": {"description": "This problem is same as the previous one, but has larger constraints.Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.For each of the $$$n$$$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $$$i$$$-th day has a ribbon with color $$$u_i$$$. Shiro wants to know the largest number $$$x$$$, such that if we consider the streak of the first $$$x$$$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $$$x - 1$$$ will have the same number of occurrences.For example, consider the following sequence of $$$u_i$$$: $$$[2, 2, 1, 1, 5, 4, 4, 5]$$$. Then $$$x = 7$$$ makes a streak, since if we remove the leftmost $$$u_i = 5$$$, each ribbon color will appear exactly twice in the prefix of $$$x - 1$$$ days. Note that $$$x = 8$$$ doesn't form a streak, since you must remove exactly one day. Since Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the total number of days. The second line contains $$$n$$$ integers $$$u_1, u_2, \\ldots, u_n$$$ ($$$1 \\leq u_i \\leq 10^5$$$)\u00a0\u2014 the colors of the ribbons the cats wear. ", "output_spec": "Print a single integer $$$x$$$\u00a0\u2014 the largest possible streak of days.", "sample_inputs": ["13\n1 1 1 2 2 2 3 3 3 4 4 4 5", "5\n10 100 20 200 1", "1\n100000", "7\n3 2 1 1 4 5 1", "6\n1 1 1 2 2 2"], "sample_outputs": ["13", "5", "1", "6", "5"], "notes": "NoteIn the first example, we can choose the longest streak of $$$13$$$ days, since upon removing the last day out of the streak, all of the remaining colors $$$1$$$, $$$2$$$, $$$3$$$, and $$$4$$$ will have the same number of occurrences of $$$3$$$. Note that the streak can also be $$$10$$$ days (by removing the $$$10$$$-th day from this streak) but we are interested in the longest streak.In the fourth example, if we take the streak of the first $$$6$$$ days, we can remove the third day from this streak then all of the remaining colors $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$ and $$$5$$$ will occur exactly once."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "886d8d7103f0a7403b06b80b914ee498"} {"nl": {"description": "You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B.A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, \"cotst\" is a subsequence of \"contest\".A palindrome is a string that reads the same forward or backward.The length of string B should be at most 104. It is guaranteed that there always exists such string.You do not need to find the shortest answer, the only restriction is that the length of string B should not exceed 104.", "input_spec": "First line contains a string A (1\u2009\u2264\u2009|A|\u2009\u2264\u2009103) consisting of lowercase Latin letters, where |A| is a length of A.", "output_spec": "Output single line containing B consisting of only lowercase Latin letters. You do not need to find the shortest answer, the only restriction is that the length of string B should not exceed 104. If there are many possible B, print any of them.", "sample_inputs": ["aba", "ab"], "sample_outputs": ["aba", "aabaa"], "notes": "NoteIn the first example, \"aba\" is a subsequence of \"aba\" which is a palindrome.In the second example, \"ab\" is a subsequence of \"aabaa\" which is a palindrome."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "9b1887582a9eb7cff49994ddcc2ee9b8"} {"nl": {"description": "Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-digit?", "input_spec": "The first line contains the only integer n (0\u2009\u2264\u2009n\u2009\u2264\u200910100000). It is guaranteed that n doesn't contain any leading zeroes.", "output_spec": "Print the number of times a number can be replaced by the sum of its digits until it only contains one digit.", "sample_inputs": ["0", "10", "991"], "sample_outputs": ["0", "1", "3"], "notes": "NoteIn the first sample the number already is one-digit \u2014 Herald can't cast a spell.The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.The third test contains number 991. As one casts a spell the following transformations take place: 991\u2009\u2192\u200919\u2009\u2192\u200910\u2009\u2192\u20091. After three transformations the number becomes one-digit."}, "positive_code": [{"source_code": " 1)\n {\n $c++;\n $b = str_split(array_sum($b));\n $x = 1;\n }\n else\n {\n break;\n } \n}\nprint $c;\n?>"}, {"source_code": "= 10)\n{\n $input = numsum($input);\n $c++;\n}\n\necho $c;"}, {"source_code": " 1) {\n$data = (string) array_sum(str_split($data));\n\t$i++;\n}\necho $i;\n"}, {"source_code": " 1){\n $count++;\n $tLine = digitalRoot($tLine, $len);\n }else{\n break;\n }\n }\n echo $count . PHP_EOL;\n}\n"}, {"source_code": "1){\n $s = sumstr(\"\".$s);\n $cnt++;\n}\n\necho $cnt;\n\n?>"}, {"source_code": "\n$str=trim(fgets(STDIN));\n$sum=0;\nif(strlen($str)==1) $cnt=0;\nelse $cnt=1;\nfor($i=0; $i 9){\n $str=(string)$sum;\n $sum=0;\n for($i=0; $i "}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n$lines=trim($lines);\n\n$res=0;\n\nwhile(strlen($lines)>1)\n{\n $new=0;\n for ($i=0; $i "}], "negative_code": [{"source_code": " 10)\n{\n $sum = numsum($sum);\n $c++;\n}\n\necho $c;"}, {"source_code": "= 10)\n{\n $sum = numsum($sum);\n $c++;\n}\n\necho $c;"}, {"source_code": "= 10)\n{\n $sum = numsum($sum);\n $c++;\n}\n\necho $c;"}, {"source_code": " 10)\n{\n $sum = numsum($sum);\n $c++;\n}\n\necho $c;"}, {"source_code": " 10)\n{\n $sum = numsum($sum);\n $c++;\n}\n\necho $c;"}, {"source_code": "= 10)\n{\n $input = numsum($input);\n $c++;\n}\n\necho $c;"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\necho $i . \"\\n\";\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\necho $i;\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\n\n\necho $i . \"\\n\";\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\necho $i;\n"}, {"source_code": " 1) {\n\t$data = (string) ((int) array_sum(str_split($data)));\n\t$i++;\n}\n\necho $i;\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\n\n\necho $i . \"\\n\";\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\necho $i;\necho PHP_EOL;"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\necho $i . \"\\r\\n\";\n"}, {"source_code": " 1) {\n\t$sum = 0;\n\tfor ($i = 0; $i < strlen($data); $i++) {\n\t\t$sum += (int) $data{$i};\n\t}\n\t$data = (string) $sum;\n\t$i++;\n}\n\n\n\necho $i . \"\\n\";\n"}, {"source_code": " 1) {\n\t$data = (string) array_sum(str_split($data));\n\t$i++;\n}\n\necho $i;\n"}], "src_uid": "ddc9201725e30297a5fc83f4eed75fc9"} {"nl": {"description": "As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n\u2009-\u20091 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.The \u00abTwo Paths\u00bb company, where Bob's brother works, has won a tender to repair two paths in Flatland. A path is a sequence of different cities, connected sequentially by roads. The company is allowed to choose by itself the paths to repair. The only condition they have to meet is that the two paths shouldn't cross (i.e. shouldn't have common cities).It is known that the profit, the \u00abTwo Paths\u00bb company will get, equals the product of the lengths of the two paths. Let's consider the length of each road equals 1, and the length of a path equals the amount of roads in it. Find the maximum possible profit for the company.", "input_spec": "The first line contains an integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009200), where n is the amount of cities in the country. The following n\u2009-\u20091 lines contain the information about the roads. Each line contains a pair of numbers of the cities, connected by the road ai,\u2009bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u2009n).", "output_spec": "Output the maximum possible profit.", "sample_inputs": ["4\n1 2\n2 3\n3 4", "7\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7", "6\n1 2\n2 3\n2 4\n5 4\n6 4"], "sample_outputs": ["1", "0", "4"], "notes": null}, "positive_code": [{"source_code": " %d\\n\", $v, $x);\n\t\t\tarray_push($lens, dfs($x, $v));\n\t\t}\n\trsort($lens);\n\t$k = count($lens);\n\tif ($k >= 2) {\n\t\t$bestlen = max($bestlen, $lens[0] + $lens[1] + 1);\n\t\t// printf(\"%d: %d + %d + 1 => %d\\n\", $v, $lens[0], $lens[1], $bestlen);\n\t}\n\treturn 1 + ($k > 0 ? $lens[0] : 0);\n}\n\nfunction solve($v) {\n\tglobal $bestlen;\n\t$bestlen = -1;\n\t$len = dfs($v);\n\t$bestlen = max($bestlen, $len);\n\t// printf($bestlen.\"\\n\");\n\treturn $bestlen - 1;\n}\n\n$ans = 0;\n$n = intval(fgets(STDIN));\n$m = $n - 1;\nfor ($i = 0; $i < $m; $i++) {\n\tfscanf(STDIN, \"%d %d\", $a[$i], $b[$i]);\n\t$a[$i]--; $b[$i]--;\n}\nfor ($j = 0; $j < $m; $j++) {\n\t$g = array_fill(0, $n, array());\n\tfor ($i = 0; $i < $m; $i++) \n\t\tif ($i != $j) {\n\t\t\tarray_push($g[$a[$i]], $b[$i]);\n\t\t\tarray_push($g[$b[$i]], $a[$i]);\n\t\t}\n\t// printf(\"j = %d : (%d, %d)\\n\", $j, $a[$j], $b[$j]);\n\t$ans = max($ans, solve($a[$j]) * solve($b[$j]));\n}\nprintf(\"%d\\n\", $ans);\n\n?>\n"}], "negative_code": [], "src_uid": "b07668a66a5e50659233ba055a893bd4"} {"nl": {"description": "Initially Ildar has an empty array. He performs $$$n$$$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. The mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, the mex of the multiset $$$[0, 2, 3]$$$ is $$$1$$$, while the mex of the multiset $$$[1, 2, 1]$$$ is $$$0$$$.More formally, on the step $$$m$$$, when Ildar already has an array $$$a_1, a_2, \\ldots, a_{m-1}$$$, he chooses some subset of indices $$$1 \\leq i_1 < i_2 < \\ldots < i_k < m$$$ (possibly, empty), where $$$0 \\leq k < m$$$, and appends the $$$mex(a_{i_1}, a_{i_2}, \\ldots a_{i_k})$$$ to the end of the array.After performing all the steps Ildar thinks that he might have made a mistake somewhere. He asks you to determine for a given array $$$a_1, a_2, \\ldots, a_n$$$ the minimum step $$$t$$$ such that he has definitely made a mistake on at least one of the steps $$$1, 2, \\ldots, t$$$, or determine that he could have obtained this array without mistakes.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 100\\,000$$$)\u00a0\u2014 the number of steps Ildar made. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the array Ildar obtained.", "output_spec": "If Ildar could have chosen the subsets on each step in such a way that the resulting array is $$$a_1, a_2, \\ldots, a_n$$$, print $$$-1$$$. Otherwise print a single integer $$$t$$$\u00a0\u2014 the smallest index of a step such that a mistake was made on at least one step among steps $$$1, 2, \\ldots, t$$$.", "sample_inputs": ["4\n0 1 2 1", "3\n1 0 1", "4\n0 1 2 239"], "sample_outputs": ["-1", "1", "4"], "notes": "NoteIn the first example it is possible that Ildar made no mistakes. Here is the process he could have followed. $$$1$$$-st step. The initial array is empty. He can choose an empty subset and obtain $$$0$$$, because the mex of an empty set is $$$0$$$. Appending this value to the end he gets the array $$$[0]$$$. $$$2$$$-nd step. The current array is $$$[0]$$$. He can choose a subset $$$[0]$$$ and obtain an integer $$$1$$$, because $$$mex(0) = 1$$$. Appending this value to the end he gets the array $$$[0,1]$$$. $$$3$$$-rd step. The current array is $$$[0,1]$$$. He can choose a subset $$$[0,1]$$$ and obtain an integer $$$2$$$, because $$$mex(0,1) = 2$$$. Appending this value to the end he gets the array $$$[0,1,2]$$$. $$$4$$$-th step. The current array is $$$[0,1,2]$$$. He can choose a subset $$$[0]$$$ and obtain an integer $$$1$$$, because $$$mex(0) = 1$$$. Appending this value to the end he gets the array $$$[0,1,2,1]$$$. Thus, he can get the array without mistakes, so the answer is $$$-1$$$.In the second example he has definitely made a mistake on the very first step, because he could not have obtained anything different from $$$0$$$.In the third example he could have obtained $$$[0, 1, 2]$$$ without mistakes, but $$$239$$$ is definitely wrong."}, "positive_code": [{"source_code": " $c)\n {\n $d = 1;\n break;\n }\n if($b[$x] == $c)\n {\n $c++;\n }\n }\n if($d == 0)\n {\n print \"-1\";\n }\n else\n {\n print $x + 1;\n }\n}\n?>"}], "negative_code": [], "src_uid": "e17427897fd5147c601204cb1c48b143"} {"nl": {"description": "Polycarp was given a row of tiles. Each tile contains one lowercase letter of the Latin alphabet. The entire sequence of tiles forms the string $$$s$$$.In other words, you are given a string $$$s$$$ consisting of lowercase Latin letters.Initially, Polycarp is on the first tile of the row and wants to get to the last tile by jumping on the tiles. Jumping from $$$i$$$-th tile to $$$j$$$-th tile has a cost equal to $$$|index(s_i) - index(s_j)|$$$, where $$$index(c)$$$ is the index of the letter $$$c$$$ in the alphabet (for example, $$$index($$$'a'$$$)=1$$$, $$$index($$$'b'$$$)=2$$$, ..., $$$index($$$'z'$$$)=26$$$) .Polycarp wants to get to the $$$n$$$-th tile for the minimum total cost, but at the same time make maximum number of jumps.In other words, among all possible ways to get to the last tile for the minimum total cost, he will choose the one with the maximum number of jumps.Polycarp can visit each tile at most once.Polycarp asks you to help\u00a0\u2014 print the sequence of indices of string $$$s$$$ on which he should jump.", "input_spec": "The first line of the input contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the test. Each test case is given by the string $$$s$$$ ($$$2 \\le |s| \\le 2 \\cdot 10^5$$$), where $$$|s|$$$\u00a0\u2014 is the length of string $$$s$$$. The string $$$s$$$ consists of lowercase Latin letters. It is guaranteed that the sum of string lengths $$$s$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "The answer to each test case consists of two lines. In the first line print two integers $$$cost$$$, $$$m$$$, where $$$cost$$$ is the minimum total cost of the path, and $$$m$$$ is the maximum number of visited tiles Polycarp can make to get to $$$n$$$-th tiles for the minimum total cost $$$cost$$$ (i.e. the number of jumps is $$$m-1$$$). In the next line print $$$m$$$ different numbers $$$j_1, j_2, \\dots, j_m$$$ ($$$1 \\le j_i \\le |s|$$$)\u00a0\u2014 the sequence of indices of the tiles Polycarp will jump on. The first number in the sequence must be $$$1$$$ (that is, $$$j_1=1$$$) and the last number must be the value of $$$|s|$$$ (that is, $$$j_m=|s|$$$). If there are multiple answers, print any of them.", "sample_inputs": ["6\n\nlogic\n\ncodeforces\n\nbca\n\naaaaaaaaaaa\n\nadbaadabad\n\nto"], "sample_outputs": ["9 4\n1 4 3 5\n16 10\n1 8 3 4 9 5 2 6 7 10\n1 2\n1 3\n0 11\n1 8 10 4 3 5 7 2 9 6 11\n3 10\n1 9 5 4 7 3 8 6 2 10\n5 2\n1 2"], "notes": "NoteIn the first test case, the required path corresponds to the picture: In this case, the minimum possible total cost of the path is achieved. Since $$$index($$$'l'$$$)=12$$$, $$$index($$$'o'$$$)=15$$$, $$$index($$$'g'$$$)=7$$$, $$$index($$$'i'$$$)=9$$$, $$$index($$$'c'$$$)=3$$$, then the total cost of the path is $$$|12-9|+|9-7|+|7-3|=3+2+4=9$$$."}, "positive_code": [{"source_code": " $item) {\n if (($start <= $end && $item < $start) || ($end <= $start && $item > $start)) {\n continue;\n }\n\n if (($start <= $end && $item > $end) || ($end <= $start && $item < $end)) {\n break;\n }\n\n $res[] = $key + 1;\n }\n\n fprintf(STDOUT, '%u %u'.PHP_EOL, abs($al[$end] - $al[$start]), count($res));\n fprintf(STDOUT, '%s'.PHP_EOL, implode(' ', $res));\n}\n/*\n\n1\naaaaaaaa\n0\n\n1\nab\n\n\n1\nlogac\n// 9 3\n// 1 3 5\n\n\na b c d e f g h i j k l m n o p q r s t u v w x y z\n\ncodeforces\nc o d e f o r c e s\n1 2 3 4 5 6 7 8 9 10\n\nc c d e e f o o r s // until the last last letter reached\n1 8 3 4 9 5 2 6 7 10\n\n\nlogic\n1 4 3 5\n\n\nlogac\n1 3 5\n\n */\n"}], "negative_code": [], "src_uid": "d17c9f91504e1d4c4eae7294bf09dcfc"} {"nl": {"description": "After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is H points, moreover each minute without food increases his hunger by D points.At any time Andrew can visit the store where tasty buns are sold (you can assume that is doesn't take time to get to the store and back). One such bun costs C roubles and decreases hunger by N points. Since the demand for bakery drops heavily in the evening, there is a special 20% discount for buns starting from 20:00 (note that the cost might become rational). Of course, buns cannot be sold by parts.Determine the minimum amount of money Andrew has to spend in order to feed his cat. The cat is considered fed if its hunger level is less than or equal to zero.", "input_spec": "The first line contains two integers hh and mm (00\u2009\u2264\u2009hh\u2009\u2264\u200923,\u200900\u2009\u2264\u2009mm\u2009\u2264\u200959) \u2014 the time of Andrew's awakening. The second line contains four integers H, D, C and N (1\u2009\u2264\u2009H\u2009\u2264\u2009105,\u20091\u2009\u2264\u2009D,\u2009C,\u2009N\u2009\u2264\u2009102).", "output_spec": "Output the minimum amount of money to within three decimal digits. You answer is considered correct, if its absolute or relative error does not exceed 10\u2009-\u20094. Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .", "sample_inputs": ["19 00\n255 1 100 1", "17 41\n1000 6 15 11"], "sample_outputs": ["25200.0000", "1365.0000"], "notes": "NoteIn the first sample Andrew can visit the store at exactly 20:00. The cat's hunger will be equal to 315, hence it will be necessary to purchase 315 buns. The discount makes the final answer 25200 roubles.In the second sample it's optimal to visit the store right after he wakes up. Then he'll have to buy 91 bins per 15 roubles each and spend a total of 1365 roubles."}, "positive_code": [{"source_code": ""}, {"source_code": " 0) {\n\t$current_hunger = $H + ($diff * $D);\n\t$c2 = ceil($current_hunger / $N) * $current_price;\n}\nelse {\n\t$c2 = ceil(1.0 * $H / $N) * $current_price;\n}\n\n\n\necho min($c1, $c2).\"\\n\";\n"}], "negative_code": [{"source_code": " 0) {\n\t$current_hunger = $H + ($diff * $D);\n\t$c2 = ceil(1.0 * $current_hunger / $N) * $current_price;\n}\nelse {\n\t$c2 = (1.0 * $H / $N) * $current_price;\n}\n\n\n\necho min($c1, $c2).\"\\n\";\n"}, {"source_code": " 0) {\n\t$current_hunger = $H + ($diff * $D);\n\t$current_price = $C - ($C*0.2);\n\t$c2 = ceil(1.0 * $current_hunger / $N) * $current_price;\n}\nelse {\n\t$c2 = (1.0 * $H / $N) * $current_price;\n}\n\n\n\necho min($c1, $c2).\"\\n\";\n"}], "src_uid": "937acacc6d5d12d45c08047dde36dcf0"} {"nl": {"description": "There is a $$$n \\times m$$$ grid. You are standing at cell $$$(1, 1)$$$ and your goal is to finish at cell $$$(n, m)$$$.You can move to the neighboring cells to the right or down. In other words, suppose you are standing at cell $$$(x, y)$$$. You can: move right to the cell $$$(x, y + 1)$$$\u00a0\u2014 it costs $$$x$$$ burles; move down to the cell $$$(x + 1, y)$$$\u00a0\u2014 it costs $$$y$$$ burles. Can you reach cell $$$(n, m)$$$ spending exactly $$$k$$$ burles?", "input_spec": "The first line contains the single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. The first and only line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1 \\le n, m \\le 100$$$; $$$0 \\le k \\le 10^4$$$)\u00a0\u2014 the sizes of grid and the exact amount of money you need to spend.", "output_spec": "For each test case, if you can reach cell $$$(n, m)$$$ spending exactly $$$k$$$ burles, print YES. Otherwise, print NO. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).", "sample_inputs": ["6\n1 1 0\n2 2 2\n2 2 3\n2 2 4\n1 4 3\n100 100 10000"], "sample_outputs": ["YES\nNO\nYES\nNO\nYES\nNO"], "notes": "NoteIn the first test case, you are already in the final cell, so you spend $$$0$$$ burles.In the second, third and fourth test cases, there are two paths from $$$(1, 1)$$$ to $$$(2, 2)$$$: $$$(1, 1)$$$ $$$\\rightarrow$$$ $$$(1, 2)$$$ $$$\\rightarrow$$$ $$$(2, 2)$$$ or $$$(1, 1)$$$ $$$\\rightarrow$$$ $$$(2, 1)$$$ $$$\\rightarrow$$$ $$$(2, 2)$$$. Both costs $$$1 + 2 = 3$$$ burles, so it's the only amount of money you can spend.In the fifth test case, there is the only way from $$$(1, 1)$$$ to $$$(1, 4)$$$ and it costs $$$1 + 1 + 1 = 3$$$ burles."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "8b0a9c7e997034d3ecce044b9f64aeba"} {"nl": {"description": "You are given a string $$$s$$$, consisting of brackets of two types: '(', ')', '[' and ']'.A string is called a regular bracket sequence (RBS) if it's of one of the following types: empty string; '(' + RBS + ')'; '[' + RBS + ']'; RBS + RBS. where plus is a concatenation of two strings.In one move you can choose a non-empty subsequence of the string $$$s$$$ (not necessarily consecutive) that is an RBS, remove it from the string and concatenate the remaining parts without changing the order.What is the maximum number of moves you can perform?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of testcases. Each of the next $$$t$$$ lines contains a non-empty string, consisting only of characters '(', ')', '[' and ']'. The total length of the strings over all testcases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each testcase print a single integer\u00a0\u2014 the maximum number of moves you can perform on a given string $$$s$$$.", "sample_inputs": ["5\n()\n[]()\n([)]\n)]([\n)[(]"], "sample_outputs": ["1\n2\n2\n0\n1"], "notes": "NoteIn the first example you can just erase the whole string.In the second example you can first erase the brackets on positions $$$1$$$ and $$$2$$$: \"[]()\", then \"()\" is left. After that you can erase it whole. You could erase the whole string from the beginning but you would get one move instead of two.In the third example you can first erase the brackets on positions $$$1$$$ and $$$3$$$: \"([)]\". They form an RBS \"()\". Then \"[]\" is left, so you can erase it whole.In the fourth example there is no subsequence that is an RBS, so you can't perform a move at all.In the fifth example you can erase the brackets on positions $$$2$$$ and $$$4$$$: \")[(]\" and get \")(\" as a result. You can erase nothing from it."}, "positive_code": [{"source_code": "0&&$str[$i]==')')\n\t{\n\t\t$cnt1++;\n\t\t$frstLeft--;\n\n\t}\n\telseif($scndLeft>0&&$str[$i]==']')\n\t{\n\t\t$cnt2++;\n\t\t$scndLeft--;\n\t}\n\n }\n echo $cnt1+$cnt2.\"\\n\";\n}"}, {"source_code": " 0) { $c++; $b1--; }\n\t\t\t\t//$b1_c = true;\n\t\t\t}\n\n\t\t\tif ($s[$i] == '[') {\n\t\t\t\t$b2++;\n\t\t\t\t$b2_c = true;\n\t\t\t}\n\t\t\tif ($s[$i] == ']') {\n\t\t\t\tif ($b2 > 0) { $c++; $b2--; }\n\t\t\t\t//$b2_c = true;\n\t\t\t}\n\t\t}\n\n\t\t\n\t\tprint $c.\"\\n\";\n\t}\n?>"}, {"source_code": " 0) {\n $square --;\n $turns++;\n }\n else if ($string[$j] == '(')\n $round++;\n else if ($string[$j] == ')' && $round > 0) {\n $round--;\n $turns++;\n }\n $j++;\n }\n array_push($result, $turns);\n}\n\nfor ($i = 0; $i < $number; $i++){\n echo $result[$i];\n if ($i < $number - 1)\n echo \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": ""}], "src_uid": "db9cec57d8ed5e914818ce9b439eb0f9"} {"nl": {"description": "Once Bob decided to lay a parquet floor in his living room. The living room is of size n\u2009\u00d7\u2009m metres. Bob had planks of three types: a planks 1\u2009\u00d7\u20092 meters, b planks 2\u2009\u00d7\u20091 meters, and c planks 2\u2009\u00d7\u20092 meters. Help Bob find out, if it is possible to parquet the living room with such a set of planks, and if it is possible, find one of the possible ways to do so. Bob doesn't have to use all the planks.", "input_spec": "The first input line contains 5 space-separated integer numbers n, m, a, b, c (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100,\u20090\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u2009104), n and m \u2014 the living room dimensions, a, b and c \u2014 amount of planks 1\u2009\u00d7\u20092, 2\u2009\u00d7\u20091 \u0438 2\u2009\u00d7\u20092 respectively. It's not allowed to turn the planks.", "output_spec": "If it is not possible to parquet the room with such a set of planks, output IMPOSSIBLE. Otherwise output one of the possible ways to parquet the room \u2014 output n lines with m lower-case Latin letters each. Two squares with common sides should contain the same letters, if they belong to one and the same plank, and different letters otherwise. Different planks can be marked with one and the same letter (see examples). If the answer is not unique, output any.", "sample_inputs": ["2 6 2 2 1", "1 1 100 100 100", "4 4 10 10 10"], "sample_outputs": ["aabcca\naabdda", "IMPOSSIBLE", "aabb\naabb\nbbaa\nbbaa"], "notes": null}, "positive_code": [{"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $j; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}], "negative_code": [{"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n $n3 = 50;\n for($x = 50; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print $v[0] . $v[1] . $v[2] . \" - \";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n for($x = 50; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n} \n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 0)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 0)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 0)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?> "}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?> "}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $n2 = array_fill(1, 50, \"a\");\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n else\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($a == 100)\n {\n print $d . \"\\n\";\n }\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?> "}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n $n3 = 50;\n for($x = 50; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n $w = 0;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($c <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n $w = 0;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($d <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n if($e > 0)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($c > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($c <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($d > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($d <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n $w = 0;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($c <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n $w = 0;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if($d <= 1)\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n if($e > 0)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($c > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($c <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($d > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($d <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n if($e > 0)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($c > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($c <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($d > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($d <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n if($e > 0)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($e <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($c > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 2] != NULL)\n {\n unset($t[$p[$r][$s - 2]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($c <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n $w = 0;\n if($d > 1)\n {\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n $w = 1;\n break;\n }\n }\n $r += 2;\n $s2 = $s;\n $s = 1;\n if($w == 1)\n {\n if(($d <= 0) && ($y != $k))\n {\n $r -= 2;\n $s = $s2;\n }\n break;\n }\n }\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s + 1] != NULL)\n {\n unset($t[$p[$r][$s + 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n for($x = 50; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if(($a == 56) && ($b == 59))\n {\n $n3 = 50;\n for($x = 50; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}, {"source_code": "= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k];\n $j .= $g[$k];\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelseif($b == 1)\n{\n $h = $a % 2;\n if($h == 0)\n {\n $i = $a / 2;\n if($d >= $i)\n {\n $j = \"\";\n $k = 0;\n $g = array_merge($g, $g);\n for($x = 0; $x < $i; $x++)\n {\n $j .= $g[$k] . \"\\n\";\n $j .= $g[$k] . \"\\n\";\n $k++;\n }\n print $j;\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n}\nelse\n{\n $h = $a % 2;\n $i = $b % 2;\n if(($h != 0) && ($i != 0))\n {\n print \"IMPOSSIBLE\";\n }\n elseif(($h != 0) && ($i == 0))\n {\n $j2 = $b / 2;\n if($c >= $j2)\n {\n $c -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = ($a - 1) / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x < $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $a2 = count($n2) / 2;\n $b2 = 1;\n $c2 = $p[1];\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n print implode($n2) . \"\\n\";\n for($x = 1; $x < $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i != 0))\n {\n $j2 = $a / 2;\n if($d >= $j2)\n {\n $d -= $j2;\n $k2 = array_merge($g, $g, $g, $g);\n $j = $a / 2;\n $k = ($b - 1) / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b - 1, \"a\");\n $p[$x] = $q;\n }\n $l2 = 1;\n $m2 = 0;\n $n2 = array();\n for($x = 1; $x <= $k; $x++)\n {\n $n2[$l2] = $k2[$m2];\n $l2++;\n $n2[$l2] = $k2[$m2];\n $l2++;\n $m2++;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1;\n }\n $n3 = 1;\n $n4 = array();\n for($x = 1; $x <= $a; $x++)\n {\n $n4[$x] = $p[$x][1];\n }\n $a2 = $a / 2;\n $b2 = 1;\n $c2 = $n4;\n $d2 = 1;\n for($x = 0; $x < $a2; $x++)\n {\n if(($n2[$b2] == $n2[$b2 - 1]) || ($n2[$b2] == $c2[$d2]) || ($n2[$b2] == $c2[$d2 + 1]) || ($n2[$b2 + 1] == $c2[$d2]) || ($n2[$b2 + 1] == $c2[$d2 + 1]))\n {\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n unset($t[$n2[$b2 - 1]]);\n unset($t[$n2[$b2]]);\n unset($t[$n2[$b2 + 1]]);\n unset($t[$c2[$d2]]);\n unset($t[$c2[$d2 + 1]]);\n $u = array_rand($t);\n $n2[$b2] = $u;\n $n2[$b2 + 1] = $u;\n }\n $b2 += 2;\n $d2 += 2;\n }\n if($a == 100)\n {\n $n3 = 96;\n for($x = 96; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n else\n {\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n array_unshift($v, $n2[$n3]);\n print implode($v) . \"\\n\";\n $n3++;\n }\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n elseif(($h == 0) && ($i == 0))\n {\n $j = $a / 2;\n $k = $b / 2;\n $l = $j * $k;\n $m = floor($c / 2);\n $n = floor($d / 2);\n $o = $m + $n + $e;\n if($o >= $l)\n {\n $p = array();\n for($x = 1; $x <= $a; $x++)\n {\n $q = array_fill(1, $b, \"a\");\n $p[$x] = $q;\n }\n $r = 1;\n $s = 1;\n for($x = 1; $x <= $j; $x++)\n {\n for($y = 1; $y <= $k; $y++)\n {\n if($e > 0)\n {\n $e--;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($c > 1)\n {\n $c -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r][$s + 1] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r + 1][$s] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n else\n {\n if($d > 1)\n {\n $d -= 2;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s] != NULL)\n {\n unset($t[$p[$r - 1][$s]]);\n }\n if($p[$r][$s - 1] != NULL)\n {\n unset($t[$p[$r][$s - 1]]);\n }\n if($p[$r + 1][$s - 1] != NULL)\n {\n unset($t[$p[$r + 1][$s - 1]]);\n }\n $u = array_rand($t);\n $p[$r][$s] = $u;\n $p[$r + 1][$s] = $u;\n $t = array(a => \"a\", b => \"b\", c => \"c\", d => \"d\", e => \"e\", f => \"f\", g => \"g\", h => \"h\", i => \"i\", j => \"j\", k => \"k\", l => \"l\", m => \"m\", n => \"n\", o => \"o\", p => \"p\", q => \"q\", r => \"r\", s => \"s\", t => \"t\", u => \"u\", v => \"v\", w => \"w\", x => \"x\", y => \"y\", z => \"z\");\n if($p[$r - 1][$s + 1] != NULL)\n {\n unset($t[$p[$r - 1][$s + 1]]);\n }\n if($p[$r][$s] != NULL)\n {\n unset($t[$p[$r][$s]]);\n }\n $u = array_rand($t);\n $p[$r][$s + 1] = $u;\n $p[$r + 1][$s + 1] = $u;\n $s += 2;\n }\n }\n }\n }\n $r += 2;\n $s = 1; \n }\n for($x = 1; $x <= $a; $x++)\n {\n $v = $p[$x];\n print implode($v) . \"\\n\";\n }\n }\n else\n {\n print \"IMPOSSIBLE\";\n }\n }\n}\n?>"}], "src_uid": "78f4d5e627a26effde89b3642bd9c5a8"} {"nl": {"description": "Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties: In one second we can add an arbitrary (possibly negative) integer to all elements of the array that are not equal to zero. When all elements of the array become equal to zero, the array explodes. Nastya is always busy, so she wants to explode the array as fast as possible. Compute the minimum time in which the array can be exploded.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the size of the array. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (\u2009-\u2009105\u2009\u2264\u2009ai\u2009\u2264\u2009105) \u2014 the elements of the array.", "output_spec": "Print a single integer \u2014 the minimum number of seconds needed to make all elements of the array equal to zero.", "sample_inputs": ["5\n1 1 1 1 1", "3\n2 0 -1", "4\n5 -6 -5 1"], "sample_outputs": ["1", "2", "4"], "notes": "NoteIn the first example you can add \u2009-\u20091 to all non-zero elements in one second and make them equal to zero.In the second example you can add \u2009-\u20092 on the first second, then the array becomes equal to [0,\u20090,\u2009\u2009-\u20093]. On the second second you can add 3 to the third (the only non-zero) element."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "0593f79604377dcfa98d2b69840ec0a6"} {"nl": {"description": "You are given a rectangular parallelepiped with sides of positive integer lengths $$$A$$$, $$$B$$$ and $$$C$$$. Find the number of different groups of three integers ($$$a$$$, $$$b$$$, $$$c$$$) such that $$$1\\leq a\\leq b\\leq c$$$ and parallelepiped $$$A\\times B\\times C$$$ can be paved with parallelepipeds $$$a\\times b\\times c$$$. Note, that all small parallelepipeds have to be rotated in the same direction.For example, parallelepiped $$$1\\times 5\\times 6$$$ can be divided into parallelepipeds $$$1\\times 3\\times 5$$$, but can not be divided into parallelepipeds $$$1\\times 2\\times 3$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^5$$$)\u00a0\u2014 the number of test cases. Each of the next $$$t$$$ lines contains three integers $$$A$$$, $$$B$$$ and $$$C$$$ ($$$1 \\leq A, B, C \\leq 10^5$$$)\u00a0\u2014 the sizes of the parallelepiped.", "output_spec": "For each test case, print the number of different groups of three points that satisfy all given conditions.", "sample_inputs": ["4\n1 1 1\n1 6 1\n2 2 2\n100 100 100"], "sample_outputs": ["1\n4\n4\n165"], "notes": "NoteIn the first test case, rectangular parallelepiped $$$(1, 1, 1)$$$ can be only divided into rectangular parallelepiped with sizes $$$(1, 1, 1)$$$.In the second test case, rectangular parallelepiped $$$(1, 6, 1)$$$ can be divided into rectangular parallelepipeds with sizes $$$(1, 1, 1)$$$, $$$(1, 1, 2)$$$, $$$(1, 1, 3)$$$ and $$$(1, 1, 6)$$$.In the third test case, rectangular parallelepiped $$$(2, 2, 2)$$$ can be divided into rectangular parallelepipeds with sizes $$$(1, 1, 1)$$$, $$$(1, 1, 2)$$$, $$$(1, 2, 2)$$$ and $$$(2, 2, 2)$$$. "}, "positive_code": [{"source_code": "insert($a[$i][1]);\n if ($i >= $k)\n $t -= $h->extract();\n if ($t * $a[$i][0] > $bt * $bb) {\n $bt = $t;\n $bb = $a[$i][0];\n }\n}\n\necho bcmul($bt, $bb), \"\\n\";\n"}], "negative_code": [{"source_code": " 100)\n exit();\n\n$t = 0.0;\n$r = \"0\";\n$h = new SplMinHeap();\nfor ($i = 0; $i < $n; $i++) {\n $t += $a[$i][1];\n $h->insert($a[$i][1]);\n if ($i >= $k)\n $t -= $h->extract();\n $ri = bcmul($a[$i][0], $t);\n if (bccomp($ri, $r) > 0)\n $r = $ri;\n}\n\necho $r, \"\\n\";\n"}, {"source_code": "insert($a[$i][1]);\n if ($i >= $k)\n $t -= $h->extract();\n $ri = $a[$i][0] * $t;\n if ($ri > $r)\n $r = $ri;\n}\n\necho $r, \"\\n\";\n"}, {"source_code": "insert($a[$i][1]);\n if ($i >= $k)\n $t -= $h->extract();\n $ri = $a[$i][0] * $t;\n if ($ri > $r)\n $r = $ri;\n}\n\nprintf(\"%.0f\\n\", $r);\n"}], "src_uid": "6b85a1fefb03566fbc557b98d1dfd7ef"} {"nl": {"description": "Alice and Bob are playing a game. They have an array of positive integers $$$a$$$ of size $$$n$$$.Before starting the game, Alice chooses an integer $$$k \\ge 0$$$. The game lasts for $$$k$$$ stages, the stages are numbered from $$$1$$$ to $$$k$$$. During the $$$i$$$-th stage, Alice must remove an element from the array that is less than or equal to $$$k - i + 1$$$. After that, if the array is not empty, Bob must add $$$k - i + 1$$$ to an arbitrary element of the array. Note that both Alice's move and Bob's move are two parts of the same stage of the game. If Alice can't delete an element during some stage, she loses. If the $$$k$$$-th stage ends and Alice hasn't lost yet, she wins.Your task is to determine the maximum value of $$$k$$$ such that Alice can win if both players play optimally. Bob plays against Alice, so he tries to make her lose the game, if it's possible.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$)\u00a0\u2014 the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$).", "output_spec": "For each test case, print one integer\u00a0\u2014 the maximum value of $$$k$$$ such that Alice can win if both players play optimally.", "sample_inputs": ["4\n\n3\n\n1 1 2\n\n4\n\n4 4 4 4\n\n1\n\n1\n\n5\n\n1 3 2 1 1"], "sample_outputs": ["2\n0\n1\n3"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "6421a81f85a53a0c8c63fbc32750f77f"} {"nl": {"description": "The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.Polycarp is a very famous freelancer. His current rating is $$$r$$$ units.Some very rich customers asked him to complete some projects for their companies. To complete the $$$i$$$-th project, Polycarp needs to have at least $$$a_i$$$ units of rating; after he completes this project, his rating will change by $$$b_i$$$ (his rating will increase or decrease by $$$b_i$$$) ($$$b_i$$$ can be positive or negative). Polycarp's rating should not fall below zero because then people won't trust such a low rated freelancer.Is it possible to complete all the projects? Formally, write a program to check if such an order of the projects exists, that Polycarp has enough rating before starting each project, and he has non-negative rating after completing each project.In other words, you have to check that there exists such an order of projects in which Polycarp will complete them, so he has enough rating before starting each project, and has non-negative rating after completing each project.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$r$$$ ($$$1 \\le n \\le 100, 1 \\le r \\le 30000$$$) \u2014 the number of projects and the initial rating of Polycarp, respectively. The next $$$n$$$ lines contain projects, one per line. The $$$i$$$-th project is represented as a pair of integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \\le a_i \\le 30000$$$, $$$-300 \\le b_i \\le 300$$$) \u2014 the rating required to complete the $$$i$$$-th project and the rating change after the project completion.", "output_spec": "Print \"YES\" or \"NO\".", "sample_inputs": ["3 4\n4 6\n10 -2\n8 -1", "3 5\n4 -5\n4 -2\n1 3", "4 4\n5 2\n5 -3\n2 1\n4 -2", "3 10\n10 0\n10 -10\n30 0"], "sample_outputs": ["YES", "YES", "YES", "NO"], "notes": "NoteIn the first example, the possible order is: $$$1, 2, 3$$$.In the second example, the possible order is: $$$2, 3, 1$$$.In the third example, the possible order is: $$$3, 1, 4, 2$$$."}, "positive_code": [{"source_code": "= $m[0])\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n }\n }\n else\n {\n $k = 1;\n }\n break;\n }\n elseif(($b - $o[1] >= $m[0]) && ($o[0] >= $o[1]))\n {\n $b -= $o[1];\n array_splice($m, 1, 1);\n array_splice($o, 1, 1);\n }\n else\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n break;\n }\n array_splice($m, 0, 1);\n array_splice($o, 0, 1);\n }\n }\n if($k == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($k == 1)\n{\n print \"NO\";\n}\n?>"}], "negative_code": [{"source_code": "= $m[0])\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n }\n }\n else\n {\n $k = 1;\n }\n break;\n }\n elseif($b - $o[1] >= $m[0])\n {\n $b -= $o[1];\n array_splice($m, 1, 1);\n array_splice($o, 1, 1);\n }\n elseif($b - $o[1] < $m[0])\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n break;\n }\n array_splice($m, 0, 1);\n array_splice($o, 0, 1);\n }\n }\n if($k == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($k == 1)\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $b) || (max($c) >= $b))\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($k == 1)\n{\n print \"NO\";\n}\n?>"}, {"source_code": " $b) || (max($c) > $b))\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($k == 1)\n{\n print \"NO\";\n}\n?>"}, {"source_code": "= $m[0])\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n }\n }\n else\n {\n $k = 1;\n }\n break;\n }\n elseif($b - $o[1] >= $m[0])\n {\n $b -= $o[1];\n array_splice($m, 1, 1);\n array_splice($o, 1, 1);\n }\n elseif($b - $o[1] < $m[0])\n {\n $b -= $o[0];\n if($b < 0)\n {\n $k = 1;\n break;\n }\n array_splice($m, 1, 1);\n array_splice($o, 1, 1);\n }\n }\n if($k == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($k == 1)\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}], "src_uid": "be90d2c6821576c4ce25706b0508b2fe"} {"nl": {"description": "Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing papers.Mr. Scrooge's signature can be represented as a polyline A1A2... An. Scrooge signs like that: first it places a pen at the point A1, then draws a segment from point A1 to point A2, then he draws a segment from point A2 to point A3 and so on to point An, where he stops signing and takes the pen off the paper. At that the resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style. As Scrooge makes the signature, he never takes the pen off the paper and his writing speed is constant \u2014 50 millimeters per second.Scrooge signed exactly k papers throughout his life and all those signatures look the same.Find the total time Scrooge wasted signing the papers.", "input_spec": "The first line contains two integers n and k (2\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009k\u2009\u2264\u20091000). Each of the following n lines contains the coordinates of the polyline's endpoints. The i-th one contains coordinates of the point Ai \u2014 integers xi and yi, separated by a space. All points Ai are different. The absolute value of all coordinates does not exceed 20. The coordinates are measured in millimeters.", "output_spec": "Print one real number \u2014 the total time Scrooges wastes on signing the papers in seconds. The absolute or relative error should not exceed 10\u2009-\u20096.", "sample_inputs": ["2 1\n0 0\n10 0", "5 10\n3 1\n-5 6\n-2 -1\n3 2\n10 0", "6 10\n5 0\n4 0\n6 0\n3 0\n7 0\n2 0"], "sample_outputs": ["0.200000000", "6.032163204", "3.000000000"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "\n$c=array(101);\nfscanf(STDIN,\"%d %d\",$n,$mul);\nfscanf(STDIN,\"%d %d\",$ox,$oy);\n$sum=0;\nfor($i=0;$i<$n-1;$i++){\n\tfscanf(STDIN,\"%d %d\",$x,$y);//echo($x.','.$y);\n\t$sum+=sqrt(pow($x-$ox,2)+pow($y-$oy,2));\n//echo($x-$ox.\"\\n\");\n\t$ox=$x;$oy=$y;\n}\nprintf(\"%1.9f\",$sum/50*$mul);"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0) {\n\t\t$dx = $x-$x1;\n\t\t$dy = $y-$y1;\n\t\t$t = $t+sqrt($dx*$dx+$dy*$dy);\n\t}\n\t$x1 = $x;\n\t$y1 = $y;\n}\n\necho($t*$k/50);\n?>"}, {"source_code": "0){\n $r+=sqrt(($px-$x)*($px-$x)+($py-$y)*($py-$y));\n }\n $px=$x;$py=$y;\n}\n\nprint number_format($r*$k/50,10,'.','');\n?>"}, {"source_code": "\n$stdin = fopen('php://stdin', 'r');\n$lines = stream_get_contents($stdin);\n\n$all=0;\n$lines=explode(\"\\n\", $lines);\n\nlist($n, $k)=explode(\" \", $lines[0]);\nfor ($i=1; $i<=$n; $i++)\n{\n $line=trim($lines[$i]);\n list ($x, $y)=explode(\" \", $line);\n $arr[$i-1]['x']=$x;\n $arr[$i-1]['y']=$y; \n}\n\nfor ($i=1; $i "}], "negative_code": [{"source_code": ""}], "src_uid": "db4a25159067abd9e3dd22bc4b773385"} {"nl": {"description": "You are given a rooted tree with n vertices. The vertices are numbered from 1 to n, the root is the vertex number 1.Each vertex has a color, let's denote the color of vertex v by cv. Initially cv\u2009=\u20090.You have to color the tree into the given colors using the smallest possible number of steps. On each step you can choose a vertex v and a color x, and then color all vectices in the subtree of v (including v itself) in color x. In other words, for every vertex u, such that the path from root to u passes through v, set cu\u2009=\u2009x.It is guaranteed that you have to color each vertex in a color different from 0.You can learn what a rooted tree is using the link: https://en.wikipedia.org/wiki/Tree_(graph_theory).", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009104)\u00a0\u2014 the number of vertices in the tree. The second line contains n\u2009-\u20091 integers p2,\u2009p3,\u2009...,\u2009pn (1\u2009\u2264\u2009pi\u2009<\u2009i), where pi means that there is an edge between vertices i and pi. The third line contains n integers c1,\u2009c2,\u2009...,\u2009cn (1\u2009\u2264\u2009ci\u2009\u2264\u2009n), where ci is the color you should color the i-th vertex into. It is guaranteed that the given graph is a tree. ", "output_spec": "Print a single integer\u00a0\u2014 the minimum number of steps you have to perform to color the tree into given colors.", "sample_inputs": ["6\n1 2 2 1 5\n2 1 1 1 1 1", "7\n1 1 2 3 1 4\n3 3 1 1 1 2 3"], "sample_outputs": ["3", "5"], "notes": "NoteThe tree from the first sample is shown on the picture (numbers are vetices' indices):On first step we color all vertices in the subtree of vertex 1 into color 2 (numbers are colors):On seond step we color all vertices in the subtree of vertex 5 into color 1:On third step we color all vertices in the subtree of vertex 2 into color 1:The tree from the second sample is shown on the picture (numbers are vetices' indices):On first step we color all vertices in the subtree of vertex 1 into color 3 (numbers are colors):On second step we color all vertices in the subtree of vertex 3 into color 1:On third step we color all vertices in the subtree of vertex 6 into color 2:On fourth step we color all vertices in the subtree of vertex 4 into color 1:On fith step we color all vertices in the subtree of vertex 7 into color 3:"}, "positive_code": [{"source_code": "= 0; $x--)\n{\n if($c[$x + 1] != $c[$b[$x] - 1])\n {\n $d++;\n }\n}\nprint $d;\n?>"}], "negative_code": [], "src_uid": "b23696f763d90335e8bfb0a5e2094c03"} {"nl": {"description": "Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: \"Fox\"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order. After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si\u2009\u2260\u2009ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100): number of names. Each of the following n lines contain one string namei (1\u2009\u2264\u2009|namei|\u2009\u2264\u2009100), the i-th name. Each name contains only lowercase Latin letters. All names are different.", "output_spec": "If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'\u2013'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on). Otherwise output a single word \"Impossible\" (without quotes).", "sample_inputs": ["3\nrivest\nshamir\nadleman", "10\ntourist\npetr\nwjmzbmr\nyeputons\nvepifanov\nscottwu\noooooooooooooooo\nsubscriber\nrowdark\ntankengineer", "10\npetr\negor\nendagorion\nfeferivan\nilovetanyaromanova\nkostka\ndmitriyh\nmaratsnowbear\nbredorjaguarturnik\ncgyforever", "7\ncar\ncare\ncareful\ncarefully\nbecarefuldontforgetsomething\notherwiseyouwillbehacked\ngoodluck"], "sample_outputs": ["bcdefghijklmnopqrsatuvwxyz", "Impossible", "aghjlnopefikdmbcqrstuvwxyz", "acbdefhijklmnogpqrstuvwxyz"], "notes": null}, "positive_code": [{"source_code": "') {\n $ok = false;\n break(2);\n }\n $rels[$ch1][$ch2] = '<';\n $rels[$ch2][$ch1] = '>';\n foreach ($rels[$ch1] as $ich2 => $irel) {\n if ($irel == '>') {\n $lessQueue[\"$ich2/$ch2\"] = true;\n }\n }\n foreach ($rels[$ch2] as $ich1 => $irel) {\n if ($irel == '<') {\n $lessQueue[\"$ch1/$ich1\"] = true;\n }\n }\n unset($lessQueue[key($lessQueue)]);\n }\n}\n\nif (! $ok) {\n echo \"Impossible\\n\";\n} else {\n $answer = \"\";\n foreach ($rels as $ch1 => $irels) {\n $pos = strlen($answer);\n foreach ($irels as $ch2 => $rel) {\n if ($ch2 >= $ch1) {\n break;\n }\n if ($rel == '<') {\n $pos = min($pos, strpos($answer, $ch2));\n }\n }\n $answer = substr($answer, 0, $pos) . $ch2 . substr($answer, $pos);\n }\n echo \"$answer\\n\";\n}\n"}], "negative_code": [], "src_uid": "12218097cf5c826d83ab11e5b049999f"} {"nl": {"description": "You are given a binary string of length $$$n$$$ (i.\u2009e. a string consisting of $$$n$$$ characters '0' and '1').In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given one if you can perform no more than $$$k$$$ moves? It is possible that you do not perform any moves at all.Note that you can swap the same pair of adjacent characters with indices $$$i$$$ and $$$i+1$$$ arbitrary (possibly, zero) number of times. Each such swap is considered a separate move.You have to answer $$$q$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$q$$$ ($$$1 \\le q \\le 10^4$$$) \u2014 the number of test cases. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 10^6, 1 \\le k \\le n^2$$$) \u2014 the length of the string and the number of moves you can perform. The second line of the test case contains one string consisting of $$$n$$$ characters '0' and '1'. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$ ($$$\\sum n \\le 10^6$$$).", "output_spec": "For each test case, print the answer on it: the lexicographically minimum possible string of length $$$n$$$ you can obtain from the given one if you can perform no more than $$$k$$$ moves.", "sample_inputs": ["3\n8 5\n11011010\n7 9\n1111100\n7 11\n1111100"], "sample_outputs": ["01011110\n0101111\n0011111"], "notes": "NoteIn the first example, you can change the string as follows: $$$1\\underline{10}11010 \\rightarrow \\underline{10}111010 \\rightarrow 0111\\underline{10}10 \\rightarrow 011\\underline{10}110 \\rightarrow 01\\underline{10}1110 \\rightarrow 01011110$$$. In the third example, there are enough operations to make the string sorted."}, "positive_code": [{"source_code": " $c)\n {\n $g = $y - $c;\n $d[$g] = 0;\n $d[$y] = 1;\n $c = 0;\n break;\n }\n }\n \n }\n print $d . \"\\n\";\n}\n?>"}, {"source_code": " 0; $q --){\n\tlist($n, $k) = explode(' ', trim(fgets(STDIN)));\n\n\t$str = trim(fgets(STDIN));\n\n\n\t$to = 0;\n\twhile($str[$to] == '0' && $to < $n-1){\n\t\t$to++;\n\t}\n\t$from = $to+1;\n\twhile($k > 0 && $from < $n){\n\t\tif($str[$from] == '0'){\n\t\t\t$k -= $from - $to;\n\t\t\tif($k < 0){\n\t\t\t\t$to -= $k;\n\t\t\t}\n\t\t\t$str[$from] = '1';\n\t\t\t$str[$to] = '0';\n\t\t\t$to++;\n\t\t}\n\t\t$from++;\n\t}\n\techo $str.\"\\n\";\n}"}, {"source_code": "= 0) {\n for ($j = $count; $j < strlen($str2); $j++) {\n if ($str2[$j] == 0) {\n if ($k == 0) {\n break;\n }\n if ($k >= ($j - $count)) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n }\n\n\n\n echo $str2.\"\\n\";\n}\n?>"}], "negative_code": [{"source_code": " $c)\n {\n $g = $y - $c;\n $d[$g] = 0;\n $d[$y] = 1;\n $c = 0;\n break;\n }\n }\n }\n print $d . \"\\n\";\n}\n?>"}, {"source_code": " 0; $q --){\n\tlist($n, $k) = explode(' ', trim(fgets(STDIN)));\n\n\t$str = trim(fgets(STDIN));\n\n\t$i = 0;\n\twhile($k != 0 && $i != $n-1){\n\t\tif($str[$i] == '1' && $str[$i+1] == '0'){\n\t\t\t$str[$i] = '0'; $str[$i+1] = '1';\n\t\t\t$k--;\n\t\t\t$i--;\n\t\t} else {\n\t\t\t$i++;\n\t\t}\n\t}\n\techo $str.\"\\n\";\n}"}, {"source_code": "= $j - $count) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n\n\n echo $str2.\"\\n\";\n}\n?>"}, {"source_code": "= 0) {\n for ($j = 1; $j < strlen($str2); $j++) {\n if ($str2[$j] == 0) {\n if ($k == 0) {\n break;\n }\n if ($k >= ($j - $count)) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n }\n \n\n\n echo $str2.\"\\n\";\n}\n?>"}, {"source_code": " ($j - $count)) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n\n\n echo $str2.\"\\n\";\n}\n?>"}, {"source_code": "= $j) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n\n\n echo $str2.\"\\n\";\n}\n?>"}, {"source_code": "= $j) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n\n\n echo $str2.\"\\n\";\n}\n?>"}, {"source_code": "= ($j - $count)) {\n $str2[$count] = 0;\n $k = $k - ($j - $count);\n $str2[$j] = 1;\n $count++;\n } else {\n $str2[$j - $k] = 0;\n $str2[$j] = 1;\n $k = 0;\n }\n }\n }\n\n\n echo $str2.\"\\n\";\n}\n?>"}], "src_uid": "d4b6bea78b80b0a94646cbaf048b473f"} {"nl": {"description": "Ashish and Vivek play a game on a matrix consisting of $$$n$$$ rows and $$$m$$$ columns, where they take turns claiming cells. Unclaimed cells are represented by $$$0$$$, while claimed cells are represented by $$$1$$$. The initial state of the matrix is given. There can be some claimed cells in the initial state.In each turn, a player must claim a cell. A cell may be claimed if it is unclaimed and does not share a row or column with any other already claimed cells. When a player is unable to make a move, he loses and the game ends.If Ashish and Vivek take turns to move and Ashish goes first, determine the winner of the game if both of them are playing optimally.Optimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves.", "input_spec": "The first line consists of a single integer $$$t$$$ $$$(1 \\le t \\le 50)$$$\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case consists of two space-separated integers $$$n$$$, $$$m$$$ $$$(1 \\le n, m \\le 50)$$$\u00a0\u2014 the number of rows and columns in the matrix. The following $$$n$$$ lines consist of $$$m$$$ integers each, the $$$j$$$-th integer on the $$$i$$$-th line denoting $$$a_{i,j}$$$ $$$(a_{i,j} \\in \\{0, 1\\})$$$.", "output_spec": "For each test case if Ashish wins the game print \"Ashish\" otherwise print \"Vivek\" (without quotes).", "sample_inputs": ["4\n2 2\n0 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 1\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0"], "sample_outputs": ["Vivek\nAshish\nVivek\nAshish"], "notes": "NoteFor the first case: One possible scenario could be: Ashish claims cell $$$(1, 1)$$$, Vivek then claims cell $$$(2, 2)$$$. Ashish can neither claim cell $$$(1, 2)$$$, nor cell $$$(2, 1)$$$ as cells $$$(1, 1)$$$ and $$$(2, 2)$$$ are already claimed. Thus Ashish loses. It can be shown that no matter what Ashish plays in this case, Vivek will win. For the second case: Ashish claims cell $$$(1, 1)$$$, the only cell that can be claimed in the first move. After that Vivek has no moves left.For the third case: Ashish cannot make a move, so Vivek wins.For the fourth case: If Ashish claims cell $$$(2, 3)$$$, Vivek will have no moves left."}, "positive_code": [{"source_code": "= $m) $rows_cnt ++ ;\n }\n \n for($i = 0; $i < $m; $i ++)\n {\n for($j = 0; $j < $n; $j ++) if($matrix[$j][$i] == '1') break ;\n \n if($j >= $n) $cols_cnt ++ ;\n }\n \n $ans = min($rows_cnt, $cols_cnt) ;\n \n if($ans & 1) echo \"Ashish\\n\" ;\n else echo \"Vivek\\n\" ; \n }\n?>"}], "negative_code": [], "src_uid": "3ccc98190189b0c8e58a96dd5ad1245d"} {"nl": {"description": "Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$. An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border).", "input_spec": "The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \\le d < n \\le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \\le m \\le 100$$$) \u2014 the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \\le x_i, y_i \\le n$$$) \u2014 position of the $$$i$$$-th grasshopper.", "output_spec": "Print $$$m$$$ lines. The $$$i$$$-th line should contain \"YES\" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["7 2\n4\n2 4\n4 1\n6 3\n4 5", "8 7\n4\n4 4\n2 8\n8 1\n6 1"], "sample_outputs": ["YES\nNO\nNO\nYES", "YES\nNO\nYES\nYES"], "notes": "NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield. "}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $d;\n $con2 = ($x + $y) <= 2 * $n - $d;\n $con3 = ($x - $y) >= -$d;\n $con4 = ($x - $y) <= $d;\n // printf(\"%d %d %d %d\\n\", $con1, $con2, $con3, $con4);\n echo ($con1 && $con2 && $con3 && $con4) ? \"YES\\n\" : \"NO\\n\";\n}\n"}], "negative_code": [], "src_uid": "9c84eb518c273942650c7262e5d8b45f"} {"nl": {"description": "You are given $$$n$$$ rectangles, each of height $$$1$$$. Each rectangle's width is a power of $$$2$$$ (i.\u2009e. it can be represented as $$$2^x$$$ for some non-negative integer $$$x$$$). You are also given a two-dimensional box of width $$$W$$$. Note that $$$W$$$ may or may not be a power of $$$2$$$. Moreover, $$$W$$$ is at least as large as the width of the largest rectangle.You have to find the smallest height of this box, such that it is able to fit all the given rectangles. It is allowed to have some empty space left in this box after fitting all the rectangles.You cannot rotate the given rectangles to make them fit into the box. Moreover, any two distinct rectangles must not overlap, i.\u2009e., any two distinct rectangles must have zero intersection area.See notes for visual explanation of sample input.", "input_spec": "The first line of input contains one integer $$$t$$$ ($$$1 \\le t \\le 5 \\cdot 10^3$$$) \u2014 the number of test cases. Each test case consists of two lines. For each test case: the first line contains two integers $$$n$$$ ($$$1 \\le n \\le 10^5$$$) and $$$W$$$ ($$$1 \\le W \\le 10^9$$$); the second line contains $$$n$$$ integers $$$w_1, w_2, \\dots, w_n$$$ ($$$1 \\le w_i \\le 10^6$$$), where $$$w_i$$$ is the width of the $$$i$$$-th rectangle. Each $$$w_i$$$ is a power of $$$2$$$; additionally, $$$\\max\\limits_{i=1}^{n} w_i \\le W$$$. The sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "Output $$$t$$$ integers. The $$$i$$$-th integer should be equal to the answer to the $$$i$$$-th test case \u2014 the smallest height of the box.", "sample_inputs": ["2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8"], "sample_outputs": ["2\n3"], "notes": "NoteFor the first test case in the sample input, the following figure shows one way to fit the given five rectangles into the 2D box with minimum height: In the figure above, the number inside each rectangle is its width. The width of the 2D box is $$$16$$$ (indicated with arrow below). The minimum height required for the 2D box in this case is $$$2$$$ (indicated on the left).In the second test case, you can have a minimum height of three by keeping two blocks (one each of widths eight and two) on each of the three levels."}, "positive_code": [{"source_code": "= $item) { $s = $mid; $high = $mid - 1; }\r\n else { $low = $mid + 1; }\r\n }\r\n return $s;\r\n}\r\n\r\nfor ($i = 0; $i < $t; $i++) {\r\n list($n, $w) = explode(\" \", trim(fgets($file)));\r\n $a = explode(\" \", trim(fgets($file)));\r\n sort($a); \r\n $f = array();\r\n \r\n for ($j = 0; $j < $n; $j++) $f[$j] = $w;\r\n for ($j = $n - 1; $j >= 0; $j--) {\r\n\t\t$x = binary_search($f, $a[$j]);\r\n\t\t$f[$x] -= $a[$j];\r\n\t}\r\n\t$ans = 0;\r\n\t\r\n\tfor ($j = 0; $j < $n; $j++) {\r\n\t if ($f[$j] != $w) $ans++;\r\n\t}\r\n\techo $ans.PHP_EOL;\r\n}\r\n?>"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $w) = IO::arr();\r\n $a = IO::arr();\r\n $arr = [];\r\n foreach ($a as $v) {\r\n if (isset($arr[$v])) {\r\n $arr[$v] += 1;\r\n } else {\r\n $arr[$v] = 1;\r\n }\r\n }\r\n $i = 0;\r\n $res = 0;\r\n krsort($arr);\r\n while($i < $n) {\r\n $base = $w;\r\n $b = [];\r\n foreach ($arr as $k => $ar) {\r\n $f = floor($base / $k);\r\n $f = min([$ar, $f]);\r\n $d = $f * $k;\r\n if ($base - $d >= 0) {\r\n $i += $f;\r\n $base -= $d;\r\n }\r\n $b[$k] = $ar - $f;\r\n if ($b[$k] < 1) {\r\n unset($b[$k]);\r\n }\r\n }\r\n $res++;\r\n $arr = $b;\r\n }\r\n IO::line($res);\r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": "= $item) { $s = $mid; $high = $mid - 1; }\r\n else { $low = $mid + 1; }\r\n }\r\n return $s;\r\n}\r\n\r\nfor ($i = 0; $i < $t; $i++) {\r\n list($n, $w) = explode(\" \", trim(fgets($file)));\r\n $a = explode(\" \", trim(fgets($file)));\r\n sort($a); \r\n $f = array();\r\n for ($j = 0; $j < $n; $j++) $f[$j] = $w;\r\n for ($j = $n - 1; $j >= 0; $j--) {\r\n\t\t$x = binary_search($f, $a[$j]);\r\n\t\t$f[$x] -= $a[$j];\r\n\t}\r\n\t$ans = 0;\r\n\t\r\n\tfor ($j = 0; $j < $n; $j++) {\r\n\t if ($f[$j] != $w) $ans++;\r\n\t}\r\n\techo $ans.PHP_EOL;\r\n}\r\n?>"}, {"source_code": "= $item) { $s = $mid; $high = $mid - 1; }\r\n else { $low = $mid + 1; }\r\n }\r\n return $s;\r\n}\r\n\r\nfor ($i = 0; $i < $t; $i++) {\r\n list($n, $w) = explode(\" \", trim(fgets($file)));\r\n $a = explode(\" \", trim(fgets($file)));\r\n sort($a); \r\n \r\n for ($j = 0; $j < $n; $j++) $f[$j] = $w;\r\n for ($j = $n - 1; $j >= 0; $j--) {\r\n\t\t$x = binary_search($f, $a[$j]);\r\n\t\t$f[$x] -= $a[$j];\r\n\t}\r\n\t$ans = 0;\r\n\t\r\n\tfor ($j = 0; $j < $n; $j++) {\r\n\t if ($f[$j] != $w) $ans++;\r\n\t}\r\n\techo $ans.PHP_EOL;\r\n}\r\n?>"}, {"source_code": "= $item) { $s = $mid; $high = $mid - 1; }\r\n else { $low = $mid + 1; }\r\n }\r\n return $s;\r\n}\r\n\r\nfor ($i = 0; $i < $t; $i++) {\r\n list($n, $w) = explode(\" \", trim(fgets($file)));\r\n $a = explode(\" \", trim(fgets($file)));\r\n sort($a); \r\n \r\n for ($j = 0; $j < $n; $j++) $f[$j] = $w;\r\n for ($j = $n - 1; $j >= 0; $j--) {\r\n\t\t$x = binary_search($f, $a[$j]);\r\n\t\t$f[$x] -= $a[$j];\r\n\t}\r\n\t$ans = 0;\r\n\t\r\n\tfor ($j = 0; $j < $n; $j++) {\r\n\t if ($f[$j] != $w) $ans++;\r\n\t}\r\n\techo $ans.PHP_EOL;\r\n}\r\n?>"}, {"source_code": ""}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $w) = IO::arr();\r\n $a = IO::arr();\r\n $arr = [];\r\n foreach ($a as $v) {\r\n if (isset($arr[$v])) {\r\n $arr[$v] += 1;\r\n } else {\r\n $arr[$v] = 1;\r\n }\r\n }\r\n $i = 0;\r\n $res = 0;\r\n krsort($arr);\r\n while($i < $n) {\r\n $base = $w;\r\n $t = [];\r\n foreach ($arr as $k => $ar) {\r\n if ($base - $k >= 0) {\r\n $t[$k] = $ar;\r\n $base -= $k;\r\n }\r\n }\r\n $x = min($t);\r\n $res += $x;\r\n $i += $x * count($t);\r\n foreach ($t as $k => $f) {\r\n $arr[$k] -= $x;\r\n if($arr[$k] == 0) {\r\n unset($arr[$k]);\r\n }\r\n }\r\n }\r\n IO::line($res);\r\n}\r\n\r\n?>"}], "src_uid": "49ba9921ae8b6bc53726e7a521eefe39"} {"nl": {"description": "The legend of the foundation of Vectorland talks of two integers $$$x$$$ and $$$y$$$. Centuries ago, the array king placed two markers at points $$$|x|$$$ and $$$|y|$$$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $$$|x - y|$$$ and $$$|x + y|$$$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.Here $$$|z|$$$ denotes the absolute value of $$$z$$$.Now, Jose is stuck on a question of his history exam: \"What are the values of $$$x$$$ and $$$y$$$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$. Now, he wants to know the number of unordered pairs formed by two different elements from these $$$n$$$ integers such that the legend could be true if $$$x$$$ and $$$y$$$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) \u00a0\u2014 the number of choices. The second line contains $$$n$$$ pairwise distinct integers $$$a_1, a_2, \\dots, a_n$$$ ($$$-10^9 \\le a_i \\le 10^9$$$)\u00a0\u2014 the choices Jose is considering.", "output_spec": "Print a single integer number\u00a0\u2014 the number of unordered pairs $$$\\{x, y\\}$$$ formed by different numbers from Jose's choices that could make the legend true.", "sample_inputs": ["3\n2 5 -3", "2\n3 6"], "sample_outputs": ["2", "1"], "notes": "NoteConsider the first sample. For the pair $$$\\{2, 5\\}$$$, the situation looks as follows, with the Arrayland markers at $$$|2| = 2$$$ and $$$|5| = 5$$$, while the Vectorland markers are located at $$$|2 - 5| = 3$$$ and $$$|2 + 5| = 7$$$: The legend is not true in this case, because the interval $$$[2, 3]$$$ is not conquered by Vectorland. For the pair $$$\\{5, -3\\}$$$ the situation looks as follows, with Arrayland consisting of the interval $$$[3, 5]$$$ and Vectorland consisting of the interval $$$[2, 8]$$$: As Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $$$\\{2, -3\\}$$$, for a total of two pairs.In the second sample, the only pair is $$$\\{3, 6\\}$$$, and the situation looks as follows: Note that even though Arrayland and Vectorland share $$$3$$$ as endpoint, we still consider Arrayland to be completely inside of Vectorland."}, "positive_code": [{"source_code": "= count($def1)) {break;}\n\tif ($own1[$j] > $def1[$i]) {$i++; unset($own1[$j]);}\n}\n\nif ($i >= count($def1)) {\n\n$own1 = array_values($own1);\nsort($own1, SORT_NUMERIC);\n$i = count($atk1)-1;\n\nfor ($j = count($own1)-1; $j >= 0; $j--) {\n\tif ($i < 0) {$dmg += $own1[$j];} else {\n\t\tif ($own1[$j] < $atk1[$i]) {break;} else {$dmg += $own1[$j] - $atk1[$i]; $i--;}\n\t}\n}\n\n}\n\n$res = $dmg;\n\n// strategy 2\n// beat least atk with most power\n$atk2 = $atk;\n$own2 = $own;\n$dmg = 0;\n\n$i = 0;\n\nfor ($j = count($own2)-1; $j >= 0; $j--) {\n\tif ($i >= count($atk2)) {break;}\n\tif ($own2[$j] < $atk2[$i]) {break;} else {$dmg += $own2[$j] - $atk2[$i]; $i++;}\n}\n\n$res = ($res < $dmg) ? $dmg : $res;\n\necho $res;"}], "negative_code": [{"source_code": "= count($def1)) {break;}\n\tif ($own1[$j] > $def1[$i]) {$i++; unset($own1[$j]);}\n}\n\nif ($i >= count($def1)) {\n\n$own1 = array_values($own1);\nsort($own1);\n$i = count($atk1)-1;\n\nfor ($j = count($own1)-1; $j >= 0; $j--) {\n\tif ($i < 0) {$dmg += $own1[$j];} else {\n\t\tif ($own1[$j] < $atk1[$i]) {$dmg = 0; break;} else {$dmg += $own1[$j] - $atk1[$i]; $i--;}\n\t}\n}\n\n}\n\n$res = $dmg;\n\n// strategy 2\n// beat least atk with most power\n$atk2 = $atk;\n$own2 = $own;\n$dmg = 0;\n\n$i = 0;\n\nfor ($j = count($own2)-1; $j >= 0; $j--) {\n\tif ($i >= count($atk2)) {break;}\n\tif ($own2[$j] < $atk2[$i]) {break;} else {$dmg += $own2[$j] - $atk2[$i]; $i++;}\n}\n\n$res = ($res < $dmg) ? $dmg : $res;\n\necho $res;"}], "src_uid": "06420ea88312103231a7bbac8a9a62d1"} {"nl": {"description": "Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1\u2009\u00d7\u2009n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed height and due to the newest irrigation system we can create artificial rain above each section.Creating artificial rain is an expensive operation. That's why we limit ourselves to creating the artificial rain only above one section. At that, the water from each watered section will flow into its neighbouring sections if their height does not exceed the height of the section. That is, for example, the garden can be represented by a 1\u2009\u00d7\u20095 rectangle, where the section heights are equal to 4, 2, 3, 3, 2. Then if we create an artificial rain over any of the sections with the height of 3, the water will flow over all the sections, except the ones with the height of 4. See the illustration of this example at the picture: As Petya is keen on programming, he decided to find such a section that if we create artificial rain above it, the number of watered sections will be maximal. Help him. ", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.", "output_spec": "Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.", "sample_inputs": ["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"], "sample_outputs": ["1", "3", "6"], "notes": null}, "positive_code": [{"source_code": " 0; $z--)\n {\n if($b[$z] < $b[$z - 1])\n {\n break;\n }\n else\n {\n $d++;\n }\n }\n array_push($c, $d);\n}\nrsort($c);\nprint $c[0];\n?>"}, {"source_code": "1) {\n $locmin[] = 0;\n for ($i=1;$i<(count($normalized)-1);$i++)\n if (($normalized[$i]<$normalized[$i+1])&&($normalized[$i]<$normalized[$i-1]))\n $locmin[] = $i; \n $locmin[] = count($normalized)-1;\n} else {\n $locmin = Array(0,0);\n}\n\nfor ($i=1;$i 1)?max($lenarr):$lenarr[0];\n\n\n?>\n"}], "negative_code": [], "src_uid": "5d11fa8528f1dc873d50b3417bef8c79"} {"nl": {"description": "There are $$$n$$$ Christmas trees on an infinite number line. The $$$i$$$-th tree grows at the position $$$x_i$$$. All $$$x_i$$$ are guaranteed to be distinct.Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all. Non-integer points cannot be occupied by anything.There are $$$m$$$ people who want to celebrate Christmas. Let $$$y_1, y_2, \\dots, y_m$$$ be the positions of people (note that all values $$$x_1, x_2, \\dots, x_n, y_1, y_2, \\dots, y_m$$$ should be distinct and all $$$y_j$$$ should be integer). You want to find such an arrangement of people that the value $$$\\sum\\limits_{j=1}^{m}\\min\\limits_{i=1}^{n}|x_i - y_j|$$$ is the minimum possible (in other words, the sum of distances to the nearest Christmas tree for all people should be minimized).In other words, let $$$d_j$$$ be the distance from the $$$j$$$-th human to the nearest Christmas tree ($$$d_j = \\min\\limits_{i=1}^{n} |y_j - x_i|$$$). Then you need to choose such positions $$$y_1, y_2, \\dots, y_m$$$ that $$$\\sum\\limits_{j=1}^{m} d_j$$$ is the minimum possible.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 2 \\cdot 10^5$$$) \u2014 the number of Christmas trees and the number of people. The second line of the input contains $$$n$$$ integers $$$x_1, x_2, \\dots, x_n$$$ ($$$-10^9 \\le x_i \\le 10^9$$$), where $$$x_i$$$ is the position of the $$$i$$$-th Christmas tree. It is guaranteed that all $$$x_i$$$ are distinct.", "output_spec": "In the first line print one integer $$$res$$$ \u2014 the minimum possible value of $$$\\sum\\limits_{j=1}^{m}\\min\\limits_{i=1}^{n}|x_i - y_j|$$$ (in other words, the sum of distances to the nearest Christmas tree for all people). In the second line print $$$m$$$ integers $$$y_1, y_2, \\dots, y_m$$$ ($$$-2 \\cdot 10^9 \\le y_j \\le 2 \\cdot 10^9$$$), where $$$y_j$$$ is the position of the $$$j$$$-th human. All $$$y_j$$$ should be distinct and all values $$$x_1, x_2, \\dots, x_n, y_1, y_2, \\dots, y_m$$$ should be distinct. If there are multiple answers, print any of them.", "sample_inputs": ["2 6\n1 5", "3 5\n0 3 1"], "sample_outputs": ["8\n-1 2 6 4 0 3", "7\n5 -2 4 -1 2"], "notes": null}, "positive_code": [{"source_code": " 0){\n\t$d++;\n\t$places = $iterate($d);\n}\n\n\n"}], "negative_code": [{"source_code": " 0){\n\t$d++;\n\t$places = $iterate($d);\n}\n\n\necho $sum . \"\\n\";\necho implode(' ', $peoples);"}, {"source_code": " 0){\n\tfor($tIndex = 0; $tIndex < $n; $tIndex++ ){\n\t\t$pos = $trees[$tIndex] - $d;\n\t\tif(array_search($pos, $trees) === false && array_search($pos, $peoples) === false){\n\t\t\t$sum += $d;\n\t\t\t$peoples[] = $pos;\n\t\t\t$m--;\n\t\t\tif($m == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t$pos = $trees[$tIndex] + $d;\n\t\tif(array_search($pos, $trees) === false && array_search($pos, $peoples) === false){\n\t\t\t$sum += $d;\n\t\t\t$peoples[] = $pos;\n\t\t\t$m--;\n\t\t\tif($m == 0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t$d++;\n}\n\necho $sum . \"\\n\";\necho implode(' ', $peoples);"}], "src_uid": "3a3666609b120d208c3e8366b186d89b"} {"nl": {"description": "The Third Doctor Who once correctly said that travel between parallel universes is \"like travelling sideways\". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.Heidi recently got her hands on a multiverse observation tool. She was able to see all $$$n$$$ universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the $$$k$$$-th universe.The tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed $$$m$$$.Obviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken.More specifically, When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends. When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment NOT containing the Doctor will cease to exist. Heidi wants to perform a simulation of $$$t$$$ decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.", "input_spec": "The first line contains four integers $$$n$$$, $$$k$$$, $$$m$$$ and $$$t$$$ ($$$2 \\le k \\le n \\le m \\le 250$$$, $$$1 \\le t \\le 1000$$$). Each of the following $$$t$$$ lines is in one of the following formats: \"$$$1$$$ $$$i$$$\" \u2014 meaning that a universe is inserted at the position $$$i$$$ ($$$1 \\le i \\le l + 1$$$), where $$$l$$$ denotes the current length of the multiverse. \"$$$0$$$ $$$i$$$\" \u2014 meaning that the $$$i$$$-th link is broken ($$$1 \\le i \\le l - 1$$$), where $$$l$$$ denotes the current length of the multiverse. ", "output_spec": "Output $$$t$$$ lines. Each line should contain $$$l$$$, the current length of the multiverse and $$$k$$$, the current position of the Doctor. It is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most $$$m$$$ and when the link breaking is performed, there will be at least one universe in the multiverse.", "sample_inputs": ["5 2 10 4\n0 1\n1 1\n0 4\n1 2"], "sample_outputs": ["4 1\n5 2\n4 2\n5 3"], "notes": "NoteThe multiverse initially consisted of 5 universes, with the Doctor being in the second.First, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first.Then, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe.Then, the rightmost link was broken.Finally, a universe was added between the first and the second universe."}, "positive_code": [{"source_code": " $f)\n {\n $b -= $a - $g;\n $a -= $f;\n }\n }\n elseif(($e == 1) && ($a != $c))\n {\n if($f <= $b)\n {\n $b++;\n }\n $a++;\n }\n print $a . \" \" . $b . \"\\n\";\n}\n?>"}], "negative_code": [{"source_code": "= $f)\n {\n $b -= $a - $g;\n $a -= $f;\n }\n }\n elseif(($e == 1) && ($a != $c))\n {\n if($f <= $b)\n {\n $b++;\n }\n $a++;\n }\n print $a . \" \" . $b . \"\\n\";\n}\n?>"}, {"source_code": " $f)\n {\n $b -= $a - $g;\n $a -= $f;\n }\n }\n elseif(($e == 1) && ($a != $c))\n {\n if($f <= $b)\n {\n $b++;\n }\n $a++;\n }\n print $a . \" \" . $b . \"\\n\";\n}\n?>"}], "src_uid": "c9d39bee8247706f2c7fc8f9d69910f6"} {"nl": {"description": "Luckily, Serval got onto the right bus, and he came to the kindergarten on time. After coming to kindergarten, he found the toy bricks very funny.He has a special interest to create difficult problems for others to solve. This time, with many $$$1 \\times 1 \\times 1$$$ toy bricks, he builds up a 3-dimensional object. We can describe this object with a $$$n \\times m$$$ matrix, such that in each cell $$$(i,j)$$$, there are $$$h_{i,j}$$$ bricks standing on the top of each other.However, Serval doesn't give you any $$$h_{i,j}$$$, and just give you the front view, left view, and the top view of this object, and he is now asking you to restore the object. Note that in the front view, there are $$$m$$$ columns, and in the $$$i$$$-th of them, the height is the maximum of $$$h_{1,i},h_{2,i},\\dots,h_{n,i}$$$. It is similar for the left view, where there are $$$n$$$ columns. And in the top view, there is an $$$n \\times m$$$ matrix $$$t_{i,j}$$$, where $$$t_{i,j}$$$ is $$$0$$$ or $$$1$$$. If $$$t_{i,j}$$$ equals $$$1$$$, that means $$$h_{i,j}>0$$$, otherwise, $$$h_{i,j}=0$$$.However, Serval is very lonely because others are bored about his unsolvable problems before, and refused to solve this one, although this time he promises there will be at least one object satisfying all the views. As his best friend, can you have a try?", "input_spec": "The first line contains three positive space-separated integers $$$n, m, h$$$ ($$$1\\leq n, m, h \\leq 100$$$)\u00a0\u2014 the length, width and height. The second line contains $$$m$$$ non-negative space-separated integers $$$a_1,a_2,\\dots,a_m$$$, where $$$a_i$$$ is the height in the $$$i$$$-th column from left to right of the front view ($$$0\\leq a_i \\leq h$$$). The third line contains $$$n$$$ non-negative space-separated integers $$$b_1,b_2,\\dots,b_n$$$ ($$$0\\leq b_j \\leq h$$$), where $$$b_j$$$ is the height in the $$$j$$$-th column from left to right of the left view. Each of the following $$$n$$$ lines contains $$$m$$$ numbers, each is $$$0$$$ or $$$1$$$, representing the top view, where $$$j$$$-th number of $$$i$$$-th row is $$$1$$$ if $$$h_{i, j}>0$$$, and $$$0$$$ otherwise. It is guaranteed that there is at least one structure satisfying the input.", "output_spec": "Output $$$n$$$ lines, each of them contains $$$m$$$ integers, the $$$j$$$-th number in the $$$i$$$-th line should be equal to the height in the corresponding position of the top view. If there are several objects satisfying the views, output any one of them.", "sample_inputs": ["3 7 3\n2 3 0 0 2 0 1\n2 1 3\n1 0 0 0 1 0 0\n0 0 0 0 0 0 1\n1 1 0 0 0 0 0", "4 5 5\n3 5 2 0 4\n4 2 5 4\n0 0 0 0 1\n1 0 1 0 0\n0 1 0 0 0\n1 1 1 0 0"], "sample_outputs": ["1 0 0 0 2 0 0\n0 0 0 0 0 0 1\n2 3 0 0 0 0 0", "0 0 0 0 4\n1 0 2 0 0\n0 5 0 0 0\n3 4 1 0 0"], "notes": "Note The graph above illustrates the object in the first example. The first graph illustrates the object in the example output for the second example, and the second graph shows the three-view drawing of it."}, "positive_code": [{"source_code": ""}, {"source_code": " $c[$x])\n {\n print \"+ \" . ($x + 1) . \" \" . ($i - $c[$x]) . \"\\n\";\n }\n }\n}\nelse\n{\n for($x = 0; $x < $a; $x++)\n {\n if($d[$x] == $h)\n {\n break;\n }\n }\n $i = $c[$x];\n for($y = $x; $y > 0; $y--)\n {\n $i -= $b;\n }\n $j = $i;\n $j -= $b;\n print $a - ($h + 1) . \"\\n\";\n for($x = 0; $x < $a; $x++)\n {\n $j += $b;\n if($j == $c[$x])\n {\n continue;\n }\n if($j < $c[$x])\n {\n print \"- \" . ($x + 1) . \" \" . ($c[$x] - $j) . \"\\n\";\n }\n elseif($j > $c[$x])\n {\n print \"+ \" . ($x + 1) . \" \" . ($j - $c[$x]) . \"\\n\";\n }\n }\n}\n?>"}], "negative_code": [], "src_uid": "7f08e74945d6b58abde1d8002b8b686a"} {"nl": {"description": "Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home.In the city in which Alice and Bob live, the first metro line is being built. This metro line contains $$$n$$$ stations numbered from $$$1$$$ to $$$n$$$. Bob lives near the station with number $$$1$$$, while Alice lives near the station with number $$$s$$$. The metro line has two tracks. Trains on the first track go from the station $$$1$$$ to the station $$$n$$$ and trains on the second track go in reverse direction. Just after the train arrives to the end of its track, it goes to the depot immediately, so it is impossible to travel on it after that.Some stations are not yet open at all and some are only partially open\u00a0\u2014 for each station and for each track it is known whether the station is closed for that track or not. If a station is closed for some track, all trains going in this track's direction pass the station without stopping on it.When the Bob got the information on opened and closed stations, he found that traveling by metro may be unexpectedly complicated. Help Bob determine whether he can travel to the Alice's home by metro or he should search for some other transport.", "input_spec": "The first line contains two integers $$$n$$$ and $$$s$$$ ($$$2 \\le s \\le n \\le 1000$$$)\u00a0\u2014 the number of stations in the metro and the number of the station where Alice's home is located. Bob lives at station $$$1$$$. Next lines describe information about closed and open stations. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$a_i = 0$$$ or $$$a_i = 1$$$). If $$$a_i = 1$$$, then the $$$i$$$-th station is open on the first track (that is, in the direction of increasing station numbers). Otherwise the station is closed on the first track. The third line contains $$$n$$$ integers $$$b_1, b_2, \\ldots, b_n$$$ ($$$b_i = 0$$$ or $$$b_i = 1$$$). If $$$b_i = 1$$$, then the $$$i$$$-th station is open on the second track (that is, in the direction of decreasing station numbers). Otherwise the station is closed on the second track.", "output_spec": "Print \"YES\" (quotes for clarity) if Bob will be able to commute to the Alice's home by metro and \"NO\" (quotes for clarity) otherwise. You can print each letter in any case (upper or lower).", "sample_inputs": ["5 3\n1 1 1 1 1\n1 1 1 1 1", "5 4\n1 0 0 0 1\n0 1 1 1 1", "5 2\n0 1 1 1 1\n1 1 1 1 1"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteIn the first example, all stations are opened, so Bob can simply travel to the station with number $$$3$$$.In the second example, Bob should travel to the station $$$5$$$ first, switch to the second track and travel to the station $$$4$$$ then.In the third example, Bob simply can't enter the train going in the direction of Alice's home."}, "positive_code": [{"source_code": ""}, {"source_code": "0) {\n\t\t\t\techo 'YES';\n\t\t\t} else {\n\t\t\t\techo 'NO';\n\t\t\t}\n\t\t} else {\n\t\t\techo 'NO';\n\t\t}\n\t}\n}"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "64b597a47106d0f08fcfad155e0495c3"} {"nl": {"description": "Polycarp likes to play with numbers. He takes some integer number $$$x$$$, writes it down on the board, and then performs with it $$$n - 1$$$ operations of the two kinds: divide the number $$$x$$$ by $$$3$$$ ($$$x$$$ must be divisible by $$$3$$$); multiply the number $$$x$$$ by $$$2$$$. After each operation, Polycarp writes down the result on the board and replaces $$$x$$$ by the result. So there will be $$$n$$$ numbers on the board after all.You are given a sequence of length $$$n$$$ \u2014 the numbers that Polycarp wrote down. This sequence is given in arbitrary order, i.e. the order of the sequence can mismatch the order of the numbers written on the board.Your problem is to rearrange (reorder) elements of this sequence in such a way that it can match possible Polycarp's game in the order of the numbers written on the board. I.e. each next number will be exactly two times of the previous number or exactly one third of previous number.It is guaranteed that the answer exists.", "input_spec": "The first line of the input contatins an integer number $$$n$$$ ($$$2 \\le n \\le 100$$$) \u2014 the number of the elements in the sequence. The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 3 \\cdot 10^{18}$$$) \u2014 rearranged (reordered) sequence that Polycarp can wrote down on the board.", "output_spec": "Print $$$n$$$ integer numbers \u2014 rearranged (reordered) input sequence that can be the sequence that Polycarp could write down on the board. It is guaranteed that the answer exists.", "sample_inputs": ["6\n4 8 6 3 12 9", "4\n42 28 84 126", "2\n1000000000000000000 3000000000000000000"], "sample_outputs": ["9 3 6 12 4 8", "126 42 84 28", "3000000000000000000 1000000000000000000"], "notes": "NoteIn the first example the given sequence can be rearranged in the following way: $$$[9, 3, 6, 12, 4, 8]$$$. It can match possible Polycarp's game which started with $$$x = 9$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "f9375003a3b64bab17176a05764c20e8"} {"nl": {"description": "You are given $$$n$$$ words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.Each lyric consists of two lines. Each line consists of two words separated by whitespace. A lyric is beautiful if and only if it satisfies all conditions below. The number of vowels in the first word of the first line is the same as the number of vowels in the first word of the second line. The number of vowels in the second word of the first line is the same as the number of vowels in the second word of the second line. The last vowel of the first line is the same as the last vowel of the second line. Note that there may be consonants after the vowel. Also, letters \"a\", \"e\", \"o\", \"i\", and \"u\" are vowels. Note that \"y\" is never vowel.For example of a beautiful lyric, \"hello hellooowww\" \"whatsup yowowowow\" is a beautiful lyric because there are two vowels each in \"hello\" and \"whatsup\", four vowels each in \"hellooowww\" and \"yowowowow\" (keep in mind that \"y\" is not a vowel), and the last vowel of each line is \"o\".For example of a not beautiful lyric, \"hey man\"\"iam mcdic\" is not a beautiful lyric because \"hey\" and \"iam\" don't have same number of vowels and the last vowels of two lines are different (\"a\" in the first and \"i\" in the second).How many beautiful lyrics can you write from given words? Note that you cannot use a word more times than it is given to you. For example, if a word is given three times, you can use it at most three times.", "input_spec": "The first line contains single integer $$$n$$$ ($$$1 \\le n \\le 10^{5}$$$)\u00a0\u2014 the number of words. The $$$i$$$-th of the next $$$n$$$ lines contains string $$$s_{i}$$$ consisting lowercase alphabet letters\u00a0\u2014 the $$$i$$$-th word. It is guaranteed that the sum of the total word length is equal or less than $$$10^{6}$$$. Each word contains at least one vowel.", "output_spec": "In the first line, print $$$m$$$\u00a0\u2014 the number of maximum possible beautiful lyrics. In next $$$2m$$$ lines, print $$$m$$$ beautiful lyrics (two lines per lyric). If there are multiple answers, print any.", "sample_inputs": ["14\nwow\nthis\nis\nthe\nfirst\nmcdics\ncodeforces\nround\nhooray\ni\nam\nproud\nabout\nthat", "7\narsijo\nsuggested\nthe\nidea\nfor\nthis\nproblem", "4\nsame\nsame\nsame\ndiffer"], "sample_outputs": ["3\nabout proud\nhooray round\nwow first\nthis is\ni that\nmcdics am", "0", "1\nsame differ\nsame same"], "notes": "NoteIn the first example, those beautiful lyrics are one of the possible answers. Let's look at the first lyric on the sample output of the first example. \"about proud hooray round\" forms a beautiful lyric because \"about\" and \"hooray\" have same number of vowels, \"proud\" and \"round\" have same number of vowels, and both lines have same last vowel. On the other hand, you cannot form any beautiful lyric with the word \"codeforces\".In the second example, you cannot form any beautiful lyric from given words.In the third example, you can use the word \"same\" up to three times."}, "positive_code": [{"source_code": " 1, e => 1, o => 1, i => 1, u => 1);\n $e = trim(fgets(STDIN));\n $f = 0;\n for($y = 0; $y < strlen($e); $y++)\n {\n if($d[$e[$y]] == TRUE)\n {\n $f++;\n $g = $e[$y];\n }\n }\n $g = $f . \"-\" . $g;\n $b[$g][count($b[$g])] = $e;\n if(count($b[$g]) == 2)\n {\n $c[count($c)] = $b[$g][0];\n $c2[count($c2)] = $b[$g][1];\n unset($b[$g]);\n }\n}\n$h = array();\n$i = reset($b);\n$k = array();\n$k2 = array();\nfor($x = 0; $x < count($b); $x++)\n{\n $j = explode(\"-\", key($b));\n $h[$j[0]][count($h[$j[0]])] = $i[0];\n if(count($h[$j[0]]) == 2)\n {\n $k[count($k)] = $h[$j[0]][0];\n $k2[count($k2)] = $h[$j[0]][1];\n unset($h[$j[0]]);\n }\n $i = next($b);\n}\nif(count($k) >= count($c))\n{\n print count($c) . \"\\n\";\n for($x = 0; $x < count($c); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n}\nelse\n{\n $l = floor((count($c) - count($k)) / 2);\n print count($k) + $l . \"\\n\";\n for($x = 0; $x < count($k); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n for($y = $x; $y < count($c); $y += 2)\n {\n if(($c[$y] != FALSE) && ($c[$y + 1] != FALSE))\n {\n print $c[$y] . \" \" . $c[$y + 1] . \"\\n\";\n print $c2[$y] . \" \" . $c2[$y + 1] . \"\\n\";\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " 1, e => 1, o => 1, i => 1, u => 1);\n $e = trim(fgets(STDIN));\n $f = 0;\n for($y = 0; $y < strlen($e); $y++)\n {\n if($d[$e[$y]] == TRUE)\n {\n $f++;\n $g = $e[$y];\n }\n }\n $g = $f . \"-\" . $g;\n $b[$g][count($b[$g])] = $e;\n if(count($b[$g]) == 2)\n {\n $c[count($c)] = $b[$g][0];\n $c2[count($c2)] = $b[$g][1];\n unset($b[$g]);\n }\n}\n$h = array();\n$i = reset($b);\n$k = array();\n$k2 = array();\nfor($x = 0; $x < count($b); $x++)\n{\n $j = explode(\"-\", key($b));\n $h[$j[0]][count($h[$j[0]])] = $i[0];\n if(count($h[$j[0]]) == 2)\n {\n $k[count($k)] = $h[$j[0]][0];\n $k2[count($k2)] = $h[$j[0]][1];\n unset($h[$j[0]]);\n }\n $i = next($b);\n}\nif(count($k) >= count($c))\n{\n print count($c) . \"\\n\";\n for($x = 0; $x < count($c); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n}\nelse\n{\n $l = floor((count($c) - count($k)) / 2);\n print count($k) + $l . \"\\n\";\n for($x = 0; $x < count($k); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n for($y = $x; $y < count($c); $y += 2)\n {\n print $c[$y] . \" \" . $c[$y + 1] . \"\\n\";\n print $c2[$y] . \" \" . $c2[$y + 1] . \"\\n\";\n }\n}\n?>"}, {"source_code": " 1, e => 1, o => 1, i => 1, u => 1);\n $e = trim(fgets(STDIN));\n $f = 0;\n for($y = 0; $y < strlen($e); $y++)\n {\n if($d[$e[$y]] == TRUE)\n {\n $f++;\n $g = $e[$y];\n }\n }\n $g = $f . \"-\" . $g;\n $b[$g][count($b[$g])] = $e;\n if(count($b[$g]) == 2)\n {\n $c[count($c)] = $b[$g][0];\n $c2[count($c2)] = $b[$g][1];\n unset($b[$g]);\n }\n}\n$h = array();\n$i = reset($b);\n$k = array();\n$k2 = array();\nfor($x = 0; $x < count($b); $x++)\n{\n $j = explode(\"-\", key($b));\n $h[$j[0]][count($h[$j[0]])] = $i[0];\n if(count($h[$j[0]]) == 2)\n {\n $k[count($k)] = $h[$j[0]][0];\n $k2[count($k2)] = $h[$j[0]][1];\n unset($h[$j[0]]);\n }\n $i = next($b);\n}\nif(count($k) >= count($c))\n{\n print count($c) . \"\\n\";\n for($x = 0; $x < count($c); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n}\nelse\n{\n $l = floor((count($c) - count($k)) / 2);\n print count($k) + $l . \"\\n\";\n for($x = 0; $x < count($k); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n for($y = $x; $y < count($c); $y += 2)\n {\n print $c[$y] . \" \" . $c2[$y] . \"\\n\";\n print $c[$y + 1] . \" \" . $c2[$y + 1] . \"\\n\";\n }\n}\n?>"}, {"source_code": " 1, e => 1, o => 1, i => 1, u => 1);\n $e = trim(fgets(STDIN));\n $f = 0;\n for($y = 0; $y < strlen($e); $y++)\n {\n if($d[$e[$y]] == TRUE)\n {\n $f++;\n $g = $e[$y];\n }\n }\n $g = $f . \"-\" . $g;\n $b[$g][count($b[$g])] = $e;\n if(count($b[$g]) == 2)\n {\n $c[count($c)] = $b[$g][0];\n $c2[count($c2)] = $b[$g][1];\n unset($b[$g]);\n }\n}\n$h = array();\n$i = reset($b);\n$k = array();\n$k2 = array();\nfor($x = 0; $x < count($b); $x++)\n{\n $j = explode(\"-\", key($b));\n $h[$j[0]][count($h[$j[0]])] = $i[0];\n if(count($h[$j[0]]) == 2)\n {\n $k[count($k)] = $h[$j[0]][0];\n $k2[count($k2)] = $h[$j[0]][1];\n unset($h[$j[0]]);\n }\n $i = next($b);\n}\nif(count($k) >= count($c))\n{\n print count($c) . \"\\n\";\n for($x = 0; $x < count($c); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n}\nelse\n{\n $l = floor((count($c) - count($k)) / 2);\n print count($k) + $l . \"\\n\";\n for($x = 0; $x < count($k); $x++)\n {\n print $k[$x] . \" \" . $c[$x] . \"\\n\";\n print $k2[$x] . \" \" . $c2[$x] . \"\\n\";\n }\n for($y = $x; $y <= count($c); $y += 2)\n {\n print $c[$y] . \" \" . $c[$y + 1] . \"\\n\";\n print $c2[$y] . \" \" . $c2[$y + 1] . \"\\n\";\n }\n}\n?>"}], "src_uid": "f06f7d0dcef10f064f5ce1e9eccf3928"} {"nl": {"description": "Petya has got 2n cards, each card contains some integer. The numbers on the cards can be the same. Let's index all cards by consecutive integers from 1 to 2n. We'll denote the number that is written on a card with number i, as ai. In order to play one entertaining game with his friends, Petya needs to split the cards into pairs so that each pair had equal numbers on the cards. Help Petya do that.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20093\u00b7105). The second line contains the sequence of 2n positive integers a1,\u2009a2,\u2009...,\u2009a2n (1\u2009\u2264\u2009ai\u2009\u2264\u20095000) \u2014 the numbers that are written on the cards. The numbers on the line are separated by single spaces.", "output_spec": "If it is impossible to divide the cards into pairs so that cards in each pair had the same numbers, print on a single line integer -1. But if the required partition exists, then print n pairs of integers, a pair per line \u2014 the indices of the cards that form the pairs. Separate the numbers on the lines by spaces. You can print the pairs and the numbers in the pairs in any order. If there are multiple solutions, print any of them.", "sample_inputs": ["3\n20 30 10 30 20 10", "1\n1 2"], "sample_outputs": ["4 2\n1 5\n6 3", "-1"], "notes": null}, "positive_code": [{"source_code": "d($a,$b,$c)) {\n $a=$i;\n $flag=0;\n }\n if (d($a,$i,$c)>d($a,$b,$c)) {\n $b=$i;\n $flag=0;\n }\n if (d($a,$b,$i)>d($a,$b,$c)) {\n $c=$i;\n $flag=0;\n }\n }\n if ($flag) break;\n}\necho ($x[$a]+$x[$b]-$x[$c]).' '.($y[$a]+$y[$b]-$y[$c]).PHP_EOL;\necho ($x[$b]+$x[$c]-$x[$a]).' '.($y[$b]+$y[$c]-$y[$a]).PHP_EOL;\necho ($x[$c]+$x[$a]-$x[$b]).' '.($y[$c]+$y[$a]-$y[$b]).PHP_EOL;\nreturn 0;"}], "negative_code": [], "src_uid": "d7857d3e6b981c313ac16a9b4b0e1b86"} {"nl": {"description": "Monocarp had a tree which consisted of $$$n$$$ vertices and was rooted at vertex $$$1$$$. He decided to study BFS (Breadth-first search), so he ran BFS on his tree, starting from the root. BFS can be described by the following pseudocode:a = [] # the order in which vertices were processedq = Queue()q.put(1) # place the root at the end of the queuewhile not q.empty(): k = q.pop() # retrieve the first vertex from the queue a.append(k) # append k to the end of the sequence in which vertices were visited for y in g[k]: # g[k] is the list of all children of vertex k, sorted in ascending order q.put(y)Monocarp was fascinated by BFS so much that, in the end, he lost his tree. Fortunately, he still has a sequence of vertices, in which order vertices were visited by the BFS algorithm (the array a from the pseudocode). Monocarp knows that each vertex was visited exactly once (since they were put and taken from the queue exactly once). Also, he knows that all children of each vertex were viewed in ascending order.Monocarp knows that there are many trees (in the general case) with the same visiting order $$$a$$$, so he doesn't hope to restore his tree. Monocarp is okay with any tree that has minimum height.The height of a tree is the maximum depth of the tree's vertices, and the depth of a vertex is the number of edges in the path from the root to it. For example, the depth of vertex $$$1$$$ is $$$0$$$, since it's the root, and the depth of all root's children are $$$1$$$.Help Monocarp to find any tree with given visiting order $$$a$$$ and minimum height.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$)\u00a0\u2014 the number of vertices in the tree. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$; $$$a_i \\neq a_j$$$; $$$a_1 = 1$$$)\u00a0\u2014 the order in which the vertices were visited by the BFS algorithm. It's guaranteed that the total sum of $$$n$$$ over test cases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case print the minimum possible height of a tree with the given visiting order $$$a$$$.", "sample_inputs": ["3\n4\n1 4 3 2\n2\n1 2\n3\n1 2 3"], "sample_outputs": ["3\n1\n1"], "notes": "NoteIn the first test case, there is only one tree with the given visiting order: In the second test case, there is only one tree with the given visiting order as well: In the third test case, an optimal tree with the given visiting order is shown below: "}, "positive_code": [{"source_code": "\n"}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": ""}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": ""}, {"source_code": " $a)\n{\n $c -= $a;\n $c++;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": " $a)\n{\n $c -= $a;\n $f = $d[0] + min($b, $c);\n}\nprint number_format($f, 6, \".\", \"\") . \"\\n\";\n?>"}, {"source_code": "0) {\n\t\t\t$sum += min($m,$k);\n\t\t\t$m -= $k;\n\t\t}\n\t}\n\t$av = $sum/$l;\n\techo $av;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0) {\n\t\t\t$sum += min($m,$k);\n\t\t\t$m -= $k;\n\t\t}\n\t}\n\t$av = $sum/$l;\n\techo $av;\n?>"}, {"source_code": "$p2) break;\n\t\t$l++;\n\t\t$m--;\n\t}\n\t$sum = 0;\n\tfor($i=$l;$i<$n;$i++) {\n\t\t$sum += $a[$i];\n\t\tif($m>0) {\n\t\t\t$sum += min($m,$k);\n\t\t\t$m -= $k;\n\t\t}\n\t}\n\t$av = $sum/($n-$l);\n\techo $av;\n?>"}, {"source_code": "1&&$l<=$m;$i++) {\n\t\t$v = ($sum-$a[$i])/($n-$l);\n\t\tif($v>=$mx) {\n\t\t\t$sum -= $a[$i];\n\t\t\t$mx = $v;\n\t\t\t$l++;\n\t\t\t$a[$i] = 0;\n\t\t}\n\t}\n\t$m -= $l;\n\tfor($i=0;$i<$n;$i++) {\n\t\tif($a[$i]==0) continue;\n\t\tif($m>0) {\n\t\t\t$sum += min($m,$k);\n\t\t\t$m -= $k;\n\t\t}\n\t\telse break;\n\t}\n\t$v = $sum/($n-$l);\n\techo $v;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "d6e44bd8ac03876cb03be0731f7dda3d"} {"nl": {"description": "Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.Patrick believes that a message is fancy if any uppercase letter stands to the left of any lowercase one. In other words, this rule describes the strings where first go zero or more uppercase letters, and then \u2014 zero or more lowercase letters.To make the message fancy, Patrick can erase some letter and add the same letter in the same place in the opposite case (that is, he can replace an uppercase letter with the lowercase one and vice versa). Patrick got interested in the following question: what minimum number of actions do we need to make a message fancy? Changing a letter's case in the message counts as one action. Patrick cannot perform any other actions.", "input_spec": "The only line of the input contains a non-empty string consisting of uppercase and lowercase letters. The string's length does not exceed 105.", "output_spec": "Print a single number \u2014 the least number of actions needed to make the message fancy.", "sample_inputs": ["PRuvetSTAaYA", "OYPROSTIYAOPECHATALSYAPRIVETSTASYA", "helloworld"], "sample_outputs": ["5", "0", "0"], "notes": null}, "positive_code": [{"source_code": "= 0; $x--)\n{\n $c = strtoupper($a[$x]);\n if($c == $a[$x])\n {\n $a = substr($a, 0, $x + 1);\n break;\n }\n}\n$d = array();\n$e = 0;\n$f = 0;\n$g = 0;\n$h = 0;\n$i = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $j = strtolower($a[$x]);\n if($j != $a[$x])\n {\n $f++;\n }\n else\n {\n $g++;\n }\n if($h == 0)\n {\n if($j == $a[$x])\n {\n $i++;\n }\n else\n {\n $d[$e] = $i;\n $e++;\n $h = 1;\n $i = 1;\n }\n }\n else\n {\n if($j != $a[$x])\n {\n $i++;\n }\n else\n {\n $d[$e] = $i;\n $e++;\n $h = 0;\n $i = 1;\n }\n }\n}\n$d[$e] = $i;\n$k = min($f, $g);\n$l = 0;\nfor($x = 0; $x <= count($d); $x++)\n{\n $l += $d[$x];\n $f -= $d[$x + 1];\n $m = $l + $f;\n $k = min($k, $m);\n $x++;\n}\nprint $k;\n?>"}, {"source_code": "in();\n\t$S_array = str_split($S);\n\t$len = count($S_array);\n\t\n\t$u_cnt = array_fill(-1, $len, 0);\n\t$min = 100000 + 1;\n\tfor ($i = -1; $i < $len - 1; $i++) {\n\t\tif ($S_array[$i + 1] >= \"A\" && $S_array[$i + 1] <= \"Z\") {\n\t\t\t$u_cnt[$i + 1] = $u_cnt[$i] + 1;\n\t\t} else {\n\t\t\t$u_cnt[$i + 1] = $u_cnt[$i];\n\t\t}\n\t}\n\tfor ($i = -1; $i < $len; $i++) {\n\t\t$min = min($min, $u_cnt[$len - 1] - $u_cnt[$i] + $i + 1 - $u_cnt[$i]);\n\t}\n\t\n\tprint($min);\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "negative_code": [{"source_code": "= 0; $x--)\n{\n $c = strtoupper($a[$x]);\n if($c == $a[$x])\n {\n $a = substr($a, 0, $x + 1);\n break;\n }\n}\n$d = array();\n$e = 0;\n$f = 0;\n$g = 0;\n$h = 0;\n$i = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $j = strtolower($a[$x]);\n if($j != $a[$x])\n {\n $f++;\n }\n else\n {\n $g++;\n }\n if($h == 0)\n {\n if($j == $a[$x])\n {\n $i++;\n }\n else\n {\n $d[$e] = $i;\n $e++;\n $h = 1;\n $i = 1;\n }\n }\n else\n {\n if($j != $a[$x])\n {\n $i++;\n }\n else\n {\n $d[$e] = $i;\n $e++;\n $h = 0;\n $i = 1;\n }\n }\n}\n$d[$e] = $i;\n$k = min($f, $g);\nfor($x = count($d) - 1; $x > 0; $x--)\n{\n $f -= $g[$x];\n $g += $g[$x + 1];\n $l = $f + $g;\n $k = min($k, $l);\n}\nprint $k;\n?>"}, {"source_code": "in();\n\t$S_array = str_split($S);\n\t$len = count($S_array);\n\t\n\t$alp = array(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\");\n\t$l_pos = \"\";\n\t$u_pos = \"\";\n\t$l_count = array_fill(0,count($len), 0);\n\t$u_count = array_fill(0,count($len), 0);\n\t$min = 100000 + 1;\n\t$l_pre = 0;\n\t$u_pre = 0;\n\tfor ($i = 0; $i < $len; $i++) {\n\t\tfor ($j = 0; $j < count($alp); $j++) {\n\t\t\t$l_count[$i] = $l_pre;\n\t\t\t$u_count[$len - 1 - $i] = $u_pre;\n\t\t\t\n\t\t\tif ($S_array[$i] === $alp[$j]) {\n\t\t\t\t$l_count[$i] += 1;\n\t\t\t}\n\t\t\tif ($S_array[$len - 1 - $i] === strtoupper($alp[$j])) {\n\t\t\t\t$u_count[$len - 1 - $i] += 1;\n\t\t\t}\n\t\t\t\n\t\t\t$l_pre = $l_count[$i];\n\t\t\t$u_pre = $u_count[$len - 1 - $i];\n\t\t}\n\t}\n\tfor ($i = 0; $i < $len; $i++) {\n\t\t\n\t\t$min = min($min, $l_count[$i] + $u_count[$i + 1]);\n\t}\n\t\n\tprint($min);\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}, {"source_code": "in();\n\t$S_array = str_split($S);\n\t$len = count($S_array);\n\t\n\t$alp = array(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\");\n\t$l_pos = \"\";\n\t$u_pos = \"\";\n\t$l_count = 0;\n\t$u_count = 0;\n\t\n\tfor ($i = 0; $i < $len; $i++) {\n\t\tfor ($j = 0; $j < count($alp); $j++) {\n\t\tif ($S_array[$i] === $alp[$j] && $l_pos === \"\") {\n\t\t\t$l_pos = $i;\n\t\t\tbreak;\n\t\t}\n\t\tif ($l_pos !== \"\" && $S_array[$i] === strtoupper($alp[$j])) {\n\t\t\t\t$u_count++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor ($i = $len - 1; $i >= 0; $i--) {\n\t\tfor ($j = 0; $j < count($alp); $j++) {\n\t\t\tif ($S_array[$i] === strtoupper($alp[$j]) && $u_pos === \"\") {\n\t\t\t\t$u_pos = $i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ($u_pos !== \"\" && $S_array[$i] === $alp[$j]) {\n\t\t\t\t\t$l_count++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t}\n\t\n\tprint(min($u_count, $l_count));\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "src_uid": "92996552cc26a05258f2f2a1eb5f8a8f"} {"nl": {"description": "Kuznecov likes art, poetry, and music. And strings consisting of lowercase English letters.Recently, Kuznecov has found two strings, $$$a$$$ and $$$b$$$, of lengths $$$n$$$ and $$$m$$$ respectively. They consist of lowercase English letters and no character is contained in both strings. Let another string $$$c$$$ be initially empty. Kuznecov can do the following two types of operations: Choose any character from the string $$$a$$$, remove it from $$$a$$$, and add it to the end of $$$c$$$. Choose any character from the string $$$b$$$, remove it from $$$b$$$, and add it to the end of $$$c$$$. But, he can not do more than $$$k$$$ operations of the same type in a row. He must perform operations until either $$$a$$$ or $$$b$$$ becomes empty. What is the lexicographically smallest possible value of $$$c$$$ after he finishes?A string $$$x$$$ is lexicographically smaller than a string $$$y$$$ if and only if one of the following holds: $$$x$$$ is a prefix of $$$y$$$, but $$$x \\neq y$$$; in the first position where $$$x$$$ and $$$y$$$ differ, the string $$$x$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$y$$$.", "input_spec": "There are several test cases in the input data. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$)\u00a0\u2014 the number of test cases. This is followed by the test cases description. The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1\\leq n,m,k \\leq 100$$$)\u00a0\u2014 parameters from the statement. The second line of each test case contains the string $$$a$$$ of length $$$n$$$. The third line of each test case contains the string $$$b$$$ of length $$$m$$$. The strings contain only lowercase English letters. It is guaranteed that no symbol appears in $$$a$$$ and $$$b$$$ simultaneously.", "output_spec": "In each test case, output a single string $$$c$$$\u00a0\u2014 the answer to the problem.", "sample_inputs": ["3\n\n6 4 2\n\naaaaaa\n\nbbbb\n\n5 9 3\n\ncaaca\n\nbedededeb\n\n7 7 1\n\nnoskill\n\nwxhtzdy"], "sample_outputs": ["aabaabaa\naaabbcc\ndihktlwlxnyoz"], "notes": "NoteIn the first test case, it is optimal to take two 'a's from the string $$$a$$$ and add them to the string $$$c$$$. Then it is forbidden to take more characters from $$$a$$$, hence one character 'b' from the string $$$b$$$ has to be taken. Following that logic, we end up with $$$c$$$ being 'aabaabaa' when string $$$a$$$ is emptied.In the second test case it is optimal to take as many 'a's from string $$$a$$$ as possible, then take as many 'b's as possible from string $$$b$$$. In the end, we take two 'c's from the string $$$a$$$ emptying it. "}, "positive_code": [{"source_code": "0 && $m>0) {\r\n if($aa[$l] < $bb[$r]) {\r\n if($tt < $k) {\r\n $tb = 0;\r\n $tt++;\r\n $ans .= $alph[$aa[$l]];\r\n $l++;\r\n $n--;\r\n } else {\r\n $tt = 0; \r\n $tb++;\r\n $ans .= $alph[$bb[$r]];\r\n $r++;\r\n $m--;\r\n }\r\n } else {\r\n if($tb < $k) {\r\n $tt = 0;\r\n $tb++;\r\n $ans .= $alph[$bb[$r]];\r\n $r++;\r\n $m--;\r\n } else {\r\n $tb = 0; \r\n $tt++;\r\n $ans .= $alph[$aa[$l]];\r\n $l++;\r\n $n--;\r\n } \r\n }\r\n }\r\n \r\n IO::pr($ans);\r\n }\r\n \r\n \r\n class IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n \r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n }\r\n \r\n class Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a; \r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\n \r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n \r\n}\r\n \r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) { \r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a; \r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n \r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n \r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i = $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $b = [];\r\n $c = [];\r\n for ($i12 = 0; $i12 < $n; $i12++) {\r\n $x = IO::arr();\r\n $k = $x[0];\r\n $min = $x[1] + 1;\r\n for ($i = 1; $i <= $k; $i++) {\r\n if ($x[$i] >= $min + $i - 1) {\r\n $min = $x[$i] - $i + 2;\r\n }\r\n }\r\n $a[] = $x;\r\n $b[] = $min;\r\n if (isset($c[$min])) {\r\n $c[$min] += $k;\r\n } else {\r\n $c[$min] = $k;\r\n }\r\n }\r\n $res = [];\r\n ksort($c);\r\n// foreach ($c as $kk => $aV) {\r\n// IO::line($kk . ' - ' . implode(' ', $aV));\r\n// }\r\n $res = 0;\r\n $d = 0;\r\n foreach ($c as $minK => $aV) {\r\n if ($d < $minK) {\r\n $res += $minK - $d;\r\n $d += $minK - $d;\r\n }\r\n $d += $aV;\r\n }\r\n IO::line($res);\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $b = [];\r\n $c = [];\r\n for ($i12 = 0; $i12 < $n; $i12++) {\r\n $x = IO::arr();\r\n $k = $x[0];\r\n $min = $x[1] + 1;\r\n for ($i = 1; $i <= $k; $i++) {\r\n if ($x[$i] >= $min + $i - 1) {\r\n $min = $x[$i] - $i + 2;\r\n }\r\n }\r\n $a[] = $x;\r\n $b[] = $min;\r\n if (isset($c[$min])) {\r\n $c[$min] += $k;\r\n } else {\r\n $c[$min] = $k;\r\n }\r\n }\r\n $res = [];\r\n ksort($c);\r\n// foreach ($c as $kk => $aV) {\r\n// IO::line($kk . ' - ' . implode(' ', $aV));\r\n// }\r\n $res = 0;\r\n foreach ($c as $minK => $aV) {\r\n if ($res < $minK) {\r\n $res+= $minK - $res;\r\n }\r\n }\r\n IO::line($res);\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $b = [];\r\n $c = [];\r\n for ($i12 = 0; $i12 < $n; $i12++) {\r\n $x = IO::arr();\r\n $k = $x[0];\r\n $min = $x[1] + 1;\r\n for ($i = 1; $i <= $k; $i++) {\r\n if ($x[$i] >= $min + $i - 1) {\r\n $min += $x[$i] - $min;\r\n }\r\n }\r\n $a[] = $x;\r\n $b[] = $min;\r\n if (isset($c[$min])) {\r\n $c[$min][] = $k;\r\n } else {\r\n $c[$min] = [$k];\r\n }\r\n }\r\n $res = [];\r\n ksort($c);\r\n// foreach ($c as $kk => $aV) {\r\n// IO::line($kk . ' - ' . implode(' ', $aV));\r\n// }\r\n foreach ($c as $minK => $aV) {\r\n $d = $minK;\r\n $f = $minK;\r\n foreach ($c as $minK2 => $aV2) {\r\n if ($d <= $minK2) {\r\n $f += $minK2 - $d;\r\n $d += $minK2 - $d;\r\n }\r\n foreach ($aV2 as $sVal) {\r\n $d += $sVal;\r\n }\r\n }\r\n $res[] = $f;\r\n }\r\n IO::line(min($res));\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $a = [];\r\n $b = [];\r\n $c = [];\r\n for ($i12 = 0; $i12 < $n; $i12++) {\r\n $x = IO::arr();\r\n $k = $x[0];\r\n $min = $x[1] + 1;\r\n for ($i = 1; $i < $k; $i++) {\r\n if ($x[$i] >= $min + $i - 1) {\r\n $min += $x[$i] - $min;\r\n }\r\n }\r\n $a[] = $x;\r\n $b[] = $min;\r\n if (isset($c[$min])) {\r\n $c[$min][] = $k;\r\n } else {\r\n $c[$min] = [$k];\r\n }\r\n }\r\n $res = [];\r\n ksort($c);\r\n// foreach ($c as $kk => $aV) {\r\n// IO::line($kk . ' - ' . implode(' ', $aV));\r\n// }\r\n foreach ($c as $minK => $aV) {\r\n $d = $minK;\r\n $f = $minK;\r\n foreach ($c as $minK2 => $aV2) {\r\n if ($d <= $minK2) {\r\n $f += $minK2 - $d;\r\n $d += $minK2 - $d;\r\n }\r\n foreach ($aV2 as $sVal) {\r\n $d += $sVal;\r\n }\r\n }\r\n $res[] = $f;\r\n }\r\n IO::line(min($res));\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}], "src_uid": "88488ff074bc25a6cf925c8a07a1d8c6"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.You may choose at most one consecutive subarray of $$$a$$$ and multiply all values contained in this subarray by $$$x$$$. You want to maximize the beauty of array after applying at most one such operation.", "input_spec": "The first line contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$$$) \u2014 the length of array $$$a$$$ and the integer $$$x$$$ respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$-10^9 \\le a_i \\le 10^9$$$) \u2014 the array $$$a$$$.", "output_spec": "Print one integer \u2014 the maximum possible beauty of array $$$a$$$ after multiplying all values belonging to some consecutive subarray $$$x$$$.", "sample_inputs": ["5 -2\n-3 8 -2 1 -6", "12 -3\n1 3 3 7 1 3 3 7 1 3 3 7", "5 10\n-1 -2 -3 -4 -5"], "sample_outputs": ["22", "42", "0"], "notes": "NoteIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).In the second test case we don't need to multiply any subarray at all.In the third test case no matter which subarray we multiply, the beauty of array will be equal to 0."}, "positive_code": [{"source_code": " $f)\n{\n for($x = 0; $x < $e - $f; $x++)\n {\n print \"0\\n\";\n }\n}\n?>"}, {"source_code": " 1) {\n if ($i >= $n) {\n echo \"0\\n\";\n $k--;\n continue;\n }\n\n $min = $items[$i++] - $sum;\n\n if ($min <= 0) {\n continue;\n }\n\n $sum += $min;\n echo $min .\"\\n\";\n\n $k--;\n while ($i < $n && $items[$i] == $sum) {\n $i++;\n }\n}\n"}], "negative_code": [], "src_uid": "0f100199a720b0fdead5f03e1882f2f3"} {"nl": {"description": "Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height of the $$$i$$$-th part of the wall.Vova can only use $$$2 \\times 1$$$ bricks to put in the wall (he has infinite supply of them, however).Vova can put bricks horizontally on the neighboring parts of the wall of equal height. It means that if for some $$$i$$$ the current height of part $$$i$$$ is the same as for part $$$i + 1$$$, then Vova can put a brick there and thus increase both heights by 1. Obviously, Vova can't put bricks in such a way that its parts turn out to be off the borders (to the left of part $$$1$$$ of the wall or to the right of part $$$n$$$ of it).The next paragraph is specific to the version 1 of the problem.Vova can also put bricks vertically. That means increasing height of any part of the wall by 2.Vova is a perfectionist, so he considers the wall completed when: all parts of the wall has the same height; the wall has no empty spaces inside it. Can Vova complete the wall using any amount of bricks (possibly zero)?", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u2014 the initial heights of the parts of the wall.", "output_spec": "Print \"YES\" if Vova can complete the wall using any amount of bricks (possibly zero). Print \"NO\" otherwise.", "sample_inputs": ["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10", "3\n1 2 3"], "sample_outputs": ["YES", "YES", "YES", "NO"], "notes": "NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put a brick vertically on part 3 to make the wall $$$[4, 5, 5]$$$, then horizontally on parts 2 and 3 to make it $$$[4, 6, 6]$$$ and then vertically on part 1 to make it $$$[6, 6, 6]$$$.In the third example the wall is already complete."}, "positive_code": [{"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0, $func = null) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $func?$func((int)$item):(int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\n/* Perform action N times. Can return values in array */\nfunction ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\n/* Integral. Keys preserved. By reference. */\nfunction cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\n/* Difference. Keys preserved. By reference. */\nfunction diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\nfunction bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n$a = $ir->readArrayOfInt($n, 0, function($e){return $e&1;});\n\n$stack = [];\nforeach ($a as $k=>$v) {\n\tif ($v) {\n\t\tif ($stack && ($k - current($stack) - 1)%2==0) {\n\t\t\tarray_pop($stack);\n\t\t} else {\n\t\t\t$stack[]=$k;\n\t\t}\n\t}\n}\n\nif (count($stack)==0) {\n\t$result = true;\n} elseif(count($stack)>1) {\n\t$result = false;\n} else {\n\t$e = array_pop($stack)&1;\n\tif ($e) {\n\t\t$result = false;\n\t} else {\n\t\t$result = ($n%2==1);\n\t}\n}\n\necho $result ? 'YES' : 'NO';\n"}], "negative_code": [{"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\n/* Perform action N times. Can return values in array */\nfunction ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\n/* Integral. Keys preserved. By reference. */\nfunction cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\n/* Difference. Keys preserved. By reference. */\nfunction diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\nfunction bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n$a = $ir->readArrayOfInt($n);\n\n$m = max($a);\n$sd = $m*$n - array_sum($a);\n\n$allOdds = true;\nfor ($i=1; $i<$n; $i++) {\n\tif (abs($a[$i] - $a[$i-1])%2==0) {\n\t\t$allOdds = false;\n\t\tbreak;\n\t}\n}\n\nif ($allOdds) {\n\techo 'NO';\n\texit();\n}\n\nif ($sd%2==0 || $n%2==1) {\n\techo 'YES';\n} else {\n\techo 'NO';\n}\n"}], "src_uid": "bb4ecfaaccd538e23f883a18f9672af8"} {"nl": {"description": "Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!The computers bought for the room were different. Some of them had only USB ports, some\u00a0\u2014 only PS/2 ports, and some had both options.You have found a price list of a certain computer shop. In it, for m mouses it is specified the cost and the type of the port that is required to plug the mouse in (USB or PS/2). Each mouse from the list can be bought at most once.You want to buy some set of mouses from the given price list in such a way so that you maximize the number of computers equipped with mouses (it is not guaranteed that you will be able to equip all of the computers), and in case of equality of this value you want to minimize the total cost of mouses you will buy.", "input_spec": "The first line contains three integers a, b and c (0\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u2009105) \u00a0\u2014 the number of computers that only have USB ports, the number of computers, that only have PS/2 ports, and the number of computers, that have both options, respectively. The next line contains one integer m (0\u2009\u2264\u2009m\u2009\u2264\u20093\u00b7105) \u00a0\u2014 the number of mouses in the price list. The next m lines each describe another mouse. The i-th line contains first integer vali (1\u2009\u2264\u2009vali\u2009\u2264\u2009109) \u00a0\u2014 the cost of the i-th mouse, then the type of port (USB or PS/2) that is required to plug the mouse in.", "output_spec": "Output two integers separated by space\u00a0\u2014 the number of equipped computers and the total cost of the mouses you will buy.", "sample_inputs": ["2 1 1\n4\n5 USB\n6 PS/2\n3 PS/2\n7 PS/2"], "sample_outputs": ["3 14"], "notes": "NoteIn the first example you can buy the first three mouses. This way you will equip one of the computers that has only a USB port with a USB mouse, and the two PS/2 mouses you will plug into the computer with PS/2 port and the computer with both ports."}, "positive_code": [{"source_code": " $f[$y])\n {\n $i += $f[$y];\n $y++;\n }\n}\nprint ($x + $y) . \" \";\nprintf(\"%.0f\", $i);\n?>"}, {"source_code": "\n list($a, $b, $c) = explode(' ', trim(fgets(STDIN)));\n $n = trim(fgets(STDIN));\n for ($i = 0; $i < $n; $i++) {\n list($x, $s) = explode(' ', trim(fgets(STDIN)));\n if ($s == \"USB\") {\n $u[] = $x;\n } elseif ($s == \"PS/2\") {\n $p[] = $x;\n }\n }\n \n sort($u);\n \n $e = array();\n \n function arrSum($inArray) {\n $result = 0;\n foreach ($inArray as $value) {\n $result = bcadd($result, $value);\n }\n return $result;\n }\n \n if (count($u) <= $a) {\n $ans += count($u);\n $sum = bcadd($sum, arrSum($u));\n } else {\n $e = array_slice($u, $a, count($u) - $a);\n $ans += $a;\n $sum = bcadd($sum, arrSum(array_slice($u, 0, $a)));\n }\n \n \n sort($p);\n \n if (count($p) <= $b) {\n $ans += count($p);\n $sum = bcadd($sum, arrSum($p));\n } else {\n $e = array_merge($e, array_slice($p, $b, count($p) - $b));\n $ans += $b;\n $sum = bcadd($sum, arrSum(array_slice($p, 0, $b)));\n }\n \n \n sort($e);\n \n if (count($e) <= $c) {\n $ans += count($e);\n $sum = bcadd($sum, arrSum($e));\n } else {\n $ans += $c;\n $sum = bcadd($sum, arrSum(array_slice($e, 0, $c)));\n }\n \n printf(\"%d %s\\n\", $ans, $sum);\n \n?>"}, {"source_code": "\n list($a, $b, $c) = explode(' ', trim(fgets(STDIN)));\n $n = trim(fgets(STDIN));\n for ($i = 0; $i < $n; $i++) {\n list($x, $s) = explode(' ', trim(fgets(STDIN)));\n if ($s == \"USB\") {\n $u[] = $x;\n } elseif ($s == \"PS/2\") {\n $p[] = $x;\n }\n }\n \n sort($u);\n \n $e = array();\n \n if (count($u) <= $a) {\n $ans += count($u);\n $sum += array_sum($u);\n } else {\n $e = array_slice($u, $a, count($u) - $a);\n $ans += $a;\n $sum += array_sum(array_slice($u, 0, $a));\n }\n sort($p);\n \n if (count($p) <= $b) {\n $ans += count($p);\n $sum += array_sum($p);\n } else {\n $e = array_merge($e, array_slice($p, $b, count($p) - $b));\n $ans += $b;\n $sum += array_sum(array_slice($p, 0, $b));\n }\n \n sort($e);\n \n \n if (count($e) <= $c) {\n $ans += count($e);\n $sum += array_sum($e);\n } else {\n $ans += $c;\n $sum += array_sum(array_slice($e, 0, $c));\n }\n \n printf(\"%d %.0f\\n\", $ans, $sum);\n \n?>"}], "negative_code": [{"source_code": " $f[$y])\n {\n $i += $f[$y];\n $y++;\n }\n else\n {\n break;\n }\n}\nif($d == 0)\n{\n print \"0 0\";\n}\nelse\n{\n print ($x + $y) . \" \" . $i;\n}\n?>"}, {"source_code": " $f[$y])\n {\n $i += $f[$y];\n $y++;\n }\n}\nprint ($x + $y) . \" \" . $i;\n?>"}, {"source_code": "\n list($a, $b, $c) = explode(' ', trim(fgets(STDIN)));\n $n = trim(fgets(STDIN));\n for ($i = 0; $i < $n; $i++) {\n list($x, $s) = explode(' ', trim(fgets(STDIN)));\n if ($s == \"USB\") {\n $u[] = $x;\n } elseif ($s == \"PS/2\") {\n $p[] = $x;\n }\n }\n \n sort($u);\n \n $f = array();\n \n if (count($u) <= $a) {\n $ans += count($u);\n $sum += array_sum($u);\n } else {\n $f = array_slice($u, $a, count($u) - $a);\n $ans += $a;\n $sum += array_sum(array_slice($u, 0, $a));\n }\n sort($p);\n \n if (count($p) <= $b) {\n $ans += count($p);\n $sum += array_sum($p);\n } else {\n $s = array_merge($f, array_slice($p, $b, count($p) - $b));\n $ans += $b;\n $sum += array_sum(array_slice($p, 0, $b));\n }\n \n sort($s);\n \n \n if (count($s) <= $c) {\n $ans += count($s);\n $sum += array_sum($s);\n } else {\n $ans += $c;\n $sum += array_sum(array_slice($s, 0, $c));\n }\n \n printf(\"%d %d\\n\", $ans, $sum);\n \n?>"}], "src_uid": "3d6151b549bd52f95ab7fdb972e6fb98"} {"nl": {"description": "Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1,\u2009b2,\u2009b3,\u2009..., where for each i\u2009>\u20091 the respective term satisfies the condition bi\u2009=\u2009bi\u2009-\u20091\u00b7q, where q is called the common ratio of the progression. Progressions in Uzhlyandia are unusual: both b1 and q can equal 0. Also, Dvastan gave Masha m \"bad\" integers a1,\u2009a2,\u2009...,\u2009am, and an integer l.Masha writes all progression terms one by one onto the board (including repetitive) while condition |bi|\u2009\u2264\u2009l is satisfied (|x| means absolute value of x). There is an exception: if a term equals one of the \"bad\" integers, Masha skips it (doesn't write onto the board) and moves forward to the next term.But the lesson is going to end soon, so Masha has to calculate how many integers will be written on the board. In order not to get into depression, Masha asked you for help: help her calculate how many numbers she will write, or print \"inf\" in case she needs to write infinitely many integers.", "input_spec": "The first line of input contains four integers b1, q, l, m (-109\u2009\u2264\u2009b1,\u2009q\u2009\u2264\u2009109, 1\u2009\u2264\u2009l\u2009\u2264\u2009109, 1\u2009\u2264\u2009m\u2009\u2264\u2009105)\u00a0\u2014 the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of \"bad\" integers, respectively. The second line contains m distinct integers a1,\u2009a2,\u2009...,\u2009am (-109\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 numbers that will never be written on the board.", "output_spec": "Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or \"inf\" (without quotes) otherwise.", "sample_inputs": ["3 2 30 4\n6 14 25 48", "123 1 2143435 4\n123 11 -5453 141245", "123 1 2143435 4\n54343 -13 6 124"], "sample_outputs": ["3", "0", "inf"], "notes": "NoteIn the first sample case, Masha will write integers 3,\u200912,\u200924. Progression term 6 will be skipped because it is a \"bad\" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a \"bad\" integer.In the third case, Masha will write infinitely integers 123. "}, "positive_code": [{"source_code": " $c)\n{\n print \"0\";\n}\nelse\n{\n if(($a == 0) || ($b == 0) || (($a == 0) && ($b == 0)))\n {\n if($f[$a * $b] == TRUE)\n {\n if($f[$a] == TRUE)\n {\n print \"0\";\n }\n else\n {\n print \"1\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n elseif(($b == 1) || (($a == 1) && ($b == 1)))\n {\n if($f[$a * $b] == TRUE)\n {\n if($f[$a] == TRUE)\n {\n print \"0\";\n }\n else\n {\n print \"1\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n elseif(($b == -1) || (($a == -1) && ($b == -1)))\n {\n if(($f[$a * $b] == TRUE) && ($f[$a * $b * (-1)] == TRUE))\n {\n if(($f[$a] == TRUE) && ($f[$a * (-1)] == TRUE))\n {\n print \"0\";\n }\n elseif($f[$a] == TRUE)\n {\n print \"1\";\n }\n elseif($f[$a * (-1)] == TRUE)\n {\n print \"1\";\n }\n else\n {\n print \"2\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n else\n {\n $g = 0;\n while(TRUE)\n {\n if(abs($a) > $c)\n {\n break;\n }\n elseif($f[$a] == FALSE)\n {\n $g++;\n }\n $a *= $b;\n }\n print $g;\n }\n}\n?>"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(abs($b1) > $l)echo \"0\\n\";\n else if(!array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if ($q == -1){\n if(abs($b1)>$l)echo \"0\\n\";\n else if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if ($q == 1){\n if(array_key_exists($b1,$a)||abs($b1)>$l)\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a)){\n if(isset($a[$b1])||abs($b1)>$l)echo \"0\\n\";\n else echo \"1\\n\";\n }\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n }"}], "negative_code": [{"source_code": " $c)\n {\n break;\n }\n elseif($f[$a] == FALSE)\n {\n $g++;\n }\n $a *= $b;\n }\n print $g;\n}\n?>"}, {"source_code": " $c)\n {\n break;\n }\n elseif($f[$a] == FALSE)\n {\n $g++;\n }\n $a *= $b;\n }\n print $g;\n}\n?>"}, {"source_code": " $c)\n {\n break;\n }\n elseif($f[$a] == FALSE)\n {\n $g++;\n }\n $a *= $b;\n }\n print $g;\n}\n?>"}, {"source_code": " $c)\n{\n print \"0\";\n}\nelse\n{\n if(($a == 0) || ($b == 0) || (($a == 0) && ($b == 0)))\n {\n if($f[$a * $b] == TRUE)\n {\n if($f[$a] == TRUE)\n {\n print \"0\";\n }\n else\n {\n print \"1\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n elseif(($b == 1) || (($a == 1) && ($b == 1)))\n {\n if($f[$a * $b] == TRUE)\n {\n if($f[$a] == TRUE)\n {\n print \"0\";\n }\n else\n {\n print \"1\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n elseif(($b == -1) || (($a == -1) && ($b == -1)))\n {\n if(($f[$a * $b] == TRUE) && ($f[$a * $b * (-1)] == TRUE))\n {\n if(($f[$a] == TRUE) && ($f[$a * (-1)] == TRUE))\n {\n print \"0\";\n }\n elseif($f[$a] == TRUE)\n {\n print \"1\";\n }\n elseif($f[$a * (-1)] == TRUE)\n {\n print \"1\";\n }\n else\n {\n print \"2\";\n }\n }\n else\n {\n print \"inf\";\n }\n }\n else\n {\n $g = 0;\n while(TRUE)\n {\n if(abs($a) > $c)\n {\n break;\n }\n elseif($f[$a] == FALSE)\n {\n $g++;\n }\n $a *= $b;\n }\n print $g;\n }\n}\n?>"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(!array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)|| abs($b1) > $l) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if ($q == -1){\n if(abs($b1)>$l)echo \"0\\n\";\n else if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if ($q == 1){\n if(array_key_exists($b1,$a)||abs($b1)>$l)\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a)){\n if(isset($a[$b1])||abs($b1)>$l)echo \"0\\n\";\n else echo \"1\\n\";\n }\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n }"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(!array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if ($q == -1){\n if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if ($q == 1){\n if(array_key_exists($b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a)){\n if(isset($a[$b1]))echo \"0\\n\";\n else echo \"1\\n\";\n }\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n }\n"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if ($q == -1){\n if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if ($q == 1){\n if(array_key_exists($b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a))echo \"0\\n\";\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n}"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(!array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)|| abs($b1) > $m) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if ($q == -1){\n if(abs($b1)>$m)echo \"0\\n\";\n else if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if ($q == 1){\n if(array_key_exists($b1,$a)||abs($b1)>$m)\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a)){\n if(isset($a[$b1])||abs($b1)>$m)echo \"0\\n\";\n else echo \"1\\n\";\n }\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n }\n"}, {"source_code": "debugMode = $flag;\n\n }\n function D($x){\n if($this->debugMode)var_dump($x);\n }\n function run(){\n list($b1,$q,$l,$m) = readLine();\n $a = readLine();\n $a = array_flip($a);\n if($q == 0) {\n if(array_key_exists(0,$a)) echo \"inf\\n\";\n else {\n if(array_key_exists($b1,$a)) echo \"0\\n\";\n else echo \"1\\n\";\n }\n\n } else if (abs($q) == 1){\n if(array_key_exists($b1,$a) && array_key_exists(-$b1,$a))\n echo \"0\\n\";\n else\n echo \"inf\\n\";\n } else if($b1) {\n $ans=0;\n while(abs($b1)<=$l) {\n if(!array_key_exists($b1,$a))$ans++;\n $b1 = $b1 * $q;\n }\n echo \"$ans\\n\";\n } else {\n if(array_key_exists(0,$a))echo \"0\\n\";\n else echo \"inf\\n\";\n }\n }\n};\n$caseNum=1;\nfor($caseId = 1;$caseId <= $caseNum; $caseId++){\n //echo 'Case #' . $caseId . ': ';\n $sol = new Solution(true);\n $sol->run();\n}"}], "src_uid": "749c290c48272a53e2e79730dab0538e"} {"nl": {"description": "Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types \u2014 shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has $$$a$$$ sticks and $$$b$$$ diamonds?", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u2014 the number of test cases. The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$0 \\le a, b \\le 10^9$$$)\u00a0\u2014 the number of sticks and the number of diamonds, respectively.", "output_spec": "For each test case print one integer \u2014 the maximum number of emeralds Polycarp can earn.", "sample_inputs": ["4\n4 4\n1000000000 0\n7 15\n8 7"], "sample_outputs": ["2\n0\n7\n5"], "notes": "NoteIn the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.In the second test case Polycarp does not have any diamonds, so he cannot craft anything."}, "positive_code": [{"source_code": "= $b * 2) echo $b . \"\\n\" ;\n else \n {\n $ans = $a - $b ;\n $a -= 2 * $ans ;\n \n $ans += intval($a / 3) * 2 ;\n \n $a = $a - 3 * intval($a / 3) ;\n if($a == 2) $ans ++ ;\n \n echo $ans . \"\\n\" ;\n }\n }\n?>"}, {"source_code": " $a) {\n $ans = $a;\n }\n if($ans > $b) {\n $ans = $b;\n }\n echo $ans . PHP_EOL;\n \n}"}], "negative_code": [{"source_code": "= $b * 2) echo $b . \"\\n\" ;\n else \n {\n $ans = min(intval($a/3), intval($b/3)) * 2 ;\n \n $a = $a - 3 * $ans / 2 ;\n $b = $b - 3 * $ans / 2 ;\n \n if($a >= 1 && $b >= 2) $ans ++ ;\n else if($a >= 2 && $b >= 1) $ans ++ ;\n \n echo $ans . \"\\n\" ;\n }\n }\n?>"}, {"source_code": "= $b * 2) echo $b . \"\\n\" ;\n else \n {\n $ans = $a - $b ;\n \n $a -= 2 * $ans ;\n \n $ans += intval($a / 3) * 2 ;\n \n echo $ans . \"\\n\" ;\n }\n }\n?>"}, {"source_code": "$data = [];\nwhile($line = fgets(STDIN)) {\n $data[] = $line\n}\n\nvar_dump($data);"}, {"source_code": " $a) {\n $ans = $a;\n }\n if($ans > $b) {\n $ans = $b;\n }\n echo $ans;\n \n}"}], "src_uid": "8bbec86e427e26158393bbfbf1a067fe"} {"nl": {"description": "For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three numbers: $$$n_0$$$ \u2014 the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$0$$$; $$$n_1$$$ \u2014 the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$1$$$; $$$n_2$$$ \u2014 the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$2$$$. For example, for the string $$$s=$$$\"1110011110\", the following substrings would be written: \"11\", \"11\", \"10\", \"00\", \"01\", \"11\", \"11\", \"11\", \"10\". Thus, $$$n_0=1$$$, $$$n_1=3$$$, $$$n_2=5$$$.Your task is to restore any suitable binary string $$$s$$$ from the given values $$$n_0, n_1, n_2$$$. It is guaranteed that at least one of the numbers $$$n_0, n_1, n_2$$$ is greater than $$$0$$$. Also, it is guaranteed that a solution exists.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) \u2014 the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \\le n_0, n_1, n_2 \\le 100$$$; $$$n_0 + n_1 + n_2 > 0$$$). It is guaranteed that the answer for given $$$n_0, n_1, n_2$$$ exists.", "output_spec": "Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.", "sample_inputs": ["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"], "sample_outputs": ["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "4bbb078b66b26d6414e30b0aae845b98"} {"nl": {"description": "Recently Petya walked in the forest and found a magic stick.Since Petya really likes numbers, the first thing he learned was spells for changing numbers. So far, he knows only two spells that can be applied to a positive integer: If the chosen number $$$a$$$ is even, then the spell will turn it into $$$\\frac{3a}{2}$$$; If the chosen number $$$a$$$ is greater than one, then the spell will turn it into $$$a-1$$$. Note that if the number is even and greater than one, then Petya can choose which spell to apply.Petya now has only one number $$$x$$$. He wants to know if his favorite number $$$y$$$ can be obtained from $$$x$$$ using the spells he knows. The spells can be used any number of times in any order. It is not required to use spells, Petya can leave $$$x$$$ as it is.", "input_spec": "The first line contains single integer $$$T$$$ ($$$1 \\le T \\le 10^4$$$) \u2014 the number of test cases. Each test case consists of two lines. The first line of each test case contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x, y \\le 10^9$$$) \u2014 the current number and the number that Petya wants to get.", "output_spec": "For the $$$i$$$-th test case print the answer on it \u2014 YES if Petya can get the number $$$y$$$ from the number $$$x$$$ using known spells, and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).", "sample_inputs": ["7\n2 3\n1 1\n3 6\n6 8\n1 2\n4 1\n31235 6578234"], "sample_outputs": ["YES\nYES\nNO\nYES\nNO\nYES\nYES"], "notes": null}, "positive_code": [{"source_code": "= 4)\n {\n print \"YES\\n\";\n }\n}\n?>"}, {"source_code": "= $y){\n $bFlag = true;\n break;\n }\n $x = $x - 1;\n if($d == $x) {\n $bFlag = false;\n break;\n }\n\n }\n } else {\n $d = $x;\n while (true) {\n $x = $x - 1;\n $x = $x * 1.5;\n if($x >= $y){\n $bFlag = true;\n break;\n }\n if($d == $x) {\n $bFlag = false;\n break;\n }\n }\n }\n } else {\n $bFlag = true;\n }\n }\n\n //echo $x . ' ' . $y . \"\\n\";\n if($bFlag){\n echo \"YES\".\"\\n\";\n } else {\n echo \"NO\".\"\\n\";\n }\n}"}, {"source_code": ""}, {"source_code": "3)\n {\n $a=(3*$a)/2;\n }\n if($a==2)$a=3;\n if($a>=$l)\n {\n echo \"YES\\n\";\n }else\n {\n echo \"NO\\n\";\n }\n\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n \n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $w=$str1[0];$y=$str1[1];\n if($w==$y)\n {\n echo \"YES\\n\";\n }else\n {\n gcd($w,$y);\n }\n\n\n }\n\n\n}\n\nsolve();\n?>"}], "negative_code": [{"source_code": "= $y) {\n $bFlag = true;\n } else {\n $bFlag = false;\n }\n } else {\n $d = $x;\n while (true) {\n $x = $x - 1;\n $x = $x * 1.5;\n if($x >= $y){\n $bFlag = true;\n break;\n }\n if($d == $x) {\n $bFlag = false;\n break;\n }\n }\n }\n } else {\n $bFlag = true;\n }\n }\n\n if($bFlag){\n echo \"YES\".\"\\n\";\n } else {\n echo \"NO\".\"\\n\";\n }\n}"}, {"source_code": "= $y) {\n $bFlag = true;\n } else {\n $bFlag = false;\n }\n } else {\n $d = $x;\n while (true) {\n $x = $x - 1;\n $x = $x * 1.5;\n if($x >= $y){\n $bFlag = true;\n break;\n }\n if($d == $x) {\n $bFlag = false;\n break;\n }\n }\n }\n } else {\n $bFlag = true;\n }\n }\n\n //echo $x . ' ' . $y . \"\\n\";\n if($bFlag){\n echo \"YES\".\"\\n\";\n } else {\n echo \"NO\".\"\\n\";\n }\n}"}, {"source_code": "=$y)\n {\n echo \"Yes \\n\";\n }else\n {\n if(lcm($w,$y)!=$y)\n echo \"Yes\\n\";\n else\n echo \"No\\n\";\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": "=$l)break;\n }\n if(is_float($a))\n {\n if($a-1<$l)\n echo \"No\\n\";\n else\n echo \"Yes\\n\";\n }else\n {\n echo \"Yes\\n\";\n }\n\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n \n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $w=$str1[0];$y=$str1[1];\n if($w==$y || $w>$y)\n {\n echo \"Yes \\n\";\n }else\n {\n gcd($w,$y);\n }\n\n\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": ""}, {"source_code": "=$l)break;\n }\n if(is_float($a))\n {\n if($a-1<$l)\n echo \"No\\n\";\n else\n echo \"Yes\\n\";\n }else\n {\n echo \"Yes\\n\";\n }\n\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n \n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $w=$str1[0];$y=$str1[1];\n if($w==$y || $w>$y)\n {\n echo \"Yes \\n\";\n }else\n {\n if($y%$w>0)\n echo \"Yes\\n\";\n else\n echo \"No\\n\";\n }\n }\n\n\n}\n\nsolve();\n?>"}, {"source_code": "=$l)break;\n }\n if(is_float($a))\n {\n if($a-1<$l)\n echo \"No\\n\";\n else\n echo \"Yes\\n\";\n }else\n {\n echo \"Yes\\n\";\n }\n\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;$t=0;\n $x=trim(fgets($handle));\n for($i=0;$i<$x;$i++)\n {\n \n $str=trim(fgets($handle));\n $str1=explode(\" \",$str);\n $w=$str1[0];$y=$str1[1];\n if($w==$y)\n {\n echo \"Yes \\n\";\n }else\n {\n gcd($w,$y);\n }\n\n\n }\n\n\n}\n\nsolve();\n?>"}], "src_uid": "b3978805756262e17df738e049830427"} {"nl": {"description": "InteractionThis is an interactive problem. You need to read participants' queries from standard input and print your responses to standard output. You don't know the number of queries upfront, so you'll need to process them as you get them; you'll know you're done once you reach the end of the file.In each query, you will be asked the question, written in one line. You have to answer it correctly, patiently and without any display of emotions. Your response is case-insensitive.Please make sure to use the stream flushing operation after each response in order not to leave part of your output in some buffer.ExampleInput\nIs it rated?\nIs it rated?\nIs it rated?\nOutput\nNO\nNO\nNO", "input_spec": null, "output_spec": null, "sample_inputs": ["Is it rated?\nIs it rated?\nIs it rated?"], "sample_outputs": ["NO\nNO\nNO"], "notes": null}, "positive_code": [{"source_code": "NO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\n"}, {"source_code": "NO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\n"}, {"source_code": "NO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO\r\nNO"}, {"source_code": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO"}, {"source_code": "no\r\nno\r\nno\r\nno\r\nno\r\nno\r\nno\r\nno"}], "negative_code": [{"source_code": "NO\r\nNO\r\nNO"}, {"source_code": "NO"}], "src_uid": "57b62c485669809c0b59afd6613f901c"} {"nl": {"description": "You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri] ki times. The queries should be processed one after another in the order they are given.One operation of a cyclic shift (rotation) is equivalent to moving the last character to the position of the first character and shifting all other characters one position to the right.For example, if the string s is abacaba and the query is l1\u2009=\u20093,\u2009r1\u2009=\u20096,\u2009k1\u2009=\u20091 then the answer is abbacaa. If after that we would process the query l2\u2009=\u20091,\u2009r2\u2009=\u20094,\u2009k2\u2009=\u20092 then we would get the string baabcaa.", "input_spec": "The first line of the input contains the string s (1\u2009\u2264\u2009|s|\u2009\u2264\u200910\u2009000) in its initial state, where |s| stands for the length of s. It contains only lowercase English letters. Second line contains a single integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009300)\u00a0\u2014 the number of queries. The i-th of the next m lines contains three integers li, ri and ki (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009|s|,\u20091\u2009\u2264\u2009ki\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 the description of the i-th query.", "output_spec": "Print the resulting string s after processing all m queries.", "sample_inputs": ["abacaba\n2\n3 6 1\n1 4 2"], "sample_outputs": ["baabcaa"], "notes": "NoteThe sample is described in problem statement."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "501b60c4dc465b8a60fd567b208ea1e3"} {"nl": {"description": "A multi-subject competition is coming! The competition has $$$m$$$ different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students. He has $$$n$$$ candidates. For the $$$i$$$-th person he knows subject $$$s_i$$$ the candidate specializes in and $$$r_i$$$ \u2014 a skill level in his specialization (this level can be negative!). The rules of the competition require each delegation to choose some subset of subjects they will participate in. The only restriction is that the number of students from the team participating in each of the chosen subjects should be the same.Alex decided that each candidate would participate only in the subject he specializes in. Now Alex wonders whom he has to choose to maximize the total sum of skill levels of all delegates, or just skip the competition this year if every valid non-empty delegation has negative sum.(Of course, Alex doesn't have any spare money so each delegate he chooses must participate in the competition).", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 10^5$$$, $$$1 \\le m \\le 10^5$$$) \u2014 the number of candidates and the number of subjects. The next $$$n$$$ lines contains two integers per line: $$$s_i$$$ and $$$r_i$$$ ($$$1 \\le s_i \\le m$$$, $$$-10^4 \\le r_i \\le 10^4$$$) \u2014 the subject of specialization and the skill level of the $$$i$$$-th candidate.", "output_spec": "Print the single integer \u2014 the maximum total sum of skills of delegates who form a valid delegation (according to rules above) or $$$0$$$ if every valid non-empty delegation has negative sum.", "sample_inputs": ["6 3\n2 6\n3 6\n2 5\n3 5\n1 9\n3 1", "5 3\n2 6\n3 6\n2 5\n3 5\n1 11", "5 2\n1 -1\n1 -5\n2 -1\n2 -1\n1 -10"], "sample_outputs": ["22", "23", "0"], "notes": "NoteIn the first example it's optimal to choose candidates $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, so two of them specialize in the $$$2$$$-nd subject and other two in the $$$3$$$-rd. The total sum is $$$6 + 6 + 5 + 5 = 22$$$.In the second example it's optimal to choose candidates $$$1$$$, $$$2$$$ and $$$5$$$. One person in each subject and the total sum is $$$6 + 6 + 11 = 23$$$.In the third example it's impossible to obtain a non-negative sum."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n {\n $g[0] += $f[0];\n }\n else\n {\n for($y = 0; $y < count($f) - 1; $y++)\n {\n $f[$y + 1] += $f[$y];\n if($f[$y + 1] <= 0)\n {\n unset($f[$y + 1]);\n break;\n }\n else\n {\n $g[$y + 1] += $f[$y + 1];\n }\n }\n }\n }\n}\nif(count($g) == 0)\n{\n print \"0\";\n}\nelse\n{\n print max($g);\n}\n?>"}, {"source_code": ""}], "src_uid": "cb688cc52bd2bf0af77084dc4a25c28b"} {"nl": {"description": "In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1,\u2009a2,\u2009...,\u2009an from the new collection. Today is Tanya's birthday, and her mother decided to spend no more than m bourles on the gift to the daughter. Tanya will choose several different types of toys from the new collection as a gift. Of course, she does not want to get a type of toy which she already has.Tanya wants to have as many distinct types of toys in her collection as possible as the result. The new collection is too diverse, and Tanya is too little, so she asks you to help her in this.", "input_spec": "The first line contains two integers n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000) and m (1\u2009\u2264\u2009m\u2009\u2264\u2009109)\u00a0\u2014 the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the types of toys that Tanya already has.", "output_spec": "In the first line print a single integer k\u00a0\u2014 the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integers t1,\u2009t2,\u2009...,\u2009tk (1\u2009\u2264\u2009ti\u2009\u2264\u2009109)\u00a0\u2014 the types of toys that Tanya should choose. If there are multiple answers, you may print any of them. Values of ti can be printed in any order.", "sample_inputs": ["3 7\n1 3 4", "4 14\n4 6 12 8"], "sample_outputs": ["2\n2 5", "4\n7 2 3 1"], "notes": "NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys."}, "positive_code": [{"source_code": "= 0)\n {\n $d[$e] = $x;\n $e++;\n }\n else\n {\n break;\n }\n }\n}\nif(count($d) == 0)\n{\n print \"0\";\n}\nelse\n{\n print count($d) . \"\\n\";\n print implode(\" \", $d);\n}\n?>"}, {"source_code": "= 0) {\n if ($rub - $k < 0) {\n break;\n }\n \n if (($t+1) == $count_types) {\n \n }\n \n if ($k < $types[$t] || is_null($types[$t]) ) {\n $rub -= $k;\n if ($rub >= 0) {\n $list[] = $k;\n $n++;\n }\n } else {\n $t++;\n }\n \n $k++;\n}\n\necho $n.\"\\n\".implode(' ', $list);\n\n\n\n?>"}], "negative_code": [{"source_code": "= 0) {\n if ($rub - $k < 0) {\n break;\n }\n \n if (($t+1) == $count_types) {\n \n }\n \n if ($k < $types[$t] || is_null($types[$t]) ) {\n $rub -= $k;\n if ($rub >= 0) {\n $list[] = $k;\n $n++;\n }\n } else {\n $t++;\n }\n \n $k++;\n}\n\necho $n.\"\\n\".implode(' ', $list);\n\n\n\n?>"}, {"source_code": "= 0) {\n if ($rub - $k < 0) {\n break;\n }\n \n if ($k < $types[$t]) {\n $rub -= $k;\n if ($rub >= 0) {\n $list[] = $k;\n $n++;\n }\n } else {\n $t++;\n }\n \n $k++;\n}\n\necho $n.\"\\n\".implode(' ', $list);\n\n\n\n?>"}], "src_uid": "0318d4d5ea3425bf6506edeb1026f597"} {"nl": {"description": "During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $$$n$$$ high school students numbered from $$$1$$$ to $$$n$$$. Initially, each student $$$i$$$ is on position $$$i$$$. Each student $$$i$$$ is characterized by two numbers\u00a0\u2014 $$$a_i$$$ and $$$b_i$$$. Dissatisfaction of the person $$$i$$$ equals the product of $$$a_i$$$ by the number of people standing to the left of his position, add the product $$$b_i$$$ by the number of people standing to the right of his position. Formally, the dissatisfaction of the student $$$i$$$, which is on the position $$$j$$$, equals $$$a_i \\cdot (j-1) + b_i \\cdot (n-j)$$$.The director entrusted Stas with the task: rearrange the people in the queue so that minimize the total dissatisfaction.Although Stas is able to solve such problems, this was not given to him. He turned for help to you.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the number of people in the queue. Each of the following $$$n$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \\leq a_i, b_i \\leq 10^8$$$)\u00a0\u2014 the characteristic of the student $$$i$$$, initially on the position $$$i$$$.", "output_spec": "Output one integer\u00a0\u2014 minimum total dissatisfaction which can be achieved by rearranging people in the queue.", "sample_inputs": ["3\n4 2\n2 3\n6 1", "4\n2 4\n3 3\n7 1\n2 3", "10\n5 10\n12 4\n31 45\n20 55\n30 17\n29 30\n41 32\n7 1\n5 5\n3 15"], "sample_outputs": ["12", "25", "1423"], "notes": "NoteIn the first example it is optimal to put people in this order: ($$$3, 1, 2$$$). The first person is in the position of $$$2$$$, then his dissatisfaction will be equal to $$$4 \\cdot 1+2 \\cdot 1=6$$$. The second person is in the position of $$$3$$$, his dissatisfaction will be equal to $$$2 \\cdot 2+3 \\cdot 0=4$$$. The third person is in the position of $$$1$$$, his dissatisfaction will be equal to $$$6 \\cdot 0+1 \\cdot 2=2$$$. The total dissatisfaction will be $$$12$$$.In the second example, you need to put people in this order: ($$$3, 2, 4, 1$$$). The total dissatisfaction will be $$$25$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "028e83d83cc99a2b3826627efd87a304"} {"nl": {"description": "For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $$$n$$$ days of summer. On the $$$i$$$-th day, $$$a_i$$$ millimeters of rain will fall. All values $$$a_i$$$ are distinct.The mayor knows that citizens will watch the weather $$$x$$$ days before the celebration and $$$y$$$ days after. Because of that, he says that a day $$$d$$$ is not-so-rainy if $$$a_d$$$ is smaller than rain amounts at each of $$$x$$$ days before day $$$d$$$ and and each of $$$y$$$ days after day $$$d$$$. In other words, $$$a_d < a_j$$$ should hold for all $$$d - x \\le j < d$$$ and $$$d < j \\le d + y$$$. Citizens only watch the weather during summer, so we only consider such $$$j$$$ that $$$1 \\le j \\le n$$$.Help mayor find the earliest not-so-rainy day of summer.", "input_spec": "The first line contains three integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$1 \\le n \\le 100\\,000$$$, $$$0 \\le x, y \\le 7$$$)\u00a0\u2014 the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after. The second line contains $$$n$$$ distinct integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\le a_i \\le 10^9$$$), where $$$a_i$$$ denotes the rain amount on the $$$i$$$-th day.", "output_spec": "Print a single integer\u00a0\u2014 the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.", "sample_inputs": ["10 2 2\n10 9 6 7 8 3 2 1 4 5", "10 2 3\n10 9 6 7 8 3 2 1 4 5", "5 5 5\n100000 10000 1000 100 10"], "sample_outputs": ["3", "8", "5"], "notes": "NoteIn the first example days $$$3$$$ and $$$8$$$ are not-so-rainy. The $$$3$$$-rd day is earlier.In the second example day $$$3$$$ is not not-so-rainy, because $$$3 + y = 6$$$ and $$$a_3 > a_6$$$. Thus, day $$$8$$$ is the answer. Note that $$$8 + y = 11$$$, but we don't consider day $$$11$$$, because it is not summer."}, "positive_code": [{"source_code": "= $x - $b; $y--)\n {\n if(($d[$x] < $d[$y]) || ($d[$y] == NULL))\n {\n $e++;\n }\n else\n {\n break;\n }\n }\n for($y = $x + 1; $y <= $x + $c; $y++)\n {\n if(($d[$x] < $d[$y]) || ($d[$y] == NULL))\n {\n $e++;\n }\n else\n {\n break;\n }\n }\n if($e == $b + $c)\n {\n print $x + 1;\n break;\n }\n}\n?>"}, {"source_code": " $aV){\n $b = true;\n for($i = 1; $i <= $a[1]; $i++){\n $f = $sK - $i;\n if(isset($n[$f])){\n if($n[$f] < $aV){\n $b = false;\n }\n }\n }\n if($b == false && $sK < sizeof($n) - 1){\n continue;\n }\n for($j = 1; $j <= $a[2]; $j++){\n $f = $sK + $j;\n if(isset($n[$f])){\n if($n[$f] < $aV){\n $b = false;\n }\n }\n }\n if($b == true){\n echo $sK+1;\n exit;\n } else {\n continue;\n }\n}\n\n \n \n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "5e2a5ee02c1a2f35a52e76cde96463a3"} {"nl": {"description": "You have a deck of $$$n$$$ cards, and you'd like to reorder it to a new one.Each card has a value between $$$1$$$ and $$$n$$$ equal to $$$p_i$$$. All $$$p_i$$$ are pairwise distinct. Cards in a deck are numbered from bottom to top, i.\u00a0e. $$$p_1$$$ stands for the bottom card, $$$p_n$$$ is the top card. In each step you pick some integer $$$k > 0$$$, take the top $$$k$$$ cards from the original deck and place them, in the order they are now, on top of the new deck. You perform this operation until the original deck is empty. (Refer to the notes section for the better understanding.)Let's define an order of a deck as $$$\\sum\\limits_{i = 1}^{n}{n^{n - i} \\cdot p_i}$$$.Given the original deck, output the deck with maximum possible order you can make using the operation above.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains the single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$)\u00a0\u2014 the size of deck you have. The second line contains $$$n$$$ integers $$$p_1, p_2,\\dots, p_n$$$ ($$$1 \\le p_i \\le n$$$; $$$p_i \\neq p_j$$$ if $$$i \\neq j$$$)\u00a0\u2014 values of card in the deck from bottom to top. It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case print the deck with maximum possible order. Print values of cards in the deck from bottom to top. If there are multiple answers, print any of them.", "sample_inputs": ["4\n4\n1 2 3 4\n5\n1 5 2 4 3\n6\n4 2 5 3 6 1\n1\n1"], "sample_outputs": ["4 3 2 1\n5 2 4 3 1\n6 1 5 3 4 2\n1"], "notes": "NoteIn the first test case, one of the optimal strategies is the next one: take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1, 2, 3]$$$, $$$p'$$$ becomes $$$[4]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1, 2]$$$, $$$p'$$$ becomes $$$[4, 3]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes $$$[1]$$$, $$$p'$$$ becomes $$$[4, 3, 2]$$$; take $$$1$$$ card from the top of $$$p$$$: $$$p$$$ becomes empty, $$$p'$$$ becomes $$$[4, 3, 2, 1]$$$. In result, $$$p'$$$ has order equal to $$$4^3 \\cdot 4 + 4^2 \\cdot 3 + 4^1 \\cdot 2 + 4^0 \\cdot 1$$$ $$$=$$$ $$$256 + 48 + 8 + 1 = 313$$$.In the second test case, one of the optimal strategies is: take $$$4$$$ cards from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[1]$$$, $$$p'$$$ becomes $$$[5, 2, 4, 3]$$$; take $$$1$$$ card from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes empty, $$$p'$$$ becomes $$$[5, 2, 4, 3, 1]$$$; In result, $$$p'$$$ has order equal to $$$5^4 \\cdot 5 + 5^3 \\cdot 2 + 5^2 \\cdot 4 + 5^1 \\cdot 3 + 5^0 \\cdot 1$$$ $$$=$$$ $$$3125 + 250 + 100 + 15 + 1 = 3491$$$.In the third test case, one of the optimal strategies is: take $$$2$$$ cards from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[4, 2, 5, 3]$$$, $$$p'$$$ becomes $$$[6, 1]$$$; take $$$2$$$ cards from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes $$$[4, 2]$$$, $$$p'$$$ becomes $$$[6, 1, 5, 3]$$$; take $$$2$$$ cards from the top of $$$p$$$ and move it to $$$p'$$$: $$$p$$$ becomes empty, $$$p'$$$ becomes $$$[6, 1, 5, 3, 4, 2]$$$. In result, $$$p'$$$ has order equal to $$$6^5 \\cdot 6 + 6^4 \\cdot 1 + 6^3 \\cdot 5 + 6^2 \\cdot 3 + 6^1 \\cdot 4 + 6^0 \\cdot 2$$$ $$$=$$$ $$$46656 + 1296 + 1080 + 108 + 24 + 2 = 49166$$$."}, "positive_code": [{"source_code": "= 1; --$i) {\r\n if ($mn < $b[$i]) {\r\n continue;\r\n }\r\n for ($j = $b[$i]; $j < $mn; ++$j) {\r\n $ans[] = $a[$j];\r\n }\r\n $mn = $b[$i];\r\n }\r\n echo implode(' ', $ans).PHP_EOL;\r\n}\r\n"}], "negative_code": [], "src_uid": "1637670255f8bd82a01e2ab20cdcc9aa"} {"nl": {"description": "You have given an array $$$a$$$ of length $$$n$$$ and an integer $$$x$$$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $$$q$$$. If $$$q$$$ is divisible by $$$x$$$, the robot adds $$$x$$$ copies of the integer $$$\\frac{q}{x}$$$ to the end of the array, and moves on to the next element. Note that the newly added elements could be processed by the robot later. Otherwise, if $$$q$$$ is not divisible by $$$x$$$, the robot shuts down.Please determine the sum of all values of the array at the end of the process.", "input_spec": "The first input line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\leq n \\leq 10^5$$$, $$$2 \\leq x \\leq 10^9$$$)\u00a0\u2014 the length of the array and the value which is used by the robot. The next line contains integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the initial values in the array. It is guaranteed that the sum of values $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case output one integer\u00a0\u2014 the sum of all elements at the end of the process.", "sample_inputs": ["2\n1 2\n12\n4 2\n4 6 8 2"], "sample_outputs": ["36\n44"], "notes": "NoteIn the first test case the array initially consists of a single element $$$[12]$$$, and $$$x=2$$$. After the robot processes the first element, the array becomes $$$[12, 6, 6]$$$. Then the robot processes the second element, and the array becomes $$$[12, 6, 6, 3, 3]$$$. After the robot processes the next element, the array becomes $$$[12, 6, 6, 3, 3, 3, 3]$$$, and then the robot shuts down, since it encounters an element that is not divisible by $$$x = 2$$$. The sum of the elements in the resulting array is equal to $$$36$$$.In the second test case the array initially contains integers $$$[4, 6, 8, 2]$$$, and $$$x=2$$$. The resulting array in this case looks like $$$ [4, 6, 8, 2, 2, 2, 3, 3, 4, 4, 1, 1, 1, 1, 1, 1]$$$."}, "positive_code": [{"source_code": "\r\n= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": " $m) {\r\n $sm += $a[$i];\r\n } else {\r\n break;\r\n }\r\n }\r\n echo nf($sm).PHP_EOL;\r\n}\r\nfunction nf($n)\r\n{\r\n return number_format($n, 0, '', '');\r\n}"}], "negative_code": [{"source_code": "\r\n $iCounter2)) {\r\n $a[$i] = Bigint::div($a[$i], $x);\r\n $iCounter2 +=1;\r\n }\r\n $min = $min == -1 ? $iCounter2 : min($min, $iCounter2);\r\n $iSum = Bigint::add($iSum, Bigint::mul($b[$i], $min));\r\n }\r\n \r\n return $iSum;\r\n}\r\n\r\n#$t = 1;\r\n$t = Read::int();\r\nwhile ($t--) {\r\n echo solve();\r\n echo \"\\n\";\r\n}\r\n\r\n\r\nclass Read\r\n{\r\n public static function string()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function int()\r\n {\r\n return intval(fgets(STDIN));\r\n }\r\n\r\n public static function array_int($sep = ' ')\r\n {\r\n $s = trim(fgets(STDIN));\r\n return preg_split(\"/[\\s,]+/\", $s);\r\n }\r\n\r\n}\r\n\r\nclass Bigint\r\n{\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 / $bigint2\r\n */\r\n public static function div($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcmod($bigint1, $bigint2) == 0 ? bcdiv($bigint1, $bigint2) : bcadd(bcdiv($bigint1, $bigint2), 1);\r\n case 'floor':\r\n return bcdiv($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcdiv($bigint1, $bigint2);\r\n return bcsub(bcdiv($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n \r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n \r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function bigintSub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n \r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n \r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n \r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n \r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n \r\nclass Algorithms\r\n{\r\n \r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n \r\n return $a;\r\n }\r\n \r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n \r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n \r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n \r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n}\r\n \r\n?>"}, {"source_code": "= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function bigintSub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function bigintSub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": ""}, {"source_code": " $m) {\r\n $sm += $a[$i];\r\n } else {\r\n break;\r\n }\r\n }\r\n echo $sm.PHP_EOL;\r\n}\r\n"}, {"source_code": " $cnt && $mn = $cnt;\r\n $a[$i] *= $mn + 1;\r\n }\r\n echo array_sum($a).PHP_EOL;\r\n}\r\n"}], "src_uid": "09c8db43681d7bc72f83287897a62f3c"} {"nl": {"description": "Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference is maximal possible!Your task is to write a program which calculates two things: The maximum beauty difference of flowers that Pashmak can give to Parmida. The number of ways that Pashmak can pick the flowers. Two ways are considered different if and only if there is at least one flower that is chosen in the first way and not chosen in the second way. ", "input_spec": "The first line of the input contains n (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105). In the next line there are n space-separated integers b1, b2, ..., bn (1\u2009\u2264\u2009bi\u2009\u2264\u2009109).", "output_spec": "The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively.", "sample_inputs": ["2\n1 2", "3\n1 4 5", "5\n3 1 2 3 1"], "sample_outputs": ["1 1", "4 1", "2 4"], "notes": "NoteIn the third sample the maximum beauty difference is 2 and there are 4 ways to do this: choosing the first and the second flowers; choosing the first and the fifth flowers; choosing the fourth and the second flowers; choosing the fourth and the fifth flowers. "}, "positive_code": [{"source_code": ""}, {"source_code": "= 0; $i--) { \n if ($arr[$i] === $arr[$n-1]) {\n $colend ++;\n } else {\n break;\n }\n}\n\nif ($i < 0) {\n $sum = 0;\n for ($j=1; $j < $n; $j++) { \n $sum += $j; \n }\n $col = $n * ($n - 1) - $sum;\n} else {\n $col = $colfirst * $colend;\n}\n\necho \"$max $col\";\n\n?>"}, {"source_code": "\n$n = trim(fgets(STDIN));\n$m = explode(\" \",trim(fgets(STDIN)));\n$mx = max($m);\n$mn = min($m);\nforeach($m as $v){\n if($v == $mx)$cmx++;\n if($v == $mn)$cmn++;\n}\nif($mx != $mn)echo ($mx-$mn).\" \".($cmx*$cmn);\nelse echo ($mx-$mn).\" \".(($n*($n-1))/2);\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": "= 0; $x--)\n{\n if($b[$x] == $g)\n {\n $d++;\n }\n else\n {\n break;\n }\n}\nfor($x = 0; $x < $a; $x++)\n{\n if($b[$x] == $f)\n {\n $e++;\n }\n else\n {\n break;\n }\n}\nprint $c . \" \" . ($d * $e);\n?>"}, {"source_code": " 0; $i--) { \n if ($arr[$i] === $arr[$n-1]) {\n $colend ++;\n } else {\n break;\n }\n}\n\n$col = $colfirst * $colend;\n\necho \"$max $col\";\n\n?>"}, {"source_code": "\n$n = trim(fgets(STDIN));\n$m = explode(\" \",trim(fgets(STDIN)));\n$mx = max($m);\n$mn = min($m);\nforeach($m as $v){\n if($v == $mx)$cmx++;\n if($v == $mn)$cmn++;\n}\necho ($mx-$mn).\" \".($cmx*$cmn);\n?>"}, {"source_code": "\n$n = trim(fgets(STDIN));\n$m = explode(\" \",trim(fgets(STDIN)));\n$mx = max($m);\n$mn = min($m);\nforeach($m as $v){\n if($v == $mx)$cmx++;\n if($v == $mn)$cmn++;\n}\nif($mx != $mn)echo ($mx-$mn).\" \".($cmx*$cmn);\nelse echo ($mx-$mn).\" \".($n*($n-1));\n?>"}], "src_uid": "eb2d1072c5308d9ef686315a122d9d3c"} {"nl": {"description": "Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be. In order to make sure that he's right and restore the correct order of keys, Santa typed his favorite patter looking only to his keyboard.You are given the Santa's favorite patter and the string he actually typed. Determine which pairs of keys could be mixed. Each key must occur in pairs at most once.", "input_spec": "The input consists of only two strings s and t denoting the favorite Santa's patter and the resulting string. s and t are not empty and have the same length, which is at most 1000. Both strings consist only of lowercase English letters.", "output_spec": "If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print \u00ab-1\u00bb (without quotes). Otherwise, the first line of output should contain the only integer k (k\u2009\u2265\u20090)\u00a0\u2014 the number of pairs of keys that should be swapped. The following k lines should contain two space-separated letters each, denoting the keys which should be swapped. All printed letters must be distinct. If there are several possible answers, print any of them. You are free to choose the order of the pairs and the order of keys in a pair. Each letter must occur at most once. Santa considers the keyboard to be fixed if he can print his favorite patter without mistakes.", "sample_inputs": ["helloworld\nehoolwlroz", "hastalavistababy\nhastalavistababy", "merrychristmas\nchristmasmerry"], "sample_outputs": ["3\nh e\nl o\nd z", "0", "-1"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "b03895599bd578a83321401428e277da"} {"nl": {"description": "A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left). Alice and Bob play dice. Alice has built a tower from n dice. We know that in this tower the adjacent dice contact with faces with distinct numbers. Bob wants to uniquely identify the numbers written on the faces of all dice, from which the tower is built. Unfortunately, Bob is looking at the tower from the face, and so he does not see all the numbers on the faces. Bob sees the number on the top of the tower and the numbers on the two adjacent sides (on the right side of the picture shown what Bob sees).Help Bob, tell whether it is possible to uniquely identify the numbers on the faces of all the dice in the tower, or not.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of dice in the tower. The second line contains an integer x (1\u2009\u2264\u2009x\u2009\u2264\u20096) \u2014 the number Bob sees at the top of the tower. Next n lines contain two space-separated integers each: the i-th line contains numbers ai,\u2009bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u20096;\u00a0ai\u2009\u2260\u2009bi) \u2014 the numbers Bob sees on the two sidelong faces of the i-th dice in the tower. Consider the dice in the tower indexed from top to bottom from 1 to n. That is, the topmost dice has index 1 (the dice whose top face Bob can see). It is guaranteed that it is possible to make a dice tower that will look as described in the input.", "output_spec": "Print \"YES\" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print \"NO\" (without the quotes).", "sample_inputs": ["3\n6\n3 2\n5 4\n2 4", "3\n3\n2 6\n4 1\n5 3"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}], "negative_code": [{"source_code": ""}, {"source_code": "\n"}], "src_uid": "2d6a1202139e1f77f32377224e1fe752"} {"nl": {"description": "Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called \"Black Square\" on his super cool touchscreen phone.In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules of the game, Jury must use this second to touch the corresponding strip to make the square go away. As Jury is both smart and lazy, he counted that he wastes exactly ai calories on touching the i-th strip.You've got a string s, describing the process of the game and numbers a1,\u2009a2,\u2009a3,\u2009a4. Calculate how many calories Jury needs to destroy all the squares?", "input_spec": "The first line contains four space-separated integers a1, a2, a3, a4 (0\u2009\u2264\u2009a1,\u2009a2,\u2009a3,\u2009a4\u2009\u2264\u2009104). The second line contains string s (1\u2009\u2264\u2009|s|\u2009\u2264\u2009105), where the \u0456-th character of the string equals \"1\", if on the i-th second of the game the square appears on the first strip, \"2\", if it appears on the second strip, \"3\", if it appears on the third strip, \"4\", if it appears on the fourth strip.", "output_spec": "Print a single integer \u2014 the total number of calories that Jury wastes.", "sample_inputs": ["1 2 3 4\n123214", "1 5 3 2\n11221"], "sample_outputs": ["13", "13"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value) {\n $calcount += $cal[$key - 1] * $value;\n}\necho $calcount;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "db9065d975878227a749083f0036a169"} {"nl": {"description": "Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule: either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before); or the girl in the dancing pair must dance for the first time. Help Fox Ciel to make a schedule that they can dance as many songs as possible.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) \u2014 the number of boys and girls in the dancing room.", "output_spec": "In the first line print k \u2014 the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.", "sample_inputs": ["2 1", "2 2"], "sample_outputs": ["2\n1 1\n2 1", "3\n1 1\n1 2\n2 2"], "notes": "NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3."}, "positive_code": [{"source_code": " 0) && ($f > 0))\n {\n continue;\n }\n else\n {\n array_push($g, $x . \" \" . $y);\n }\n }\n}\nprint count($g) . \"\\n\";\nfor($z = 0; $z < count($g) - 1; $z++)\n{\n print $g[$z] . \"\\n\";\n}\nprint $g[$z];\n?>"}, {"source_code": ""}], "src_uid": "14fc3a7fef44a02791aee62838c4c8c8"} {"nl": {"description": "A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$\\color{blue}{\\texttt{B}}\\color{red}{\\texttt{R}}$$$ and as $$$\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}$$$.During use, the stamp must completely fit on the given $$$n$$$ cells (it cannot be partially outside the cells). The stamp can be applied multiple times to the same cell. Each usage of the stamp recolors both cells that are under the stamp.For example, one possible sequence of stamps to make the picture $$$\\color{blue}{\\texttt{B}}\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}\\color{blue}{\\texttt{B}}\\texttt{W}$$$ could be $$$\\texttt{WWWWW} \\to \\texttt{WW}\\color{brown}{\\underline{\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}}}\\texttt{W} \\to \\color{brown}{\\underline{\\color{blue}{\\texttt{B}}\\color{red}{\\texttt{R}}}}\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}\\texttt{W} \\to \\color{blue}{\\texttt{B}}\\color{brown}{\\underline{\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}}}\\color{blue}{\\texttt{B}}\\texttt{W}$$$. Here $$$\\texttt{W}$$$, $$$\\color{red}{\\texttt{R}}$$$, and $$$\\color{blue}{\\texttt{B}}$$$ represent a white, red, or blue cell, respectively, and the cells that the stamp is used on are marked with an underline.Given a final picture, is it possible to make it using the stamp zero or more times?", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the length of the picture. The second line of each test case contains a string $$$s$$$\u00a0\u2014 the picture you need to make. It is guaranteed that the length of $$$s$$$ is $$$n$$$ and that $$$s$$$ only consists of the characters $$$\\texttt{W}$$$, $$$\\texttt{R}$$$, and $$$\\texttt{B}$$$, representing a white, red, or blue cell, respectively. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "Output $$$t$$$ lines, each of which contains the answer to the corresponding test case. As an answer, output \"YES\" if it possible to make the picture using the stamp zero or more times, and \"NO\" otherwise. You can output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive answer).", "sample_inputs": ["12\n5\nBRBBW\n1\nB\n2\nWB\n2\nRW\n3\nBRB\n3\nRBB\n7\nWWWWWWW\n9\nRBWBWRRBW\n10\nBRBRBRBRRB\n12\nBBBRWWRRRWBR\n10\nBRBRBRBRBW\n5\nRBWBW"], "sample_outputs": ["YES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nYES\nNO"], "notes": "NoteThe first test case is explained in the statement.For the second, third, and fourth test cases, it is not possible to stamp a single cell, so the answer is \"NO\".For the fifth test case, you can use the stamp as follows: $$$\\texttt{WWW} \\to \\texttt{W}\\color{brown}{\\underline{\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}}} \\to \\color{brown}{\\underline{\\color{blue}{\\texttt{B}}\\color{red}{\\texttt{R}}}}\\color{blue}{\\texttt{B}}$$$.For the sixth test case, you can use the stamp as follows: $$$\\texttt{WWW} \\to \\texttt{W}\\color{brown}{\\underline{\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}}} \\to \\color{brown}{\\underline{\\color{red}{\\texttt{R}}\\color{blue}{\\texttt{B}}}}\\color{blue}{\\texttt{B}}$$$.For the seventh test case, you don't need to use the stamp at all."}, "positive_code": [{"source_code": " 0 && ( strpos( $arr[$j], 'R') === false || strpos( $arr[$j], 'B') === false)){\r\n $hasOdd =true;\r\n }\r\n }\r\n echo ($hasOdd? 'No':'Yes').\"\\n\";\r\n}\r\n"}, {"source_code": " 0,\r\n 'R' => 0\r\n ];\r\n foreach(str_split($s) as $ch) {\r\n if($ch == 'W') {\r\n if(($temp['B'] == 0 && $temp['R'] != 0) || ($temp['B'] != 0 && $temp['R'] == 0)) {\r\n // $bA = false;\r\n break;\r\n }\r\n $temp = [\r\n 'B' => 0,\r\n 'R' => 0\r\n ];\r\n } else {\r\n $temp[$ch] += 1;\r\n }\r\n }\r\n if(($temp['B'] == 0 && $temp['R'] != 0) || ($temp['B'] != 0 && $temp['R'] == 0)) {\r\n pr($no);\r\n } else {\r\n pr($yes);\r\n }\r\n \r\n\r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\nfunction getDar2($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, getDar2($n, $k-1));\r\n}\r\n function ComandR($aCordinate) {\r\n return [$aCordinate[0] + 1, $aCordinate[1]];\r\n }\r\n function ComandL($aCordinate) {\r\n return [$aCordinate[0] - 1, $aCordinate[1]];\r\n }\r\n function ComandU($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] + 1];\r\n }\r\n function ComandD($aCordinate) {\r\n return [$aCordinate[0], $aCordinate[1] - 1];\r\n }\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }"}, {"source_code": ""}], "negative_code": [{"source_code": " -1 ? 'No': 'Yes'). \"\\n\";\r\n }\r\n else {\r\n $hasOdd = false;\r\n $x='';\r\n $res = [];\r\n for ($k = 0; $k < $l; $k++) {\r\n if($s[$k] != 'W') {\r\n $x .= $s[$k];\r\n }else {\r\n $res[]= $x;\r\n $x = '';\r\n }\r\n }\r\n for($k = 0; $k < count($res); $k++)\r\n {\r\n if(strlen($res[$k])%2!=0 && strlen($res[$k]) < $l-1){\r\n $hasOdd = true;\r\n }\r\n }\r\n\r\n echo ($hasOdd ? \"No\": \"Yes\"). \"\\n\";\r\n }\r\n}\r\n"}], "src_uid": "3f284afb044c8a57a02cd015d06e0ef0"} {"nl": {"description": "After lessons Nastya decided to read a book. The book contains $$$n$$$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number $$$k$$$ as the first page which was not read (i.e. she read all pages from the $$$1$$$-st to the $$$(k-1)$$$-th).The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 the number of chapters in the book. There are $$$n$$$ lines then. The $$$i$$$-th of these lines contains two integers $$$l_i$$$, $$$r_i$$$ separated by space ($$$l_1 = 1$$$, $$$l_i \\leq r_i$$$)\u00a0\u2014 numbers of the first and the last pages of the $$$i$$$-th chapter. It's guaranteed that $$$l_{i+1} = r_i + 1$$$ for all $$$1 \\leq i \\leq n-1$$$, and also that every chapter contains at most $$$100$$$ pages. The $$$(n+2)$$$-th line contains a single integer $$$k$$$ ($$$1 \\leq k \\leq r_n$$$)\u00a0\u2014 the index of the marked page. ", "output_spec": "Print a single integer\u00a0\u2014 the number of chapters which has not been completely read so far.", "sample_inputs": ["3\n1 3\n4 7\n8 11\n2", "3\n1 4\n5 9\n10 12\n9", "1\n1 7\n4"], "sample_outputs": ["3", "2", "1"], "notes": "NoteIn the first example the book contains $$$11$$$ pages and $$$3$$$ chapters\u00a0\u2014 $$$[1;3]$$$, $$$[4;7]$$$ and $$$[8;11]$$$. Nastya marked the $$$2$$$-nd page, so she finished in the middle of the $$$1$$$-st chapter. So, all chapters has not been read so far, so the answer is $$$3$$$.The book in the second example contains $$$12$$$ pages and $$$3$$$ chapters too, but Nastya finished reading in the middle of the $$$2$$$-nd chapter, so that the answer is $$$2$$$."}, "positive_code": [{"source_code": " array(\n 'min_range' => $val[0],\n 'max_range' => $val[1]\n )\n )\n )) {\n echo $unreaded - $i . PHP_EOL;\n } else {\n $i++;\n }\n}\n"}, {"source_code": ""}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $r[$i]){\n\t\t$c++;\t\n\t}\n}\n\nfwrite(STDOUT, $n-$c);\n\n?>"}, {"source_code": "= $k){\n $n = $n - $i;\n echo $n;\n return 0;\n }\n}\n?>"}], "negative_code": [{"source_code": "= $k){\n echo $n - $i;\n return 0;\n }\n}\n?>"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= $chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}, {"source_code": " $chapter) {\n if ($unreadPageIndex <= (int)$chapter[1]) {\n $chaptersRemained = $nrChapters - $index + 1;\n echo $chaptersRemained;\n exit();\n }\n \n if ($index == $nrChapters){\n echo \"Wrong unread page index!\";\n exit();\n }\n }"}], "src_uid": "2545b6af730f99193041a8810b728cb3"} {"nl": {"description": "Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.String s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.", "input_spec": "First line of input contains string s, consisting only of lowercase Latin letters (1\u2009\u2264\u2009|s|\u2009\u2264\u20091000, |s| denotes the length of s). Second line of input contains integer k (1\u2009\u2264\u2009k\u2009\u2264\u200926).", "output_spec": "Print single line with a minimum number of necessary changes, or the word \u00abimpossible\u00bb (without quotes) if it is impossible.", "sample_inputs": ["yandex\n6", "yahoo\n5", "google\n7"], "sample_outputs": ["0", "1", "impossible"], "notes": "NoteIn the first test case string contains 6 different letters, so we don't need to change anything.In the second test case string contains 4 different letters: {'a',\u2009'h',\u2009'o',\u2009'y'}. To get 5 different letters it is necessary to change one occurrence of 'o' to some letter, which doesn't occur in the string, for example, {'b'}.In the third test case, it is impossible to make 7 different letters because the length of the string is 6."}, "positive_code": [{"source_code": "= $b)\n {\n print \"0\";\n }\n else\n {\n print $b - count($c);\n }\n}\n?>"}, {"source_code": " strlen($l))\n{\n echo \"impossible\";\n exit;\n}\n\n$cc = array();\nforeach(str_split($l) as $c) {\n if (!isset($cc[$c]))\n $cc[$c] = true;\n}\n\n$rr = max(0, $r - sizeof($cc));\necho ($rr);"}, {"source_code": ""}, {"source_code": " $l)\n{\n echo \"impossible\";\n exit;\n}\n\n$cc = array();\nforeach($l as $c) {\n if (!isset($cc[$c]))\n $cc[$c] = true;\n}\n\necho ($r - sizeof($cc));"}, {"source_code": " strlen($l))\n{\n echo \"impossible\";\n exit;\n}\n\n$cc = array();\nforeach(str_split($l) as $c) {\n if (!isset($cc[$c]))\n $cc[$c] = true;\n}\n\necho ($r - sizeof($cc));"}], "src_uid": "bd5912fe2c5c37658f28f6b159b39645"} {"nl": {"description": "Let's call a binary string $$$T$$$ of length $$$m$$$ indexed from $$$1$$$ to $$$m$$$ paranoid if we can obtain a string of length $$$1$$$ by performing the following two kinds of operations $$$m-1$$$ times in any order : Select any substring of $$$T$$$ that is equal to 01, and then replace it with 1. Select any substring of $$$T$$$ that is equal to 10, and then replace it with 0.For example, if $$$T = $$$ 001, we can select the substring $$$[T_2T_3]$$$ and perform the first operation. So we obtain $$$T = $$$ 01.You are given a binary string $$$S$$$ of length $$$n$$$ indexed from $$$1$$$ to $$$n$$$. Find the number of pairs of integers $$$(l, r)$$$ $$$1 \\le l \\le r \\le n$$$ such that $$$S[l \\ldots r]$$$ (the substring of $$$S$$$ from $$$l$$$ to $$$r$$$) is a paranoid string. ", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The description of test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$)\u00a0\u2014 the size of $$$S$$$. The second line of each test case contains a binary string $$$S$$$ of $$$n$$$ characters $$$S_1S_2 \\ldots S_n$$$. ($$$S_i = $$$ 0 or $$$S_i = $$$ 1 for each $$$1 \\le i \\le n$$$) It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, output the number of pairs of integers $$$(l, r)$$$ $$$1 \\le l \\le r \\le n$$$ such that $$$S[l \\ldots r]$$$ (the substring of $$$S$$$ from $$$l$$$ to $$$r$$$) is a paranoid string. ", "sample_inputs": ["5\n\n1\n\n1\n\n2\n\n01\n\n3\n\n100\n\n4\n\n1001\n\n5\n\n11111"], "sample_outputs": ["1\n3\n4\n8\n5"], "notes": "NoteIn the first sample, $$$S$$$ already has length $$$1$$$ and doesn't need any operations.In the second sample, all substrings of $$$S$$$ are paranoid. For the entire string, it's enough to perform the first operation.In the third sample, all substrings of $$$S$$$ are paranoid except $$$[S_2S_3]$$$, because we can't perform any operations on it, and $$$[S_1S_2S_3]$$$ (the entire string)."}, "positive_code": [{"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}, {"source_code": " 0) {\r\n $ans += pow($min, $max);\r\n \r\n }\r\n IO::pr($ans);\r\n}\r\n\r\n\r\nclass IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}\r\n\r\n"}, {"source_code": " 1) {\r\n $sN = '';\r\n $tt = $n;\r\n for($i=0; $i<$tt-1; $i++) {\r\n if($s[$i] == '0' && $s[$i+1] == '1') {\r\n $sN .= '1'; \r\n $n--;\r\n $i++;\r\n } elseif($s[$i] == '1' && $s[$i+1] == '0') { \r\n $sN .= '0'; \r\n $n--;\r\n $i++; \r\n } else {\r\n $sN .= $s[$i]; \r\n }\r\n } \r\n if($tt == $n) {\r\n break;\r\n } else {\r\n $ans += $tt - $n == 1 ? 1 : ($tt - $n) + 1 ;\r\n $s = $sN;\r\n }\r\n }\r\n \r\n \r\n IO::pr($ans);\r\n}\r\n\r\n\r\nclass IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}\r\n\r\n"}], "src_uid": "bc45b3b665ccef5c9451ff2ecc5198a8"} {"nl": {"description": "You are given a string s consisting only of characters 0 and 1. A substring [l,\u2009r] of s is a string slsl\u2009+\u20091sl\u2009+\u20092... sr, and its length equals to r\u2009-\u2009l\u2009+\u20091. A substring is called balanced if the number of zeroes (0) equals to the number of ones in this substring.You have to determine the length of the longest balanced substring of s.", "input_spec": "The first line contains n (1\u2009\u2264\u2009n\u2009\u2264\u2009100000) \u2014 the number of characters in s. The second line contains a string s consisting of exactly n characters. Only characters 0 and 1 can appear in s.", "output_spec": "If there is no non-empty balanced substring in s, print 0. Otherwise, print the length of the longest balanced substring.", "sample_inputs": ["8\n11010111", "3\n111"], "sample_outputs": ["4", "0"], "notes": "NoteIn the first example you can choose the substring [3,\u20096]. It is balanced, and its length is 4. Choosing the substring [2,\u20095] is also possible.In the second example it's impossible to find a non-empty balanced substring."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n $f[$c[$x]] = $x;\n}\nksort($f);\n$g = min($c);\n$h = array();\n$i = 0;\nfor($x = $g; $x < count($c) + $g; $x++)\n{\n $j = abs($e[$x] - $f[$x]);\n $i = max($i, $j);\n}\nprint $i;\n?>"}], "negative_code": [], "src_uid": "08fa04303060d38d6cd0f3a321a527ad"} {"nl": {"description": "The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.There are n stations in the subway. It was built according to the Bertown Transport Law: For each station i there exists exactly one train that goes from this station. Its destination station is pi, possibly pi\u2009=\u2009i; For each station i there exists exactly one station j such that pj\u2009=\u2009i. The President will consider the convenience of subway after visiting it. The convenience is the number of ordered pairs (x,\u2009y) such that person can start at station x and, after taking some subway trains (possibly zero), arrive at station y (1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u2009n).The mayor of Bertown thinks that if the subway is not convenient enough, then the President might consider installing a new mayor (and, of course, the current mayor doesn't want it to happen). Before President visits the city mayor has enough time to rebuild some paths of subway, thus changing the values of pi for not more than two subway stations. Of course, breaking the Bertown Transport Law is really bad, so the subway must be built according to the Law even after changes.The mayor wants to do these changes in such a way that the convenience of the subway is maximized. Help him to calculate the maximum possible convenience he can get! ", "input_spec": "The first line contains one integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100000) \u2014 the number of stations. The second line contains n integer numbers p1, p2, ..., pn (1\u2009\u2264\u2009pi\u2009\u2264\u2009n) \u2014 the current structure of the subway. All these numbers are distinct.", "output_spec": "Print one number \u2014 the maximum possible value of convenience.", "sample_inputs": ["3\n2 1 3", "5\n1 5 4 3 2"], "sample_outputs": ["9", "17"], "notes": "NoteIn the first example the mayor can change p2 to 3 and p3 to 1, so there will be 9 pairs: (1,\u20091), (1,\u20092), (1,\u20093), (2,\u20091), (2,\u20092), (2,\u20093), (3,\u20091), (3,\u20092), (3,\u20093).In the second example the mayor can change p2 to 4 and p3 to 5."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": " 0) || ($c[$e] == 0))\n {\n $c[$d]++;\n }\n elseif($c[$e] > 0)\n {\n $c[$e]++;\n }\n}\nrsort($c);\n$f = 0;\nif(($c[0] == 2) && ($c[1] == 2))\n{\n unset($c[0]);\n $c[1] = 4;\n for($x = 1; $x <= count($c); $x++)\n {\n $g = pow($c[$x], 2);\n $f += $g;\n }\n}\nelseif(($c[0] == 2) && ($c[1] == 1))\n{\n unset($c[0]);\n $c[1] = 3;\n for($x = 1; $x <= count($c); $x++)\n {\n $g = pow($c[$x], 2);\n $f += $g;\n }\n}\nelseif(($c[0] == 1) && ($c[1] == 1))\n{\n unset($c[0]);\n $c[1] = 2;\n for($x = 1; $x <= count($c); $x++)\n {\n $g = pow($c[$x], 2);\n $f += $g;\n }\n}\nelse\n{\n for($x = 0; $x < count($c); $x++)\n {\n $g = pow($c[$x], 2);\n $f += $g;\n }\n}\nprintf(\"%.0f\", $f);\n?>"}, {"source_code": ""}], "src_uid": "ad9fd71025c5f91cece740ea95b0eb6f"} {"nl": {"description": "Alice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat! Initially, Alice's cat is located in a cell $$$(x,y)$$$ of an infinite grid. According to Alice's theory, cat needs to move: exactly $$$a$$$ steps left: from $$$(u,v)$$$ to $$$(u-1,v)$$$; exactly $$$b$$$ steps right: from $$$(u,v)$$$ to $$$(u+1,v)$$$; exactly $$$c$$$ steps down: from $$$(u,v)$$$ to $$$(u,v-1)$$$; exactly $$$d$$$ steps up: from $$$(u,v)$$$ to $$$(u,v+1)$$$. Note that the moves can be performed in an arbitrary order. For example, if the cat has to move $$$1$$$ step left, $$$3$$$ steps right and $$$2$$$ steps down, then the walk right, down, left, right, right, down is valid.Alice, however, is worrying that her cat might get lost if it moves far away from her. So she hopes that her cat is always in the area $$$[x_1,x_2]\\times [y_1,y_2]$$$, i.e. for every cat's position $$$(u,v)$$$ of a walk $$$x_1 \\le u \\le x_2$$$ and $$$y_1 \\le v \\le y_2$$$ holds.Also, note that the cat can visit the same cell multiple times.Can you help Alice find out if there exists a walk satisfying her wishes?Formally, the walk should contain exactly $$$a+b+c+d$$$ unit moves ($$$a$$$ to the left, $$$b$$$ to the right, $$$c$$$ to the down, $$$d$$$ to the up). Alice can do the moves in any order. Her current position $$$(u, v)$$$ should always satisfy the constraints: $$$x_1 \\le u \\le x_2$$$, $$$y_1 \\le v \\le y_2$$$. The staring point is $$$(x, y)$$$.You are required to answer $$$t$$$ test cases independently.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^3$$$) \u2014 the number of testcases. The first line of each test case contains four integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ ($$$0 \\le a,b,c,d \\le 10^8$$$, $$$a+b+c+d \\ge 1$$$). The second line of the test case contains six integers $$$x$$$, $$$y$$$, $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, $$$y_2$$$ ($$$-10^8 \\le x_1\\le x \\le x_2 \\le 10^8$$$, $$$-10^8 \\le y_1 \\le y \\le y_2 \\le 10^8$$$).", "output_spec": "For each test case, output \"YES\" in a separate line, if there exists a walk satisfying her wishes. Otherwise, output \"NO\" in a separate line. You can print each letter in any case (upper or lower).", "sample_inputs": ["6\n3 2 2 2\n0 0 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 1\n1 1 1 1\n1 1 1 1 1 1\n0 0 0 1\n0 0 0 0 0 1\n5 1 1 1\n0 0 -100 -100 0 100\n1 1 5 1\n0 0 -100 -100 100 0"], "sample_outputs": ["Yes\nNo\nNo\nYes\nYes\nYes"], "notes": "NoteIn the first test case, one valid exercising walk is $$$$$$(0,0)\\rightarrow (-1,0) \\rightarrow (-2,0)\\rightarrow (-2,1) \\rightarrow (-2,2)\\rightarrow (-1,2)\\rightarrow(0,2)\\rightarrow (0,1)\\rightarrow (0,0) \\rightarrow (-1,0)$$$$$$"}, "positive_code": [{"source_code": " 0 && $x == $x1 && $x == $x2)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n if($c == $d && $d > 0 && $y == $y1 && $y == $y2)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n \n $min_a = min($a, $b) ;\n $min_b = min($c, $d) ;\n \n $a -= $min_a ;\n $b -= $min_a ;\n \n $c -= $min_b ;\n $d -= $min_b ;\n \n if($a > 0 && $x - $a < $x1)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n if($b > 0 && $x + $b > $x2)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n if($c > 0 && $y - $c < $y1)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n if($d > 0 && $y + $d > $y2)\n {\n echo \"NO\\n\" ;\n continue ;\n }\n echo \"YES\\n\" ;\n }\n?>"}], "negative_code": [], "src_uid": "7224ffd4776af4129739e1b28f696050"} {"nl": {"description": "There was an electronic store heist last night.All keyboards which were in the store yesterday were numbered in ascending order from some integer number $$$x$$$. For example, if $$$x = 4$$$ and there were $$$3$$$ keyboards in the store, then the devices had indices $$$4$$$, $$$5$$$ and $$$6$$$, and if $$$x = 10$$$ and there were $$$7$$$ of them then the keyboards had indices $$$10$$$, $$$11$$$, $$$12$$$, $$$13$$$, $$$14$$$, $$$15$$$ and $$$16$$$.After the heist, only $$$n$$$ keyboards remain, and they have indices $$$a_1, a_2, \\dots, a_n$$$. Calculate the minimum possible number of keyboards that have been stolen. The staff remember neither $$$x$$$ nor the number of keyboards in the store before the heist.", "input_spec": "The first line contains single integer $$$n$$$ $$$(1 \\le n \\le 1\\,000)$$$\u00a0\u2014 the number of keyboards in the store that remained after the heist. The second line contains $$$n$$$ distinct integers $$$a_1, a_2, \\dots, a_n$$$ $$$(1 \\le a_i \\le 10^{9})$$$\u00a0\u2014 the indices of the remaining keyboards. The integers $$$a_i$$$ are given in arbitrary order and are pairwise distinct.", "output_spec": "Print the minimum possible number of keyboards that have been stolen if the staff remember neither $$$x$$$ nor the number of keyboards in the store before the heist.", "sample_inputs": ["4\n10 13 12 8", "5\n7 5 6 4 8"], "sample_outputs": ["2", "0"], "notes": "NoteIn the first example, if $$$x=8$$$ then minimum number of stolen keyboards is equal to $$$2$$$. The keyboards with indices $$$9$$$ and $$$11$$$ were stolen during the heist.In the second example, if $$$x=4$$$ then nothing was stolen during the heist."}, "positive_code": [{"source_code": ""}, {"source_code": "= 1)\n {\n $s += $f;\n } \n}\n\necho $s;\n"}, {"source_code": ""}, {"source_code": " 1)\n {\n ++$s;\n }\n}\n\necho $s;\n"}, {"source_code": " 1)\n {\n ++$s;\n }\n}\n\necho $s;\n"}, {"source_code": "= 1)\n {\n echo \"f: $f \\n\";\n $s += $f;\n } \n}\n\necho $s;\n"}, {"source_code": "= 0; $x--)\n{\n if($d[$x] == 2)\n {\n $f++;\n }\n else\n {\n $e += 1 * $f;\n }\n}\nprint $e;\n?>"}, {"source_code": "0){\n while ($metal_length>$j && $heavy_positions[$i]>$metal_positions[$j]){\n $j++;\n }\n if($metal_length>$j){\n if($heavy_positions[$i]<$metal_positions[$j]){\n $substring += $metal_length-$j;\n }\n }\n }\n }\n return $substring;\n}\n \nfunction FindPosition($string,$needle){\n $lastPos = 0;\n $positions = array();\n\n while (($lastPos = strpos($string, $needle, $lastPos))!== false) {\n $positions[] = $lastPos;\n $lastPos = $lastPos + strlen($needle);\n }\n return $positions;\n}\n\n\n$string = trim(fgets(STDIN));\necho FindSubString($string);\n\n"}, {"source_code": "\n\nerror_reporting(false);\n//error_reporting(E_ALL);\n\n$handle = fopen('php://stdin', 'r');\n//$handle = fopen('in.txt', 'r');\n\n$str = trim(fgets($handle));\n\n//set_time_limit(3);\n\n$c = 0;\n$hh = 0;\n$mm = 0;\n\n\n\n\nfor($i=0; $i \n"}], "negative_code": [], "src_uid": "960e4c234666d2444b80d5966f1d285d"} {"nl": {"description": "Boboniu likes bit operations. He wants to play a game with you.Boboniu gives you two sequences of non-negative integers $$$a_1,a_2,\\ldots,a_n$$$ and $$$b_1,b_2,\\ldots,b_m$$$.For each $$$i$$$ ($$$1\\le i\\le n$$$), you're asked to choose a $$$j$$$ ($$$1\\le j\\le m$$$) and let $$$c_i=a_i\\& b_j$$$, where $$$\\&$$$ denotes the bitwise AND operation. Note that you can pick the same $$$j$$$ for different $$$i$$$'s.Find the minimum possible $$$c_1 | c_2 | \\ldots | c_n$$$, where $$$|$$$ denotes the bitwise OR operation.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1\\le n,m\\le 200$$$). The next line contains $$$n$$$ integers $$$a_1,a_2,\\ldots,a_n$$$ ($$$0\\le a_i < 2^9$$$). The next line contains $$$m$$$ integers $$$b_1,b_2,\\ldots,b_m$$$ ($$$0\\le b_i < 2^9$$$).", "output_spec": "Print one integer: the minimum possible $$$c_1 | c_2 | \\ldots | c_n$$$.", "sample_inputs": ["4 2\n2 6 4 0\n2 4", "7 6\n1 9 1 9 8 1 0\n1 1 4 5 1 4", "8 5\n179 261 432 162 82 43 10 38\n379 357 202 184 197"], "sample_outputs": ["2", "0", "147"], "notes": "NoteFor the first example, we have $$$c_1=a_1\\& b_2=0$$$, $$$c_2=a_2\\& b_1=2$$$, $$$c_3=a_3\\& b_1=0$$$, $$$c_4 = a_4\\& b_1=0$$$.Thus $$$c_1 | c_2 | c_3 |c_4 =2$$$, and this is the minimal answer we can get."}, "positive_code": [{"source_code": "\n"}], "negative_code": [{"source_code": "\n"}], "src_uid": "3da5075048a127319ffa8913859d2aa7"} {"nl": {"description": "Let's call a positive integer $$$n$$$ ordinary if in the decimal notation all its digits are the same. For example, $$$1$$$, $$$2$$$ and $$$99$$$ are ordinary numbers, but $$$719$$$ and $$$2021$$$ are not ordinary numbers.For a given number $$$n$$$, find the number of ordinary numbers among the numbers from $$$1$$$ to $$$n$$$.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$). Then $$$t$$$ test cases follow. Each test case is characterized by one integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$).", "output_spec": "For each test case output the number of ordinary numbers among numbers from $$$1$$$ to $$$n$$$.", "sample_inputs": ["6\n1\n2\n3\n4\n5\n100"], "sample_outputs": ["1\n2\n3\n4\n5\n18"], "notes": null}, "positive_code": [{"source_code": "= 2) { $ans = 9 * ($len - 1); }\r\n \r\n $s = (string) $n;\r\n $f = $s[0]; \r\n $m = '';\r\n for ($j = 0; $j < $len; $j++) { $m .= $f; }\r\n \r\n if ($m > $n) { $ans += $f - 1; }\r\n else { $ans += $f; }\r\n \r\n echo $ans.PHP_EOL;\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$nums = array(\r\n 2 => 9,\r\n 3 => 18,\r\n 4 => 27,\r\n 5 => 36,\r\n 6 => 45,\r\n 7 => 54,\r\n 8 => 63,\r\n 9 => 72,\r\n 10 => 81,\r\n 11 => 90,\r\n);\r\n\r\n\r\n$t = IO::str();\r\n\r\nfunction makeDel($q)\r\n{\r\n $s = '';\r\n while($q--) {\r\n $s .= '1';\r\n }\r\n return $s;\r\n}\r\nwhile($t--){\r\n $n = IO::str();\r\n\r\n if ($n < 10) {\r\n $res[] = $n;\r\n continue;\r\n }\r\n\r\n $s = $nums[strlen($n)];\r\n $del = makeDel(strlen($n));\r\n\r\n while($n >= $del) {\r\n $s++;\r\n $n = $n - $del;\r\n }\r\n\r\n $res[] = $s;\r\n}\r\n\r\nIO::res($res);"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $l = strlen($n);\r\n $last = 1;\r\n $res = 0;\r\n for ($i = 1; $i < 10; $i++) {\r\n $r = '';\r\n for ($j = 0; $j < $l; $j++) {\r\n $r .= $i;\r\n if ((int)$r <= $n) {\r\n $res++;\r\n $last = (int)$r + 1;\r\n }\r\n }\r\n }\r\n\r\n IO::line($res);\r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": "= 2) { $ans = 9 * ($len - 1); }\r\n \r\n $s = (string) $n;\r\n $f = $s[0]; \r\n $m = '';\r\n for ($j = 0; $j < $len; $j++) { $m .= $f; }\r\n \r\n if ($m > $v[$i]) { $ans += $f - 1; }\r\n else { $ans += $f; }\r\n echo $ans.PHP_EOL;\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 2) { $ans = 9 * ($len - 1); }\r\n \r\n $s = (string) $n;\r\n $f = $s[0]; \r\n $m = '';\r\n for ($j = 0; $j < $len; $j++) { $m .= $f; }\r\n \r\n if ($m > $v[$i]) { $ans += $f - 1; }\r\n else { $ans += $f; }\r\n echo $ans.PHP_EOL;\r\n }\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " 2) { $ans += 9 * ($len - 2); }\r\n \r\n $s = (string) $n;\r\n $f = $s[0]; \r\n $m = '';\r\n for ($j = 0; $j < $len; $j++) { $m .= $f; }\r\n \r\n if ($m > $v[$i]) { $ans += $f - 1; }\r\n else { $ans += $f; }\r\n echo $ans.PHP_EOL;\r\n }\r\n}\r\n\r\n?>"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$nums = array(\r\n 2 => 9,\r\n 3 => 18,\r\n 4 => 27,\r\n 5 => 36,\r\n 6 => 45,\r\n 7 => 54,\r\n 8 => 63,\r\n 9 => 72,\r\n 10 => 81,\r\n 11 => 90,\r\n);\r\n\r\n\r\n$t = IO::str();\r\n\r\nfunction makeDel($q)\r\n{\r\n $s = '';\r\n while($q--) {\r\n $s .= '1';\r\n }\r\n return $s;\r\n}\r\nwhile($t--){\r\n $n = IO::str();\r\n\r\n if ($n < 10) {\r\n $res[] = $n;\r\n continue;\r\n }\r\n\r\n $s = $nums[strlen($n)];\r\n $del = makeDel(strlen($n));\r\n\r\n while($n > $del) {\r\n $s++;\r\n $n = $n - $del;\r\n }\r\n\r\n $res[] = $s;\r\n}\r\n\r\nIO::res($res);"}], "src_uid": "ac7d117d58046872e9d665c9f99e5bff"} {"nl": {"description": "You are given two arrays $$$a$$$ and $$$b$$$ of $$$n$$$ positive integers each. You can apply the following operation to them any number of times: Select an index $$$i$$$ ($$$1\\leq i\\leq n$$$) and swap $$$a_i$$$ with $$$b_i$$$ (i.\u00a0e. $$$a_i$$$ becomes $$$b_i$$$ and vice versa). Find the minimum possible value of $$$\\max(a_1, a_2, \\ldots, a_n) \\cdot \\max(b_1, b_2, \\ldots, b_n)$$$ you can get after applying such operation any number of times (possibly zero). ", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$) \u2014 the number of test cases. Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1\\le n\\le 100$$$) \u2014 the length of the arrays. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10\\,000$$$) where $$$a_i$$$ is the $$$i$$$-th element of the array $$$a$$$. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \\ldots, b_n$$$ ($$$1 \\le b_i \\le 10\\,000$$$) where $$$b_i$$$ is the $$$i$$$-th element of the array $$$b$$$.", "output_spec": "For each test case, print a single integer, the minimum possible value of $$$\\max(a_1, a_2, \\ldots, a_n) \\cdot \\max(b_1, b_2, \\ldots, b_n)$$$ you can get after applying such operation any number of times.", "sample_inputs": ["3\n\n6\n\n1 2 6 5 1 2\n\n3 4 3 2 2 5\n\n3\n\n3 3 3\n\n3 3 3\n\n2\n\n1 2\n\n2 1"], "sample_outputs": ["18\n9\n2"], "notes": "NoteIn the first test, you can apply the operations at indices $$$2$$$ and $$$6$$$, then $$$a = [1, 4, 6, 5, 1, 5]$$$ and $$$b = [3, 2, 3, 2, 2, 2]$$$, $$$\\max(1, 4, 6, 5, 1, 5) \\cdot \\max(3, 2, 3, 2, 2, 2) = 6 \\cdot 3 = 18$$$.In the second test, no matter how you apply the operations, $$$a = [3, 3, 3]$$$ and $$$b = [3, 3, 3]$$$ will always hold, so the answer is $$$\\max(3, 3, 3) \\cdot \\max(3, 3, 3) = 3 \\cdot 3 = 9$$$.In the third test, you can apply the operation at index $$$1$$$, then $$$a = [2, 2]$$$, $$$b = [1, 1]$$$, so the answer is $$$\\max(2, 2) \\cdot \\max(1, 1) = 2 \\cdot 1 = 2$$$."}, "positive_code": [{"source_code": " $b[$i]) {\r\n $s = $b[$i];\r\n $b[$i] = $a[$i];\r\n $a[$i] = $s;\r\n }\r\n }\r\n echo max($a) * max($b) . \"\\n\";\r\n \r\n }"}], "negative_code": [{"source_code": " 2) {\r\n echo $new[$m] * $new[$n]. \"\\n\";\r\n } else {\r\n echo $new[$m] * $new[$m1]. \"\\n\";\r\n }\r\n \r\n \r\n }"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "e80088bee9c0df6adf280f8ffbeaa4a9"} {"nl": {"description": "Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1,\u2009x2,\u2009...,\u2009xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save.", "input_spec": "The first line of input contains three space-separated integers n,\u2009a,\u2009b\u00a0(1\u2009\u2264\u2009n\u2009\u2264\u2009105;\u00a01\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009109). The second line of input contains n space-separated integers x1,\u2009x2,\u2009...,\u2009xn\u00a0(1\u2009\u2264\u2009xi\u2009\u2264\u2009109).", "output_spec": "Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.", "sample_inputs": ["5 1 4\n12 6 11 9 1", "3 1 2\n1 2 3", "1 1 1\n1"], "sample_outputs": ["0 2 3 1 1", "1 0 1", "0"], "notes": null}, "positive_code": [{"source_code": "\n"}], "negative_code": [{"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "\n"}], "src_uid": "3c63e2e682d3c8051c3cecc3fa9c4e8c"} {"nl": {"description": "\u00abNext please\u00bb, \u2014 the princess called and cast an estimating glance at the next groom.The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured \u00abOh...\u00bb. Whenever the groom is richer than all previous ones added together, she exclaims \u00abWow!\u00bb (no \u00abOh...\u00bb in this case). At the sight of the first groom the princess stays calm and says nothing.The fortune of each groom is described with an integer between 1 and 50000. You know that during the day the princess saw n grooms, said \u00abOh...\u00bb exactly a times and exclaimed \u00abWow!\u00bb exactly b times. Your task is to output a sequence of n integers t1,\u2009t2,\u2009...,\u2009tn, where ti describes the fortune of i-th groom. If several sequences are possible, output any of them. If no sequence exists that would satisfy all the requirements, output a single number -1.", "input_spec": "The only line of input data contains three integer numbers n,\u2009a and b (1\u2009\u2264\u2009n\u2009\u2264\u2009100,\u20090\u2009\u2264\u2009a,\u2009b\u2009\u2264\u200915,\u2009n\u2009>\u2009a\u2009+\u2009b), separated with single spaces.", "output_spec": "Output any sequence of integers t1,\u2009t2,\u2009...,\u2009tn, where ti (1\u2009\u2264\u2009ti\u2009\u2264\u200950000) is the fortune of i-th groom, that satisfies the given constraints. If no sequence exists that would satisfy all the requirements, output a single number -1.", "sample_inputs": ["10 2 3", "5 0 0"], "sample_outputs": ["5 1 3 6 16 35 46 4 200 99", "10 10 6 6 5"], "notes": "NoteLet's have a closer look at the answer for the first sample test. The princess said \u00abOh...\u00bb (highlighted in bold): 5 1 3 6 16 35 46 4 200 99. The princess exclaimed \u00abWow!\u00bb (highlighted in bold): 5 1 3 6 16 35 46 4 200 99. "}, "positive_code": [{"source_code": " 0)\n {\n $d = array(\"1\");\n }\n else\n {\n $d = array(\"1\", \"1\");\n }\n for($x = 1; $x < 100; $x++)\n {\n if($c > 0)\n {\n $e = array_sum($d);\n $e++;\n array_push($d, $e);\n $c--;\n }\n else\n {\n break;\n }\n }\n for($x = 1; $x <= 100; $x++)\n {\n if($b > 0)\n {\n $e = $d[count($d) - 1];\n $e++;\n array_push($d, $e);\n $b--;\n }\n else\n {\n break;\n }\n }\n $f = count($d);\n for($x = 1; $x <= $a - $f; $x++)\n {\n $e = $d[count($d) - 1];\n array_push($d, $e);\n }\n if(($d[count($d) - 1] > 50000) || (count($d) > $a))\n {\n print \"-1\";\n }\n else\n {\n print implode(\" \", $d);\n }\n}\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction array_printf(array $arr) {\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\tif ($a === $n - 1 && $n != 1) {\n\t\tprintf(\"%d\",-1);\n\t\treturn;\n\t} elseif ($b === 0 && $a !== 0) {\n\t\t$array_a = array(1, 1,);\n\t\tfor ($i = 2; $i < $a + 2; $i++) {\n\t\t\t$array_a[] = $i;\n\t\t}\n\t\t\n\t\t$num = $n - count($array_a);\n\t\t//$array_a = array_fill(count($array_a) - 1, $n - $a - 2, (int)1);\n\t\t//for ($i = 0; $i < $n - count($array_a); $i++) {\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$array_a[] = 1;\n\t\t}\n\t\tarray_printf($array_a);\n\t\treturn;\n\t}\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\t//for ($i = 1; $i <= $a; $i++) {\n\t//array_pop not get, pop.so number - 1.\n\t//$begin = array_pop(&$arr);\n\t\n//test coding\n//printf(\"%d\\n\",(int)$arr[count($arr)]);\n//printf(\"%d\\n\",(int)null);\n\n\t$begin = $arr[count($arr) - 1]; \n\tfor ($i = $begin + 1; $i < $a + $begin + 1; $i++) {\n\t\t//$arr[] = $i + 1;\n\t\t$arr[] = $i;\n\t}\n\t//for ($i = 0; $i < $b - 1; $i++) {\n\t\t//$arr[] = array_sum($arr) + 1;\n\t//}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\tarray_printf($arr);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n \n elseif ($b==0 && $n-$a == 1) {$c=true; break;}\n elseif ($b==0 && $i == 1) {$money[$i]=$money[$i-1];}\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; $a-=1;}\n else $money[$i] = $money[$i-1];\n}\nif ($money[$n-1] < 50001 && !$c) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}], "negative_code": [{"source_code": " 0)\n {\n $d = array(\"1\");\n }\n else\n {\n $d = array(\"1\", \"1\");\n }\n for($x = 1; $x < 100; $x++)\n {\n if(($b == 0) && ($c == 0))\n {\n break;\n }\n else\n {\n if($c > 0)\n {\n $e = array_sum($d);\n $e++;\n array_push($d, $e);\n $c--;\n }\n if($b > 0)\n {\n $e = $d[count($d) - 1];\n $e++;\n array_push($d, $e);\n $b--;\n }\n }\n }\n $f = count($d);\n for($x = 1; $x <= $a - $f; $x++)\n {\n $e = $d[count($d) - 1];\n array_push($d, $e);\n }\n if(($d[count($d) - 1] > 50000) || (count($d) > $a))\n {\n print \"-1\";\n }\n else\n {\n print implode(\" \", $d);\n }\n}\n?>"}, {"source_code": " 0)\n{\n $d = array(\"1\");\n}\nelse\n{\n $d = array(\"1\", \"1\");\n}\nfor($x = 1; $x < 100; $x++)\n{\n if(($b == 0) && ($c == 0))\n {\n break;\n }\n else\n {\n if($c > 0)\n {\n $e = array_sum($d);\n $e++;\n array_push($d, $e);\n $c--;\n }\n if($b > 0)\n {\n $e = $d[count($d) - 1];\n $e++;\n array_push($d, $e);\n $b--;\n }\n }\n}\n$f = count($d);\nfor($x = 1; $x <= $a - $f; $x++)\n{\n $e = $d[count($d) - 1];\n array_push($d, $e);\n}\nif(($d[count($d) - 1] > 50000) || (count($d) > $a))\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": " 0)\n {\n $e = array_sum($d);\n $e++;\n array_push($d, $e);\n $c--;\n }\n if($b > 0)\n {\n $e = $d[count($d) - 1];\n $e++;\n array_push($d, $e);\n $b--;\n }\n }\n}\n$f = count($d);\nfor($x = 1; $x <= $a - $f; $x++)\n{\n $e = $d[count($d) - 1];\n array_push($d, $e);\n}\nif($d[count($d) - 1] > 50000)\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": " 0)\n{\n $d = array(\"1\");\n}\nelse\n{\n $d = array(\"1\", \"1\");\n}\nfor($x = 1; $x < 100; $x++)\n{\n if(($b == 0) && ($c == 0))\n {\n break;\n }\n else\n {\n if($c > 0)\n {\n $e = array_sum($d);\n $e++;\n array_push($d, $e);\n $c--;\n }\n if($b > 0)\n {\n $e = $d[count($d) - 1];\n $e++;\n array_push($d, $e);\n $b--;\n }\n }\n}\n$f = count($d);\nfor($x = 1; $x <= $a - $f; $x++)\n{\n $e = $d[count($d) - 1];\n array_push($d, $e);\n}\nif($d[count($d) - 1] > 50000)\n{\n print \"-1\";\n}\nelse\n{\n print implode(\" \", $d);\n}\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction array_printf(array $arr) {\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\tif ($a === $n - 1) {\n\t\tprintf(\"%d\",-1);\n\t\treturn;\n\t} elseif ($b === 0 && $a !== 0) {\n\t\t$array_a = array(1, 1,);\n\t\tfor ($i = 2; $i < $a + 2; $i++) {\n\t\t\t$array_a[] = $i;\n\t\t}\n\t\t\n\t\t$num = $n - count($array_a);\n\t\t//$array_a = array_fill(count($array_a) - 1, $n - $a - 2, (int)1);\n\t\t//for ($i = 0; $i < $n - count($array_a); $i++) {\n\t\tfor ($i = 0; $i < $num; $i++) {\n\t\t\t$array_a[] = 1;\n\t\t}\n\t\tarray_printf($array_a);\n\t\treturn;\n\t}\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\t//for ($i = 1; $i <= $a; $i++) {\n\t//array_pop not get, pop.so number - 1.\n\t//$begin = array_pop(&$arr);\n\t\n//test coding\n//printf(\"%d\\n\",(int)$arr[count($arr)]);\n//printf(\"%d\\n\",(int)null);\n\n\t$begin = $arr[count($arr) - 1]; \n\tfor ($i = $begin + 1; $i < $a + $begin + 1; $i++) {\n\t\t//$arr[] = $i + 1;\n\t\t$arr[] = $i;\n\t}\n\t//for ($i = 0; $i < $b - 1; $i++) {\n\t\t//$arr[] = array_sum($arr) + 1;\n\t//}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\tarray_printf($arr);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\t//for ($i = 1; $i <= $a; $i++) {\n\tfor ($i = 1; $i < $a + 2; $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\tfor ($i = 0; $i < $b - 1; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\t//for ($i = 1; $i <= $a; $i++) {\n\tfor ($i = 2; $i <= ($a + 1); $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\tfor ($i = 0; $i < $n - ($a + $b); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 1; $i <= $a; $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\tfor ($i = 0; $i < $n - ($a + $b); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\t//for ($i = 1; $i <= $a; $i++) {\n\tfor ($i = 2; $i <= ($a + 2); $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\tfor ($i = 0; $i < $b - 1; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\tfor ($i = 0; $i < $n - ($a + $b); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\t//for ($i = 1; $i <= $a; $i++) {\n\t$begin = array_sum($arr);\n\tfor ($i = $begin; $i < $a + $begin; $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\t//for ($i = 0; $i < $b - 1; $i++) {\n\t\t//$arr[] = array_sum($arr) + 1;\n\t//}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t//$arr[] = 1;\n\t$arr[] = 2;\n\t//for ($i = 1; $i <= $a; $i++) {\n\tfor ($i = 2; $i <= ($a + 1); $i++) {\n\t\t$arr[] = $i + 1;\n\t}\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\tfor ($i = 0; $i < $n - ($a + $b); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\t//for ($i = 1; $i <= $a; $i++) {\n\t//array_pop not get, pop.so number - 1.\n\t//$begin = array_pop(&$arr);\n\t\n//test coding\n//printf(\"%d\\n\",(int)$arr[count($arr)]);\n//printf(\"%d\\n\",(int)null);\n\n\t$begin = $arr[count($arr) - 1]; \n\tfor ($i = $begin + 1; $i < $a + $begin + 1; $i++) {\n\t\t//$arr[] = $i + 1;\n\t\t$arr[] = $i;\n\t}\n\t//for ($i = 0; $i < $b - 1; $i++) {\n\t\t//$arr[] = array_sum($arr) + 1;\n\t//}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "tok = $tok;\n\t\t$this->token = strtok($str_line, $this->tok);\n\t}\n\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t$this->token = strtok($this->tok);\n\t\treturn $thisToken;\n\t} \n\t\t\n\tpublic function nextFloat() {\n\t\treturn (float)$this->nextToken();\n\t}\n\t\n\tpublic function nextInt() {\n\t\treturn (int)$this->nextToken();\n\t}\n}\n\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$n = $Token->nextInt();\n\t$a = $Token->nextInt();\n\t$b = $Token->nextInt();\n\t\n\tif ($b === 0 && $a !== 0) {\n\t\tprintf(\"%d\",-1);\n\t\treturn;\n\t}\n\t//this is for more reading.really array() is not useful.\n\t$arr = array();\n\t$arr[] = 1;\n\tfor ($i = 0; $i < $b; $i++) {\n\t\t$arr[] = array_sum($arr) + 1;\n\t}\n\t//for ($i = 1; $i <= $a; $i++) {\n\t//array_pop not get, pop.so number - 1.\n\t//$begin = array_pop(&$arr);\n\t\n//test coding\n//printf(\"%d\\n\",(int)$arr[count($arr)]);\n//printf(\"%d\\n\",(int)null);\n\n\t$begin = $arr[count($arr) - 1]; \n\tfor ($i = $begin + 1; $i < $a + $begin + 1; $i++) {\n\t\t//$arr[] = $i + 1;\n\t\t$arr[] = $i;\n\t}\n\t//for ($i = 0; $i < $b - 1; $i++) {\n\t\t//$arr[] = array_sum($arr) + 1;\n\t//}\n\tfor ($i = 0; $i < $n - ($a + $b + 1); $i++) {\n\t\t$arr[] = 1;\n\t}\n\t$message = \"\";\n\tforeach ($arr as $value) {\n\t\t$message .= \"$value\" . \" \";\n\t}\n\t$message = rtrim($message);\n\tprintf('%s', $message);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1; print \"$n $a $b\";\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; --$b;}\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; --$a;}\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n elseif ($b==0 && $i==1) $c=true;\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; $a-=1;}\n else $money[$i] = $money[$i-1];\n}\nif ($money[$n-1] < 50001 && !$c) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1; print \"$n $a $b\";\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; --$b;}\n elseif ($a>0) {$money[$i]=2; --$a;}\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n elseif ($a>0) {$money[$i]=2; $a-=1;}\n else $money[$i] = 1;\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n elseif ($a>0) {$money[$i]=2; $a-=1;}\n else $money[$i] = $money[$i-1];\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n elseif ($b==0 && $i==1 && $a != 0) $c=true;\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; $a-=1;}\n else $money[$i] = $money[$i-1];\n}\nif ($money[$n-1] < 50001 && !$c) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=0; print \"$n $a $b\";\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; --$b;}\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; --$a;}\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; --$b;}\n elseif ($a>0) {$money[$i]=2; --$a;}\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}, {"source_code": "\nlist($n,$a,$b)=explode(' ', fgets(STDIN));\n$money[0]=1;\nfor ($i=1;$i<$n;++$i) {\n $sum+=$money[$i-1];\n if ($b>0) {$money[$i]=$sum+1; $b-=1;}\n elseif ($a>0) {$money[$i]=$money[$i-1]+1; $a-=1;}\n else $money[$i] = $money[$i-1];\n}\nif ($money[$n-1] < 50001) for ($i=0;$i<$n;++$i) print \"$money[$i] \";\n else echo '-1';\n"}], "src_uid": "573995cbae2a7b28ed92d71c48cd9039"} {"nl": {"description": "You are given an array $$$a$$$ of length $$$n$$$. We define the equality of the array as the number of indices $$$1 \\le i \\le n - 1$$$ such that $$$a_i = a_{i + 1}$$$. We are allowed to do the following operation: Select two integers $$$i$$$ and $$$x$$$ such that $$$1 \\le i \\le n - 1$$$ and $$$1 \\le x \\le 10^9$$$. Then, set $$$a_i$$$ and $$$a_{i + 1}$$$ to be equal to $$$x$$$. Find the minimum number of operations needed such that the equality of the array is less than or equal to $$$1$$$.", "input_spec": "Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) \u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10 ^ 5$$$) \u2014 the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u2014 elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10 ^ 5$$$", "output_spec": "For each test case, print the minimum number of operations needed.", "sample_inputs": ["4\n\n5\n\n1 1 1 1 1\n\n5\n\n2 1 1 1 2\n\n6\n\n1 1 2 3 3 4\n\n6\n\n1 2 1 4 5 4"], "sample_outputs": ["2\n1\n2\n0"], "notes": "NoteIn the first test case, we can select $$$i=2$$$ and $$$x=2$$$ to form $$$[1, 2, 2, 1, 1]$$$. Then, we can select $$$i=3$$$ and $$$x=3$$$ to form $$$[1, 2, 3, 3, 1]$$$.In the second test case, we can select $$$i=3$$$ and $$$x=100$$$ to form $$$[2, 1, 100, 100, 2]$$$."}, "positive_code": [{"source_code": "=1;$i--){\r\n if($arr[$i]==$arr[$i-1]){\r\n $l=$i;\r\n break;\r\n }\r\n }\r\n\r\n if($l-$f>0){\r\n if($l-$f==1){ echo \"1\\n\";}\r\n else{\r\n $z=$l-$f-1;\r\n echo $z.\"\\n\";\r\n }\r\n }else{\r\n echo \"0\\n\";\r\n }\r\n}"}], "negative_code": [], "src_uid": "a91be662101762bcb2c58b8db9ff61e0"} {"nl": {"description": "Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one unit right. A 'U' indicates he should move one unit up. A 'D' indicates he should move one unit down.But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.", "input_spec": "The first and only line contains the string s (1\u2009\u2264\u2009|s|\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the instructions Memory is given.", "output_spec": "If there is a string satisfying the conditions, output a single integer\u00a0\u2014 the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.", "sample_inputs": ["RRU", "UDUR", "RUUR"], "sample_outputs": ["-1", "1", "2"], "notes": "NoteIn the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to \"LDUR\". This string uses 1 edit, which is the minimum possible. It also ends at the origin."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ">1;\n\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ">1;\n\n\n?>"}, {"source_code": ""}, {"source_code": ">1;\n\n\n?>"}, {"source_code": ">1;\n\n\n?>"}], "src_uid": "8237ac3f3c2e79f5f70be1595630207e"} {"nl": {"description": "Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted n flowers in a row on his windowsill and started waiting for them to grow. However, after some time the beaver noticed that the flowers stopped growing. The beaver thinks it is bad manners to present little flowers. So he decided to come up with some solutions. There are m days left to the birthday. The height of the i-th flower (assume that the flowers in the row are numbered from 1 to n from left to right) is equal to ai at the moment. At each of the remaining m days the beaver can take a special watering and water w contiguous flowers (he can do that only once at a day). At that each watered flower grows by one height unit on that day. The beaver wants the height of the smallest flower be as large as possible in the end. What maximum height of the smallest flower can he get?", "input_spec": "The first line contains space-separated integers n, m and w (1\u2009\u2264\u2009w\u2009\u2264\u2009n\u2009\u2264\u2009105;\u00a01\u2009\u2264\u2009m\u2009\u2264\u2009105). The second line contains space-separated integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Print a single integer \u2014 the maximum final height of the smallest flower.", "sample_inputs": ["6 2 3\n2 2 2 2 1 1", "2 5 1\n5 8"], "sample_outputs": ["2", "9"], "notes": "NoteIn the first sample beaver can water the last 3 flowers at the first day. On the next day he may not to water flowers at all. In the end he will get the following heights: [2, 2, 2, 3, 2, 2]. The smallest flower has height equal to 2. It's impossible to get height 3 in this test."}, "positive_code": [{"source_code": "> 1;\n $x = $t; \n $f = array_fill(0, $n + 1, 0);\n $check = true;\n for ($i = 0; $i < $n; $i++) {\n if ($x < 0) { $check = false; break; }\n if ($i > 0) $f[$i] += $f[$i - 1];\n if ($a[$i] + $f[$i] < $m) {\n $k = $m - $a[$i] - $f[$i];\n $f[$i] += $k;\n $f[min($i + $w, $n)] -= $k;\n $x -= $k;\n }\n }\n if ($x < 0) $check = false;\n if ($check) $l = ($ans = $m) + 1; else $r = $m;\n }\n echo $ans;"}], "negative_code": [], "src_uid": "48c8dc603511fd3f0e6ad00dfc801a7e"} {"nl": {"description": "Kuroni has $$$n$$$ daughters. As gifts for them, he bought $$$n$$$ necklaces and $$$n$$$ bracelets: the $$$i$$$-th necklace has a brightness $$$a_i$$$, where all the $$$a_i$$$ are pairwise distinct (i.e. all $$$a_i$$$ are different), the $$$i$$$-th bracelet has a brightness $$$b_i$$$, where all the $$$b_i$$$ are pairwise distinct (i.e. all $$$b_i$$$ are different). Kuroni wants to give exactly one necklace and exactly one bracelet to each of his daughters. To make sure that all of them look unique, the total brightnesses of the gifts given to each daughter should be pairwise distinct. Formally, if the $$$i$$$-th daughter receives a necklace with brightness $$$x_i$$$ and a bracelet with brightness $$$y_i$$$, then the sums $$$x_i + y_i$$$ should be pairwise distinct. Help Kuroni to distribute the gifts.For example, if the brightnesses are $$$a = [1, 7, 5]$$$ and $$$b = [6, 1, 2]$$$, then we may distribute the gifts as follows: Give the third necklace and the first bracelet to the first daughter, for a total brightness of $$$a_3 + b_1 = 11$$$. Give the first necklace and the third bracelet to the second daughter, for a total brightness of $$$a_1 + b_3 = 3$$$. Give the second necklace and the second bracelet to the third daughter, for a total brightness of $$$a_2 + b_2 = 8$$$. Here is an example of an invalid distribution: Give the first necklace and the first bracelet to the first daughter, for a total brightness of $$$a_1 + b_1 = 7$$$. Give the second necklace and the second bracelet to the second daughter, for a total brightness of $$$a_2 + b_2 = 8$$$. Give the third necklace and the third bracelet to the third daughter, for a total brightness of $$$a_3 + b_3 = 7$$$. This distribution is invalid, as the total brightnesses of the gifts received by the first and the third daughter are the same. Don't make them this upset!", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u00a0\u2014 the number of daughters, necklaces and bracelets. The second line of each test case contains $$$n$$$ distinct integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 1000$$$) \u00a0\u2014 the brightnesses of the necklaces. The third line of each test case contains $$$n$$$ distinct integers $$$b_1, b_2, \\dots, b_n$$$ ($$$1 \\le b_i \\le 1000$$$) \u00a0\u2014 the brightnesses of the bracelets.", "output_spec": "For each test case, print a line containing $$$n$$$ integers $$$x_1, x_2, \\dots, x_n$$$, representing that the $$$i$$$-th daughter receives a necklace with brightness $$$x_i$$$. In the next line print $$$n$$$ integers $$$y_1, y_2, \\dots, y_n$$$, representing that the $$$i$$$-th daughter receives a bracelet with brightness $$$y_i$$$. The sums $$$x_1 + y_1, x_2 + y_2, \\dots, x_n + y_n$$$ should all be distinct. The numbers $$$x_1, \\dots, x_n$$$ should be equal to the numbers $$$a_1, \\dots, a_n$$$ in some order, and the numbers $$$y_1, \\dots, y_n$$$ should be equal to the numbers $$$b_1, \\dots, b_n$$$ in some order. It can be shown that an answer always exists. If there are multiple possible answers, you may print any of them.", "sample_inputs": ["2\n3\n1 8 5\n8 4 5\n3\n1 7 5\n6 1 2"], "sample_outputs": ["1 8 5\n8 4 5\n5 1 7\n6 2 1"], "notes": "NoteIn the first test case, it is enough to give the $$$i$$$-th necklace and the $$$i$$$-th bracelet to the $$$i$$$-th daughter. The corresponding sums are $$$1 + 8 = 9$$$, $$$8 + 4 = 12$$$, and $$$5 + 5 = 10$$$.The second test case is described in the statement."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $s2){\n echo \"NO\\n\";\n } else {\n echo \"YES\\n\";\n echo \"2\\n\";\n echo $s1 . ' ' . $s2. \"\\n\";\n }\n }\n}\n"}, {"source_code": ""}, {"source_code": "\n\n$n = trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n\t$cnt = intval(trim(fgets(STDIN)));\n\t$str = trim(fgets(STDIN));\n\t\n\tif($cnt<2){\n\t\techo \"NO\\n\";\n\t}elseif($cnt==2){\n\t\tif(intval(substr($str,0,1))>=intval(substr($str,1,1))){\n\t\t\techo \"NO\\n\";\n\t\t}else{\n\t\t\techo \"YES\\n\";\n\t\t\techo \"2\\n\";\n\t\t\techo substr($str,0,1).\" \".substr($str,1,1).\"\\n\";\n\t\t}\n\t}else{\n\t\techo \"YES\\n\";\n\t\techo \"2\\n\";\n\t\techo substr($str,0,1).\" \".substr($str,1).\"\\n\";\n\t}\n}"}], "negative_code": [{"source_code": ""}, {"source_code": "\n\n$n = trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n\t$cnt = intval(trim(fgets(STDIN)));\n\t$str = trim(fgets(STDIN));\n\t\n\tif($cnt<2){\n\t\techo \"NO\\n\";\n\t}elseif($cnt==2){\n\t\tif(intval(substr($str,0,1))<=intval(substr($str,1,1))){\n\t\t\techo \"NO\\n\";\n\t\t}else{\n\t\t\techo \"YES\\n\";\n\t\t\techo \"2\";\n\t\t\techo substr($str,0,1).\" \".substr($str,1,1).\"\\n\";\n\t\t}\n\t}else{\n\t\techo \"YES\\n\";\n\t\techo \"2\";\n\t\techo substr($str,0,1).\" \".substr($str,1).\"\\n\";\n\t}\n}"}, {"source_code": "\n\n$n = trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n\t$cnt = intval(trim(fgets(STDIN)));\n\t$str = trim(fgets(STDIN));\n\t\n\tif($cnt<2){\n\t\techo \"NO\\n\";\n\t}elseif($cnt==2){\n\t\tif(intval(substr($str,0,1))<=intval(substr($str,1,1))){\n\t\t\techo \"NO\\n\";\n\t\t}else{\n\t\t\techo \"YES\\n\";\n\t\t\techo substr($str,0,1).\" \".substr($str,1,1).\"\\n\";\n\t\t}\n\t}else{\n\t\techo \"YES\\n\";\n\t\techo substr($str,0,1).\" \".substr($str,1).\"\\n\";\n\t}\n}"}, {"source_code": "\n$n = trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n\t$cnt = intval(trim(fgets(STDIN)));\n\t$str = trim(fgets(STDIN));\n\t\n\tif($cnt<2){\n\t\techo \"NO\\n\";\n\t}elseif($cnt==2){\n\t\tif(intval(substr($str,0,1))<=intval(substr($str,1,1))){\n\t\t\techo \"NO\\n\";\n\t\t}else{\n\t\t\techo substr($str,0,1).\" \".substr($str,1,1);\n\t\t}\n\t}else{\n\t\techo substr($str,0,1).\" \".substr($str,1);\n\t}\n}"}, {"source_code": "\n\n$n = trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n\t$cnt = intval(trim(fgets(STDIN)));\n\t$str = trim(fgets(STDIN));\n\t\n\tif($cnt<2){\n\t\techo \"NO\\n\";\n\t}elseif($cnt==2){\n\t\tif(intval(substr($str,0,1))<=intval(substr($str,1,1))){\n\t\t\techo \"NO\\n\";\n\t\t}else{\n\t\t\techo \"YES\\n\";\n\t\t\techo \"2\\n\";\n\t\t\techo substr($str,0,1).\" \".substr($str,1,1).\"\\n\";\n\t\t}\n\t}else{\n\t\techo \"YES\\n\";\n\t\techo \"2\\n\";\n\t\techo substr($str,0,1).\" \".substr($str,1).\"\\n\";\n\t}\n}"}], "src_uid": "9f87a89c788bd7c7b66e51db9fe47e46"} {"nl": {"description": "You are given a string $$$s$$$, consisting only of characters '0' or '1'. Let $$$|s|$$$ be the length of $$$s$$$.You are asked to choose some integer $$$k$$$ ($$$k > 0$$$) and find a sequence $$$a$$$ of length $$$k$$$ such that: $$$1 \\le a_1 < a_2 < \\dots < a_k \\le |s|$$$; $$$a_{i-1} + 1 < a_i$$$ for all $$$i$$$ from $$$2$$$ to $$$k$$$. The characters at positions $$$a_1, a_2, \\dots, a_k$$$ are removed, the remaining characters are concatenated without changing the order. So, in other words, the positions in the sequence $$$a$$$ should not be adjacent.Let the resulting string be $$$s'$$$. $$$s'$$$ is called sorted if for all $$$i$$$ from $$$2$$$ to $$$|s'|$$$ $$$s'_{i-1} \\le s'_i$$$.Does there exist such a sequence $$$a$$$ that the resulting string $$$s'$$$ is sorted?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The only line of each testcase contains a string $$$s$$$ ($$$2 \\le |s| \\le 100$$$). Each character is either '0' or '1'.", "output_spec": "For each testcase print \"YES\" if there exists a sequence $$$a$$$ such that removing the characters at positions $$$a_1, a_2, \\dots, a_k$$$ and concatenating the parts without changing the order produces a sorted string. Otherwise, print \"NO\". You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).", "sample_inputs": ["5\n10101011011\n0000\n11111\n110\n1100"], "sample_outputs": ["YES\nYES\nYES\nYES\nNO"], "notes": "NoteIn the first testcase you can choose a sequence $$$a=[1,3,6,9]$$$. Removing the underlined letters from \"10101011011\" will produce a string \"0011111\", which is sorted.In the second and the third testcases the sequences are already sorted.In the fourth testcase you can choose a sequence $$$a=[3]$$$. $$$s'=$$$ \"11\", which is sorted.In the fifth testcase there is no way to choose a sequence $$$a$$$ such that $$$s'$$$ is sorted."}, "positive_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $d = $s;\r\n $last0 = -3;\r\n $bool = true;\r\n $bl = true;\r\n foreach ($s as $k => $v) {\r\n if($v == 1 && $bl) {\r\n if($k - $last0 >= 2) {\r\n $last0 = $k;\r\n unset($d[$k]);\r\n } else {\r\n $bl = false;\r\n }\r\n }\r\n if ($v == 0 && !$bl) {\r\n if($k - $last0 >= 2) {\r\n $last0 = $k;\r\n unset($d[$k]);\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n $last = -1;\r\n foreach ($d as $f) {\r\n if ($last > $f) {\r\n $bool = false;\r\n break;\r\n }\r\n $last = $f;\r\n }\r\n\r\n\r\n if ($bool) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": ""}, {"source_code": "= $cur) $z = true;\n\t else $last = $cur;\n\t }\n\t }\n\t else\n\t {\n\t if($s[$i] == '0')\n\t {\n\t $cur = $i + 1;\n\t \n\t if($last + 1 >= $cur)\n\t {\n\t print \"NO\\n\";;\n\t continue 2;\n\t }\n\n\t $last = $cur;\n\t }\n\t }\n\t }\n\n\t print \"YES\\n\";\n\t}\n?>"}], "negative_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $last0 = $last1 = -3;\r\n $bool0 = $bool1 = true;\r\n $aZero = $aOne = [];\r\n foreach ($s as $k => $v) {\r\n if (($k == 0 && $s[1] != $v) || ($k == count($s) - 1 && $s[count($s) - 2] != $v)) {\r\n continue;\r\n }\r\n if($v == 0) {\r\n $aZero[$k] = $k;\r\n } else {\r\n $aOne[$k] = $k;\r\n }\r\n }\r\n\r\n for($i = 0; $i <= end($aZero); $i++) {\r\n if ($s[$i] == 1) {\r\n if ($i - $last1 < 2) {\r\n $bool1 = false;\r\n }\r\n $last1 = $i;\r\n }\r\n if ($s[$i] == 0) {\r\n if ($i - $last0 < 2) {\r\n $bool0 = false;\r\n }\r\n $last0 = $i;\r\n }\r\n }\r\n\r\n if ($bool1 || $bool0) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $last0 = $last1 = -3;\r\n $bool0 = $bool1 = true;\r\n $aZero = $aOne = [];\r\n foreach ($s as $k => $v) {\r\n if($v == 0) {\r\n $aZero[$k] = $k;\r\n } else {\r\n $aOne[$k] = $k;\r\n }\r\n }\r\n for($i = 0; $i <= end($aZero); $i++) {\r\n if ($s[$i] == 1) {\r\n if ($i - $last1 < 2) {\r\n $bool1 = false;\r\n }\r\n $last1 = $i;\r\n }\r\n if ($s[$i] == 0) {\r\n if ($i - $last0 < 2) {\r\n $bool0 = false;\r\n }\r\n $last0 = $i;\r\n }\r\n }\r\n\r\n if ($bool1 || $bool0) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $last = -3;\r\n $bool = true;\r\n foreach ($s as $k => $v) {\r\n if ($v == 0 && $k - $last < 2) {\r\n $bool = false;\r\n //break;\r\n }\r\n if($v == 0) {\r\n $last = $k;\r\n }\r\n }\r\n if (!$bool) {\r\n $bool = true;\r\n $last1 = -3;\r\n for ($i = 0; $i < $last; $i++) {\r\n if ($s[$i] == 1 && $i - $last1 < 2) {\r\n $bool = false;\r\n break;\r\n }\r\n if($s[$i] == 1) {\r\n $last1 = $i;\r\n }\r\n }\r\n }\r\n\r\n if ($bool) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $last = -3;\r\n $bool = true;\r\n foreach ($s as $k => $v) {\r\n if ($v == 0 && $k - $last < 2) {\r\n $bool = false;\r\n //break;\r\n }\r\n if($v == 0) {\r\n $last = $k;\r\n }\r\n }\r\n if (!$bool && $last + 1 != count($s)) {\r\n $bool = true;\r\n $last1 = -3;\r\n for ($i = 0; $i < $last; $i++) {\r\n if ($s[$i] == 1 && $i - $last1 < 2) {\r\n $bool = false;\r\n break;\r\n }\r\n if($s[$i] == 1) {\r\n $last1 = $i;\r\n }\r\n }\r\n }\r\n\r\n if ($bool) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $s = str_split(IO::str());\r\n $last = -3;\r\n $bool = true;\r\n foreach ($s as $k => $v) {\r\n if ($v == 0 && $k - $last < 2) {\r\n $bool = false;\r\n break;\r\n }\r\n if($v == 0) {\r\n $last = $k;\r\n }\r\n }\r\n if (!$bool) {\r\n $bool = true;\r\n $last1 = -3;\r\n for ($i = 0; $i < $last; $i++) {\r\n if ($s[$i] == 1 && $i - $last1 < 2) {\r\n $bool = false;\r\n break;\r\n }\r\n if($s[$i] == 1) {\r\n $last1 = $i;\r\n }\r\n }\r\n }\r\n\r\n if ($bool) {\r\n IO::line('YES');\r\n } else {\r\n IO::line('NO');\r\n }\r\n\r\n}"}, {"source_code": ""}], "src_uid": "357dcc8fb7783d878cd2c4ed34eb437e"} {"nl": {"description": "Find out if it is possible to partition the first $$$n$$$ positive integers into two non-empty disjoint sets $$$S_1$$$ and $$$S_2$$$ such that:$$$\\mathrm{gcd}(\\mathrm{sum}(S_1), \\mathrm{sum}(S_2)) > 1$$$ Here $$$\\mathrm{sum}(S)$$$ denotes the sum of all elements present in set $$$S$$$ and $$$\\mathrm{gcd}$$$ means thegreatest common divisor.Every integer number from $$$1$$$ to $$$n$$$ should be present in exactly one of $$$S_1$$$ or $$$S_2$$$.", "input_spec": "The only line of the input contains a single integer $$$n$$$ ($$$1 \\le n \\le 45\\,000$$$)", "output_spec": "If such partition doesn't exist, print \"No\" (quotes for clarity). Otherwise, print \"Yes\" (quotes for clarity), followed by two lines, describing $$$S_1$$$ and $$$S_2$$$ respectively. Each set description starts with the set size, followed by the elements of the set in any order. Each set must be non-empty. If there are multiple possible partitions\u00a0\u2014 print any of them.", "sample_inputs": ["1", "3"], "sample_outputs": ["No", "Yes\n1 2\n2 1 3"], "notes": "NoteIn the first example, there is no way to partition a single number into two non-empty sets, hence the answer is \"No\".In the second example, the sums of the sets are $$$2$$$ and $$$4$$$ respectively. The $$$\\mathrm{gcd}(2, 4) = 2 > 1$$$, hence that is one of the possible answers."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "bb7bace930d5c5f231bfc2061576ec45"} {"nl": {"description": "Consider an array $$$a$$$ of $$$n$$$ positive integers.You may perform the following operation: select two indices $$$l$$$ and $$$r$$$ ($$$1 \\leq l \\leq r \\leq n$$$), then decrease all elements $$$a_l, a_{l + 1}, \\dots, a_r$$$ by $$$1$$$. Let's call $$$f(a)$$$ the minimum number of operations needed to change array $$$a$$$ into an array of $$$n$$$ zeros.Determine if for all permutations$$$^\\dagger$$$ $$$b$$$ of $$$a$$$, $$$f(a) \\leq f(b)$$$ is true. $$$^\\dagger$$$ An array $$$b$$$ is a permutation of an array $$$a$$$ if $$$b$$$ consists of the elements of $$$a$$$ in arbitrary order. For example, $$$[4,2,3,4]$$$ is a permutation of $$$[3,2,4,4]$$$ while $$$[1,2,2]$$$ is not a permutation of $$$[1,2,3]$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) \u2014 the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$) \u2014 the length of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) \u2014 description of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case, print \"YES\" (without quotes) if for all permutations $$$b$$$ of $$$a$$$, $$$f(a) \\leq f(b)$$$ is true, and \"NO\" (without quotes) otherwise. You can output \"YES\" and \"NO\" in any case (for example, strings \"yEs\", \"yes\" and \"Yes\" will be recognized as a positive response).", "sample_inputs": ["3\n\n4\n\n2 3 5 4\n\n3\n\n1 2 3\n\n4\n\n3 1 3 2"], "sample_outputs": ["YES\nYES\nNO"], "notes": "NoteIn the first test case, we can change all elements to $$$0$$$ in $$$5$$$ operations. It can be shown that no permutation of $$$[2, 3, 5, 4]$$$ requires less than $$$5$$$ operations to change all elements to $$$0$$$.In the third test case, we need $$$5$$$ operations to change all elements to $$$0$$$, while $$$[2, 3, 3, 1]$$$ only needs $$$3$$$ operations."}, "positive_code": [{"source_code": " $ar[$i]) {\n $sorted = false;\n break;\n }\n }\n\n if (!$sorted) {\n $sorted = true;\n for (++$i; $i < $n; ++$i) {\n if ($ar[$i - 1] < $ar[$i]) {\n $sorted = false;\n break;\n }\n }\n }\n\n if ($sorted) {\n echo 'YES'.PHP_EOL;\n } else {\n echo 'NO'.PHP_EOL;\n }\n}\n\n/*\n\n1\n5\n1 2 3 2 1\n// yes\n\n1\n5\n3 2 1 2 3\n// no\n\n1\n5\n1 2 3 4 5\n// yes\n\n1\n4\n1 1 1 1\n// yes\n\n1\n7\n2 1 3 4 2 1 2\n// no\n */\n"}, {"source_code": " $ar[$i]) {\n// $sorted = false;\n// break;\n// }\n// }\n// }\n\n // try asc\n $sorted = false;\n\n if (!$sorted) {\n $sorted = true;\n\n for ($i = 1; $i < $n; ++$i) {\n if ($ar[$i - 1] > $ar[$i]) {\n $sorted = false;\n break;\n }\n }\n\n if (!$sorted) {\n $sorted = true;\n for (++$i; $i < $n; ++$i) {\n if ($ar[$i - 1] < $ar[$i]) {\n $sorted = false;\n break;\n }\n }\n }\n }\n\n if ($sorted) {\n echo 'YES'.PHP_EOL;\n } else {\n echo 'NO'.PHP_EOL;\n }\n}\n\n/*\n\n1\n5\n1 2 3 2 1\n// yes\n\n1\n5\n3 2 1 2 3\n// no\n\n1\n5\n1 2 3 4 5\n// yes\n\n1\n4\n1 1 1 1\n\n1\n7\n2 1 3 4 2 1 2\n// no\n */\n"}, {"source_code": " $p[$i] and $p[$i] < $p[$i+1]) $works = false;\r\n }\r\n if ($works) fwrite($cout, \"YES\\n\");\r\n else fwrite($cout, \"NO\\n\");\r\n} ?>"}], "negative_code": [{"source_code": " $ar[$i - 1]) {\n $sorted = false;\n break;\n }\n }\n // 4 4 3 2 1\n if (!$sorted) {\n $sorted = true;\n\n for (++$i; $i < $n; ++$i) {\n if ($ar[$i] < $ar[$i - 1]) {\n $sorted = false;\n break;\n }\n }\n }\n\n // try desc\n\n if (!$sorted) {\n $sorted = true;\n\n for ($i = 1; $i < $n; ++$i) {\n if ($ar[$i] < $ar[$i - 1]) {\n $sorted = false;\n break;\n }\n }\n\n if (!$sorted) {\n $sorted = true;\n for (++$i; $i < $n; ++$i) {\n if ($ar[$i] > $ar[$i - 1]) {\n $sorted = false;\n break;\n }\n }\n }\n }\n\n if ($sorted) {\n echo 'YES'.PHP_EOL;\n } else {\n echo 'NO'.PHP_EOL;\n }\n}\n\n/*\n\n1\n5\n1 2 3 2 1\n// yes\n\n1\n5\n3 2 1 2 3\n// yes\n\n1\n5\n1 2 3 4 5\n// yes\n\n1\n4\n1 1 1 1\n\n */\n"}], "src_uid": "c35d309dd6a9569ec298e7128aa3fc0e"} {"nl": {"description": "A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters \u00ab+\u00bb and \u00ab1\u00bb into this sequence. For example, sequences \u00ab(())()\u00bb, \u00ab()\u00bb and \u00ab(()(()))\u00bb are regular, while \u00ab)(\u00bb, \u00ab(()\u00bb and \u00ab(()))(\u00bb are not.One day Johnny got bracket sequence. He decided to remove some of the brackets from it in order to obtain a regular bracket sequence. What is the maximum length of a regular bracket sequence which can be obtained?", "input_spec": "Input consists of a single line with non-empty string of \u00ab(\u00bb and \u00ab)\u00bb characters. Its length does not exceed 106.", "output_spec": "Output the maximum possible length of a regular bracket sequence.", "sample_inputs": ["(()))(", "((()())"], "sample_outputs": ["4", "6"], "notes": null}, "positive_code": [{"source_code": " 0))\n {\n $c--;\n array_push($d, $x - $e - $c + 1);\n }\n elseif(($a[$x] == \"(\") && ($b == 0))\n {\n $c = 1;\n $b = 1;\n $e = $x;\n }\n elseif(($a[$x] == \"(\") && ($b == 1))\n {\n $c++;\n }\n elseif(($a[$x] == \")\") && ($b == 1))\n {\n $c--;\n if($c == -1)\n {\n array_push($d, $x - $e);\n $b = 0;\n }\n }\n}\nif((strlen($a) == 1) || (count($d) == 0))\n{\n print \"0\";\n}\nelse\n{\n print array_sum($d);\n}\n?>"}, {"source_code": "\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "2ce2d0c4ac5e630bafad2127a1b589dd"} {"nl": {"description": "You have a string $$$s$$$ consisting of lowercase Latin alphabet letters. You can color some letters in colors from $$$1$$$ to $$$k$$$. It is not necessary to paint all the letters. But for each color, there must be a letter painted in that color.Then you can swap any two symbols painted in the same color as many times as you want. After that, $$$k$$$ strings will be created, $$$i$$$-th of them will contain all the characters colored in the color $$$i$$$, written in the order of their sequence in the string $$$s$$$.Your task is to color the characters of the string so that all the resulting $$$k$$$ strings are palindromes, and the length of the shortest of these $$$k$$$ strings is as large as possible.Read the note for the first test case of the example if you need a clarification.Recall that a string is a palindrome if it reads the same way both from left to right and from right to left. For example, the strings abacaba, cccc, z and dxd are palindromes, but the strings abab and aaabaa\u00a0\u2014 are not.", "input_spec": "The first line of input data contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of input data sets in the test. The descriptions of the input data sets follow. The first line of the description of each input data set contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 2 \\cdot 10^5$$$)\u00a0\u2014 the length of the string and the number of colors in which its letters can be painted. The second line of the description of each input data set contains a string $$$s$$$ of length $$$n$$$ consisting of lowercase letters of the Latin alphabet. It is guaranteed that the sum of n over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each set of input data, output a single integer \u00a0\u2014 the maximum length of the shortest palindrome string that can be obtained.", "sample_inputs": ["10\n\n8 2\n\nbxyaxzay\n\n6 3\n\naaaaaa\n\n6 1\n\nabcdef\n\n6 6\n\nabcdef\n\n3 2\n\ndxd\n\n11 2\n\nabcabcabcac\n\n6 6\n\nsipkic\n\n7 2\n\neatoohd\n\n3 1\n\nllw\n\n6 2\n\nbfvfbv"], "sample_outputs": ["3\n2\n1\n1\n1\n5\n1\n1\n3\n3"], "notes": "Note In the first test case, $$$s$$$=\"bxyaxzay\", $$$k=2$$$. We use indices in the string from $$$1$$$ to $$$8$$$. The following coloring will work: $$$\\mathtt{\\mathbf{\\color{red}{b}\\color{blue}{xy}\\color{red}{a}\\color{blue}{x}z\\color{red}{a}\\color{blue}{y}}}$$$ (the letter z remained uncolored). After painting: swap two red characters (with the indices $$$1$$$ and $$$4$$$), we get $$$\\mathtt{\\mathbf{\\color{red}{a}\\color{blue}{xy}\\color{red}{b}\\color{blue}{x}z\\color{red}{a}\\color{blue}{y}}}$$$; swap two blue characters (with the indices $$$5$$$ and $$$8$$$), we get $$$\\mathtt{\\mathbf{\\color{red}{a}\\color{blue}{xy}\\color{red}{b}\\color{blue}{y}z\\color{red}{a}\\color{blue}{x}}}$$$. Now, for each of the two colors we write out the corresponding characters from left to right, we get two strings $$$\\mathtt{\\mathbf{\\color{red}{aba}}}$$$ and $$$\\mathtt{\\mathbf{\\color{blue}{xyyx}}}$$$. Both of them are palindromes, the length of the shortest is $$$3$$$. It can be shown that the greatest length of the shortest palindrome cannot be achieved. In the second set of input data, the following coloring is suitable: $$$[1, 1, 2, 2, 3, 3]$$$. There is no need to swap characters. Both received strings are equal to aa, they are palindromes and their length is $$$2$$$. In the third set of input data, you can color any character and take it into a string. In the fourth set of input data, you can color the $$$i$$$th character in the color $$$i$$$. In the fifth set of input data can be colored in each of the colors of one character. In the sixth set of input data, the following coloring is suitable: $$$[1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0]$$$. Rearrange the characters so as to get the palindromes abcba and acbca."}, "positive_code": [{"source_code": " &$Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $EvenLettersSum += $Count;\r\n $Count = 0;\r\n }\r\n else\r\n {\r\n $EvenLettersSum += $Count - 1;\r\n $Count = 1;\r\n }\r\n }\r\n \r\n $OddRemainders = array_sum ($Letters);\r\n \r\n $EvenPairs = $EvenLettersSum / 2;\r\n \r\n $PairsByPalindrome = floor ($EvenPairs / $k);\r\n $RemainingEvenPairs = $EvenPairs % $k;\r\n \r\n for ($i = 0; $i < $k; $i++)\r\n {\r\n $DivPalindromes [] = 2 * $PairsByPalindrome;\r\n }\r\n \r\n \r\n for ($i = 0; $i < $RemainingEvenPairs; $i++)\r\n {\r\n $DivPalindromes [$i] += 2;\r\n }\r\n \r\n sort ($DivPalindromes);\r\n \r\n $c = count ($DivPalindromes);\r\n \r\n if ($OddRemainders > 0)\r\n {\r\n $i = 0;\r\n \r\n do\r\n {\r\n $DivPalindromes [$i++]++; \r\n $OddRemainders--;\r\n } while ($i < $c && $OddRemainders > 0);\r\n }\r\n \r\n \r\n \r\n $DivPalindromes = array_values (\r\n array_filter ($DivPalindromes)\r\n );\r\n \r\n $c = count ($DivPalindromes);\r\n \r\n $min = min ($DivPalindromes);\r\n \r\n $i = -1;\r\n $j = $c;\r\n \r\n while (in_array ($min, $DivPalindromes))\r\n {\r\n do\r\n {\r\n $j--;\r\n \r\n if ($j <= 0) break 2;\r\n } while ($DivPalindromes [$j] % 2 != 0);\r\n \r\n do\r\n {\r\n $i++;\r\n if ($i >= $c) break 2;\r\n } while ($DivPalindromes [$i] % 2 != 0);\r\n \r\n if ($DivPalindromes [$j] - $DivPalindromes [$i] >= 2)\r\n {\r\n $DivPalindromes [$i]++;\r\n $DivPalindromes [$j]--;\r\n }\r\n }\r\n \r\n return min ($DivPalindromes);\r\n}"}], "negative_code": [{"source_code": " &$Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $EvenLettersSum += $Count;\r\n $Count = 0;\r\n }\r\n else\r\n {\r\n $EvenLettersSum += $Count - 1;\r\n $Count = 1;\r\n }\r\n }\r\n \r\n $OddRemainders = array_sum ($Letters);\r\n \r\n $EvenPairs = $EvenLettersSum / 2;\r\n \r\n $PairsByPalindrome = floor ($EvenPairs / $k);\r\n $RemainingEvenPairs = $EvenPairs % $k;\r\n \r\n for ($i = 0; $i < $k; $i++)\r\n {\r\n $DivPalindromes [] = 2 * $PairsByPalindrome;\r\n }\r\n \r\n for ($i = 0; $i < $RemainingEvenPairs; $i++)\r\n {\r\n $DivPalindromes [$i] += 2;\r\n }\r\n \r\n sort ($DivPalindromes);\r\n \r\n $c = count ($DivPalindromes);\r\n \r\n if ($OddRemainders > 0)\r\n {\r\n $i = 0;\r\n \r\n do\r\n {\r\n $DivPalindromes [$i++]++; \r\n $OddRemainders--;\r\n } while ($i < $c && $OddRemainders > 0);\r\n }\r\n \r\n \r\n $DivPalindromes = array_values (\r\n array_filter ($DivPalindromes)\r\n );\r\n \r\n \r\n $c = count ($DivPalindromes);\r\n \r\n for ($i = 0; $i < $c - 1; $i++)\r\n {\r\n if ($DivPalindromes [$i] % 2 == 0 && \r\n $DivPalindromes [$i + 1] % 2 == 0 && \r\n $DivPalindromes [$i + 1] - $DivPalindromes [$i] >= 2)\r\n {\r\n $DivPalindromes [$i]++;\r\n $DivPalindromes [$i + 1]--;\r\n }\r\n }\r\n \r\n return min ($DivPalindromes);\r\n}"}, {"source_code": " &$Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $EvenLettersSum += $Count;\r\n $Count = 0;\r\n }\r\n else\r\n {\r\n $EvenLettersSum += $Count - 1;\r\n $Count = 1;\r\n }\r\n }\r\n \r\n $OddRemainders = array_sum ($Letters);\r\n \r\n $EvenPairs = $EvenLettersSum / 2;\r\n \r\n $PairsByPalindrome = floor ($EvenPairs / $k);\r\n $RemainingEvenPairs = $EvenPairs % $k;\r\n \r\n for ($i = 0; $i < $k; $i++)\r\n {\r\n $DivPalindromes [] = 2 * $PairsByPalindrome;\r\n }\r\n \r\n for ($i = 0; $i < $RemainingEvenPairs; $i++)\r\n {\r\n $DivPalindromes [$i] += 2;\r\n }\r\n \r\n sort ($DivPalindromes);\r\n \r\n $c = count ($DivPalindromes);\r\n \r\n if ($OddRemainders > 0)\r\n {\r\n $i = 0;\r\n \r\n do\r\n {\r\n $DivPalindromes [$i++]++; \r\n $OddRemainders--;\r\n } while ($i < $c && $OddRemainders > 0);\r\n }\r\n \r\n $DivPalindromes = array_values (\r\n array_filter ($DivPalindromes)\r\n );\r\n \r\n $c = count ($DivPalindromes);\r\n \r\n for ($i = 0; $i < $c - 1; $i++)\r\n {\r\n if ($DivPalindromes [$i] % 2 == 0 && \r\n $DivPalindromes [$i + 1] % 2 == 0 && \r\n $DivPalindromes [$i + 1] - $DivPalindromes [$i] >= 2)\r\n {\r\n $DivPalindromes [$i]++;\r\n $DivPalindromes [$i + 1]--;\r\n }\r\n }\r\n \r\n return min ($DivPalindromes);\r\n}"}, {"source_code": " $Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $MaxEvenPalindromeLength += $Count;\r\n unset ($Letters [$Letter]);\r\n }\r\n }\r\n \r\n $Length2 = $MaxEvenPalindromeLength / $k;\r\n \r\n if ($Length2 < 1)\r\n {\r\n return 1;\r\n }\r\n \r\n if ($Length2 % 2 != 0)\r\n {\r\n foreach ($Letters as $Letter => &$Count)\r\n {\r\n $Count--;\r\n }\r\n \r\n unset ($Count);\r\n }\r\n \r\n return $Length2 + floor (array_sum (array_values ($Letters)) / $k);\r\n}"}, {"source_code": " $Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $EvenLettersTotal++;\r\n $MaxPalindromeLength += $Count;\r\n }\r\n else\r\n {\r\n $OddLettersTotal++;\r\n \r\n if ($Count > $LongestOddLetterCount)\r\n {\r\n $LongestOddLetterCount = $Count;\r\n }\r\n }\r\n }\r\n \r\n if ($EvenLettersTotal == $OddLettersTotal)\r\n {\r\n $MaxPalindromeLength += $OddLettersTotal;\r\n }\r\n else\r\n {\r\n $MaxPalindromeLength += $LongestOddLetterCount;\r\n }\r\n \r\n return (($MaxPalindromeLength - $MaxPalindromeLength % $k) / $k) \r\n ? : 1;\r\n}"}, {"source_code": " $Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $MaxPalindromeLength += $Count;\r\n }\r\n else\r\n {\r\n $OddLettersTotal++;\r\n \r\n if ($Count > $LongestOddLetterCount)\r\n {\r\n $LongestOddLetterCount = $Count;\r\n }\r\n }\r\n }\r\n \r\n if ($n / $k == $OddLettersTotal)\r\n {\r\n $MaxPalindromeLength += $OddLettersTotal;\r\n }\r\n else\r\n {\r\n $MaxPalindromeLength += $LongestOddLetterCount;\r\n }\r\n \r\n return (($MaxPalindromeLength - $MaxPalindromeLength % $k) / $k) \r\n ? : 1;\r\n}"}, {"source_code": " $Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $MaxPalindromeLength += $Count;\r\n }\r\n else\r\n {\r\n if ($Count > $LongestOddLetterCount)\r\n {\r\n $LongestOddLetterCount = $Count;\r\n }\r\n }\r\n }\r\n \r\n $MaxPalindromeLength += $LongestOddLetterCount;\r\n \r\n return ($MaxPalindromeLength - $MaxPalindromeLength % $k) / $k;\r\n}"}, {"source_code": " $Count)\r\n {\r\n if ($Count % 2 == 0)\r\n {\r\n $MaxPalindromeLength += $Count;\r\n }\r\n else\r\n {\r\n if ($Count > $LongestOddLetterCount)\r\n {\r\n $LongestOddLetterCount = $Count;\r\n }\r\n }\r\n }\r\n \r\n $MaxPalindromeLength += $LongestOddLetterCount;\r\n \r\n return ($MaxPalindromeLength - $MaxPalindromeLength % $k) / $k;\r\n}"}], "src_uid": "ca817fe0a97e2d8a6bcfcb00103b6b6d"} {"nl": {"description": "Consider a table of size $$$n \\times m$$$, initially fully white. Rows are numbered $$$1$$$ through $$$n$$$ from top to bottom, columns $$$1$$$ through $$$m$$$ from left to right. Some square inside the table with odd side length was painted black. Find the center of this square.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 115$$$) \u2014 the number of rows and the number of columns in the table. The $$$i$$$-th of the next $$$n$$$ lines contains a string of $$$m$$$ characters $$$s_{i1} s_{i2} \\ldots s_{im}$$$ ($$$s_{ij}$$$ is 'W' for white cells and 'B' for black cells), describing the $$$i$$$-th row of the table.", "output_spec": "Output two integers $$$r$$$ and $$$c$$$ ($$$1 \\le r \\le n$$$, $$$1 \\le c \\le m$$$) separated by a space \u2014 the row and column numbers of the center of the black square.", "sample_inputs": ["5 6\nWWBBBW\nWWBBBW\nWWBBBW\nWWWWWW\nWWWWWW", "3 3\nWWW\nBWW\nWWW"], "sample_outputs": ["2 4", "2 1"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "524273686586cdeb7827ffc1ad59d85a"} {"nl": {"description": "Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets of stickers as she wants, and may specify any string of length n for the sheets, but all the sheets must be identical, so the string is the same for all sheets. Once she attains the sheets of stickers, she will take some of the stickers from the sheets and arrange (in any order) them to form s. Determine the minimum number of sheets she has to buy, and provide a string describing a possible sheet of stickers she should buy.", "input_spec": "The first line contains string s (1\u2009\u2264\u2009|s|\u2009\u2264\u20091000), consisting of lowercase English characters only. The second line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000).", "output_spec": "On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of n lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string s, print instead a single line with the number -1.", "sample_inputs": ["banana\n4", "banana\n3", "banana\n2"], "sample_outputs": ["2\nbaan", "3\nnab", "-1"], "notes": "NoteIn the second example, Piegirl can order 3 sheets of stickers with the characters \"nab\". She can take characters \"nab\" from the first sheet, \"na\" from the second, and \"a\" from the third, and arrange them to from \"banana\"."}, "positive_code": [{"source_code": " 1){\n\t\t$mid = floor(($lo + $hi) / 2);\n\t\t$used = 0;\n\t\tforeach($cnt as $val)\n\t\t\t$used += ceil($val / $mid);\n\t\tif($used <= $n)\n\t\t\t$hi = $mid;\n\t\telse\n\t\t\t$lo = $mid;\n\t}\n\tif($hi == $inf){\n\t\techo -1; exit();\n\t}\n\techo $hi . PHP_EOL;\n\tforeach($cnt as $key => $val)\n\t\tfor($i = 0; $i < ceil($val / $hi); $i++){\n\t\t\techo $key; $n--;\n\t\t}\n\twhile($n--)\n\t\techo 'z';\n?>\n"}], "negative_code": [], "src_uid": "f16f00edbc0c2e984caa04f71ae0324e"} {"nl": {"description": "Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the side equals n squares (n is an odd number) and each unit square contains some small letter of the English alphabet.Valera needs to know if the letters written on the square piece of paper form letter \"X\". Valera's teacher thinks that the letters on the piece of paper form an \"X\", if: on both diagonals of the square paper all letters are the same; all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals. Help Valera, write the program that completes the described task for him.", "input_spec": "The first line contains integer n (3\u2009\u2264\u2009n\u2009<\u2009300; n is odd). Each of the next n lines contains n small English letters \u2014 the description of Valera's paper.", "output_spec": "Print string \"YES\", if the letters on the paper form letter \"X\". Otherwise, print string \"NO\". Print the strings without quotes.", "sample_inputs": ["5\nxooox\noxoxo\nsoxoo\noxoxo\nxooox", "3\nwsw\nsws\nwsw", "3\nxpx\npxp\nxpe"], "sample_outputs": ["NO", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $half) ? ($i - $half - 1) : 0);\n\t$string .= str_repeat(($i == $half) ? $x : $y, 1) . strrev($string);\n\treturn $string;\n}\n$count = trim(fgets(STDIN));\n\n$line = trim(fgets(STDIN));\n$x = $line[0];\n$y = $line[1];\nif ($x === $y) {\n\tdie('NO');\n}\nif ($line !== createLine($x, $y, $count, 0)) {\n\tdie('NO');\n}\nfor ($i = 1, $il = $count; $i < $il; $i++) {\n\t$line = trim(fgets(STDIN));\n\tif ($line !== createLine($x, $y, $count, $i)) {\n\t\tdie('NO');\n\t}\n}\n\ndie('YES');\n"}, {"source_code": "= $pol)\n\t\t\t$num = $n - 1 - $i;\n\t\telse \n\t\t\t$num = $i;\n\t\tif($j == $num && ($str[$j] != $d || $str[$n -1 - $j] != $d) )\n\t\t\t$res = 0;\n\t\tif($j != $num && ($str[$j] != $p || $str[$n -1 - $j] != $p))\n\t\t\t$res = 0;\n\t}\n\t\n}\nif($res)\n\techo \"YES\";\nelse\n\techo \"NO\";\n?>"}], "negative_code": [{"source_code": " 2))\n {\n $b = 1;\n }\n if($e[$x - 1] != $e[$a - $x])\n {\n $c = 1;\n }\n}\nif(($b == 1) || ($c == 1))\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\";\n}\n?>"}, {"source_code": ""}, {"source_code": " $half) ? ($i - $half - 1) : 0);\n\t$string .= str_repeat(($i == $half) ? $x : $y, 1) . strrev($string);\n\treturn $string;\n}\n$count = trim(fgets(STDIN));\n\n$line = trim(fgets(STDIN));\n$x = $line[0];\n$y = $line[1];\nif ($line !== createLine($x, $y, $count, 0)) {\n\tdie('NO');\n}\nfor ($i = 1, $il = $count; $i < $il; $i++) {\n\t$line = trim(fgets(STDIN));\n\tif ($line !== createLine($x, $y, $count, $i)) {\n\t\tdie('NO');\n\t}\n}\n\ndie('YES');\n"}, {"source_code": " 0))\n {\n break;\n }\n elseif($h > 0)\n {\n $h--;\n }\n if(($f[$i] != 1) && ($i <= $b))\n {\n break;\n }\n elseif($i <= $b)\n {\n $i++;\n }\n }\n print $g . \"\\n\";\n }\n}\n?>"}, {"source_code": "= 1){\n echo $k.\"\\n\";\n break;\n } elseif (!in_array($a[1] + $k, $b) && ($a[1] + $k) <= $a[0]){\n echo $k.\"\\n\";\n break;\n } else {\n continue;\n }\n }\n \n}\n"}, {"source_code": "=1;$j--)\n {\n if($map[$j]==0){$l=$j;break;}\n\n }\n if($r>-1 && $l>-1)\n {\n if(($r-$s)<=($s-$l))echo ($r-$s).\"\\n\";\n else echo ($s-$l).\"\\n\";\n }else if($r>-1)\n {\n echo ($r-$s).\"\\n\";\n }else if($l>-1)\n {\n echo ($s-$l).\"\\n\";\n }else\n {\n echo \"0\".\"\\n\";\n }\n}\n\n\n?>"}], "negative_code": [], "src_uid": "faae9c0868b92b2355947c9adcaefb43"} {"nl": {"description": "You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' \u2014 colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained garland is nice.A garland is called nice if any two lamps of the same color have distance divisible by three between them. I.e. if the obtained garland is $$$t$$$, then for each $$$i, j$$$ such that $$$t_i = t_j$$$ should be satisfied $$$|i-j|~ mod~ 3 = 0$$$. The value $$$|x|$$$ means absolute value of $$$x$$$, the operation $$$x~ mod~ y$$$ means remainder of $$$x$$$ when divided by $$$y$$$.For example, the following garlands are nice: \"RGBRGBRG\", \"GB\", \"R\", \"GRBGRBG\", \"BRGBRGB\". The following garlands are not nice: \"RR\", \"RGBG\".Among all ways to recolor the initial garland to make it nice you have to choose one with the minimum number of recolored lamps. If there are multiple optimal solutions, print any of them.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' \u2014 colors of lamps in the garland.", "output_spec": "In the first line of the output print one integer $$$r$$$ \u2014 the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ \u2014 a nice garland obtained from the initial one with minimum number of recolors. If there are multiple optimal solutions, print any of them.", "sample_inputs": ["3\nBRB", "7\nRGBGRBB"], "sample_outputs": ["1\nGRB", "3\nRGBRGBR"], "notes": null}, "positive_code": [{"source_code": " RGB, 1 => RBG, 2 => BRG, 3 => BGR, 4 => GRB, 5 => GBR);\n$d = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);\nfor($x = 0; $x < $a; $x += 3)\n{\n if(($b[$x] == \"R\") && ($b[$x] == TRUE))\n {\n $d[2]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n if(($b[$x + 1] == \"G\") && ($b[$x + 1] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[4]++;\n $d[5]++;\n if(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"B\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[2]++;\n $d[3]++;\n $d[4]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"R\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[3]++;\n $d[5]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n }\n elseif(($b[$x] == \"G\") && ($b[$x] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[3]++;\n if(($b[$x + 1] == \"G\") && ($b[$x + 1] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[4]++;\n $d[5]++;\n if(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"B\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[2]++;\n $d[3]++;\n $d[4]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"R\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[3]++;\n $d[5]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n }\n elseif(($b[$x] == \"B\") && ($b[$x] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[4]++;\n $d[5]++;\n if(($b[$x + 1] == \"G\") && ($b[$x + 1] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[4]++;\n $d[5]++;\n if(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"B\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[2]++;\n $d[3]++;\n $d[4]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n elseif(($b[$x + 1] == \"R\") && ($b[$x + 1] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[3]++;\n $d[5]++;\n if(($b[$x + 2] == \"G\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[3]++;\n $d[4]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"B\") && ($b[$x + 2] == TRUE))\n {\n $d[1]++;\n $d[2]++;\n $d[3]++;\n $d[5]++;\n }\n elseif(($b[$x + 2] == \"R\") && ($b[$x + 2] == TRUE))\n {\n $d[0]++;\n $d[1]++;\n $d[2]++;\n $d[4]++;\n }\n }\n }\n}\n$f = min($d);\nfor($x = 0; $x < 6; $x++)\n{\n if($d[$x] == $f)\n {\n break;\n }\n}\n$i = $c[$x];\n$g = $a % 3;\n$h = floor($a / 3);\n$j = \"\";\nfor($x = 0; $x < $h; $x++)\n{\n $j .= $i;\n}\nif($g == 1)\n{\n $j .= $i[0];\n}\nelseif($g == 2)\n{\n $j .= $i[0];\n $j .= $i[1];\n}\nprint $f . \"\\n\";\nprint $j;\n?>"}, {"source_code": ""}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n$s = $ir->readString();\n\n$a = [\n\t'RGB' => ['R', 'G', 'B', 0],\n\t'GBR' => ['G', 'B', 'R', 0],\n\t'BRG' => ['B', 'R', 'G', 0],\n\t\n\t'RBG' => ['R', 'B', 'G', 0],\n\t'BGR' => ['B', 'G', 'R', 0],\n\t'GRB' => ['G', 'R', 'B', 0],\n];\n\nfor ($i = 0; $i<$n; $i++) {\n\t$j = $i%3;\n\tforeach ($a as &$aa) {\n\t\tif ($aa[$j] != $s[$i]) {\n\t\t\t$aa[3] += 1;\n\t\t}\n\t}\n\tunset($aa);\n}\n\n$min = $a['RGB'][3];\n$seq = 'RGB';\nforeach ($a as $k=>$aa) {\n\tif ($aa[3] < $min) {\n\t\t$min = $aa[3];\n\t\t$seq = $k;\n\t}\n}\n\n$s = str_repeat($seq, intval($n/3)+1);\n$s = substr($s, 0, $n);\necho $min.\"\\n\";\necho $s;\n"}], "negative_code": [{"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n$s = $ir->readString();\n\n$a = [\n\t'RGB' => ['R', 'G', 'B', 0],\n\t'GBR' => ['G', 'B', 'R', 0],\n\t'BRG' => ['B', 'R', 'G', 0],\n\t\n\t'RBG' => ['R', 'B', 'G', 0],\n\t'BGR' => ['B', 'G', 'R', 0],\n\t'GRB' => ['G', 'R', 'B', 0],\n];\n\nfor ($i = 0; $i<$n; $i++) {\n\t$j = $i%3;\n\tforeach ($a as &$aa) {\n\t\tif ($aa[$j] != $s[$i]) {\n\t\t\t$aa[3] += 1;\n\t\t}\n\t}\n}\n\n$min = 1e6;\n$seq = '';\nforeach ($a as $k=>$aa) {\n\tif ($aa[3] < $min) {\n\t\t$min = $aa[3];\n\t\t$seq = $k;\n\t}\n}\n\n$s = str_repeat($seq, intval($n/3)+1);\n$s = substr($s, 0, $n);\necho $min.\"\\n\";\necho $s;\n"}], "src_uid": "e67b79e39511b0107a51edc0179afb82"} {"nl": {"description": "You are given a permutation of n numbers p1,\u2009p2,\u2009...,\u2009pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l\u2009\u2264\u2009r) and reverse the order of the elements pl,\u2009pl\u2009+\u20091,\u2009...,\u2009pr. Your task is to find the expected value of the number of inversions in the resulting permutation.", "input_spec": "The first line of input contains two integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009k\u2009\u2264\u2009109). The next line contains n integers p1,\u2009p2,\u2009...,\u2009pn \u2014 the given permutation. All pi are different and in range from 1 to n. The problem consists of three subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows. In subproblem G1 (3 points), the constraints 1\u2009\u2264\u2009n\u2009\u2264\u20096, 1\u2009\u2264\u2009k\u2009\u2264\u20094 will hold. In subproblem G2 (5 points), the constraints 1\u2009\u2264\u2009n\u2009\u2264\u200930, 1\u2009\u2264\u2009k\u2009\u2264\u2009200 will hold. In subproblem G3 (16 points), the constraints 1\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009k\u2009\u2264\u2009109 will hold. ", "output_spec": "Output the answer with absolute or relative error no more than 1e\u2009-\u20099.", "sample_inputs": ["3 1\n1 2 3", "3 4\n1 3 2"], "sample_outputs": ["0.833333333333333", "1.458333333333334"], "notes": "NoteConsider the first sample test. We will randomly pick an interval of the permutation (1,\u20092,\u20093) (which has no inversions) and reverse the order of its elements. With probability , the interval will consist of a single element and the permutation will not be altered. With probability we will inverse the first two elements' order and obtain the permutation (2,\u20091,\u20093) which has one inversion. With the same probability we might pick the interval consisting of the last two elements which will lead to the permutation (1,\u20093,\u20092) with one inversion. Finally, with probability the randomly picked interval will contain all elements, leading to the permutation (3,\u20092,\u20091) with 3 inversions. Hence, the expected number of inversions is equal to ."}, "positive_code": [{"source_code": "= 2 ? $max1 : 1;\n$max3 = $k >= 3 ? $max1 : 1;\n$max4 = $k >= 4 ? $max1 : 1;\n\n$sum = 0;\n\nfor ($rng1 = 0; $rng1 < $max1; $rng1++) {\n $np1 = substr_replace($p, strrev(substr($p, $ranges[$rng1][0], $ranges[$rng1][1])), $ranges[$rng1][0], $ranges[$rng1][1]);\n for ($rng2 = 0; $rng2 < $max2; $rng2++) {\n $np2 = substr_replace($np1, strrev(substr($np1, $ranges[$rng2][0], $ranges[$rng2][1])), $ranges[$rng2][0], $ranges[$rng2][1]);\n for ($rng3 = 0; $rng3 < $max3; $rng3++) {\n $np3 = substr_replace($np2, strrev(substr($np2, $ranges[$rng3][0], $ranges[$rng3][1])), $ranges[$rng3][0], $ranges[$rng3][1]);\n for ($rng4 = 0; $rng4 < $max4; $rng4++) {\n $np4 = substr_replace($np3, strrev(substr($np3, $ranges[$rng4][0], $ranges[$rng4][1])), $ranges[$rng4][0], $ranges[$rng4][1]);\n for ($i = 0; $i < $n; $i++) {\n for ($j = $i + 1; $j < $n; $j++) {\n if ($np4[$j] < $np4[$i]) {\n $sum++;\n }\n }\n }\n }\n }\n }\n}\n\nprintf(\"%.10f\", $sum / pow($max1, $k));\n"}, {"source_code": "= 2 ? $max1 : 1;\n$max3 = $k >= 3 ? $max1 : 1;\n$max4 = $k >= 4 ? $max1 : 1;\n\n$sum = 0;\n\nfor ($rng1 = 0; $rng1 < $max1; $rng1++) {\n $np1 = $p;\n array_splice($np1, $ranges[$rng1][0], $ranges[$rng1][1], array_reverse(array_slice($np1, $ranges[$rng1][0], $ranges[$rng1][1])));\n for ($rng2 = 0; $rng2 < $max2; $rng2++) {\n $np2 = $np1;\n array_splice($np2, $ranges[$rng2][0], $ranges[$rng2][1], array_reverse(array_slice($np2, $ranges[$rng2][0], $ranges[$rng2][1])));\n for ($rng3 = 0; $rng3 < $max3; $rng3++) {\n $np3 = $np2;\n array_splice($np3, $ranges[$rng3][0], $ranges[$rng3][1], array_reverse(array_slice($np3, $ranges[$rng3][0], $ranges[$rng3][1])));\n for ($rng4 = 0; $rng4 < $max4; $rng4++) {\n $np4 = $np3;\n array_splice($np4, $ranges[$rng4][0], $ranges[$rng4][1], array_reverse(array_slice($np4, $ranges[$rng4][0], $ranges[$rng4][1])));\n for ($i = 0; $i < $n; $i++) {\n for ($j = $i + 1; $j < $n; $j++) {\n if ($np4[$j] < $np4[$i]) {\n $sum++;\n }\n }\n }\n }\n }\n }\n}\n\nprintf(\"%.10f\", $sum / pow($max1, $k));\n"}], "negative_code": [], "src_uid": "0496f5b6c7c159e4448f5b04c45a411b"} {"nl": {"description": "Phoenix has collected $$$n$$$ pieces of gold, and he wants to weigh them together so he can feel rich. The $$$i$$$-th piece of gold has weight $$$w_i$$$. All weights are distinct. He will put his $$$n$$$ pieces of gold on a weight scale, one piece at a time. The scale has an unusual defect: if the total weight on it is exactly $$$x$$$, it will explode. Can he put all $$$n$$$ gold pieces onto the scale in some order, without the scale exploding during the process? If so, help him find some possible order. Formally, rearrange the array $$$w$$$ so that for each $$$i$$$ $$$(1 \\le i \\le n)$$$, $$$\\sum\\limits_{j = 1}^{i}w_j \\ne x$$$.", "input_spec": "The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\le n \\le 100$$$; $$$1 \\le x \\le 10^4$$$)\u00a0\u2014 the number of gold pieces that Phoenix has and the weight to avoid, respectively. The second line of each test case contains $$$n$$$ space-separated integers $$$(1 \\le w_i \\le 100)$$$\u00a0\u2014 the weights of the gold pieces. It is guaranteed that the weights are pairwise distinct.", "output_spec": "For each test case, if Phoenix cannot place all $$$n$$$ pieces without the scale exploding, print NO. Otherwise, print YES followed by the rearranged array $$$w$$$. If there are multiple solutions, print any.", "sample_inputs": ["3\n3 2\n3 2 1\n5 3\n1 2 3 4 8\n1 5\n5"], "sample_outputs": ["YES\n3 2 1\nYES\n8 1 2 3 4\nNO"], "notes": "NoteIn the first test case, Phoenix puts the gold piece with weight $$$3$$$ on the scale first, then the piece with weight $$$2$$$, and finally the piece with weight $$$1$$$. The total weight on the scale is $$$3$$$, then $$$5$$$, then $$$6$$$. The scale does not explode because the total weight on the scale is never $$$2$$$.In the second test case, the total weight on the scale is $$$8$$$, $$$9$$$, $$$11$$$, $$$14$$$, then $$$18$$$. It is never $$$3$$$.In the third test case, Phoenix must put the gold piece with weight $$$5$$$ on the scale, and the scale will always explode."}, "positive_code": [{"source_code": " $x) {\r\n $m = 0;\r\n for ($j = 0; $j < $n; $j++) { $m += $a[$j]; $r[$j] = $m; }\r\n \r\n $c = array_search($x, $r);\r\n if ($c === false) { \r\n $f = 1; \r\n } else {\r\n $d = $n + 1;\r\n while ($d--) {\r\n $m = $a[$n - 1];\r\n unset($a[$n - 1]);\r\n array_unshift($a, $m);\r\n \r\n $r = array();\r\n $m = 0;\r\n \r\n for ($j = 0; $j < $n; $j++) { $m += $a[$j]; $r[$j] = $m; }\r\n \r\n $c = array_search($x, $r);\r\n if ($c === false) { $f = 1; break; }\r\n $g++;\r\n }\r\n }\r\n \r\n if ($f == 1) { \r\n echo 'YES'.PHP_EOL; \r\n for ($j = 0; $j < $n; $j++) { echo $a[$j].' '; }\r\n echo PHP_EOL;\r\n } else { echo 'NO'.PHP_EOL; }\r\n}\r\n \r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": " 0 ? $diff : 0)) / 4 + $counts[2] / 2);\t\n\t\n\treturn $sum;\n}\n\nfunction get_counts($groups){\n\t\n\t$counts = array(0,0,0,0,0);\n\tforeach ($groups as $g) $counts[$g]++;\n\n\treturn $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;\n"}, {"source_code": " 0 ? $counts[1] - $counts[3] : 0)) / 4 + $counts[2] / 2);\n\treturn $sum;\n}\n\nfunction get_counts($groups){\n\t\n\t$counts = array(0,0,0,0,0);\n\tforeach ($groups as $g) $counts[$g]++;\n\n\treturn $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;\n"}, {"source_code": "0,2=>0,3=>0,4=>0);\nforeach ($groups as $key => $value) {\n\t$ready_groups[$value]++;\n}\nif ($ready_groups[2] % 2 == 0) {\n\t$result = $ready_groups[2]/2;\n\t$ready_groups[2]=0;\n} else {\n\t$ready_groups[2] -= 1;\n\t$result = $ready_groups[2]/2;\n\t$ready_groups[2] = 1;\n}\nif ($ready_groups[1] > $ready_groups[3]) {\n\t$result += $ready_groups[3];\n\t$ready_groups[1] -= $ready_groups[3];\n\t$ready_groups[3] = 0;\n} else {\n\t$result += $ready_groups[1];\n\t$ready_groups[3] -= $ready_groups[1];\n\t$ready_groups[1] = 0;\n}\nif ($ready_groups[1] > 0 && $ready_groups[2] > 0) {\n\t$result += 1;\n\t$ready_groups[1] -= 2;\n\t$ready_groups[2] = 0;\n}\nif ($ready_groups[1] > 0) {\n\tif ($ready_groups[1]/4 >= 1) {\n\t\t$result += round($ready_groups[1]/4);\n\t\t$ready_groups[1] -= round($ready_groups[1]/4) * 4;\n\t}\n\tif ($ready_groups[1] > 0) {\n\t\t$ready_groups[1] = 0;\n\t\t$result++;\n\t}\n}\n$result += $ready_groups[4];\n$result += $ready_groups[3];\n$result += $ready_groups[2];\nif ($count > 0) $result++;\nfprintf(STDOUT, $result);"}, {"source_code": "\nfgets(STDIN); $a=explode(' ',trim(fgets(STDIN))); \n$va=array_count_values($a);\n$out=$va[4];\nif($va[2]>=2) {$out+=floor($va[2]/2); $va[2]%=2;}\nif($va[3]>=$va[1]) {$out+=$va[1]; $va[3]-=$va[1]; $va[1]=0;}\nelse {$out+=$va[3]; $va[1]-=$va[3]; $va[3]=0;}\n$out+=$va[3];\nif($va[2] && $va[1]) {$out++; $va[1]-=2; $va[2]=0;}\n$out+=$va[2];\nif($va[1]>0) {$out+=ceil($va[1]/4);}\nprint($out);\n?>\n"}, {"source_code": " 0)\n\t{\n\t\t$freq[$num]--;\n\t\n\t\t$sum = $maxInCar - $num;\n\t\t$ended = true;\t\t\n\t\t\n\t\tforeach($freq as $n => $count)\n\t\t{\n\t\t\tfor($i = 0; $i < $count; $i++)\n\t\t\t{\n\t\t\t\tif($sum >= $n)\n\t\t\t\t{\n\t\t\t\t\t$sum -= $n;\n\t\t\t\t\t$freq[$n]--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t$cars++;\n\t}\n}\n\necho $cars;"}, {"source_code": " 0)\n\t{\n\t\t$freq[$num]--;\n\t\n\t\t$sum = $maxInCar - $num;\n\t\t$ended = true;\t\t\n\t\t\n\t\tforeach($freq as $n => $count)\n\t\t{\n\t\t\tif($sum >= $n)\n\t\t\t{\t\t\t\t\n\t\t\t\tfor($i = 0; $i < $count; $i++)\n\t\t\t\t{\n\t\t\t\t\t$sum -= $n;\n\t\t\t\t\t$freq[$n]--;\n\t\t\t\t\t\t\n\t\t\t\t\tif($sum < $n)\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(!$sum)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t$cars++;\n\t}\n}\n\necho $cars;"}, {"source_code": "$people) {\n $people = $group_array[$i];\n $key = $i;\n if ($people == 4) {\n $cars++;\n //unset($group_array[$key]);\n }\n\n if ($people == 3) {\n\n if ($one>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $one--;\n } else {\n $three++;\n }\n }\n if ($people == 2) {\n if ($two>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $two--;\n //unset()\n } else {\n $two++;\n }\n }\n if ($people== 1) {\n if ($three>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $three--;\n } else {\n $one++;\n }\n }\n }\n\n if ($three>0) {\n $cars += $three;\n }\n\n if ($two>0) {\n if ($one>0) {\n $cars++;\n if ($one>2) {\n $count_one = $one-2;\n $cars += ceil($count_one/4);\n $one = 0;\n } else {\n $one = 0;\n }\n } else {\n $cars += $two;\n }\n }\n\n if ($one > 0) {\n $cars += ceil($one/4);\n }\n\n //echo $cars;\n fputs(STDOUT, $cars);\n ?>"}, {"source_code": "$threeCounter){\n $extra = $oneCounter - $threeCounter ; \n $totalOne = $twoCounter*2 + $extra ;\n $counter = $fourCounter + $threeCounter + ceil($totalOne/4);\n\n}else{\n $counter = $fourCounter + $threeCounter + ceil($twoCounter/2);\n}\n\n\nfwrite(STDOUT, $counter.\"\\n\"); \n"}, {"source_code": " 0){ \n\n $taxi += $x[1] / 4; \n\n}\n\necho ceil($taxi);\n\n?>"}, {"source_code": "0){\n\t\t\t$taxi1--;\n\t\t\t$flag = 1;\t\n\t\t}\n\t\t\n\t}\n\tif($taxi1>0){\n\t\tif($flag==1) $taxi1--;\n\t\t$taxi += floor($taxi1/4) ;\n\t\tif($taxi1%4!=0){\n\t\t\t$taxi++;\n\t\t}\n\t}\n\t\n\tprintf(\"%d\", $taxi);\n?>"}, {"source_code": " 0) {\n\t\twhile (count($list) > 1) {\n if ($list[0] + $list[count($list)-1] <= 4) {\n $list[0] += $list[count($list)-1];\n unset($list[count($list)-1]);\n $list = array_values($list);\n } else {\n break;\n }\n }\n\t\tunset($list[0]);\n $list = array_values($list);\n\t\t$total++;\n\t}\n\techo $total;\n\t*/"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0,2=>0,3=>0,4=>0);\n++$sCounts[(int)strtok($str,\" \\t\\n\")];\nfor($i=1; $i<$n; ++$i) {\n ++$sCounts[(int)strtok(\" \\t\\n\")];\n}\n\n$taxiCount = 0;\n$taxiCount += $sCounts[4] + $sCounts[3] + (int)($sCounts[2]/2);\nif($sCounts[1] > $sCounts[3]) {\n $sCounts[1] -= $sCounts[3];\n} else {\n $sCounts[1] = 0;\n}\n$sCounts[2] %= 2;\nif($sCounts[2] == 1) {\n ++$taxiCount;\n if($sCounts[1] <= 2) {\n $sCounts[1] = 0;\n } else {\n $sCounts[1] -= 2;\n }\n}\n$taxiCount += (int)($sCounts[1]/4);\nif($sCounts[1]%4 != 0) {\n ++$taxiCount;\n}\nfprintf($output,\"%d\",$taxiCount);\n\n?>"}, {"source_code": " 0,\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n );\n foreach($input['counts'] as $count) {\n $c[intval($count)]++;\n }\n // \u0437\u0430\u0431\u0440\u0430\u043b\u0438 \u0432\u0441\u0435 \u0447\u0435\u0442\u0432\u0435\u0440\u043a\u0438\n $i += $c[4];\n\n // \u0437\u0430\u0431\u0440\u0430\u043b\u0438 \u0432\u0441\u0435 \u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043f\u043e\u0434\u0441\u0430\u0434\u0438\u043b\u0438\n $i += $c[3];\n $c[1] = ($c[3] > $c[1]) ? 0 : $c[1] - $c[3];\n\n $i += ceil((($c[2] * 2) + $c[1]) / 4);\n\n\n dataProvider::set($i);\n\n\n class dataProvider\n {\n public static function get()\n {\n $stdin = file_get_contents('php://stdin');\n $lines = explode(\"\\n\", $stdin, 2);\n $lines[1] = explode(' ', $lines[1]);\n return array(\n 'n' => intval($lines[0]),\n 'counts' => $lines[1],\n );\n }\n\n public static function set($data)\n {\n file_put_contents('php://stdout', $data);\n }\n }\n?>"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = (int)(fgets($fp));\n$group = explode(\" \", str_replace( \"\\n\", '', fgets($fp) ) );\n\nsort($group);\n\n$start = 0;\n$end = $count - 1;\n\nwhile( true )\n{\n\tif( $end == $start ){\n\t\tbreak;\n\t}\n\tif( $group[ $end ] + $group[ $start ] > 4 )\n\t{\n\t\t$end --;\n\t} else {\n\t\t$count --;\n\t\t$group[ $end ] += $group[ $start ];\n\t\t$start ++;\n\t}\n}\necho $count;\n\nfclose($fp);\n?>"}, {"source_code": "\", (time() - $t);"}, {"source_code": "=0)\nprint $k[4]+ceil($k[2]/2)+$k[3];\nelse print $k[4]+$k[3]+ ceil(($k[2]-1)/2)+ceil((($k[1]-$k[3])+2*($k[2]%2))/4);\n?>"}, {"source_code": " 0){$line = str_replace($del,'',$line);$dataex[] = $line;$text = explode(\" \",$line);\nforeach($text as $txt){$arr_txt[] = $txt;$this->linex[$id] = $il;$this->liney[$il] = $id;$id++;}}$il++;}$this->arr_line = $dataex;$this->arr_txt = $arr_txt;}\nfunction G(){$ret = $this->arr_txt[$this->ntxt++];$this->nline = $this->linex[$this->ntxt];return $ret;}\nfunction GL(){$this->ntxt = $this->liney[$this->nline]+1;return $this->arr_line[$this->nline++];}} /*init*/ $dxs = new stdIn(false);\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////// DECLARE FUNCTIONS ///////////////////////////////////////\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n$n = $dxs->G();$taxis=0;\nfor($i=0;$i<$n;$i++){\n $grupo[$i]= $dxs->G();\n}\nrsort($grupo);\n\nforeach($grupo as $k => $grup){\n if($grup == 4){\n\t$taxis++;\n }else{\n\t$grupito[$grup]++;\n }\n}\n//echo $taxis;\n//print_r($grupo);print_r($grupito);\n$taxis += $grupito[3];\nif($grupito[3]>=$grupito[1]){\n $grupito[3]=0;$grupito[1]=0;\n}else{\n $grupito[1] -= $grupito[3];\n}\n//print_r($grupito);echo $taxis;\n$ndos = (int)($grupito[2]/2);\n$taxis += $ndos;\n//echo $taxis.\":\".$ndos;\n$grupito[2] -= $ndos*2;\nif($grupito[2]>0){$taxis++;$grupito[2]-=1;$grupito[1]-=2;}\nif($grupito[1]>0){\n $nuno = (int)(ceil($grupito[1]/4));\n $taxis += $nuno;\n //echo \"->\".$uno;\n}\n//print_r($grupito);\n////////////////////////////////// PRINT OUTPUT ////////////////////////////////////////////////\necho $taxis;\n/////////////////////////////////////////////////////////////////////////////////////////////////\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0);\nforeach( array_count_values($groups) as $k => $v) $gv[$k] = $v;\n\n$c = floor($gv[2]/2);\n$gv[2] -= floor($gv[2]/2)*2;\n$c += $gv[4];\n\nfor($i = 0; $i < $gv[3]; $i++)\n{\n $c++;\n if($gv[1] > 0) $gv[1]--;\n}\n\nfor($i = 0; $i < $gv[2]; $i++)\n{\n $c++;\n if($gv[1] >= 2)\n {\n $gv[1] -= 2;\n } elseif($gv[1] >= 1)\n {\n $gv[1] -= 1;\n } \n}\n\nfor($i = 0; $i < $gv[1]; $i++)\n{\n $c++;\n if($gv[1] >= 3)\n {\n $i+=3;\n } elseif($gv[1] === 2)\n {\n $i += 2;\n } elseif($gv[1] === 1) \n {\n $i++;\n } \n}\n\necho $c;"}, {"source_code": "0)\n{\n\t$count[4] = $count[4] - 1;\n\t$taxi = $taxi + 1;\n}\nwhile($count[3]>0)\n{\n\t$count[3] = $count[3] - 1;\n\tif($count[1]>0)\n\t{\n\t\t$count[1] = $count[1] - 1;\n\t}\n\t$taxi = $taxi + 1;\n}\nwhile($count[2]>1)\n{\n\t$count[2] = $count[2] - 2;\n\t$taxi = $taxi + 1;\n}\nwhile($count[1]>0)\n{\n\tif($count[2]>0){\n\t\t$count[2] = $count[2] - 1;\n\t\t$count[1] = $count[1] - 2;\n\t}\n\telse\n\t{\n\t\t$count[1] = $count[1] - 4;\n\t}\n\t$taxi = $taxi + 1;\n}\nif($count[2]>0)\n\t$taxi = $taxi + 1;\necho $taxi;\n?>"}, {"source_code": " $value) {\n\tif ($value==1) {\n\t\t$one+=1;\n\t}elseif ($value==2) {\n\t\t$two+=1;\n\t}elseif ($value==3) {\n\t\t$three+=1;\n\t}elseif ($value==4) {\n\t\t$four+=1;\n\t}\n}\n//====================\nif ($three == 0) {\n\t$sum = ($four*4+$two*2+$one);\n\tif ($sum%4==0 ) {\n\t\t$taxi= $sum/4;\n\t}else{\n\t\t$taxi= intval($sum/4)+1;\n\t}\n\tgoto end;\n}else{\n\tif ($one>=$three) {\n\t\t$rest_one = $one - $three;\n\t\t$taxi+=$three;\n\t}else{\n\t\t$rest_one=0;\n\t\t$taxi+=$three;\n\t}\n\n\tif ($rest_one ==0) {\n\t\tif ($two%2==0) {\n\t\t\t$taxi+=($two*2)/4;\n\t\t}else{\n\t\t\t$taxi+=intval(($two*2)/4)+1;\n\t\t}\n\t}else{\n\t\t$sum_two_and_one= (2*$two)+$rest_one;\n\t\tif ($sum_two_and_one%4==0) {\n\t\t\t$taxi+=$sum_two_and_one/4;\n\t\t\t$rest_one=0;\n\t\t}else{\n\t\t\t$taxi+=intval($sum_two_and_one/4)+1;\n\t\t\t$rest_one=0;\n\t\t}\n\t}\t\n\n\tif ($rest_one%4==0) {\n\t\t$taxi+=$rest_one/4;\n\t}else{\n\t\t$taxi+=intval($rest_one/4)+1;\n\t}\n}\n//=====================\n$taxi+=$four;\nend:\necho $taxi;\n\n?>\n"}, {"source_code": "= $IncompleteTeam['3']){\n $IncompleteTeam['1'] -= $IncompleteTeam['3'];\n $Cars += $IncompleteTeam['3'];\n unset($IncompleteTeam['3']);\n}else{\n $IncompleteTeam['1'] = 0;\n $Cars += $IncompleteTeam['3'];\n unset($IncompleteTeam['3']);\n}\n\nif($IncompleteTeam['2'] % 2 == 0){\n $Cars += $IncompleteTeam['2'] / 2;\n unset($IncompleteTeam['2']);\n}else{\n if($IncompleteTeam['1'] >= 2){\n $IncompleteTeam['1'] -= 2;\n }else{\n $IncompleteTeam['1'] = 0;\n }\n $Cars += ceil($IncompleteTeam['2'] / 2);\n unset($IncompleteTeam['2']);\n}\n\n$Cars += ceil($IncompleteTeam['1'] / 4);\n\necho $Cars . \"\\r\\n\";\n?>"}, {"source_code": "$arr[1]){\n\t$count+=$arr[3]+ceil($arr[2]/2);\n\techo $count;\n\texit;\n}\n\nelse if($arr[3]<$arr[1]){\n\t$count+=$arr[3];\n\t$arr[1]-=$arr[3];\n}\n\nelse{\n\t$count+=$arr[3]+ceil($arr[2]/2);\n\techo $count;\n\texit;\n}\n\n\n$count+=ceil(($arr[2]*2+$arr[1])/4);\necho $count;\n?>"}, {"source_code": "$kol[3]) \n {\n $answer += $kol[3];\n $kol[1] -= $kol[3];\n $kol[3] = 0;\n if ($kol[2]>0)\n {\n $answer++;\n $kol[1]--;\n if($kol[1]>0) $kol[1]--;\n $kol[2]--;\n }\n } else\n {\n $answer += $kol[1];\n $kol[3] -= $kol[1];\n $kol[1] = 0;\n }\n if($kol[1]>0)\n {\n $t = intval($kol[1]/4);\n $answer += $t;\n $kol[1] -= $t*4;\n if ($kol[1]>0) $answer++;\n }\n $answer += $kol[3]+$kol[2];\n echo $answer;\n?>"}, {"source_code": " 1) {\n $c += (int)(($have[2] - 1) / 2);\n $have[2] = 1;\n }\n }\n\n // 1\n if (isset($have[1])) {\n if (isset($have[2])) {\n if ($have[2] > 0 && $have[1] > 1) {\n $min_2_1 = min($have[2], (int)($have[1] / 2));\n\n if ($min_2_1 > 0) {\n $have[2] -= $min_2_1;\n $have[1] -= $min_2_1 * 2;\n $c += $min_2_1;\n }\n } elseif ($have[2] > 0 && $have[1] > 0) {\n $min_2_1 = min($have[2], $have[1]);\n\n if ($min_2_1 > 0) {\n $have[2] -= $min_2_1;\n $have[1] -= $min_2_1 * 2;\n $c += $min_2_1;\n }\n }\n }\n\n $ones = (int)($have[1] / 4);\n $c += $ones;\n $have[1] -= $ones * 4;\n\n if ($have[1] > 0) {\n $c++;\n }\n }\n\n if (isset($have[2])) {\n $c += $have[2];\n }\n\n if (isset($have[3])) {\n $c += $have[3];\n }\n\n return $c;\n}\n\n$r = 0;\n\nlist($n) = fscanf($input, \"%d\\n\");\n\n$s = fscanf($input, trim(str_repeat(\"%d \", $n)));\n\n$r = foo($s);\n\nfwrite($output, $r);\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0);\nforeach ($groupsSizes as $size) {\n $groups[(int)$size]++;\n}\n\n$result = $groups[4] + $groups[3] + (int)($groups[2] / 2);\n$groups[1] -= $groups[3];\nif ($groups[2] % 2) {\n $result++;\n $groups[1] -= 2;\n}\nif ($groups[1] > 0) {\n $result += ceil($groups[1] / 4);\n}\n\necho $result;"}, {"source_code": " 0 ? 1 : 0;\nprintf(\"%d\", $n);"}, {"source_code": "0) \n $mas[4]++;\necho $mas[4];\n\n\necho $r; "}, {"source_code": " 0 ? $counts[1] - $counts[3] : 0)) / 4 + $counts[2] / 2);\n return $sum;\n}\n\nfunction get_counts($groups){\n\n $counts = array(0,0,0,0,0);\n foreach ($groups as $g) $counts[$g]++;\n\n return $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;"}, {"source_code": "\n"}, {"source_code": "4)\n {\n $end--;\n }\n else\n {\n $group[$end]+=$group[$start];\n $start++;\n $n--;\n $summary++;\n }\n}\n echo $n;\n\n?>"}, {"source_code": " 0 && $k[0] > 0)\n\t{\n\t\t$ans++;\n\t\t$k[1] = 0;\n\t\t($k[0] > 1 ? $k[0] -= 2: $k[0] = 0);\n\t}\n\n\t$ans += $k[2];\n\t$ans += intdiv($k[1], 2) + ($k[1] % 2 ? 1 : 0);\n\t$ans += intdiv($k[0], 4) + ($k[0] % 4 ? 1 : 0);\n\n\tfwrite(STDOUT, $ans.\"\\n\");\n?>\n"}, {"source_code": "0){\n $count[3]--;\n if($count[1]>0) $count[1]--;\n $res++;\n}\nwhile($count[2]>1){\n $count[2]-=2;\n $res++;\n}\nwhile($count[1]>0){\n if($count[2]>0){\n $count[2]--;\n $count[1]-=2;\n }\n else \n $count[1]-=4;\n $res++;\n}\nif ($count[2]>0) $res++;\n\nprint($res+$count[4]);"}, {"source_code": "0) {$c=$c+floor($m[1]/4);$m[1]=$m[1]%4;}\nif ($m[1]>0) {$c++;}\n\n\n//echo $m[1].' '.$m[2].' '.$m[3].' '.$m[4];\necho $c;\n?>"}, {"source_code": "\nerror_reporting(0);\n\n$fp = fopen(\"php://stdin\",'r');\n$count = (int)(fgets($fp));\n$group = explode(\" \", str_replace( \"\\n\", '', fgets($fp) ) );\n\nsort($group);\n\n$start = 0;\n$end = $count - 1;\n\nwhile( true )\n{\n\tif( $end == $start ){\n\t\tbreak;\n\t}\n\tif( $group[ $end ] + $group[ $start ] > 4 )\n\t{\n\t\t$end --;\n\t} else {\n\t\t$count --;\n\t\t$group[ $end ] += $group[ $start ];\n\t\t$start ++;\n\t}\n}\necho $count;\n\nfclose($fp);\n?>"}, {"source_code": " $m [ 3 ] ) \n $m [ 1 ] -= $m [ 3 ];\n else \n $m [ 1 ] = 0;\n \n $total += floor ( $m [ 2 ] / 2 );\n \n $m [ 2 ] %= 2;\n \n $total += floor ( ( $m [ 2 ] * 2 + $m [ 1 ] + 3 ) / 4 );\n \n echo $total;\n?>"}, {"source_code": " 0){$line = str_replace($del,'',$line);$dataex[] = $line;$text = explode(\" \",$line);\nforeach($text as $txt){$arr_txt[] = $txt;$this->linex[$id] = $il;$this->liney[$il] = $id;$id++;}}$il++;}$this->arr_line = $dataex;$this->arr_txt = $arr_txt;}\nfunction G(){$ret = $this->arr_txt[$this->ntxt++];$this->nline = $this->linex[$this->ntxt];return $ret;}\nfunction GL(){$this->ntxt = $this->liney[$this->nline]+1;return $this->arr_line[$this->nline++];}} /*init*/ $dxs = new stdIn(false);\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////// DECLARE FUNCTIONS ///////////////////////////////////////\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n$n = $dxs->G();$taxis=0;\nfor($i=0;$i<$n;$i++){\n $grupo[$i]= $dxs->G();\n}\nrsort($grupo);\n\nforeach($grupo as $k => $grup){\n if($grup == 4){\n\t$taxis++;\n }else{\n\t$grupito[$grup]++;\n }\n}\n//echo $taxis;\n//print_r($grupo);print_r($grupito);\n$taxis += $grupito[3];\nif($grupito[3]>=$grupito[1]){\n $grupito[3]=0;$grupito[1]=0;\n}else{\n $grupito[1] -= $grupito[3];\n}\n//print_r($grupito);echo $taxis;\n$ndos = (int)($grupito[2]/2);\n$taxis += $ndos;\n//echo $taxis.\":\".$ndos;\n$grupito[2] -= $ndos*2;\nif($grupito[2]>0){$taxis++;$grupito[2]-=1;$grupito[1]-=2;}\nif($grupito[1]>0){\n $nuno = (int)(ceil($grupito[1]/4));\n $taxis += $nuno;\n //echo \"->\".$uno;\n}\n//print_r($grupito);\n////////////////////////////////// PRINT OUTPUT ////////////////////////////////////////////////\necho $taxis;\n/////////////////////////////////////////////////////////////////////////////////////////////////\n?>"}, {"source_code": " 0, 0, 0, 0);\n\n$groups = explode(' ', getLine());\nforeach ($groups as $c) {\n $ccnt[$c]++;\n}\n\n$ccnt[1] -= $ccnt[3];\nif ($ccnt[1]<0) $ccnt[1] = 0;\n\n$tcnt = $ccnt[4] + $ccnt[3] + floor($ccnt[2]/2);\n\n$ccnt[2] %= 2;\n$ccnt[1] = $ccnt[1]-2*$ccnt[2];\nif ($ccnt[1]<0) $ccnt[1] = 0;\n\n$tcnt += $ccnt[2] + ceil($ccnt[1]/4);\n\necho $tcnt . PHP_EOL;\n\nfunction getLine()\n{\n return str_replace(array(\"\\n\", \"\\r\"), array(\"\", \"\"), fgets(STDIN));\n}"}, {"source_code": "0 && $_1>0){\n $min=$_3>$_1?$_1:$_3;\n $_3-=$min;\n $_1-=$min;\n $out+=$min;\n }\n if($_2>1){\n $out+=floor($_2/2);\n $_2=$_2%2;\n }\n if($_2==1 && $_1>=2){\n $_1-=2;\n $_2=0;\n $out++;\n }\n if($_1>=4){\n $out+=floor($_1/4);\n $_1=$_1%4;\n }\n if($_3>0){\n $out+=$_3;\n $_3=0;\n }\n if($_2==1 && $_1==1){\n $out+=1;\n $_2=0;\n $_1=0;\n }\n if($_2>0){\n $out++;\n $_2=0;\n }\n if($_1>0){\n $out+=1;\n $_1=0;\n }\n\n\necho $out;\n\n?>"}, {"source_code": " 0 ? $holder[1] - $holder[3] : 0)) / 4 + $holder[2] / 2 );\n\necho $races;"}, {"source_code": " 0){\n\t$need_2 = 1;\n}else{\n\t$need_2 = 0;\n}\n\nif($n1 > $n3){\n\t$allow_1 = $n1-$n3;\n}else{\n\t$allow_1 = 0;\n}\nif($allow_1 % 4 > 2 && $need_2 > 0){\n\t$ajuste = 1;\n}else{\n\t$ajuste = 0;\n}\n\n$res = $n4 + $n3 + intval($n2/2) + $need_2 + intval($allow_1/4) + ($allow_1 % 4 > 0? 1 - $need_2 : 0) + $ajuste;\necho $res;\n?>\n"}, {"source_code": ""}, {"source_code": " $ordered[1]) { \n # all 1s go with a 3, the rest of the 3s are on their own\n $numCars += $ordered[3]; \n $ordered[1] = 0;\n $ordered[3] = 0;\n $numCars += ceil($ordered[2] / 2);\n $ordered[2] = 0;\n}\nelse if ($ordered[1] > $ordered[3]){ \n # getting rid of all 3s\n $numCars += $ordered[3];\n $ordered[1] -= $ordered[3];\n $numCars += floor($ordered[2] / 2);\n \n if ($ordered[2] % 2) { \n # there is 1 group that can't be paired\n if ($ordered[1] <= 2){\n $ordered[1] = 0;\n }\n else {\n $ordered[1] -= 2;\n }\n $ordered[2] = 0;\n $numCars++;\n }\n \n $numCars += ceil($ordered[1] / 4);\n}\nelse { \n # 3s and 1s cancel each other out\n $numCars += $ordered[3];\n $ordered[1] = 0;\n $ordered[3] = 0;\n $numCars += ceil($ordered[2] / 2);\n $ordered[2] = 0;\n}\n\necho $numCars;\n\n?>"}, {"source_code": "0) $count++;\n\n echo $count;\n?>"}, {"source_code": " intval($lines[0]),\n 'counts' => $lines[1],\n );\n\n $i = 0;\n $c = array(\n 0 => 0,\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n );\n foreach($input['counts'] as $count) {\n $c[intval($count)]++;\n }\n $i += $c[4];\n\n $i += $c[3];\n $c[1] = ($c[3] > $c[1]) ? 0 : $c[1] - $c[3];\n\n $i += ceil((($c[2] * 2) + $c[1]) / 4);\n\n\n file_put_contents('php://stdout', $i);\n\n\n\n?>"}, {"source_code": "0) $res+=1;\necho $res;\n?>"}, {"source_code": " 0){ \n $taxi += $group[1] / 4; \n}\n\necho ceil($taxi);\n\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\t\tif ($one_first == 0 && $three_first == 0) $one_and_three = 0;\n\t\t$answer = $four + $two + $one_and_three;\n\t\techo $answer;\n\t} else {\n\t\t$two = floor($two_first / 2);\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (($one_first % 2) != 0) $two = 0;\n\t\t\tif ($one_first == 1) $two = 1;\n\t\t\tif ($one_first <= 2 && $three_first < 1) {\n\t\t\t\t$answer = $four + $two;\n\t\t\t} else {\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t}\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\t\tif ($one_first == 0 && $three_first == 0) $one_and_three = 0;\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (($one_first % 2) != 0) $two = 0;\n\t\t\tif ($one_first == 1) $two = 1;\n\t\t\tif ($one_first <= 2 && $three_first < 1) {\n\t\t\t\t$answer = $four + $two;\n\t\t\t} else {\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t}\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": "= $a[1]){\n $a[1] = 0;\n}\nelse if ($a[3] < $a[1]){\n $a[1] -= $a[3];\n}\n\n$sisa = floor($a[2]/2);\n$a[2] %= 2;\nif ($a[2] > 0){\n $sisa += 1;\n if ($a[1] > 1)\n $a[1] -= 2;\n else if ($a[1] == 1)\n $a[1] -= 1;\n}\n\nif ($a[1] > 0){\n $a[1] = ceil($a[1] / 4);\n}\n\n$taxi = $a[1] + $a[3] + $a[4] + $sisa;\necho $taxi;\n?>"}, {"source_code": " $arr[1]) $arr[1] = 0;\n else if ($arr[3] < $arr[1]) $arr[1] = $arr[1] - $arr[3];\n else $arr[1] = 0;\n }\n $car+= $arr[3];\n }\n \n if (isset($arr[2])) {\n $car+= floor($arr[2] / 2);\n $arr[2] = $arr[2] % 2;\n \n if ($arr[2]) {\n $car+= 1;\n if (isset($arr[2])) $arr[1]-= 2;\n }\n }\n \n if (isset($arr[1]) && $arr[1] > 0) {\n $car+= ceil($arr[1] / 4);\n }\n \n echo $car;\n?>"}, {"source_code": " 0 ? 1 : 0;\n\nprintf(\"%d\", $n);\n?>"}, {"source_code": "$r) if ($r==='') unset($rating[$key]);\n$n = isset($fl[0]) ? $fl[0] : 0;\n\n$c1 = $c2 = $c3 = $c4 = 0;\nfor ($i = 0,$cnt = count($groups); $i < $cnt; $i++){\n switch ($groups[$i]){\n case 1: $c1++; break;\n case 2: $c2++; break;\n case 3: $c3++; break;\n case 4: $c4++; break;\n }\n}\n$count += $c4;\nif ($c3 >= $c1){\n $count += $c3;\n $c1 = 0;\n}else{\n $count += $c1 - ($c1 - $c3);\n $c1 = $c1-$c3;\n}\n\nif ($c2 % 2 == 1 && $c1 >= 2){\n $c1 -= 2;\n $c2 += 1;\n}\n\n$count += ($c2>>1);\n\nif ($c2 % 2 > 0){\n $count++;\n if ($c1 == 1) $c1 = 0;\n}\nif ($c1 % 4 == 0){\n $count += $c1/4;\n}else{\n $count += 1 + (int)($c1/4);\n}\n\necho $count;"}, {"source_code": ""}, {"source_code": "=$ret[0]){\n $ans+=$ret[2];\n $ret[0]=0;\n }\n else{\n $ans+=$ret[2];\n $ret[0]-=$ret[2];\n }\n// fprintf(STDOUT,\"%d\\n\",$ans);\n $ans+=floor($ret[1]/2);//\u4e24\u4eba\u7ec4\n $ret[1]%=2;\n// fprintf(STDOUT,\"%d\\n\",$ans);\n //\u5269\u4f59\u4e24\u4eba\u7ec4\u548c\u5269\u4f59\u4e00\u4eba\u7ec4\n if($ret[1]>0){\n $ans++;\n if($ret[0]>0){\n $ret[0]-=2;\n }\n }\n// fprintf(STDOUT,\"%d\\n\",$ans);\n //\u5269\u4f59\u4e00\u4eba\u7ec4\n if($ret[0]>0){\n $ans+=floor(($ret[0]-1)/4);\n $ans++;\n }\n\n fprintf(STDOUT,\"%d\\n\",$ans);\n}"}, {"source_code": "= 0) {\n\t\t\t$t1 += (2 * $t2);\n\t\t\tif ($t1 % 4 == 0) {\n\t\t\t\t$ta += ($t1 /= 4);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$t1 /= 4; \n\t\t\t\t$t1++;\n\t\t\t\t$ta += $t1;\n\t\t\t}\n\t\t}\n\t\techo floor($ta);\n?>"}, {"source_code": "0)\n{\n\t$count[4] = $count[4] - 1;\n\t$taxi = $taxi + 1;\n}\nwhile($count[3]>0)\n{\n\t$count[3] = $count[3] - 1;\n\tif($count[1]>0)\n\t{\n\t\t$count[1] = $count[1] - 1;\n\t}\n\t$taxi = $taxi + 1;\n}\nwhile($count[2]>1)\n{\n\t$count[2] = $count[2] - 2;\n\t$taxi = $taxi + 1;\n}\nwhile($count[1]>0)\n{\n\tif($count[2]>0){\n\t\t$count[2] = $count[2] - 1;\n\t\t$count[1] = $count[1] - 2;\n\t}\n\telse\n\t{\n\t\t$count[1] = $count[1] - 4;\n\t}\n\t$taxi = $taxi + 1;\n}\nif($count[2]>0)\n\t$taxi = $taxi + 1;\necho $taxi;\n?>"}, {"source_code": "= $c3) {\n $c1 -= $c3;\n} else {\n $c1 = 0;\n}\n\nif (($c2 % 2) == 0) {\n $out += $c2/2;\n} else {\n $out += intval($c2/2);\n $c1 += 2;\n}\n\n$out += ceil($c1/4);\n\necho $out;\n\n?>"}, {"source_code": "calc($one, $two, $three, 0) + $four;\n }\n\n if ($one && $three) {\n $min = min($one, $three);\n return $this->calc($one - $min, $two, $three - $min, 0) + $min;\n }\n\n if ($three) {\n return $this->calc(0, $two, 0, 0) + $three;\n }\n\n if ($two) {\n return $this->calc($one + 2 * ($two % 2), 0, 0, 0) + intval($two / 2);\n }\n\n return intval($one / 4) + ($one % 4 != 0);\n }\n\n public function solve()\n {\n fscanf(STDIN, '%d', $n);\n $count = array_count_values(explode(' ', trim(fgets(STDIN)))) + ['1' => 0, '2' => 0, '3' => 0, '4' => 0];\n echo $this->calc($count['1'], $count['2'], $count['3'], $count['4']) . PHP_EOL;\n }\n}\n\n$sol = new Solution();\n$sol->solve();\n\n"}, {"source_code": "$gr[1]) {\n$gr[1]=0;\n} else {\n$gr[1]-=$gr[3];\n}\n$taxis+=floor($gr[2]/2);\n$gr[2]=$gr[2]%2;\nif ($gr[2]==1 && $gr[1]>0) {\n$taxis+=$gr[2];\n$gr[1]-=2;\n} else if ($gr[2]==1) $taxis+=1;\nif ($gr[1]>0) {\n$taxis+=floor($gr[1]/4);\nif($gr[1]%4>0) $taxis+=1;\n}\necho $taxis;\n?>"}, {"source_code": "=$tmp[0]){\n $count=$count+$tmp[2];\n $tmp[0]=0;\n } else {\n $count=$count+$tmp[2];\n $tmp[0]=$tmp[0]- $tmp[2];\n } \n \n\n $count=$count+(int)($tmp[1]/2);\n\n $tmp[1]=$tmp[1]-2*(int)($tmp[1]/2);\n \n if ($tmp[1]==1 and $tmp[0]<=2){\n $count=$count+1; $tmp[0]=0;\n } else if ($tmp[1]==1 and $tmp[0]>2){ \n $count=$count+1; $tmp[0]=$tmp[0]-2;\n } \n \n $count=$count+ceil($tmp[0]/4); \n print($count);\n \n?>"}, {"source_code": ""}, {"source_code": " 0 ? ($res[1] - $res[3]) : 0;\nif (($res[2] % 2) == 1) {\n $e1_rem = (($e1_rem - 2) > 0) ? ($e1_rem - 2) : 0;\n $totalcount += 1;\n}\n\nif ($e1_rem > 0)\n $totalcount += floor($e1_rem / 4);\n\nif (($e1_rem % 4) > 0)\n $totalcount += 1;\n\necho $totalcount;\n\n?>"}, {"source_code": " 0, \"two\" => 0, \"three\" => 0, \"four\" => 0);\n\nfor($i = 0; $i < $n; $i++) {\n if($s[$i] == 1)$digits[\"one\"]++;\n if($s[$i] == 2)$digits[\"two\"]++;\n if($s[$i] == 3)$digits[\"three\"]++;\n if($s[$i] == 4)$digits[\"four\"]++;\n}\n\n\n$ones = $digits[\"one\"];\n$twos = $digits[\"two\"];\n$threes = $digits[\"three\"];\n$fours = $digits[\"four\"];\n\n\n\n$taxis = 0;\n\n\nfor($i = 0; $i < $fours; $i++) {\n $digits[\"four\"]--;\n $taxis++;\n}\n\nfor($i = 0; $i < $threes; $i++) {\n if($digits[\"three\"] >= 1) {\n if($digits[\"one\"] >= 1) {\n $digits[\"three\"]--;\n $digits[\"one\"]--;\n $taxis++;\n }\n else {\n $digits[\"three\"]--;\n $taxis++;\n }\n }\n else{break;}\n}\n\n\n\n\n\n$ones = $digits[\"one\"];\n$twos = $digits[\"two\"];\n$threes = $digits[\"three\"];\n$fours = $digits[\"four\"];\n\n\nfor($i = 0; $i < $twos; $i++) {\n if($digits[\"two\"] >= 1) {\n if($digits[\"two\"] >= 2) {\n $digits[\"two\"]--;\n $digits[\"two\"]--;\n $taxis++;\n }\n elseif($digits[\"one\"] >= 1) {\n if($digits[\"one\"] >= 2) {\n $digits[\"one\"]--;\n $digits[\"one\"]--;\n }\n elseif($digits[\"one\"] >= 1) {\n $digits[\"one\"]--;\n }\n $digits[\"two\"]--;\n $taxis++;\n }\n elseif($digits[\"two\"] == 1) {\n $digits[\"two\"]--;\n $taxis++;\n }\n else {}\n }\n else {break;}\n}\n\n\n$ones = $digits[\"one\"];\n$twos = $digits[\"two\"];\n$threes = $digits[\"three\"];\n$fours = $digits[\"four\"];\n\n\n\nfor($i = 0; $i < $ones; $i++) {\n if($digits[\"one\"] >= 4) {\n $digits[\"one\"] -= 4;\n $taxis++;\n }\n elseif($digits[\"one\"] == 3) {\n $digits[\"one\"] -= 3;\n $taxis++;\n }\n elseif($digits[\"one\"] == 2) {\n $digits[\"one\"] -= 2;\n $taxis++;\n }\n elseif($digits[\"one\"] == 1) {\n $digits[\"one\"] -= 1;\n $taxis++;\n }\n else {break;}\n}\n\n\n\n\n\necho $taxis;\n\n\n\n\n\n?>"}, {"source_code": " 0) {\n $answer += ceil($groups[1] / 4);\n}\n\necho $answer . PHP_EOL;\n\n"}, {"source_code": " 0 && $fancyCar < 4) {\n\t$fancyCar += 1;\n\t$groupOfOne -= 1;\n}\n\nif($fancyCar > 0) {\n\t$taxi += 1;\n}\n\n// all 1\n$taxi += ceil($groupOfOne / 4);\n\nprintf($taxi);"}, {"source_code": " 0 && $fancyCar < 4) {\n\t\t$fancyCar += 1;\n\t\t$groupCount[1] -= 1;\n\t}\n}\n\nif($fancyCar > 0) {\n\t$taxi += 1;\n}\n\n// all 1\nif (isset($groupCount[1])) {\n\t$taxi += ceil($groupCount[1] / 4);\n}\n\nprintf($taxi);"}, {"source_code": "= $poz; --$i) {\n $sum = $groups[$i];\n while( $poz < $i ) {\n if ( $sum + $groups[$poz] <= 4 ) {\n $sum += $groups[$poz++]; \n }\n else break;\n }\n $taxiCount++; \n}\n\necho $taxiCount;\n"}, {"source_code": "= $count1) {\n $count1 = 0;\n } else {\n $count1 = $count1 - $count3;\n }\n\n $temp = $left + $count1;\n\n while($temp > 0) {\n $total++;\n $temp = $temp - 4;\n }\necho (int) $total.\"\\n\";"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$g=explode(\" \",trim(fgets(STDIN)));\nforeach($g as $v)$m[$v]++;\nif($m[1]<$m[3])$x=$m[4]+ceil($m[2]/2)+($m[3]-$m[1])+$m[1];\nelse $x=$m[4]+$m[3]+ceil((($m[2]*2)+($m[1]-$m[3]))/4);\necho $x;\n?>"}, {"source_code": " 0) {\n $answer += ceil($groups[1] / 4);\n}\n\necho $answer . PHP_EOL;"}, {"source_code": " 0){\n\t$taxi += $group[1] / 4;\n}\n\necho ceil($taxi);\n"}, {"source_code": " 100000 || $iGroupsCount < 1) {\n\tdie;\n}\n\n$sGroups = fgets(STDIN);\n$aGroups = explode(' ', $sGroups);\n\nforeach ($aGroups as & $iGroup) {\n\t$iGroup = (int) $iGroup;\n}\n\nunset($iGroup);\n\nif (count($aGroups) != $iGroupsCount) {\n\tdie;\n}\n\n$aGrouped = array_count_values($aGroups);\n\nif (key_exists(0, $aGrouped)) {\n\tdie;\n}\n\nfor ($i = 1; $i <= 4; $i ++) {\n\tif (!key_exists($i, $aGrouped)) {\n\t\t$aGrouped[$i] = 0;\n\t}\n}\n\n$iTaxies = $aGrouped[4] + $aGrouped[3] + ceil($aGrouped[2] / 2);\n\n$iSlots = $aGrouped[1] - $aGrouped[3] - ($aGrouped[2] % 2 == 0 ? 0 : 2);\n\nif ($iSlots > 0) {\n\t$iTaxies += ceil($iSlots / 4);\n}\n\necho $iTaxies;"}, {"source_code": " 0 ? 1 : 0;\n echo $n;"}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n\n$cars=0;\n$people_in_groups=array(1=>0,2=>0,3=>0,4=>0);\n\n$n=trim($lines[0]);\n$groups=explode(\" \", trim($lines[1]));\nforeach ($groups as $count)\n $people_in_groups[$count]++;\n//print_r($people_in_groups);\n\n//\u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b, \u0433\u0434\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 - \u0438 \u043a\u0430\u0436\u0434\u0443\u044e \u0432 \u043c\u0430\u0448\u0438\u043d\u0443;\n$tmp=$people_in_groups[4];\n$cars+=$tmp;\nunset($people_in_groups[4]);\n\n\n//\u0417\u0430\u043f\u0438\u0445\u0438\u0432\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e 3 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u043f\u043e 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 - \u0432 1 \u043c\u0430\u0448\u0438\u043d\u0443\n$tmp=min($people_in_groups[3], $people_in_groups[1]);\n$people_in_groups[3]=$people_in_groups[3]-$tmp;\n$people_in_groups[1]=$people_in_groups[1]-$tmp;\n$cars+=$tmp;\n$cars+=$people_in_groups[3];\nunset($people_in_groups[3]);\n\n\n//\u0417\u0430\u043f\u0438\u0445\u0438\u0432\u0430\u0435\u043c \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0430\u0447\u043a\u0443 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e 2 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u0415\u0441\u043b\u0438 \u0438\u0445 \u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e - \u0432\u043b\u0435\u0437\u0443\u0442 \u0440\u043e\u0432\u043d\u043e \u0432 \u0442\u0430\u0447\u043a\u0438. \u041d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 - \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c\n\n//\u0413\u0440\u0443\u043f\u043f \u043f\u043e 2 \u0431\u044b\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u0418\u0445 \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0432 \u0442\u0430\u0447\u043a\u0438, \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442\nif ($people_in_groups[2]%2==0)\n{\n $tmp=$people_in_groups[2]/2;\n $cars+=$tmp;\n unset($people_in_groups[2]);\n}\nif ($people_in_groups[2]%2==1)\n{\n $tmp=ceil($people_in_groups[2]/2); //\u0412 \u0442\u0430\u0447\u043a\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c 2 \u043c\u0435\u0441\u0442\u0430 \u043f\u043e\u0434 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443\n unset($people_in_groups[2]);\n $cars+=$tmp;\n\n $tmp=min(2, $people_in_groups[1]);\n $people_in_groups[1]=$people_in_groups[1]-$tmp;\n}\n\n$tmp=ceil($people_in_groups[1]/4);\n$cars+=$tmp;\necho $cars;\n?>"}, {"source_code": ""}, {"source_code": " $c3)\n {\n print $c4 + $c3 + ceil(($c1 - $c3 + 2) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + 1 + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + 1;\n }\n}\nelseif($c2 % 2 == 0)\n{\n if($c1 > $c3)\n {\n print $c4 + $c3 + ($c2 / 2) + ceil(($c1 - $c3) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + ($c2 / 2) + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + ($c2 / 2);\n }\n}\nelseif($c2 % 2 != 0)\n{\n if($c1 > $c3)\n {\n print $c4 + $c3 + floor($c2 / 2) + 1 + ceil(($c1 - $c3 - 2) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + floor($c2 / 2) + 1 + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + floor($c2 / 2) + 1;\n }\n}\n?>"}, {"source_code": "= $c[3])\n{\n $d = min($c[1], $c[3]);\n $e = $c[1] - $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nelseif($c[1] < $c[3])\n{\n $d = $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $h = ceil($g / 4);\n}\nprint $c[4] + $d + $f + $h;\n?>"}, {"source_code": "= $c[3])\n{\n $d = min($c[1], $c[3]);\n $e = $c[1] - $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nelseif($c[1] < $c[3])\n{\n $d = $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nprint $c[4] + $d + $f + $h;\n?>"}, {"source_code": "= $c[3])\n{\n $d = min($c[1], $c[3]);\n $e = $c[1] - $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nelse\n{\n $d = $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $h = ceil($g / 4);\n}\nprint $c[4] + $d + $f + $h;\n?>"}], "negative_code": [{"source_code": "=0 ; $i--) { \n\t\t\tif ($a!=$i) {\n\t\t\t\t$maxval=$num_people_in_group[$i];\n\t\t\t\tif ($maxval==4) {\n\t\t\t\t\t$num_people_in_group[$i]=0;\n\t\t\t\t\t$taxi+=1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}elseif ($maxval==0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}elseif (($value+$maxval)==4 ) {\n\t\t\t\t\t$num_people_in_group[$i]=0;\n\t\t\t\t\t$num_people_in_group[$a]=0;\n\t\t\t\t\t$taxi+=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}elseif (($value+$maxval)<4 and $i!=$a) {\n\t\t\t\t\t$num_people_in_group[$i]+=$value;\n\t\t\t\t\t$num_people_in_group[$a]=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}/*elseif (($value+$maxval)>4 and $i!=$a) {\n\t\t\t\t\t//$taxi+=2;\n\t\t\t\t\tbreak;\n\t\t\t\t}*/\n\t\t\t}else{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\tif ($a == $i) {\n\tbreak;\n\t}\n}\n\t\nforeach ($num_people_in_group as $value) {\n\tif ($value>0) {\n\t\t$taxi+=1;\n\t}\n}\n}\necho $taxi;\n\n?>"}, {"source_code": " $group_num) {\n\tif ($group_num==0 or $group_num==4) {\n\t\tbreak;\n\t}elseif ($group_num<4 ) {\n\t\t$current_group_num = $group_num;\n\t\t$current_key = $key;\n\t\tforeach ($num_people_in_group as $key => $group_num) {\n\t\t\tif ($current_group_num+$group_num<=4 and $current_key != $key) {\n\t\t\t\t$num_people_in_group[$key]= 0;\n\t\t\t\t$num_people_in_group[$current_key]= $current_group_num+$group_num;\n\t\t\t\t$num_groups-=1;\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n}\n\n}\n\nforeach ($num_people_in_group as $key => $value) {\n\tif ($value!=0) {\n\t\t$x+=1;\n\t}\n}\necho $x;\n//echo \"====================\";\n//print_r($num_people_in_group);\n?>"}, {"source_code": "= 0) {\n\t\t\t$t1 += (2 * $t2);\n\t\t\tif ($t1 % 4 == 0) {\n\t\t\t\t$ta += ($t1 /= 4);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$t1 /= 4; \n\t\t\t\t$t1++;\n\t\t\t\t$ta += $t1;\n\t\t\t}\n\t\t}\n\t\techo $ta;\n?>"}, {"source_code": " 0){\n\t$taxi += ceil($groups[1] / 4);\n}\necho ceil($taxi);\n?>"}, {"source_code": "\n"}, {"source_code": "= 0) {\n\t\t$sum += $counts[3] + ceil($counts[2] / 2);\n\t} else {\n\t\t$rest_ones = $count[1] - $count[3];\n\t\t$sum += $counts[3] + floor($count[2] / 2);\n\t\t\n\t\tif ($count[2] % 2 - $rest_ones >= 0) {\n\t\t\t$sum += ($counts[2] % 2 == 0) ? 0 : 1;\n\t\t} else {\n\t\t\t$rest_ones = $rest_ones - $counts[2] % 2;\n\t\t\t$sum += floor($rest_ones / 4) + ($rest_ones % 4 == 0 ? 0 : 1); \n\t\t}\n\t}\n\n\treturn $sum;\n}\n\nfunction get_counts($groups){\n\t\n\t$counts = array(0,0,0,0,0);\n\tforeach ($groups as $g) $counts[$g]++;\n\n\treturn $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;\n"}, {"source_code": " 0) {\n\t\twhile (count($list) > 1) {\n if ($list[0] + $list[count($list)-1] <= 4) {\n $list[0] += $list[count($list)-1];\n unset($list[count($list)-1]);\n $list = array_values($list);\n } else {\n break;\n }\n }\n\t\tunset($list[0]);\n $list = array_values($list);\n\t\t$total++;\n\t}\n\techo $total;\n\t*/"}, {"source_code": " 0){\n\t$taxi += $group[1] / 4;\n}\n\necho ceil($taxi);\n"}, {"source_code": ""}, {"source_code": " 0) {\n\t\tif (count($list) > 1) {\n\t\t\twhile (count($list) > 1) {\n if ($list[0] == 4) {\n\t unset($list[0]);\n rsort($list);\n break;\n } elseif ($list[0] + $list[count($list)-1] <= 4) {\n unset($list[0]);\n unset($list[count($list)-1]);\n rsort($list);\n } else {\n break;\n }\n }\n\t\t} else {\n\t\t\tunset($list[0]);\n\t\t\trsort($list);\n\t\t}\n\t\t$total++;\n\t}\n\techo $total;"}, {"source_code": "list($n)=explode(\" \",trim(fgets(STDIN)));\n$s=explode(\" \",trim(fgets(STDIN)));\nfor ($i=0,$sum=0;$i<$n;$i++){\nif ($s[$i]==4) {$k[$i]=1;$sum++;};\nif ($k[$i]==0){\nfor ($j=$i+1;$j<$n;$j++)\nif (($s[$i]+$s[$j])==4) {$k[$i]=1;$k[$j]=1;$sum++;break;} \n}}\nfor ($i=0;$i<$n;$i++){\nif ($s[$i]==3) {($k[$i]=1);$sum++;}\nif ($k[$i]==0) $r+=$s[$i];}\nprint ceil($r/4)+$sum;\n?>"}, {"source_code": "$val) {\n\t\tif (count($list) > 0) {\n\t\t\tif ($val + $list[count($list)-1] <= 4) {\n\t\t\t\tunset($list[count($list)-1]);\n\t\t\t}\n\t\t}\n\t\t$total++;\n\t\tunset($list[$key]);\n\t}\n\techo $total;"}, {"source_code": "$kol[3]) \n {\n $answer += $kol[3];\n $kol[1] -= $kol[3];\n $kol[3] = 0;\n echo 'to'.$answer.'to';\n if ($kol[2]>0)\n {\n $answer++;\n $kol[1]--;\n $kol[2]--;\n }\n } else\n {\n $answer += $kol[1];\n $kol[3] -= $kol[1];\n $kol[1] = 0;\n }\n if($kol[1]>0)\n {\n $t = intval($kol[1]/4);\n $answer += $t;\n $kol[1] -= $t*4;\n if ($kol[1]>0) $answer++;\n }\n $answer += $kol[3]+$kol[2];\n echo $answer;\n?>"}, {"source_code": "0){\n\t\t\t$taxi1--;\n\t\t\t$flag = 1;\t\n\t\t}\n\t\t\n\t}\n\tif($taxi1>0){\n\t\tif($flag==1) $taxi1--;\n\t\t$taxi += (int) $taxi1/4;\n\t\tif($taxi1%4!=0){\n\t\t\t$taxi++;\n\t\t}\n\t}\n\t\n\tprintf(\"%d\", $taxi);\n?>"}, {"source_code": "= $c[3])\n{\n $d = min($c[1], $c[3]);\n $e = $c[1] - $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nelse\n{\n $d = min($c[1], $c[3]);\n $e = ($c[3] - $c[1]) * 3;\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nprint $c[4] + $d + $f + $h;\n?>"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": "= $cnt1){\n\t$cnt = $cnt + $cnt1;\n\t$cnt3 = $cnt3 - $cnt1;\n\t$cnt1 = 0;\n}\nelseif($cnt3 < $cnt1){\n\t$cnt = $cnt + $cnt3;\n\t$cnt1 = $cnt1 - $cnt3;\n\t$cnt3 = 0;\n}\n$cnt = $cnt + ($cnt2/2);\n$cnt2 = $cnt2%2;\n\nif($cnt3 > 0){\n\t$cnt = $cnt + $cnt3 + $cnt2;\n}\nelseif($cnt2==1 && $cnt1==0 && $cnt3==0) {\n\t$cnt++;\n}elseif($cnt1>0){\n\tif($cnt2>0){\n\t\t$cnt++;\n\t\t$cnt1=$cnt1-2;\n\t\t$cnt2=0;\n\t}\n\tif($cnt1>0){\n\t\t$cnt=$cnt+($cnt1/4);\n\t\tif($cnt1%4!=0){\n\t\t\t$cnt++;\n\t\t}\n\t}\n\t\n}\necho count($cnt);\n"}, {"source_code": ""}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": "0)\n{\n\t$count[4] = $count[4] - 1;\n\t$taxi = $taxi + 1;\n}\nwhile($count[3]>0)\n{\n\t$count[3] = $count[3] - 1;\n\tif($count[1]>0)\n\t{\n\t\t$count[1] = $count[1] - 1;\n\t}\n\t$taxi = $taxi + 1;\n}\nwhile($count[2]>1)\n{\n\t$count[2] = $count[2] - 2;\n\t$taxi = $taxi + 1;\n}\nwhile($count[1]>0)\n{\n\tif($count[2]>0){\n\t\t$count[2] = $count[2] - 2;\n\t}\n\telse\n\t{\n\t\t$count[1] = $count[1] - 4;\n\t}\n\t$taxi = $taxi + 1;\n}\nif($count[2]>0)\n\t$taxi = $taxi + 1;\necho $taxi;\n?>"}, {"source_code": " 0) {\n\t\twhile (count($list) > 1) {\n if ($list[0] + $list[count($list)-1] <= 4) {\n $list[0] += $list[count($list)-1];\n unset($list[count($list)-1]);\n $list = array_values($list);\n } else {\n break;\n }\n }\n\t\tunset($list[0]);\n $list = array_values($list);\n\t\t$total++;\n\t}\n\techo $total;\n\t*/"}, {"source_code": " 4){\n\t\t$total++;\n\t\t$j=0;\n\t}\n\t$j=$j+$s[$i];\n\t$i++;\n}\n\nif($j == 0){\n\techo $total;\n}\nelse{\n\techo $total=$total+1;\n}\n\n\n\n\n?>"}, {"source_code": "= $c[3])\n{\n $d = min($c[1], $c[3]);\n $e = $c[1] - $c[3];\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nelse\n{\n $d = min($c[1], $c[3]);\n $e = ($c[3] - $c[1]) * 3;\n $f = floor(($c[2] * 2) / 4);\n $g = ($c[2] * 2) % 4;\n $e += $g;\n $h = ceil($e / 4);\n}\nprint $c[4] + $d + $f + $h;\n?>"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": " 0 && ($key = array_search($value, $arr_sisa)) !== false) {\n\t\t unset($arr_sisa[$key]);\n\t\t}\n\t\telse{\n\t\t\tarray_push($arr_taxi,1);\n\t\t\tarray_push($arr_sisa, $sisa_seat);\n\t\t}\n\t}\n}\necho count($arr_taxi);\n?>"}, {"source_code": ""}, {"source_code": "=0 ; $i--) { \n\t\t\tif ($a!=$i) {\n\t\t\t\t$maxval=$num_people_in_group[$i];\n\t\t\t\tif ($maxval==4) {\n\t\t\t\t\t$num_people_in_group[$i]=0;\n\t\t\t\t\t$taxi+=1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}elseif ($maxval==0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}elseif (($value+$maxval)==4 ) {\n\t\t\t\t\t$num_people_in_group[$i]=0;\n\t\t\t\t\t$num_people_in_group[$a]=0;\n\t\t\t\t\t$taxi+=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}elseif (($value+$maxval)<4 and $i!=$a) {\n\t\t\t\t\t$num_people_in_group[$i]+=$value;\n\t\t\t\t\t$num_people_in_group[$a]=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}/*elseif (($value+$maxval)>4 and $i!=$a) {\n\t\t\t\t\t//$taxi+=2;\n\t\t\t\t\tbreak;\n\t\t\t\t}*/\n\t\t\t}else{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\tif ($a == $i) {\n\tbreak;\n\t}\n}\n\t\nforeach ($num_people_in_group as $value) {\n\tif ($value>0) {\n\t\t$taxi+=1;\n\t}\n}\n}\necho $taxi;\n\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": " 0) {\n $answer += ceil($groups[1] / 4);\n}\n\necho $answer . PHP_EOL;\n\n"}, {"source_code": " 0) {\n\t\twhile (count($list) > 1) {\n if ($list[0] + $list[count($list)-1] <= 4) {\n $list[0] += $list[count($list)-1];\n unset($list[count($list)-1]);\n $list = array_values($list);\n } else {\n break;\n }\n }\n\t\tunset($list[0]);\n $list = array_values($list);\n\t\t$total++;\n\t}\n\techo $total;\n\t*/"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": "0)\n{\n\t$taxi = $taxi + 1;\n\t$count[4] = $count[4] - 1;\n}\nwhile($count[3]>0)\n{\n\t$taxi = $taxi + 1;\n\t$count[3] = $count[3] - 1;\n\tif($count[1]>0)\n\t{\n\t\t$count[1] = $count[1] - 1;\n\t}\n}\nwhile($count[2]>1)\n{\n\t$taxi = $taxi + 1;\n\t$count[2] = $count[2] - 2;\n}\nwhile($count[1]>0)\n{\n\tif($count[2]>0){\n\t\t$count[1] = $count[1] - 2;\n\t}\n\telse\n\t{\n\t\t$count[1] = $count[1] - 4;\n\t}\n\t$taxi = $taxi + 1;\n}\necho $taxi;\n?>"}, {"source_code": " intval($lines[0]),\n 'counts' => $lines[1],\n);\n$i = 0;\n$c = array(\n 0 => 0,\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n);\nforeach($input['counts'] as $count) {\n $c[intval($count)]++;\n}\n$i += $c[4];\n$i += $c[3];\n$c[1] = ($c[3] > $c[1]) ? 0 : $c[1] - $c[3];\n$i += ceil((($c[2] * 2) + $c[1]) / 4);\nfile_put_contents('php://stdout', $i);\n?>"}, {"source_code": " $group){\n\t$count += $group;\n}\necho ceil($count / 4);\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0);\nforeach( array_count_values($groups) as $k => $v) $gv[$k] = $v;\n$c = $gv[4];\n\nfor($i = 0; $i < $gv[3]; $i++)\n{\n $c++;\n if($gv[1] > 0) $gv[1]--;\n}\n\nfor($i = 0; $i < $gv[2]; $i++)\n{\n $c++;\n $gv[2] -= 1;\n if($gv[2] > 0)\n {\n $i++;\n } elseif($gv[1] >= 2)\n {\n $gv[1] -= 2;\n } elseif($gv[1] === 1) \n {\n $gv[1]--;\n } \n}\n\nfor($i = 0; $i < $gv[1]; $i++)\n{\n $c++;\n if($gv[1] >= 3)\n {\n $i+=3;\n } elseif($gv[1] === 2)\n {\n $i += 2;\n } elseif($gv[1] === 1) \n {\n $i++;\n } \n}\n\necho $c;"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode(',', $one_minus_three);\n\t\t\t\t\t$b = (int) '0.'.$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\t\tif ($one_first == 0 && $three_first == 0) $one_and_three = 0;\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($one_first <= 2 && $three_first < 1) {\n\t\t\t\t$answer = $four + $two;\n\t\t\t} else {\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t}\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": "= 0.75) { unset($s[$i]); $count++;} }\nif(isset($s[0])) { $count = $count + ceil(array_sum ($s)/4); }\necho $count;\n?>"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": ""}, {"source_code": "$r) if ($r==='') unset($rating[$key]);\n$n = isset($fl[0]) ? $fl[0] : 0;\n\n$c1 = $c2 = $c3 = $c4 = 0;\nfor ($i = 0,$cnt = count($groups); $i < $cnt; $i++){\n switch ($groups[$i]){\n case 1: $c1++; break;\n case 2: $c2++; break;\n case 3: $c3++; break;\n case 4: $c4++; break;\n }\n}\n$count += $c4;\nif ($c3 >= $c1){\n $count += $c3;\n $c1 = 0;\n}else{\n $count += $c1 - ($c1 - $c3);\n $c1 = $c1-$c3;\n}\nif ($c2 % 2 == 1 && $c1 >= 2){\n $c1 -= 2;\n $c2 += 1;\n}\n$cc = ($c2>>1);\n$count += $cc;\n\nif ($c2 - $cc * 2 > 0) $count++;\nif ($c1 % 4 == 0){\n $count += $c1/4;\n}else{\n $count += 1 + (int)($c1/4);\n}\necho $count;"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\t\tif ($one_first == 0 && $three_first == 0) $one_and_three = 0;\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($one_first <= 2 && $three_first < 1) {\n\t\t\t\t$answer = $four + $two;\n\t\t\t} else {\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\t\t\t}\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": "\n$n = rtrim(fgets(stdin));\n$arr = explode(' ',rtrim(fgets(stdin)));\n$cnt = array();\nfor ($i = 0;$i < $n;$i++){\n $cnt[$arr[$i]]++;\n}\n$cnt[1] -= $cnt[3];\nif ($cnt[1] < 0)\n $cnt[1] = 0;\n\n$result = $cnt[4] + $cnt[3] + ceil(($cnt[2]*2+$cnt[1])/4);\nprintf(\"%d\\n\",$result);\n\n?>"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": "$people) {\n $people = $group_array[$i];\n $key = $i;\n if ($people == 4) {\n $cars++;\n //unset($group_array[$key]);\n }\n\n if ($people == 3) {\n\n if ($one>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $one--;\n } else {\n $three++;\n }\n }\n if ($people == 2) {\n if ($two>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $two--;\n //unset()\n } else {\n $two++;\n }\n }\n if ($people== 1) {\n if ($three>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n $three--;\n } else {\n $one++;\n }\n }\n }\n\n if ($three>0) {\n $cars += $three;\n }\n\n if ($two>0) {\n if ($one>0) {\n $cars++;\n if ($one>2) {\n $count_one = $one-2;\n $cars += ceil($count_one/4);\n $one = array();\n } else {\n $one = array();\n }\n } else {\n $cars += $two;\n }\n }\n\n if ($one > 0) {\n $cars += ceil($one/4);\n }\n\n //echo $cars;\n fputs(STDOUT, $cars);"}, {"source_code": "4) $count+=$ss[3];\n else\n {\n $sum = $three+$one; \n $count += floor($sum); \n $ost = $sum - floor($sum);\n if ($ost <=0.75 AND $ost>0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": "0)\n{\n\t$taxi = $taxi + 1;\n\t$count[4] = $count[4] - 1;\n}\nwhile($count[3]>0)\n{\n\t$taxi = $taxi + 1;\n\t$count[3] = $count[3] - 1;\n\tif($count[1]>0)\n\t{\n\t\t$count[1] = $count[1] - 1;\n\t}\n}\nwhile($count[2]>1)\n{\n\t$taxi = $taxi + 1;\n\t$count[2] = $count[2] - 2;\n}\nwhile($count[1]>0)\n{\n\tif($count[2]>0){\n\t\t$count[1] = $count[1] - 2;\n\t}\n\telse\n\t{\n\t\t$count[1] = $count[1] - 4;\n\t}\n\t$taxi = $taxi + 1;\n}\necho $taxi;\n?>"}, {"source_code": ""}, {"source_code": "$kol[3]) \n {\n $answer += $kol[3];\n $kol[1] -= $kol[3];\n $kol[3] = 0;\n if ($kol[2]>0)\n {\n $answer++;\n $kol[1]--;\n $kol[2]--;\n }\n } else\n {\n $answer += $kol[1];\n $kol[3] -= $kol[1];\n $kol[1] = 0;\n }\n if($kol[1]>0)\n {\n $t = intval($kol[1]/4);\n $answer += $t;\n $kol[1] -= $t*4;\n if ($kol[1]>0) $answer++;\n }\n $answer += $kol[3];\n echo $answer;\n?>"}, {"source_code": "0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": " 0){\n\t$taxi += ceil($groups[1] / 4);\n}\necho ceil($taxi);\n?>"}, {"source_code": "= $a[1]){\n $a[1] = 0;\n}\nelse if ($a[3] < $a[1]){\n $a[1] -= $a[3];\n}\n$a[2] = ceil($a[2]/2);\n$taxi = $a[1] + $a[2] + $a[3] + $a[4];\necho $taxi;\n?>"}, {"source_code": ""}, {"source_code": "$strParty = trim(fgets(STDIN)); \n$strCount = trim(fgets(STDIN));\n$arrayCount = explode(\" \",$strCount);\n//$strParty = 100000;\n//for($i = 0; $i < $strParty;$i++) $arrayCount[$i] = rand(1,4);\n\nif(!$arrayCount) exit(1);\nif(!$strParty) exit(1);\nif($strParty != count($arrayCount)) exit(1);\n\nfunction first($arrayCount)\n{\n\nfor($i = 0; $i < count($arrayCount);$i++) if($arrayCount[$i] == 2) $arrayTwoDigits[] = $i;\n\n\nfor($i = 0; $i < count($arrayTwoDigits);$i++)\n{\n if($arrayCount[$arrayTwoDigits[$i+1]])\n {\n if($arrayCount[$arrayTwoDigits[$i]] + $arrayCount[$arrayTwoDigits[$i+1]] == 4) \n {\n $arrayCount[$arrayTwoDigits[$i+1]] = 4;\n unset($arrayCount[$arrayTwoDigits[$i]]);\n }\n }\n\n}\n\nsort($arrayCount);\nreturn $arrayCount;\n}\n\nfunction four($arrayCount)\n{\n\nfor($i = 0; $i < count($arrayCount);$i++) if($arrayCount[$i] == 1) $arrayTwoDigits2[] = $i;\n\n\nfor($i = 0; $i < count($arrayTwoDigits2);$i++)\n{\n if($arrayCount[$arrayTwoDigits2[$i+1]])\n {\n if($arrayCount[$arrayTwoDigits2[$i]] + $arrayCount[$arrayTwoDigits2[$i+1]] == 2) \n {\n $arrayCount[$arrayTwoDigits2[$i+1]] = 2;\n unset($arrayCount[$arrayTwoDigits2[$i]]);\n }\n }\n\n}\n\nsort($arrayCount);\nreturn $arrayCount;\n}\n\nfunction second($arrayCount)\n{\nfor($i = 0; $i < count($arrayCount);$i++) if($arrayCount[$i] == 3) $arrayTwoDigits1[] = $i;\n\n\nfor($i = 0; $i < count($arrayCount);$i++)\n{\n if($arrayCount[$i] == 1)\n {\n $j = 0;\n if($arrayCount[$i] + $arrayCount[$arrayTwoDigits1[$j]] == 4) \n {\n $arrayCount[$arrayTwoDigits1[$j]] = $arrayCount[$i] + $arrayCount[$arrayTwoDigits1[$j]];\n unset($arrayCount[$i]);\n unset($arrayTwoDigits1[$j]);\n sort($arrayTwoDigits1);\n }\n } \n\n}\nsort($arrayCount);\nreturn $arrayCount;\n}\n\n$arrayCount = first($arrayCount);\n//print_r($arrayCount);\n$arrayCount = second($arrayCount);\n//print_r($arrayCount);\n$arrayCount = four($arrayCount);\n$arrayCount = first($arrayCount);\n\nfor($i =0; $i < count($arrayCount);$i++)\n{\n if($arrayCount[$i+1])\n {\n if($arrayCount[$i] + $arrayCount[$i+1] <=4 )\n {\n $arrayCount[$i+1] = $arrayCount[$i] + $arrayCount[$i+1];\n unset($arrayCount[$i]);\n }\n }\n \n}\nsort($arrayCount);\n\n\n\n\n// print_r($arrayCount);\n$cCount = count($arrayCount);\nprint $cCount;"}, {"source_code": "\n"}, {"source_code": " 0) {\n\t\t$sum += ceil($diff / 4 + $counts[2] / 2);\n\t} else {\n\t\t$sum += ceil($counts[2] / 2);\t\n\t}\n\treturn $sum;\n}\n\nfunction get_counts($groups){\n\t\n\t$counts = array(0,0,0,0,0);\n\tforeach ($groups as $g) $counts[$g]++;\n\n\treturn $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;\n"}, {"source_code": ""}, {"source_code": " 4){\n\t\t$total++;\n\t\t$j=0;\n\t}\n\t$j=$j+$s[$i];\n\t$i++;\n}\n\nif($j == 0){\n\techo $total;\n}\nelse{\n\techo $total=$total+1;\n}\n\n\n\n\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first <= 2 && $three_first == 0) $two = 0;\n\t\t\tif ($four == 0 && $one_first == 0 && $three_first == 0) $two = 1;\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}, {"source_code": " 0) {\n\t\twhile (count($list) > 1) {\n if ($list[0] + $list[count($list)-1] <= 4) {\n $list[0] += $list[count($list)-1];\n unset($list[count($list)-1]);\n $list = array_values($list);\n } else {\n break;\n }\n }\n\t\tunset($list[0]);\n $list = array_values($list);\n\t\t$total++;\n\t}\n\techo $total;\n\t*/"}, {"source_code": "$arr[1]){\n\t$count+=$arr[3]+ceil($arr[2]/2);\n\techo $count;\n\texit;\n}\n\nelse if($arr[3]<$arr[1]){\n\t$count+=$arr[3];\n\t$arr[1]-=$arr[3];\n}\n\nelse{\n\t$count+=$arr[3]+ceil($arr[2]/2);\n\techo $count;\n\texit;\n}\n\n\n$count+=ceil(($arr[2]*2+$arr[1])/4);\necho $count;\n?>"}, {"source_code": ""}, {"source_code": " 0){\n\t$taxi += ceil($groups[1] / 4);\n}\necho ceil($taxi);\n?>"}, {"source_code": "$people) {\n if ($people == 4) {\n $cars++;\n unset($group_array[$key]);\n }\n \n if ($people == 3) {\n \n if (count($one)>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n array_shift($one);\n } else {\n $three[$key] = 1;\n }\n }\n if ($people == 2) {\n if (count($two)>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n array_shift($two);\n } else {\n $two[$key] = 1;\n }\n }\n if ($people== 1) {\n if (count($three)>0) { //\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0448\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 - \u0441\u0430\u0436\u0430\u0435\u043c \u0432 \u0442\u0430\u0447\u043a\u0443 \u0447\u0443\u0432\u0430\u043a\u043e\u0432\n $cars++;\n array_shift($three);\n } else {\n $one[$key] = 1;\n }\n }\n }\n\n if (count($three)>0) {\n $cars += count($three);\n }\n\n if (count($two)>0) {\n if (count($one)>0) {\n $cars++;\n if (count($one)>2) {\n $count_one = count($one)-2;\n $cars += ceil($count_one/4);\n $one = array();\n }\n } else {\n $cars += count($two);\n }\n }\n\n if (count($one) > 0) {\n $cars += ceil(count($one)/4);\n }\n \n fputs(STDOUT, $cars);\n\n\n?>"}, {"source_code": " 1) {\n $c += (int)(($have[2] - 1) / 2);\n $have[2] = 1;\n }\n }\n\n // 1\n if (isset($have[1])) {\n if (isset($have[2])) {\n if ($have[2] > 0 && $have[1] > 1) {\n $min_2_1 = min($have[2], (int)($have[1] / 2));\n\n if ($min_2_1 > 0) {\n $have[2] -= $min_2_1;\n $have[1] -= $min_2_1 * 2;\n $c += $min_2_1;\n }\n }\n }\n\n if ($have[1] > 0) {\n $ones = (int)($have[1] / 4);\n $c += $ones;\n $have[1] -= $ones * 4;\n $c++;\n }\n }\n\n if (isset($have[2])) {\n $c += $have[2];\n }\n\n if (isset($have[3])) {\n $c += $have[3];\n }\n\n return $c;\n}\n\n$r = 0;\n\nlist($n) = fscanf($input, \"%d\\n\");\n\n$s = fscanf($input, trim(str_repeat(\"%d \", $n)));\n\n$r = foo($s);\n\nfwrite($output, $r);\n"}, {"source_code": ""}, {"source_code": "4) $three = $ss[3]; else $three = 0;\n \n $sum = $three+$one; \n $count += floor($sum); \n $ost = $sum - floor($sum);\n if ($ost <=0.75 AND $ost>0.25 AND $three%2 ==1 ) { $count++; $ost = 0; }\n \n }\nif (isset($ss[2])) \n{ \n$two = ($ss[2]*2)/4; \n$count += floor($ss[2]/2); \n$ost += $two - floor($two);\n}\nif ($ost!=0) $count+=ceil($ost);\necho $count;\n?>"}, {"source_code": ""}, {"source_code": " $c3)\n {\n print $c4 + $c3 + ceil(($c1 - $c3 + 2) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + 1 + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + 1;\n }\n}\nelseif($c2 % 2 == 0)\n{\n if($c1 > $c3)\n {\n print $c4 + $c3 + ($c2 / 2) + ceil(($c1 - $c3) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + ($c2 / 2) + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + ($c2 / 2);\n }\n}\nelseif($c2 % 2 != 0)\n{\n if($c1 > $c3)\n {\n print $c4 + $c3 + floor($c2 / 2) + 1 + ceil(($c1 - $c3 - 1) / 4);\n }\n elseif($c1 < $c3)\n {\n print $c4 + $c1 + floor($c2 / 2) + 1 + ($c3 - $c1);\n }\n elseif($c1 == $c3)\n {\n print $c4 + $c1 + floor($c2 / 2) + 1;\n }\n}\n?>"}, {"source_code": "= 0) {\n\t\t$sum += $counts[3] + ceil($counts[2] / 2);\n\t} else {\n\t\t$rest_ones = $count[1] - $count[3];\n\t\t$sum += $counts[3] + floor($count[2] / 2);\n\t\t\n\t\tif ($count[2] % 2 - $rest_ones >= 0) {\n\t\t\t$sum += $counts[2] % 2;\n\t\t} else {\n\t\t\t$rest_ones = $rest_ones - $counts[2] % 2;\n\t\t\t$sum += $rest_ones / 4 + $rest_ones % 4; \n\t\t}\n\t}\n\n\treturn $sum;\n}\n\nfunction get_counts($groups){\n\t\n\t$counts = array(0,0,0,0,0);\n\tforeach ($groups as $g) $counts[$groups]++;\n\n\treturn $counts;\n}\n\n$groups = read();\n$counts = get_counts($groups);\n$sum = get_sum($counts);\n\necho $sum;\n"}, {"source_code": " 0){\n\t$taxi += $group[1] / 4;\n}\n\necho ceil($taxi);\n"}, {"source_code": ""}, {"source_code": "= 0.75) { unset($s[$i]); $count++;} }\nif(isset($s[0])) { $count = $count + ceil(array_sum ($s)/4);}\necho $count;\n?>"}, {"source_code": "= 0.75) { unset($s[$i]); $count++;} }\nif(isset($s[0])) { $count = $count + ceil(array_sum ($s)/4);}\necho $count;\n?>"}, {"source_code": "= $a[1]){\n $a[1] = 0;\n}\nelse if ($a[3] < $a[1]){\n $a[1] -= $a[3];\n}\n$a[2] = ceil($a[2]/2);\n$taxi = $a[1] + $a[2] + $a[3] + $a[4];\necho $taxi;\n?>"}, {"source_code": " 0) {\n\t\tif (count($list) > 1) {\n\t\t\twhile (count($list) > 1) {\n if ($list[0] == 4) {\n\t unset($list[0]);\n rsort($list);\n } elseif ($list[0] + $list[count($list)-1] <= 4) {\n unset($list[0]);\n unset($list[count($list)-1]);\n rsort($list);\n } else {\n break;\n }\n }\n\t\t} else {\n\t\t\tunset($list[0]);\n\t\t\trsort($list);\n\t\t}\n\t\t$total++;\n\t}\n\techo $total;"}, {"source_code": "0 || $_2>0 || $_3>0){\n if($_3>0 && $_1>0){\n $min=$_3>$_1?$_1:$_3;\n $_3-=$min;\n $_1-=$min;\n $out+=$min;\n }\n if($_2>1){\n $out+=floor($_2/2);\n $_2=$_2%2;\n }\n if($_2==1 && $_1>=2){\n $_1-=2;\n $_2=0;\n $out+=1;\n }\n if($_1>=4){\n $out+=floor($_1/4);\n $_1=$_1%4;\n }\n if($_1>0){\n $out+=1;\n $_1=0;\n }\n if($_2>0){\n $out+=1;\n $_2=0;\n }\n if($_3>0){\n $out+=1;\n $_3=0;\n }\n}\n\necho $out;\n\n?>"}, {"source_code": "\n"}, {"source_code": " 0) {\n\t\tif (count($list) > 1) {\n\t\t\tif ($list[0] + $list[count($list)-1] <= 4) {\n\t\t\t\tunset($list[count($list)-1]);\n\t\t\t}\n\t\t}\n\t\t$total++;\n\t\tunset($list[0]);\n\t\trsort($list);\n\t}\n\techo $total;"}, {"source_code": " 0 && $k[0] > 0)\n\t{\n\t\t$ans++;\n\t\t$k[1] = 0;\n\t\t($k[0] > 1 ? $k[0] -= 2: $k[0] = 0);\n\t}\n\n\t$ans += $k[2];\n\n\n\tfwrite(STDOUT, $ans.\"\\n\");\n?>\n"}, {"source_code": " $group){\n\t$count += $group;\n}\necho ceil($count / 4);\n?>"}, {"source_code": "= 100000) die;\nsort($s);\nfor ($i = 0; $i < $n; $i++) \n{\n if (max($s) == 4) {$key = array_search(4, $s); unset($s[$key]); $count++;}\n if (($s[0]+max($s))<=4) { $s[0]=$s[0]+array_pop($s); sort($s);}\n}\n$c = count($s);\nfor ($i = 0; $i < $c; $i++) { if ($s[$i]/4 >= 0.75) { unset($s[$i]); $count++;} }\nif(isset($s[0])) { $count = $count + ceil(array_sum ($s)/4); }\necho $count;\n?>"}, {"source_code": " $one_first) {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 1-\u0446 (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 3-\u043a.\n\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t} else {\n\t\t\t\t// \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b-\u0432\u0443 3-\u043a (\u0442.\u043a. \u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0435) \u043f\u043b\u044e\u0441 \u043a\u043e\u043b-\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f 1-\u0446, \u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 4 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.\n\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t}\n\t\t}\n\n\t\t// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438\n\t\t$answer = $four + $two + $one_and_three;\n\n\t\techo $answer;\n\t} else {\n\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 2-\u043a \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0434\u043b\u044f \u0447\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 2-\u043a.\n\t\t$two = floor($two_first / 2);\n\t\t// \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 2-\u043a\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 1-\u0446\u044b \u0438 3-\u043a\u0438.\n\t\tif ($two_first == 1) {\n\t\t\t$two = 1;\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) { \n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2);\n\t\t\t} else {\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first));\n\t\t\t\t} else {\n\t\t\t\t\t$one_and_three = ($three_first + ceil(($one_first - $three_first) / 4));\n\t\t\t\t}\n\t\t\t}\n\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\techo $answer;\n\t\t} else {\n\t\t\t// \u0415\u0441\u043b\u0438 2-\u043a \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c 1-\u0446\u044b \u0438 3-\u043a\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0437\u0430\u043f\u0430\u0441\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 2-\u043a\u0430.\n\t\t\t// \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e-\u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a.\n\t\t\t$one_first = count(array_diff($s, array(2, 3, 4)));\n\t\t\t$three_first = count(array_diff($s, array(1, 2, 4)));\n\t\t\tif ($one_first == $three_first) {\n\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b-\u0432\u043e 1-\u0446 \u0438 3-\u043a \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043e\u043d\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f 2-\u043a\u0438.\n\t\t\t\t$one_and_three = (($one_first + $three_first) / 2) + 1;\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t} else {\n\t\t\t\t// \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0430\u0447\u0435.\n\t\t\t\t// \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0435\u0433\u043a\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 3-\u043a \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 1-\u0446.\n\t\t\t\t// \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u0443\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0438\u0437 3-\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u0438\u0437 2-\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.\n\t\t\t\tif ($three_first > $one_first) {\n\t\t\t\t\t$one_and_three = ($one_first + ($three_first - $one_first)) + 1;\n\t\t\t\t} else {\n\t\t\t\t\t// \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 1-\u0446 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 3-\u043a, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0446\u0435\u043b\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0430\u043a\u0441\u0438 \u0441 1-\u043c\u0438, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c\n\t\t\t\t\t$one_minus_three = (($one_first - $three_first) / 4);\n\t\t\t\t\tlist($a, $b) = explode('.', $one_minus_three);\n\t\t\t\t\t$b = '0.'.$b;\n\t\t\t\t\t$b = (double)$b;\n\t\t\t\t\t// \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 0,5 (\u0442.\u0435. 2 / 4), \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438 \u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f.\n\t\t\t\t\tif ($b <= 0.5) {\n\t\t\t\t\t\t$b = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u0418\u043d\u0430\u0447\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0430\u043a\u0441\u0438.\n\t\t\t\t\t\t$b = 2;\n\t\t\t\t\t}\n\n\n\t\t\t\t\t$one_and_three = ($three_first + $a + $b);\n\t\t\t\t}\n\n\t\t\t\t$answer = $four + $two + $one_and_three;\n\n\t\t\t\techo $answer;\n\t\t\t}\n\t\t}\n\t}\n?>"}], "src_uid": "371100da1b044ad500ac4e1c09fa8dcb"} {"nl": {"description": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness of each book is either 1 or 2. All books have the same page heights. Shaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. Help Shaass to find the minimum total thickness of the vertical books that we can achieve.", "input_spec": "The first line of the input contains an integer n, (1\u2009\u2264\u2009n\u2009\u2264\u2009100). Each of the next n lines contains two integers ti and wi denoting the thickness and width of the i-th book correspondingly, (1\u2009\u2264\u2009ti\u2009\u2264\u20092,\u20091\u2009\u2264\u2009wi\u2009\u2264\u2009100).", "output_spec": "On the only line of the output print the minimum total thickness of the vertical books that we can achieve.", "sample_inputs": ["5\n1 12\n1 3\n2 15\n2 5\n2 1", "3\n1 10\n2 1\n2 4"], "sample_outputs": ["5", "3"], "notes": null}, "positive_code": [{"source_code": "= $k)\n {\n break;\n }\n else\n {\n $f = $m;\n break;\n }\n }\n else\n {\n for($x = $l; $x < $a; $x++)\n {\n if($j[$x] == 1)\n {\n break;\n }\n }\n $f -= $j[$x];\n $k += $g[$x];\n if($f < $k)\n {\n $f += $j[$x];\n break;\n }\n elseif($f >= $k)\n {\n break;\n } \n }\n }\n elseif($f == $k)\n {\n break;\n }\n elseif($f > $k)\n {\n $f -= $j[$l];\n $k += $g[$l];\n $l++;\n }\n}\nprint $f;\n?>"}], "negative_code": [{"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\n//////////\nasort($l);\n$m = array_keys($l);\n$n = array();\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n array_push($n, $d[$m[$x]]);\n array_push($o, $e[$m[$x]]);\n}\n$p = array_sum($n);\n$r = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $r += $o[$x];\n $p -= $n[$x];\n if($p >= $r)\n {\n continue; \n }\n else\n {\n $p += $n[$x];\n break;\n }\n}\n//////////\n$t = array_reverse($d);\n$u = array_reverse($e);\nasort($u);\n$v = array_keys($u);\n$w = array(); // \u0442\u043e\u043b\u0449\u0438\u043d\u0430\nfor($x = 0; $x < $a; $x++)\n{\n array_push($w, $t[$v[$x]]);\n}\nsort($u); // \u0448\u0438\u0440\u0438\u043d\u0430\n$jj = array_sum($i);\n$kk = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $kk += $g[$x];\n $jj -= $w[$x];\n if($jj >= $kk)\n {\n continue; \n }\n else\n {\n $jj += $w[$x];\n break;\n }\n}\n//////////\nprint min($j, $p, $jj);\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nprint $j;\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\n//////////\nasort($l);\n$m = array_keys($l);\n$n = array();\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n array_push($n, $d[$m[$x]]);\n array_push($o, $e[$m[$x]]);\n}\n$p = array_sum($n);\n$r = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $r += $o[$x];\n $p -= $n[$x];\n if($p >= $r)\n {\n continue; \n }\n else\n {\n $p += $n[$x];\n break;\n }\n}\n//////////\nprint min($j, $p);\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nif($a == 50)\n{\n print implode(\" \", $i) . \"\\n\";\n print implode(\" \", $g) . \"\\n\";\n print array_sum($i);\n \n}\nelse\n{\n print $j;\n}\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\n//////////\nasort($l);\n$m = array_keys($l);\n$n = array();\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n array_push($n, $d[$m[$x]]);\n array_push($o, $e[$m[$x]]);\n}\n$p = array_sum($n);\n$r = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $r += $o[$x];\n $p -= $n[$x];\n if($p >= $r)\n {\n continue; \n }\n else\n {\n $p += $n[$x];\n break;\n }\n}\n//////////\nprint min($j, $p);\n?>"}, {"source_code": " $k)\n {\n $f -= $j[$l];\n $k += $g[$l];\n $l++;\n }\n}\nprint $f;\n?>"}, {"source_code": "= $k)\n {\n break;\n } \n }\n }\n elseif($f == $k)\n {\n break;\n }\n elseif($f > $k)\n {\n $f -= $j[$l];\n $k += $g[$l];\n $l++;\n }\n}\nprint $f;\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\n//////////\nasort($l);\n$m = array_keys($l);\n$n = array();\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n array_push($n, $d[$m[$x]]);\n array_push($o, $e[$m[$x]]);\n}\n$p = array_sum($n);\n$r = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $r += $o[$x];\n $p -= $n[$x];\n if($p >= $r)\n {\n continue; \n }\n else\n {\n $p += $n[$x];\n break;\n }\n}\n//////////\nprint min($j, $p);\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nif($a == 50)\n{\n print_r($i);\n print_r($g);\n}\nelse\n{\n print $j;\n}"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nif($a == 50)\n{\n print implode(\" \", $i) . \"\\n\";\n print implode(\" \", $g);\n}\nelse\n{\n print $j;\n}\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\n//////////\nasort($l);\n$m = array_keys($l);\n$n = array();\n$o = array();\nfor($x = 0; $x < $a; $x++)\n{\n array_push($n, $d[$m[$x]]);\n array_push($o, $e[$m[$x]]);\n}\n$p = array_sum($n);\n$r = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $r += $o[$x];\n $p -= $n[$x];\n if($p >= $r)\n {\n continue; \n }\n else\n {\n $p += $n[$x];\n break;\n }\n}\n//////////\nprint min($j, $p);\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nprint $j;\n?>"}, {"source_code": "= $k)\n {\n continue; \n }\n else\n {\n $j += $i[$x];\n break;\n }\n}\nif($a == 50)\n{\n print_r($i);\n print_r($g);\n}\nelse\n{\n print $j;\n}\n?>"}], "src_uid": "f9c16d5c72fe139aa91bc1a9e44d4dc2"} {"nl": {"description": "Mark is asked to take a group photo of $$$2n$$$ people. The $$$i$$$-th person has height $$$h_i$$$ units.To do so, he ordered these people into two rows, the front row and the back row, each consisting of $$$n$$$ people. However, to ensure that everyone is seen properly, the $$$j$$$-th person of the back row must be at least $$$x$$$ units taller than the $$$j$$$-th person of the front row for each $$$j$$$ between $$$1$$$ and $$$n$$$, inclusive.Help Mark determine if this is possible.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1\\leq t\\leq 100$$$) \u2014 the number of test cases. Each test case consists of two lines. The first line of each test case contains two positive integers $$$n$$$ and $$$x$$$ ($$$1\\leq n\\leq 100$$$, $$$1\\leq x\\leq 10^3$$$) \u2014 the number of people in each row and the minimum difference Mark wants. The second line of each test case contains $$$2n$$$ positive integers $$$h_1,h_2,\\ldots,h_{2n}$$$ ($$$1\\leq h_i\\leq 10^3$$$) \u2014 the height of each person in units. Note that the sum of $$$n$$$ over all test cases is not bounded.", "output_spec": "For each test case, print a single line containing \"YES\" if Mark could arrange people satisfying his condition and \"NO\" otherwise. You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answers).", "sample_inputs": ["3\n\n3 6\n\n1 3 9 10 12 16\n\n3 1\n\n2 5 2 2 2 5\n\n1 2\n\n8 6"], "sample_outputs": ["YES\nNO\nYES"], "notes": "NoteIn the first test case, one possible order is to have the third, fifth, and sixth person on the back row and the second, first, and fourth on the front row. The heights of the people will look like this. Back$$$9$$$$$$12$$$$$$16$$$Front$$$3$$$$$$1$$$$$$10$$$ It works because $$$h_3-h_2 = 9-3 \\geq 6$$$, $$$h_5-h_1 = 12-1\\geq 6$$$, and $$$h_6-h_4 = 16-10\\geq 6$$$. In the second test case, it can be shown there is no way to order people in a way that satisfies the condition.In the third test case, the only way to arrange people to satisfy the condition is to have the first person on the back row and the second person on the front row."}, "positive_code": [{"source_code": " $arr[$i+$n]) {\r\n\t\t\t$mark = false ;\r\n\t\t\tbreak ;\r\n\t\t}\r\n\t}\r\n\tif($mark) printLine(\"YES\") ;\r\n\telse printLine(\"NO\") ;\r\n\r\n\r\n}"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}"}], "negative_code": [], "src_uid": "52769cd7b3b0d63a7259a5d0754c4803"} {"nl": {"description": "You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace \"01\" with \"10\" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace \"12\" with \"21\" or vice versa).For example, for string \"010210\" we can perform the following moves: \"010210\" $$$\\rightarrow$$$ \"100210\"; \"010210\" $$$\\rightarrow$$$ \"001210\"; \"010210\" $$$\\rightarrow$$$ \"010120\"; \"010210\" $$$\\rightarrow$$$ \"010201\". Note than you cannot swap \"02\" $$$\\rightarrow$$$ \"20\" and vice versa. You cannot perform any other operations with the given string excluding described above.You task is to obtain the minimum possible (lexicographically) string by using these swaps arbitrary number of times (possibly, zero).String $$$a$$$ is lexicographically less than string $$$b$$$ (if strings $$$a$$$ and $$$b$$$ have the same length) if there exists some position $$$i$$$ ($$$1 \\le i \\le |a|$$$, where $$$|s|$$$ is the length of the string $$$s$$$) such that for every $$$j < i$$$ holds $$$a_j = b_j$$$, and $$$a_i < b_i$$$.", "input_spec": "The first line of the input contains the string $$$s$$$ consisting only of characters '0', '1' and '2', its length is between $$$1$$$ and $$$10^5$$$ (inclusive).", "output_spec": "Print a single string \u2014 the minimum possible (lexicographically) string you can obtain by using the swaps described above arbitrary number of times (possibly, zero).", "sample_inputs": ["100210", "11222121", "20"], "sample_outputs": ["001120", "11112222", "20"], "notes": null}, "positive_code": [{"source_code": " 0)\n {\n $d .= \"0\";\n $b[0]--;\n }\n elseif($b[1] > 0)\n {\n $d .= \"1\";\n $b[1]--;\n }\n }\n}\n$e = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n if($a[$x] == 2)\n {\n $d .= \"2\";\n $e = 1;\n }\n elseif(($a[$x] == 0) && ($e == 1))\n {\n $d .= \"0\";\n }\n}\nprint $d;\n?>"}, {"source_code": " $value){\n if($value == 1){ \n $numOf1++;\n } \n if($value == 2 && !$stop){ \n $stop = true;\n $stopIndex = $key;\n } \n if(!$stop && $value == 0){ \n echo '0';\n } \n}\nfor($i = 0; $i < $numOf1; $i++){\n echo '1';\n}\n\nif($stop){\n\tfor($i = $stopIndex; $i < sizeof($input); $i++){ \n\t\tif($input[$i] != 1){\n\t\t\techo \"$input[$i]\";\n\t\t}\n\t}\n}"}], "negative_code": [{"source_code": " 1)\n {\n $b .= \"0\";\n $c[0]--;\n }\n elseif($c[1] > 0)\n {\n $b .= \"1\";\n $c[1]--;\n }\n elseif($c[2] > 0)\n {\n $b .= \"2\";\n $c[2]--;\n }\n }\n $b .= \"0\";\n $d = 0;\n $e = 0;\n }\n}\nif($e > 0)\n{\n for($y = 0; $y < $e; $y++)\n {\n if($c[0] > 1)\n {\n $b .= \"0\";\n $c[0]--;\n }\n elseif($c[1] > 0)\n {\n $b .= \"1\";\n $c[1]--;\n }\n elseif($c[2] > 0)\n {\n $b .= \"2\";\n $c[2]--;\n }\n }\n}\nprint $b;\n?>"}, {"source_code": " $value){\n if($value == 1){ \n $numOf1++;\n } \n if($value == 2 && !$stop){ \n $stop = true;\n $stopIndex = $key;\n } \n if(!$stop && $value == 0){ \n echo '0';\n } \n}\nfor($i = 0; $i < $numOf1; $i++){\n echo '1';\n}\n\nfor($i = $stopIndex; $i < sizeof($input); $i++){ \n if($input[$i] != 1){\n echo \"$input[$i]\";\n }\n}"}, {"source_code": " $input[($i+1)]){\n $canSwapThisTime = canSwap($value, $input[($i+1)]);\n if($canSwapThisTime){\n\t\t\t\t//echo \"can swap at position $i
\";\n\t\t\t\tarray_push($swapPosition, $i);\n\t\t\t\t$canSwapAny = true;\n\t\t\t}\n }\n }\n\tforeach($swapPosition as $value){\n\t\tswap($input, $value, $value+1);\n\t}\n}\n\n$input = implode(\"\", $input);\necho \"$input\";\n\nfunction swap(&$a, $position1, $position2){\n $temp = $a[$position1];\n $a[$position1] = $a[$position2];\n $a[$position2] = $temp;\n}\n\nfunction canSwap($item1, $item2){\n $diff = abs($item2 - $item1);\n if($diff == 1){\n return true;\n }\n return false;\n}"}, {"source_code": " $input[($i+1)]){\n $canSwapThisTime = canSwap($value, $input[($i+1)]);\n if($canSwapThisTime){\n\t\t\t\t//echo \"can swap at position $i
\";\n\t\t\t\tarray_push($swapPosition, $i);\n\t\t\t\t$canSwapAny = true;\n\t\t\t\t$i++;\n\t\t\t}\n }\n }\n\tforeach($swapPosition as $value){\n\t\tswap($input, $value, $value+1);\n\t}\n}\n\n$input = implode(\"\", $input);\necho \"$input\";\n\nfunction swap(&$a, $position1, $position2){\n $temp = $a[$position1];\n $a[$position1] = $a[$position2];\n $a[$position2] = $temp;\n}\n\nfunction canSwap($item1, $item2){\n $diff = abs($item2 - $item1);\n if($diff == 1){\n return true;\n }\n return false;\n}"}, {"source_code": " $value){\n if($value == 1){ \n $numOf1++;\n } \n if($value == 2){ \n $stop = true;\n $stopIndex = $key;\n } \n if(!$stop && $value == 0){ \n echo '0';\n } \n}\nfor($i = 0; $i < $numOf1; $i++){\n echo '1';\n}\n\nfor($i = $stopIndex; $i < sizeof($input); $i++){ \n if($input[$i] != 1){\n echo \"$input[$i]\";\n }\n}\n\n\n"}], "src_uid": "91cefa6793e77b3e4f4896616a164ff2"} {"nl": {"description": "Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck.Inna wants her present to show Dima how great a programmer he is. For that, she is going to give Dima commands one by one. There are two types of commands: Add a given number into one of containers. For the queue and the stack, you can add elements only to the end. For the deck, you can add elements to the beginning and to the end. Extract a number from each of at most three distinct containers. Tell all extracted numbers to Inna and then empty all containers. In the queue container you can extract numbers only from the beginning. In the stack container you can extract numbers only from the end. In the deck number you can extract numbers from the beginning and from the end. You cannot extract numbers from empty containers. Every time Dima makes a command of the second type, Inna kisses Dima some (possibly zero) number of times. Dima knows Inna perfectly well, he is sure that this number equals the sum of numbers he extracts from containers during this operation.As we've said before, Dima knows Inna perfectly well and he knows which commands Inna will give to Dima and the order of the commands. Help Dima find the strategy that lets him give as more kisses as possible for his birthday!", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of Inna's commands. Then n lines follow, describing Inna's commands. Each line consists an integer: Integer a (1\u2009\u2264\u2009a\u2009\u2264\u2009105) means that Inna gives Dima a command to add number a into one of containers. Integer 0 shows that Inna asks Dima to make at most three extractions from different containers. ", "output_spec": "Each command of the input must correspond to one line of the output \u2014 Dima's action. For the command of the first type (adding) print one word that corresponds to Dima's choice: pushStack \u2014 add to the end of the stack; pushQueue \u2014 add to the end of the queue; pushFront \u2014 add to the beginning of the deck; pushBack \u2014 add to the end of the deck. For a command of the second type first print an integer k (0\u2009\u2264\u2009k\u2009\u2264\u20093), that shows the number of extract operations, then print k words separated by space. The words can be: popStack \u2014 extract from the end of the stack; popQueue \u2014 extract from the beginning of the line; popFront \u2014 extract from the beginning from the deck; popBack \u2014 extract from the end of the deck. The printed operations mustn't extract numbers from empty containers. Also, they must extract numbers from distinct containers. The printed sequence of actions must lead to the maximum number of kisses. If there are multiple sequences of actions leading to the maximum number of kisses, you are allowed to print any of them.", "sample_inputs": ["10\n0\n1\n0\n1\n2\n0\n1\n2\n3\n0", "4\n1\n2\n3\n0"], "sample_outputs": ["0\npushStack\n1 popStack\npushStack\npushQueue\n2 popStack popQueue\npushStack\npushQueue\npushFront\n3 popStack popQueue popFront", "pushStack\npushQueue\npushFront\n3 popStack popQueue popFront"], "notes": null}, "positive_code": [{"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n else\n {\n $c = 0;\n if(count($d) == \"1\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n array_push($f, \"1 popStack\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n elseif(count($d) == \"2\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n array_push($f, \"2 popStack popQueue\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n elseif(count($d) >= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n $d = array();\n $f = array();\n $g = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -1);\n print $h;\n }\n }\n}\n?>"}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n\n$x = $f[0];\n\n$a = array();\n\n$_in = array('pushQueue','pushStack','pushFront');\n$_out = array(' popQueue',' popStack',' popFront');\n\nfor($i=1;$i<=$x;$i++) {\n\tif ($f[$i]==0) {\n\n\t\t$b = $a;\n\t\tarsort($b);\n\t\t\n\t\t$b = array_keys(array_slice($b,0,3,true));\n\n\t\t$j = 0;\n\n\t\tforeach ($a as $k=>$kiss) {\n\t\t\tif ($j<3 && in_array($k,$b)) {\n\t\t\t\t$str .= $_in[$j++];\n\t\t\t} else {\n\t\t\t\t$str .= 'pushBack';\n\t\t\t}\n\t\t\t$str .= L;\n\t\t}\n\n\t\t$str .= $j;\n\n\t\tfor ($c=0;$c<$j;$c++) {\n\t\t\t$str .= $_out[$c];\n\t\t}\n\n\t\t$str .= L;\n\n\t\t$a = array();\n\n\t} else {\n\t\t$a[] = $f[$i];\n\t}\n}\n\nfor ($i=0;$i"}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\");\n $f[$e[0]] = \"pushStack\";\n $f[$e[1]] = \"pushQueue\";\n $f[$e[2]] = \"pushFront\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n }\n $d = array();\n $f = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n }\n }\n}\nfor($x = 0; $x < $a - 1; $x++)\n{\n print $g[$x] . \"\\n\";\n}\nprint $g[$x];\n?>"}, {"source_code": ""}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n else\n {\n $c = 0;\n if(count($d) == \"1\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n array_push($f, \"1 popStack\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -1);\n print $h;\n }\n elseif(count($d) == \"2\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n array_push($f, \"2 popStack popQueue\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -1);\n print $h;\n }\n elseif(count($d) >= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -1);\n print $h;\n }\n }\n $d = array();\n $f = array();\n $g = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\");\n $f[$e[0]] = \"pushStack\";\n $f[$e[1]] = \"pushQueue\";\n $f[$e[2]] = \"pushFront\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n }\n $d = array();\n $f = array();\n }\n }\n else\n {\n array_push($d, $b);\n $c++;\n }\n}\nfor($x = 0; $x < $a - 1; $x++)\n{\n print $g[$x] . \"\\n\";\n}\nprint $g[$x];\n?>"}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n else\n {\n $c = 0;\n if(count($d) == \"1\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n array_push($f, \"1 popStack\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -3);\n print $h;\n }\n elseif(count($d) == \"2\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n array_push($f, \"2 popStack popQueue\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -3);\n print $h;\n }\n elseif(count($d) >= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\" . \"\\n\");\n $f[$e[0]] = \"pushStack\" . \"\\n\";\n $f[$e[1]] = \"pushQueue\" . \"\\n\";\n $f[$e[2]] = \"pushFront\" . \"\\n\";\n array_push($f, \"3 popStack popQueue popFront\" . \"\\n\");\n $g = array_merge($g, $f);\n $h = substr(implode(\"\", $g), 0, -3);\n print $h;\n }\n }\n $d = array();\n $f = array();\n $g = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n $h = implode(\"\", $g);\n print $h;\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= \"3\")\n {\n rsort($d);\n $f = array_fill(0, count($d), \"pushBack\");\n $d[0] = \"pushStack\";\n $d[1] = \"pushQueue\";\n $d[2] = \"pushFront\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n }\n $d = array();\n $f = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n }\n }\n}\nfor($x = 0; $x < $a - 1; $x++)\n{\n print $g[$x] . \"\\n\";\n}\nprint $g[$x];\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\");\n $f[$e[0]] = \"pushStack\";\n $f[$e[1]] = \"pushQueue\";\n $f[$e[2]] = \"pushFront\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n }\n $d = array();\n $f = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n }\n }\n}\nfor($x = 0; $x < $a - 1; $x++)\n{\n print $g[$x] . \"\\n\";\n}\nprint $g[$x];\n?>"}, {"source_code": "= \"3\")\n {\n arsort($d);\n $e = array_keys($d);\n $f = array_fill(0, count($d), \"pushBack\");\n $f[$e[0]] = \"pushStack\";\n $f[$e[1]] = \"pushQueue\";\n $f[$e[2]] = \"pushFront\";\n array_push($f, \"3 popStack popQueue popFront\");\n $g = array_merge($g, $f);\n }\n $d = array();\n $f = array();\n }\n }\n else\n {\n if($x != $a)\n {\n $d[$c] = $b;\n $c++;\n }\n else\n {\n array_push($d, $b);\n $f = array_fill(0, count($d), \"pushBack\");\n $g = array_merge($g, $f);\n }\n }\n}\nfor($x = 0; $x < $a - 1; $x++)\n{\n print $g[$x] . \"\\n\";\n}\nprint $g[$x];\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n\n/*\n\n pushStack \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0441\u0442\u0435\u043a\u0430;\t\tarray_push ( array &$array , mixed $var\n pushQueue \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438;\tarray_push ( array &$array , mixed $var\n pushFront \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0435\u043a\u0430;\t\tarray_unshift ( array &$array , mixed $var \n pushBack \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0434\u0435\u043a\u0430. \t\tarray_push ( array &$array , mixed $var\n\n popStack \u2014 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u043a\u043e\u043d\u0446\u0430 \u0441\u0442\u0435\u043a\u0430;\t\tarray_pop ( array &$array )\n popQueue \u2014 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438;\tmixed array_shift ( array &$array )\n popFront \u2014 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043a\u0430;\t\tmixed array_shift ( array &$array )\n popBack \u2014 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u043a\u043e\u043d\u0446\u0430 \u0434\u0435\u043a\u0430. \t\tarray_pop ( array &$array )\n\n*/\n\n$x = $f[0];\n\n$stek = $dek = $och = array();\n$q = array('stek'=>0,'dek'=>0,'och'=>0);\n\nfor($i=1;$i<=$x;$i++) {\n\tif ($f[$i]==0) {\n\t\tarsort($q);\n\t\t$comms = 0;\n\t\t$str = '';\n\n\t\tforeach ($q as $var=>$n) if ($n) {\n\t\t\t$comms++;\n\t\t\tswitch ($var) {\n\t\t\t\tcase 'stek':\n\t\t\t\t\t$str .= ' popStack';\n\t\t\t\t\tarray_pop($stek);\n\t\t\t\tbreak;\n\t\t\t\tcase 'dek':\n\t\t\t\t\tif ($dek[0] > $dek[$q['dek']-1]) {\n\t\t\t\t\t\t$str .= ' popFront';\n\t\t\t\t\t\tarray_shift($dek);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$str .= ' popBack';\n\t\t\t\t\t\tarray_pop($dek);\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\tcase 'och':\n\t\t\t\t\t$str .= ' popQueue';\n\t\t\t\t\tarray_shift($och);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t$q[$var]--;\n\t\t}\n\n\t\t$stek = $dek = $och = array();\n\t\t$q = array('stek'=>0,'dek'=>0,'och'=>0);\n\n\n\t\techo $comms.$str.L;\n\t} else {\n\t\tasort($q);\n\t\t$kiss = $f[$i];\n\t\t$var = key($q);\n\n\t\tif ($q[$var]==0) {\n\t\t\tswitch ($var) {\n\t\t\t\tcase 'stek':\n\t\t\t\t\t$str = 'pushStack';\n\t\t\t\t\tarray_push($stek,$kiss);\n\t\t\t\tbreak;\n\t\t\t\tcase 'dek':\n\t\t\t\t\t$str = 'pushFront';\n\t\t\t\t\tarray_unshift($dek,$kiss);\n\t\t\t\tbreak;\n\t\t\t\tcase 'och':\n\t\t\t\t\t$str = 'pushQueue';\n\t\t\t\t\tarray_push($och,$kiss);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t$q[$var]++;\t\t\t\n\t\t} else {\n\n\t\t\tif ($kiss > $stek[$q['stek']-1]) {\n\t\t\t\t$str = 'pushStack';\n\t\t\t\tarray_push($stek,$kiss);\n\t\t\t\t$q['stek']++;\n\t\t\t} else {\n\t\t\t\tif ($kiss < $och[0]) {\n\t\t\t\t\t$str = 'pushQueue';\n\t\t\t\t\tarray_push($och,$kiss);\n\t\t\t\t\t$q['och']++;\n\t\t\t\t} else {\n\t\t\t\t\tif ($kiss > $dek[0] && $kiss > $dek[$q['dek']-1]) {\n\t\t\t\t\t\tif ($dek[0] < $dek[$q['dek']-1]) {\n\t\t\t\t\t\t\tarray_unshift($dek,$kiss);\n\t\t\t\t\t\t\t$str = 'pushFront';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tarray_push($dek,$kiss);\n\t\t\t\t\t\t\t$str = 'pushBack';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} elseif ($kiss > $dek[0] && $kiss < $dek[$q['dek']-1]) {\n\t\t\t\t\t\tarray_unshift($dek,$kiss);\n\t\t\t\t\t\t$str = 'pushFront';\n\t\t\t\t\t} elseif ($kiss < $dek[0] && $kiss > $dek[$q['dek']-1]) {\n\t\t\t\t\t\tarray_push($dek,$kiss);\n\t\t\t\t\t\t$str = 'pushBack';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ($dek[0] < $dek[$q['dek']-1]) {\n\t\t\t\t\t\t\tarray_push($dek,$kiss);\n\t\t\t\t\t\t\t$str = 'pushBack';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tarray_unshift($dek,$kiss);\n\t\t\t\t\t\t\t$str = 'pushFront';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\t$q['dek']++;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\t\n\n\t\techo $str.L;\n\t}\n}\n"}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n\n$x = $f[0];\n\n$stek = $dek = $och = array();\n\n$q = array('stek'=>0,'dek'=>0,'och'=>0);\n\nfor($i=1;$i<=$x;$i++) {\n\tif ($f[$i]==0) {\n\t\tarsort($q);\n\t\t$comms = 0;\n\t\t$str = '';\n\n\t\tforeach ($q as $var=>$n) if ($n) {\n\t\t\t$comms++;\n\t\t\tswitch ($var) {\n\t\t\t\tcase 'stek':\n\t\t\t\t\t$str .= ' popStack';\n\t\t\t\t\tarray_pop($stek);\n\t\t\t\tbreak;\n\t\t\t\tcase 'dek':\n\t\t\t\t\t$str .= ' popBack';\n\t\t\t\t\tarray_pop($dek);\n\t\t\t\tbreak;\n\t\t\t\tcase 'och':\n\t\t\t\t\t$str .= ' popQueue';\n\t\t\t\t\tarray_shift($och);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t$q[$var]--;\n\t\t}\n\n\t\techo $comms.$str.L;\n\t} else {\n\t\tasort($q);\n\t\t$var = key($q);\n\t\tswitch ($var) {\n\t\t\tcase 'stek':\n\t\t\t\t$str = 'pushStack';\n\t\t\t\tarray_push($stek,$var);\n\t\t\tbreak;\n\t\t\tcase 'dek':\n\t\t\t\t$str = 'pushFront';\n\t\t\t\tarray_unshift($dek,$var);\n\t\t\tbreak;\n\t\t\tcase 'och':\n\t\t\t\t$str = 'pushQueue';\n\t\t\t\tarray_push($och,$var);\n\t\t\tbreak;\n\t\t}\n\n\t\t$q[$var]++;\n\n\t\techo $str.L;\n\t}\n}"}, {"source_code": "\n$f = file('php://stdin',FILE_IGNORE_NEW_LINES);\ndefine('L',PHP_EOL);\n//-----------------------\n\n$x = $f[0];\n\n$a = array();\n\n$_in = array('pushQueue','pushStack','pushFront');\n$_out = array(' popQueue',' popStack',' popFront');\n\nfor($i=1;$i<=$x;$i++) {\n\tif ($f[$i]==0) {\n\n\t\t$b = $a;\n\t\tarsort($b);\n\t\t\n\t\t$b = array_keys(array_slice($b,0,3,true));\n\n\t\t$j = 0;\n\n\t\tforeach ($a as $k=>$kiss) {\n\t\t\tif ($j<3 && in_array($k,$b)) {\n\t\t\t\t$str .= $_in[$j++];\n\t\t\t} else {\n\t\t\t\t$str .= 'pushBack';\n\t\t\t}\n\t\t\t$str .= L;\n\t\t}\n\n\t\t$str .= $j;\n\n\t\tfor ($c=0;$c<$j;$c++) {\n\t\t\t$str .= $_out[$c];\n\t\t}\n\n\t\t$str .= L;\n\n\t\t$a = array();\n\n\t} else {\n\t\t$a[] = $f[$i];\n\t}\n}\n\necho $str;"}], "src_uid": "07ae50199dd94f72313ee7675fefadb7"} {"nl": {"description": "Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.This time Miroslav laid out $$$n$$$ skewers parallel to each other, and enumerated them with consecutive integers from $$$1$$$ to $$$n$$$ in order from left to right. For better cooking, he puts them quite close to each other, so when he turns skewer number $$$i$$$, it leads to turning $$$k$$$ closest skewers from each side of the skewer $$$i$$$, that is, skewers number $$$i - k$$$, $$$i - k + 1$$$, ..., $$$i - 1$$$, $$$i + 1$$$, ..., $$$i + k - 1$$$, $$$i + k$$$ (if they exist). For example, let $$$n = 6$$$ and $$$k = 1$$$. When Miroslav turns skewer number $$$3$$$, then skewers with numbers $$$2$$$, $$$3$$$, and $$$4$$$ will come up turned over. If after that he turns skewer number $$$1$$$, then skewers number $$$1$$$, $$$3$$$, and $$$4$$$ will be turned over, while skewer number $$$2$$$ will be in the initial position (because it is turned again).As we said before, the art of cooking requires perfect timing, so Miroslav wants to turn over all $$$n$$$ skewers with the minimal possible number of actions. For example, for the above example $$$n = 6$$$ and $$$k = 1$$$, two turnings are sufficient: he can turn over skewers number $$$2$$$ and $$$5$$$.Help Miroslav turn over all $$$n$$$ skewers.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 1000$$$, $$$0 \\leq k \\leq 1000$$$)\u00a0\u2014 the number of skewers and the number of skewers from each side that are turned in one step.", "output_spec": "The first line should contain integer $$$l$$$\u00a0\u2014 the minimum number of actions needed by Miroslav to turn over all $$$n$$$ skewers. After than print $$$l$$$ integers from $$$1$$$ to $$$n$$$ denoting the number of the skewer that is to be turned over at the corresponding step.", "sample_inputs": ["7 2", "5 1"], "sample_outputs": ["2\n1 6", "2\n1 4"], "notes": "NoteIn the first example the first operation turns over skewers $$$1$$$, $$$2$$$ and $$$3$$$, the second operation turns over skewers $$$4$$$, $$$5$$$, $$$6$$$ and $$$7$$$.In the second example it is also correct to turn over skewers $$$2$$$ and $$$5$$$, but turning skewers $$$2$$$ and $$$4$$$, or $$$1$$$ and $$$5$$$ are incorrect solutions because the skewer $$$3$$$ is in the initial state after these operations."}, "positive_code": [{"source_code": "= $d)\n {\n print \"1\\n\";\n print ($d + 1);\n }\n else\n {\n $e = $b * 2 + 1;\n $f = $a % $e;\n $g = 1;\n print ceil($a / $e) . \"\\n\";\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n $g += ($b * 2) + 1;\n }\n $g -= ($b * 2) + 1;\n $i = $a - $g;\n if($g + $i > $a)\n {\n $g = 1;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n else\n {\n $j = $i - $b + 1;\n if($j <= 0)\n {\n $j = 1;\n }\n $g = $j;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n }\n}\n?>"}], "negative_code": [{"source_code": "= $d)\n {\n print \"1\\n\";\n print ($d + 1);\n }\n else\n {\n $e = $b * 2 + 1;\n $f = $a % $e;\n $g = 1;\n print ceil($a / $e) . \"\\n\";\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n $g += ($b * 2) + 1;\n }\n $g -= ($b * 2) + 1;\n $i = $a - $g;\n if($g + $i >= $a)\n {\n $g = 1;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n else\n {\n $j = $i - $b + 1;\n $g = $j;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n }\n}\n?>"}, {"source_code": "= $d)\n {\n print \"1\\n\";\n print ($d + 1);\n }\n else\n {\n $e = $b * 2 + 1;\n $f = $a % $e;\n $g = 1;\n print ceil($a / $e) . \"\\n\";\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n $g += ($b * 2) + 1;\n }\n $g -= ($b * 2) + 1;\n $i = $a - $g;\n if($g + $i <= $a)\n {\n $g = 1;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n else\n {\n $j = $i - $b;\n $g = $j;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n }\n}\n?>"}, {"source_code": "= $d)\n {\n print \"1\\n\";\n print ($d + 1);\n }\n else\n {\n $e = $b * 2 + 1;\n $f = $a % $e;\n $g = 1;\n print ceil($a / $e) . \"\\n\";\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n $g += ($b * 2) + 1;\n }\n $g -= ($b * 2) + 1;\n $i = $a - $g;\n $j = $i - $b;\n $g = $j;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n}\n?>"}, {"source_code": "= $d)\n {\n print \"1\\n\";\n print ($d + 1);\n }\n else\n {\n $e = $b * 2 + 1;\n $f = $a % $e;\n $g = 1;\n print ceil($a / $e) . \"\\n\";\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n $g += ($b * 2) + 1;\n }\n $g -= ($b * 2) + 1;\n $i = $a - $g;\n if($g + $i > $a)\n {\n $g = 1;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n else\n {\n $j = $i - $b + 1;\n if($j <= 0)\n {\n $j++;\n }\n $g = $j;\n for($x = 1; $x <= ceil($a / $e); $x++)\n {\n print $g . \" \";\n $g += ($b * 2) + 1;\n }\n }\n }\n}\n?>"}], "src_uid": "dfd60a02670749c67b0f96df1a0709b9"} {"nl": {"description": "Ksusha the Squirrel is standing at the beginning of a straight road, divided into n sectors. The sectors are numbered 1 to n, from left to right. Initially, Ksusha stands in sector 1. Ksusha wants to walk to the end of the road, that is, get to sector n. Unfortunately, there are some rocks on the road. We know that Ksusha hates rocks, so she doesn't want to stand in sectors that have rocks.Ksusha the squirrel keeps fit. She can jump from sector i to any of the sectors i\u2009+\u20091,\u2009i\u2009+\u20092,\u2009...,\u2009i\u2009+\u2009k. Help Ksusha! Given the road description, say if she can reach the end of the road (note, she cannot stand on a rock)?", "input_spec": "The first line contains two integers n and k (2\u2009\u2264\u2009n\u2009\u2264\u20093\u00b7105,\u20091\u2009\u2264\u2009k\u2009\u2264\u20093\u00b7105). The next line contains n characters \u2014 the description of the road: the i-th character equals \".\", if the i-th sector contains no rocks. Otherwise, it equals \"#\". It is guaranteed that the first and the last characters equal \".\".", "output_spec": "Print \"YES\" (without the quotes) if Ksusha can reach the end of the road, otherwise print \"NO\" (without the quotes).", "sample_inputs": ["2 1\n..", "5 2\n.#.#.", "7 3\n.#.###."], "sample_outputs": ["YES", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": "= $a - 1)\n {\n $j = 1;\n break;\n }\n}\nif($j == 1)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}, {"source_code": "= $a - 1)\n {\n $j = 1;\n break;\n }\n}\nif($j == 1)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}], "src_uid": "d504d894b2f6a830c4d3b4edc54395be"} {"nl": {"description": "In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment ti and needs to be processed for di units of time. All ti are guaranteed to be distinct.When a query appears server may react in three possible ways: If server is free and query queue is empty, then server immediately starts to process this query. If server is busy and there are less than b queries in the queue, then new query is added to the end of the queue. If server is busy and there are already b queries pending in the queue, then new query is just rejected and will never be processed. As soon as server finished to process some query, it picks new one from the queue (if it's not empty, of course). If a new query comes at some moment x, and the server finishes to process another query at exactly the same moment, we consider that first query is picked from the queue and only then new query appears.For each query find the moment when the server will finish to process it or print -1 if this query will be rejected.", "input_spec": "The first line of the input contains two integers n and b (1\u2009\u2264\u2009n,\u2009b\u2009\u2264\u2009200\u2009000)\u00a0\u2014 the number of queries and the maximum possible size of the query queue. Then follow n lines with queries descriptions (in chronological order). Each description consists of two integers ti and di (1\u2009\u2264\u2009ti,\u2009di\u2009\u2264\u2009109), where ti is the moment of time when the i-th query appears and di is the time server needs to process it. It is guaranteed that ti\u2009-\u20091\u2009<\u2009ti for all i\u2009>\u20091.", "output_spec": "Print the sequence of n integers e1,\u2009e2,\u2009...,\u2009en, where ei is the moment the server will finish to process the i-th query (queries are numbered in the order they appear in the input) or \u2009-\u20091 if the corresponding query will be rejected.", "sample_inputs": ["5 1\n2 9\n4 8\n10 9\n15 2\n19 1", "4 1\n2 8\n4 8\n10 9\n15 2"], "sample_outputs": ["11 19 -1 21 22", "10 18 27 -1"], "notes": "NoteConsider the first sample. The server will start to process first query at the moment 2 and will finish to process it at the moment 11. At the moment 4 second query appears and proceeds to the queue. At the moment 10 third query appears. However, the server is still busy with query 1, b\u2009=\u20091 and there is already query 2 pending in the queue, so third query is just rejected. At the moment 11 server will finish to process first query and will take the second query from the queue. At the moment 15 fourth query appears. As the server is currently busy it proceeds to the queue. At the moment 19 two events occur simultaneously: server finishes to proceed the second query and the fifth query appears. As was said in the statement above, first server will finish to process the second query, then it will pick the fourth query from the queue and only then will the fifth query appear. As the queue is empty fifth query is proceed there. Server finishes to process query number 4 at the moment 21. Query number 5 is picked from the queue. Server finishes to process query number 5 at the moment 22. "}, "positive_code": [{"source_code": " $c[$f])\n {\n $j = $f;\n $k = count($c);\n for($y = $j; $y < $k + $j; $y++)\n {\n if($g < $c[$f])\n {\n if(count($c) <= $b)\n {\n $i += $h;\n $c[$d] = $i;\n $d++;\n print \" \";\n printf(\"%.0f\", $i);\n }\n else\n {\n print \" -1\";\n }\n break;\n }\n elseif($g == $c[$f])\n {\n unset($c[$f]);\n $f++;\n $i += $h;\n $c[$d] = $i;\n $d++;\n print \" \";\n printf(\"%.0f\", $i);\n break;\n }\n elseif($g > $c[$f])\n {\n unset($c[$f]);\n $f++;\n }\n if(count($c) == 0)\n {\n $i = $g + $h;\n $c[$d] = $i;\n $d++;\n print \" \";\n printf(\"%.0f\", $i);\n break;\n }\n }\n }\n }\n}\n?>"}, {"source_code": "=$c_t) {\n\t\t$c_t=bcadd($t, $d);\n\t\t$q=array();\n\t\t$q[]=$c_t;\n\t\t$q_count=1;\n\t\t$head=0;\n\t\t\n\t\t$this_t=$c_t;\n\t\t\n\t} else {\n\t\t//remove finished queries from queue\n\t\twhile($q_count>0 && $q[$head]<=$t) {\n\t\t\tunset($q[$head]);\n\t\t\t$head++;\n\t\t\t$q_count--;\n\t\t}\n\t\t\n\t\tif($q_count===0) {\n\t\t\t$q=array();\n\t\t\t$head=0;\n\t\t}\n\n\t\tif($q_count<$b+1) {\t\n\t\t\t$c_t=bcadd($c_t, $d);\n\t\t\t$q[]=$c_t;\n\t\t\t$q_count++;\n\t\t\t$this_t=$c_t;\n\t\t} else {\n\t\t\t$this_t=-1;\n\t\t}\n\t}\n\t\n\techo $this_t;\n\tif($i<$n-1)\n\t\techo ' ';\n\t\n}"}], "negative_code": [{"source_code": "= $e)\n {\n $c[$x] = $f + $g;\n $e = $f + $g;\n $h[$x] = $e;\n $i = $x;\n }\n else\n {\n $d++;\n $c[$x] = $e + $g;\n $e += $g;\n $h[$x] = $e;\n }\n }\n elseif($d < $b)\n {\n if($f >= $e)\n {\n $d = 0;\n $c[$x] = $f + $g;\n $e = $f + $g;\n $h[$x] = $e;\n $i = $x;\n }\n else\n {\n $d++;\n $c[$x] = $e + $g;\n $e += $g;\n $h[$x] = $e;\n }\n }\n elseif($d == $b)\n {\n if($f < $h[$i])\n {\n $c[$x] = \"-1\";\n }\n elseif(($f >= $h[$i]) && ($f < $h[count($h) - 1]))\n {\n $j = $i;\n while(TRUE)\n {\n if($f < $h[$j])\n {\n break;\n }\n else\n {\n $j++;\n }\n }\n $i = $j;\n if($h[$j - 1] == $f)\n {\n $d += $i;\n }\n $h[$j - 1] = $f;\n $d -= $i;\n $c[$x] = $e + $g;\n $e += $g;\n }\n elseif($f >= $h[count($h) - 1])\n {\n $d = 0;\n $c[$x] = $f + $g;\n $e = $f + $g;\n $h[$x] = $e;\n $i = $x;\n }\n }\n elseif($d > $b)\n {\n $c[$x] = \"-1\";\n }\n}\nprint implode(\" \", $c);\n?>"}, {"source_code": " $c[$f])\n {\n $j = $f;\n $k = $c;\n for($y = $j; $y < count($k) + $j; $y++)\n {\n if($g < $c[$f])\n {\n if(count($c) <= $b)\n {\n $i += $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n }\n else\n {\n $e .= \"-1 \";\n }\n }\n elseif($g == $c[$f])\n {\n unset($c[$f]);\n $f++;\n $i += $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n break;\n }\n elseif($g > $c[$f])\n {\n unset($c[$f]);\n $f++;\n }\n if(count($c) == 0)\n {\n $i = $g + $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n break;\n }\n }\n }\n }\n}\nprint trim($e);\n?>"}, {"source_code": " $c[$f])\n {\n $j = $f;\n $k = count($c);\n for($y = $j; $y < $k + $j; $y++)\n {\n if($g < $c[$f])\n {\n if(count($c) <= $b)\n {\n $i += $h;\n $c[$d] = $i;\n $d++;\n print \" \" . $i;\n }\n else\n {\n print \" -1\";\n }\n break;\n }\n elseif($g == $c[$f])\n {\n unset($c[$f]);\n $f++;\n $i += $h;\n $c[$d] = $i;\n $d++;\n print \" \" . $i;\n break;\n }\n elseif($g > $c[$f])\n {\n unset($c[$f]);\n $f++;\n }\n if(count($c) == 0)\n {\n $i = $g + $h;\n $c[$d] = $i;\n $d++;\n print \" \" . $i;\n break;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $c[$f])\n {\n $j = $f;\n $k = $c;\n for($y = $j; $y < count($k) + $j; $y++)\n {\n if($g < $c[$f])\n {\n if(count($c) <= $b)\n {\n $i += $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n }\n else\n {\n $e .= \"-1 \";\n }\n }\n elseif($g == $c[$f])\n {\n unset($c[$f]);\n $f++;\n $i += $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n }\n elseif($g > $c[$f])\n {\n unset($c[$f]);\n $f++;\n }\n if(count($c) == 0)\n {\n $i = $g + $h;\n $c[$d] = $i;\n $d++;\n $e .= $i . \" \";\n break;\n }\n }\n }\n }\n}\nprint trim($e);\n?>"}, {"source_code": "=$c_t) {\n\t\t$c_t=$t+$d;\n\t\t$q=array();\n\t\t$q[]=$c_t;\n\t\t$q_count=1;\n\t\t$head=0;\n\t\t\n\t\t$this_t=$c_t;\n\t\t\n\t} else {\n\t\t//remove finished queries from queue\n\t\twhile($q_count>0 && $q[$head]<=$t) {\n\t\t\tunset($q[$head]);\n\t\t\t$head++;\n\t\t\t$q_count--;\n\t\t}\n\t\t\n\t\tif($q_count===0) {\n\t\t\t$q=array();\n\t\t\t$head=0;\n\t\t}\n\n\t\tif($q_count<$b+1) {\t\n\t\t\t$c_t=$c_t+$d;\n\t\t\t$q[]=$c_t;\n\t\t\t$q_count++;\n\t\t\t$this_t=$c_t;\n\t\t} else {\n\t\t\t$this_t=-1;\n\t\t}\n\t}\n\t\n\techo $this_t;\n\tif($i<$n-1)\n\t\techo ' ';\n\t\n}"}], "src_uid": "5981594b2d6d1077ce2249b641d18f10"} {"nl": {"description": "In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems for her. Namely, the Olympiad number i should be prepared by pi people for ti days, the preparation for the Olympiad should be a continuous period of time and end exactly one day before the Olympiad. On the day of the Olympiad the juries who have prepared it, already do not work on it.For example, if the Olympiad is held on December 9th and the preparation takes 7 people and 6 days, all seven members of the jury will work on the problems of the Olympiad from December, 3rd to December, 8th (the jury members won't be working on the problems of this Olympiad on December 9th, that is, some of them can start preparing problems for some other Olympiad). And if the Olympiad is held on November 3rd and requires 5 days of training, the members of the jury will work from October 29th to November 2nd.In order not to overload the jury the following rule was introduced: one member of the jury can not work on the same day on the tasks for different Olympiads. Write a program that determines what the minimum number of people must be part of the jury so that all Olympiads could be prepared in time.", "input_spec": "The first line contains integer n \u2014 the number of Olympiads in 2013 (1\u2009\u2264\u2009n\u2009\u2264\u2009100). Each of the following n lines contains four integers mi, di, pi and ti \u2014 the month and day of the Olympiad (given without leading zeroes), the needed number of the jury members and the time needed to prepare the i-th Olympiad (1\u2009\u2264\u2009mi\u2009\u2264\u200912, di\u2009\u2265\u20091, 1\u2009\u2264\u2009pi,\u2009ti\u2009\u2264\u2009100), di doesn't exceed the number of days in month mi. The Olympiads are given in the arbitrary order. Several Olympiads can take place in one day. Use the modern (Gregorian) calendar in the solution. Note that all dates are given in the year 2013. This is not a leap year, so February has 28 days. Please note, the preparation of some Olympiad can start in 2012 year.", "output_spec": "Print a single number \u2014 the minimum jury size.", "sample_inputs": ["2\n5 23 1 2\n3 13 2 3", "3\n12 9 2 1\n12 8 1 3\n12 8 2 2", "1\n1 10 1 13"], "sample_outputs": ["2", "3", "1"], "notes": null}, "positive_code": [{"source_code": "= 1 && $t <= 1000)\r\n{break;}}\r\n$tab = array();for($i=0;$i<$t;$i++){$tab[$i] = (string)readline(); }\r\n/* $t = 4;\r\n $tab = array(\"aaaab\",\"aabbbabaa\",\"abbb\",\"abbaab\");*/\r\n $ab = array();$ba= array();\r\n for($i=0;$i<$t;$i++)\r\n {$ab[$i] = 0;$ba[$i]=0;\r\n for($j=0;$j $ba[$i]){\r\n if($tab[$i][$j] ==\"a\"&&$tab[$i][$j+1]==\"b\")\r\n {$tab[$i][$j]=\"b\";}\r\n elseif($tab[$i][intval(strlen($tab[$i]))-1]==\"b\") {\r\n $tab[$i][intval(strlen($tab[$i]))-1]=\"a\";\r\n }\r\n $ab[$i]--;\r\n } \r\n while($ba[$i]>$ab[$i]){\r\n if($tab[$i][$j] ==\"b\"&&$tab[$i][$j+1]==\"a\")\r\n {$tab[$i][$j]=\"a\";}\r\n elseif($tab[$i][intval(strlen($tab[$i]))-1]==\"a\") {\r\n $tab[$i][intval(strlen($tab[$i]))-1]=\"b\";\r\n }\r\n $ba[$i]--;}\r\n \r\n }}\r\n \r\n for($i=0;$i<$t;$i++){\r\n echo $tab[$i].\"\\n\";\r\n }\r\n \r\n?>\r\n\r\n"}], "negative_code": [{"source_code": "= 1 && $t <= 1000)\r\n{break;}}\r\n$tab = array();for($i=0;$i<$t;$i++){$tab[$i] = (string)readline(); }\r\n /*$t = 4;\r\n $tab = array(\"b\",\"aabbbabaa\",\"abbb\",\"abbaab\");*/\r\n $ab = array();$ba= array();\r\n for($i=0;$i<$t;$i++)\r\n {$ab[$i] = 0;$ba[$i]=0;\r\n for($j=0;$j $ba[$i]){\r\n if($tab[$i][$j] ==\"a\"&&$tab[$i][$j+1]==\"b\"){$tab[$i][$j]=\"b\";}\r\n $ab[$i]--;\r\n } \r\n while($ba[$i]>$ab[$i]){\r\n if($tab[$i][$j] ==\"b\"&&$tab[$i][$j+1]==\"a\"){$tab[$i][$j]=\"a\";}\r\n $ba[$i]--;}}}\r\n \r\n for($i=0;$i<$t;$i++){\r\n echo $tab[$i].\"\\n\";\r\n }\r\n \r\n?>\r\n\r\n"}, {"source_code": "= 1 && $t <= 1000)\r\n{break;}}\r\n$tab = array();for($i=0;$i<$t;$i++){$tab[$i] = (string)readline(); }\r\n /*$t = 4;\r\n $tab = array(\"b\",\"aabbabaa\",\"abbb\",\"abbaab\");*/\r\n for($i=0;$i<$t;$i++)\r\n {$ab = 0;$ba=0;\r\n for($j=0;$j $ba){\r\n if($tab[$i][$j] ==\"a\"&&$tab[$i][$j+1]==\"b\"){$tab[$i][$j]=\"b\";}\r\n $ab--;\r\n } \r\n while($ba>$ab){\r\n if($tab[$i][$j] ==\"b\"&&$tab[$i][$j+1]==\"a\"){$tab[$i][$j]=\"a\";}\r\n $ba--;}\r\n } \r\n for($i=0;$i<$t;$i++){\r\n echo $tab[$i].\"\\n\";\r\n }\r\n \r\n?>\r\n\r\n"}], "src_uid": "351ffff1dfe1bc1762f062f612463759"} {"nl": {"description": "Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three a,\u2009b,\u2009c the following conditions held: a\u2009<\u2009b\u2009<\u2009c; a divides b, b divides c. Naturally, Xenia wants each element of the sequence to belong to exactly one group of three. Thus, if the required partition exists, then it has groups of three.Help Xenia, find the required partition or else say that it doesn't exist.", "input_spec": "The first line contains integer n (3\u2009\u2264\u2009n\u2009\u2264\u200999999) \u2014 the number of elements in the sequence. The next line contains n positive integers, each of them is at most 7. It is guaranteed that n is divisible by 3.", "output_spec": "If the required partition exists, print groups of three. Print each group as values of the elements it contains. You should print values in increasing order. Separate the groups and integers in groups by whitespaces. If there are multiple solutions, you can print any of them. If there is no solution, print -1.", "sample_inputs": ["6\n1 1 1 2 2 2", "6\n2 2 1 1 4 6"], "sample_outputs": ["-1", "1 2 4\n1 2 6"], "notes": null}, "positive_code": [{"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$g = 0;\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\nif(($g == 0) && (array_sum($c) == 0))\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 6 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\n$g = 0;\nif($c[1] != 0)\n{\n $g = 1;\n}\nif($c[2] != 0)\n{\n $g = 1;\n}\nif($c[3] != 0)\n{\n $g = 1;\n}\nif($c[4] != 0)\n{\n $g = 1;\n}\nif($c[6] != 0)\n{\n $g = 1;\n}\nif($g == 0)\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 6 => 0, 7 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\n$g = 0;\nif($c[1] != 0)\n{\n $g = 1;\n}\nif($c[2] != 0)\n{\n $g = 1;\n}\nif($c[3] != 0)\n{\n $g = 1;\n}\nif($c[4] != 0)\n{\n $g = 1;\n}\nif($c[6] != 0)\n{\n $g = 1;\n}\nif($c[7] != 0)\n{\n $g = 1;\n}\nif($g == 0)\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$g = 0;\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\nif(($g == 0) && ($d != 0) && ($e != 0) && ($f != 0))\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$g = 0;\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\nif($c[1] < 0)\n{\n $g = 1;\n}\nif($c[2] < 0)\n{\n $g = 1;\n}\nif($c[3] < 0)\n{\n $g = 1;\n}\nif($c[4] < 0)\n{\n $g = 1;\n}\nif($c[5] < 0)\n{\n $g = 1;\n}\nif($c[6] < 0)\n{\n $g = 1;\n}\nif($c[7] < 0)\n{\n $g = 1;\n}\nif($g == 0)\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0, 2 => 0, 3 => 0, 4 => 0, 6 => 0);\nfor($x = 0; $x < $a; $x++)\n{\n $c[$b[$x]]++;\n}\n$d = $c[4];\n$c[1] -= $c[4];\n$c[2] -= $c[4];\n$c[4] -= $c[4];\n$e = $c[3];\n$c[1] -= $c[3];\n$c[6] -= $c[3];\n$c[3] -= $c[3];\n$f = $c[1];\n$c[2] -= $c[1];\n$c[6] -= $c[1];\n$c[1] -= $c[1];\n$g = array_sum($c);\nif($g == 0)\n{\n for($x = 1; $x <= $d; $x++)\n {\n print \"1 2 4\\n\";\n }\n for($x = 1; $x <= $e; $x++)\n {\n print \"1 3 6\\n\";\n }\n for($x = 1; $x <= $f; $x++)\n {\n print \"1 2 6\\n\";\n }\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": "= 0) && ($i >= 0))\n{\n $j = 1;\n}\nelseif(($h < 0) && ($i < 0))\n{\n $j = 2;\n}\nelseif(($h >= 0) && ($i < 0))\n{\n $j = 3;\n}\nelseif(($h < 0) && ($i >= 0))\n{\n $j = 4;\n}\nif($h == 0)\n{\n $k = 1;\n}\nif($i == 0)\n{\n $l = 1;\n}\nfor($x = 1; $x <= $a; $x++)\n{\n if($j == 1)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 2)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 3)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 4)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n}\nif($n == 1)\n{\n print $m;\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0) {$e = $xd;} else {$w = -$xd;}\nif ($yd > 0) {$n = $yd;} else {$s = -$yd;}\n\n$raw = g();\n$str = $raw[0];\nfor ($i = 0; $i < $t; $i++) {\n\t$wind = substr($str, $i, 1);\n\tswitch ($wind) {\n\t\tcase \"N\":\n\t\t\t$n--;\n\t\t\tbreak;\n\t\tcase \"E\":\n\t\t\t$e--;\n\t\t\tbreak;\n\t\tcase \"S\":\n\t\t\t$s--;\n\t\t\tbreak;\n\t\tcase \"W\":\n\t\t\t$w--;\n\t\t\tbreak;\n\t}\n\tif (check()) {\n\t\techo $i+1;\n\t\texit;\n\t}\n}\necho \"-1\";\n\nfunction check() {\n\tglobal $n, $e, $s, $w;\n\tif (($n <= 0) && ($e <= 0) && ($s <= 0) && ($w <= 0)) {return true;} else {return false;}\n}\n\n// End of submission file\n// Submission by chaotic_iak\n?>"}, {"source_code": " 0)\n $exp[1]++;\n break;\n case 'S':\n if($exp[2] - $exp[4] > 0)\n $exp[2]--;\n break;\n case 'W':\n if($exp[1] - $exp[3] > 0)\n $exp[1]--;\n break;\n case 'N':\n if($exp[4] - $exp[2] > 0)\n $exp[2]++;\n break;\n }\n if($exp[1] == $exp[3] && $exp[2] == $exp[4]){\n echo $i + 1;\n exit;\n }\n}\necho -1;\nexit;"}, {"source_code": " 0, \n 'W' => 0, \n 'E' => 0,\n 'N' => 0\n );\n $c = 1;\n $flag = TRUE;\n if(check($sx, $sy, $ex, $ey, $cnt)){\n echo 0;\n exit;\n }\n foreach($arr as $a){\n\n $cnt[$a] += 1;\n if(check($sx, $sy, $ex, $ey,$cnt)){\n $flag = FALSE;\n break;\n }\n $c++;\n }\n \n if($flag == TRUE){\n echo -1;\n }\n else{\n echo $c;\n }\n\n function check($sx, $sy, $ex, $ey, $cnt){\n \n $flag1 = FALSE;\n $flag2 = FALSE;\n if($ex - $sx >= 0 && $cnt['E'] >= ($ex - $sx)){\n\n $flag1 = TRUE;\n }\n if($sx - $ex >= 0 && $cnt['W'] >= ($sx - $ex)){\n \n $flag1 = TRUE;\n }\n\n if($ey - $sy >= 0 && $cnt['N'] >= ($ey - $sy)){\n\n $flag2 = TRUE;\n }\n if($sy - $ey >= 0 && $cnt['S'] >= ($sy - $ey)){\n \n $flag2 = TRUE;\n }\n\n if($flag1 && $flag2) return TRUE;\n return FALSE;\n }\n?>\n"}], "negative_code": [{"source_code": "= 0) && ($i >= 0))\n{\n $j = 1;\n}\nelseif(($h < 0) && ($i < 0))\n{\n $j = 2;\n}\nelseif(($h >= 0) && ($i < 0))\n{\n $j = 3;\n}\nelseif(($h < 0) && ($i >= 0))\n{\n $j = 4;\n}\nif($h == 0)\n{\n $k = 1;\n}\nif($i == 0)\n{\n $l = 1;\n}\nfor($x = 1; $x <= $a; $x++)\n{\n if($j == 1)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 2)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 3)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 4)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n}\nif($n == 1)\n{\n print $m;\n}\nelse\n{\n print $m;\n}\n?>"}, {"source_code": "= 0) && ($i >= 0))\n{\n $j = 1;\n}\nelseif(($h < 0) && ($i < 0))\n{\n $j = 2;\n}\nelseif(($h >= 0) && ($i < 0))\n{\n $j = 3;\n}\nelseif(($h < 0) && ($i >= 0))\n{\n $j = 4;\n}\nfor($x = 1; $x <= $a; $x++)\n{\n if($j == 1)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 2)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 3)\n {\n if(($g[$x] == \"E\") && ($k == 0))\n {\n $h--;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"S\") && ($l == 0))\n {\n $i++;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n elseif($j == 4)\n {\n if(($g[$x] == \"W\") && ($k == 0))\n {\n $h++;\n if($h == 0)\n {\n $k = 1;\n }\n }\n elseif(($g[$x] == \"N\") && ($l == 0))\n {\n $i--;\n if($i == 0)\n {\n $l = 1;\n }\n }\n if(($k == 1) && ($l == 1))\n {\n $m = $x;\n $n = 1;\n break;\n }\n }\n}\nif($n == 1)\n{\n print $m;\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0) {$e = $xd;} else {$w = -$xd;}\nif ($yd > 0) {$n = $yd;} else {$s = -$yd;}\n\n$raw = g();\n$str = $raw[0];\nfor ($i = 0; $i < $t; $i++) {\n\t$wind = substr($str, $i, 1);\n\tswitch ($wind) {\n\t\tcase \"N\":\n\t\t\t$n--;\n\t\t\tbreak;\n\t\tcase \"E\":\n\t\t\t$e--;\n\t\t\tbreak;\n\t\tcase \"S\":\n\t\t\t$s--;\n\t\t\tbreak;\n\t\tcase \"W\":\n\t\t\t$w--;\n\t\t\tbreak;\n\t}\n\tif (check()) {\n\t\techo $i+1;\n\t\texit;\n\t}\n}\necho \"-1\";\necho \"\\n $n $e $s $w\";\n\nfunction check() {\n\tglobal $n, $e, $s, $w;\n\tif (($n <= 0) && ($e <= 0) && ($s <= 0) && ($w <= 0)) {return true;} else {return false;}\n}\n\n// End of submission file\n// Submission by chaotic_iak\n?>"}, {"source_code": " 0)\n $exp[1]++;\n break;\n case 'S':\n if($exp[2] - $exp[4] > 0)\n $exp[2]++;\n break;\n case 'W':\n if($exp[1] - $exp[3] > 0)\n $exp[1]++;\n break;\n case 'N':\n if($exp[4] - $exp[2] > 0)\n $exp[2]++;\n break;\n }\n if($exp[1] == $exp[3] && $exp[2] == $exp[4]){\n echo $i + 1;\n exit;\n }\n}\necho -1;\nexit;"}, {"source_code": " 0)\n $exp[1]++;\n break;\n case 'S':\n if($exp[2] - $exp[4] > 0)\n $exp[2]++;\n break;\n case 'W':\n if($exp[1] - $exp[3] > 0)\n $exp[1]++;\n break;\n case 'N':\n if($exp[4] - $exp[2] > 0)\n $exp[2]++;\n break;\n }\n if($exp[1] == $exp[3] && $exp[2] == $exp[4]){\n echo $i + 1;\n exit;\n }\n}\necho -1;\nexit;"}, {"source_code": " 0, \n 'W' => 0, \n 'E' => 0,\n 'N' => 0\n );\n $c = 0;\n $flag = TRUE;\n foreach($arr as $a){\n\n if(check($sx, $sy, $ex, $ey,$cnt)){\n $flag = FALSE;\n break;\n }\n $cnt[$a] += 1;\n $c++;\n }\n \n if($flag == TRUE){\n echo -1;\n }\n else{\n echo $c;\n }\n\n function check($sx, $sy, $ex, $ey, $cnt){\n \n $flag1 = FALSE;\n $flag2 = FALSE;\n if($ex - $sx >= 0 && $cnt['E'] >= ($ex - $sx)){\n\n $flag1 = TRUE;\n }\n if($sx - $ex >= 0 && $cnt['W'] >= ($sx - $ex)){\n \n $flag1 = TRUE;\n }\n\n if($ey - $sy >= 0 && $cnt['N'] >= ($ey - $sy)){\n\n $flag2 = TRUE;\n }\n if($sy - $ey >= 0 && $cnt['S'] >= ($sy - $ey)){\n \n $flag2 = TRUE;\n }\n\n if($flag1 && $flag2) return TRUE;\n return FALSE;\n }\n?>\n"}, {"source_code": " 0, \n 'W' => 0, \n 'E' => 0,\n 'N' => 0\n );\n $c = 1;\n $flag = TRUE;\n foreach($arr as $a){\n\n $cnt[$a] += 1;\n if(check($sx, $sy, $ex, $ey,$cnt)){\n $flag = FALSE;\n break;\n }\n $c++;\n }\n \n if($flag == TRUE){\n echo -1;\n }\n else{\n echo $c;\n }\n\n function check($sx, $sy, $ex, $ey, $cnt){\n \n $flag1 = FALSE;\n $flag2 = FALSE;\n if($ex - $sx > 0 && $cnt['E'] >= ($ex - $sx)){\n\n $flag1 = TRUE;\n }\n if($sx - $ex > 0 && $cnt['W'] >= ($sx - $ex)){\n \n $flag1 = TRUE;\n }\n\n if($ey - $sy > 0 && $cnt['N'] >= ($ey - $sy)){\n\n $flag2 = TRUE;\n }\n if($sy - $ey > 0 && $cnt['S'] >= ($sy - $ey)){\n \n $flag2 = TRUE;\n }\n\n if($flag1 && $flag2) return TRUE;\n return FALSE;\n }\n?>\n"}], "src_uid": "aa31a2a1ad1575aee051ddee8642c53a"} {"nl": {"description": "Xenia the vigorous detective faced n (n\u2009\u2265\u20092) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right. Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the note to one of his neighbours in the row. In other words, if this spy's number is x, he can pass the note to another spy, either x\u2009-\u20091 or x\u2009+\u20091 (if x\u2009=\u20091 or x\u2009=\u2009n, then the spy has only one neighbour). Also during a step the spy can keep a note and not pass it to anyone.But nothing is that easy. During m steps Xenia watches some spies attentively. Specifically, during step ti (steps are numbered from 1) Xenia watches spies numbers li,\u2009li\u2009+\u20091,\u2009li\u2009+\u20092,\u2009...,\u2009ri (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009n). Of course, if during some step a spy is watched, he can't do anything: neither give the note nor take it from some other spy. Otherwise, Xenia reveals the spies' cunning plot. Nevertheless, if the spy at the current step keeps the note, Xenia sees nothing suspicious even if she watches him.You've got s and f. Also, you have the steps during which Xenia watches spies and which spies she is going to watch during each step. Find the best way the spies should act in order to pass the note from spy s to spy f as quickly as possible (in the minimum number of steps).", "input_spec": "The first line contains four integers n, m, s and f (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105;\u00a01\u2009\u2264\u2009s,\u2009f\u2009\u2264\u2009n;\u00a0s\u2009\u2260\u2009f;\u00a0n\u2009\u2265\u20092). Each of the following m lines contains three integers ti,\u2009li,\u2009ri (1\u2009\u2264\u2009ti\u2009\u2264\u2009109,\u20091\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009n). It is guaranteed that t1\u2009<\u2009t2\u2009<\u2009t3\u2009<\u2009...\u2009<\u2009tm.", "output_spec": "Print k characters in a line: the i-th character in the line must represent the spies' actions on step i. If on step i the spy with the note must pass the note to the spy with a lesser number, the i-th character should equal \"L\". If on step i the spy with the note must pass it to the spy with a larger number, the i-th character must equal \"R\". If the spy must keep the note at the i-th step, the i-th character must equal \"X\". As a result of applying the printed sequence of actions spy s must pass the note to spy f. The number of printed characters k must be as small as possible. Xenia must not catch the spies passing the note. If there are miltiple optimal solutions, you can print any of them. It is guaranteed that the answer exists.", "sample_inputs": ["3 5 1 3\n1 1 2\n2 2 3\n3 3 3\n4 1 1\n10 1 3"], "sample_outputs": ["XXRR"], "notes": null}, "positive_code": [{"source_code": "= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f < $i)\n {\n $f2 = $f;\n $f += $i - $f;\n for($y = $f2; $y < $i; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n break;\n }\n }\n if($c == $d)\n {\n break;\n }\n if((($c >= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n if($c == $d)\n {\n break;\n }\n}\nif($c != $d)\n{\n $m = abs($c - $d);\n for($x = 1; $x <= $m; $x++)\n {\n $c += $h;\n $e .= $g;\n }\n}\nprint $e;\n?>"}, {"source_code": "= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f < $i)\n {\n $f2 = $f;\n $f += $i - $f;\n for($y = $f2; $y < $i; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n break;\n }\n }\n if($c == $d)\n {\n break;\n }\n if((($c >= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f > $i)\n {\n $l = 1;\n }\n if($c == $d)\n {\n break;\n }\n}\nif($l == 1)\n{\n $l = 0;\n $f += $i - $i2 - 1;\n for($y = $i2; $y < $f; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n $l = 2;\n break;\n }\n }\n}\nif($c != $d)\n{\n $m = abs($c - $d);\n for($x = 1; $x <= $m; $x++)\n {\n $c += $h;\n $e .= $g;\n }\n}\nprint $e;\n?>"}, {"source_code": " $f) ? -1 : 1;\n$pt = 0;\n$time = 1;\nwhile ($s != $f) {\n\tif ($t[$pt] != $time) {$s += $dir; $res .= ($dir < 0) ? \"L\" : \"R\"; $time++;} else {\n\t\tif ((($l[$pt] <= $s) && ($s <= $r[$pt])) || (($l[$pt] <= $s+$dir) && ($s+$dir <= $r[$pt]))) {$res .= \"X\";} else {$s += $dir; $res .= ($dir < 0) ? \"L\" : \"R\";}\n\t\t$pt++; $time++;\n\t}\n}\necho $res;"}], "negative_code": [{"source_code": "= min($g, $h)) && (($c + 1) <= max($g, $h)))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n break;\n }\n }\n }\n else\n {\n if((($d - 1) >= min($g, $h)) && (($d - 1) <= max($g, $h)))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n break;\n }\n }\n }\n }\n else\n {\n $i = 0;\n for($y = $x; $y < $f; $y++)\n {\n if($c < $d)\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n $i = 1;\n break;\n }\n }\n }\n if($i == 1)\n {\n break;\n }\n else\n {\n $x = $f - 1;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": "= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f < $i)\n {\n $f2 = $f;\n $f += $i - $f;\n for($y = $f2; $y < $i; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n break;\n }\n }\n if((($c >= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f > $i)\n {\n $l = 1;\n }\n if($c == $d)\n {\n break;\n }\n}\nif($l == 1)\n{\n $l = 0;\n $f += $i - $i2 - 1;\n for($y = $i2; $y < $f; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n $l = 2;\n break;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": "= min($g, $h)) && (($c + 1) <= max($g, $h)))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n break;\n }\n }\n }\n else\n {\n if((($d + 1) >= min($g, $h)) && (($d + 1) <= max($g, $h)))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n break;\n }\n }\n }\n }\n else\n {\n $i = 0;\n for($y = $x; $y < $f; $y++)\n {\n if($c < $d)\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n $i = 1;\n break;\n }\n }\n }\n if($i == 1)\n {\n break;\n }\n else\n {\n $x = $f - 1;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": "= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f < $i)\n {\n $f2 = $f;\n $f += $i - $f;\n for($y = $f2; $y < $i; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n break;\n }\n }\n if($c == $d)\n {\n break;\n }\n if((($c >= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n elseif($f > $i)\n {\n $l = 1;\n }\n if($c == $d)\n {\n break;\n }\n}\nif($l == 1)\n{\n $l = 0;\n $f += $i - $i2 - 1;\n for($y = $i2; $y < $f; $y++)\n {\n $c += $h;\n $e .= $g;\n if($c == $d)\n {\n $l = 2;\n break;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": "= min($g, $h)) && ($c <= max($g, $h))) || ((($c + 1) >= min($g, $h)) && (($c + 1) <= max($g, $h))))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n break;\n }\n }\n }\n else\n {\n if(((($d >= min($g, $h)) && ($d <= max($g, $h)))) || ((($d + 1) >= min($g, $h)) && (($d + 1) <= max($g, $h))))\n {\n $e .= \"X\";\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n break;\n }\n }\n }\n }\n else\n {\n $i = 0;\n for($y = $x; $y < $f; $y++)\n {\n if($c < $d)\n {\n $e .= \"R\";\n $c++;\n if($c == $d)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n $e .= \"L\";\n $d--;\n if($d == $d)\n {\n $i = 1;\n break;\n }\n }\n }\n if($i == 1)\n {\n break;\n }\n else\n {\n $x = $f - 1;\n }\n }\n}\nprint $e;\n?>"}, {"source_code": "= $j) && ($c <= $k)) || (($c + $h >= $j) && ($c + $h <= $k)))\n {\n $e .= \"X\";\n }\n else\n {\n $c += $h;\n $e .= $g;\n }\n $f++;\n }\n else\n {\n $l = 1;\n }\n if($c == $d)\n {\n break;\n }\n}\nprint $e;\n?>"}], "src_uid": "c1c9815e2274a1f147eab7bd8ee2d574"} {"nl": {"description": "Hongcow likes solving puzzles.One day, Hongcow finds two identical puzzle pieces, with the instructions \"make a rectangle\" next to them. The pieces can be described by an n by m grid of characters, where the character 'X' denotes a part of the puzzle and '.' denotes an empty part of the grid. It is guaranteed that the puzzle pieces are one 4-connected piece. See the input format and samples for the exact details on how a jigsaw piece will be specified.The puzzle pieces are very heavy, so Hongcow cannot rotate or flip the puzzle pieces. However, he is allowed to move them in any directions. The puzzle pieces also cannot overlap.You are given as input the description of one of the pieces. Determine if it is possible to make a rectangle from two identical copies of the given input. The rectangle should be solid, i.e. there should be no empty holes inside it or on its border. Keep in mind that Hongcow is not allowed to flip or rotate pieces and they cannot overlap, i.e. no two 'X' from different pieces can share the same position.", "input_spec": "The first line of input will contain two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009500), the dimensions of the puzzle piece. The next n lines will describe the jigsaw piece. Each line will have length m and will consist of characters '.' and 'X' only. 'X' corresponds to a part of the puzzle piece, '.' is an empty space. It is guaranteed there is at least one 'X' character in the input and that the 'X' characters form a 4-connected region.", "output_spec": "Output \"YES\" if it is possible for Hongcow to make a rectangle. Output \"NO\" otherwise.", "sample_inputs": ["2 3\nXXX\nXXX", "2 2\n.X\nXX", "5 5\n.....\n..X..\n.....\n.....\n....."], "sample_outputs": ["YES", "NO", "YES"], "notes": "NoteFor the first sample, one example of a rectangle we can form is as follows 111222111222For the second sample, it is impossible to put two of those pieces without rotating or flipping to form a rectangle.In the third sample, we can shift the first tile by one to the right, and then compose the following rectangle: .......XX................"}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "b395be2597f4cc0478bc45f774fa1c01"} {"nl": {"description": "Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element that is equal to the required one, the search ends. The efficiency of the algorithm is the number of performed comparisons. The fewer comparisons the linear search has made, the more effective it is.Vasya believes that a linear search would work better if it sequentially iterates through the elements, starting with the 1-st one (in this problem we consider the elements of the array indexed from 1 to n) and ending with the n-th one. And Petya says that Vasya is wrong: the search will need less comparisons if it sequentially iterates the elements starting from the n-th and ending with the 1-st one. Sasha argues that the two approaches are equivalent.To finally begin the task, the teammates decided to settle the debate and compare the two approaches on an example. For this, they took an array that is a permutation of integers from 1 to n, and generated m queries of the form: find element with value bi in the array. They want to calculate for both approaches how many comparisons in total the linear search will need to respond to all queries. If the first search needs fewer comparisons, then the winner of the dispute is Vasya. If the second one does, then the winner is Petya. If both approaches make the same number of comparisons, then Sasha's got the upper hand.But the problem is, linear search is too slow. That's why the boys aren't going to find out who is right before the end of the training, unless you come in here. Help them to determine who will win the dispute.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of elements in the array. The second line contains n distinct space-separated integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n) \u2014 the elements of array. The third line contains integer m (1\u2009\u2264\u2009m\u2009\u2264\u2009105) \u2014 the number of queries. The last line contains m space-separated integers b1,\u2009b2,\u2009...,\u2009bm (1\u2009\u2264\u2009bi\u2009\u2264\u2009n) \u2014 the search queries. Note that the queries can repeat.", "output_spec": "Print two integers, showing how many comparisons Vasya's approach needs and how many comparisons Petya's approach needs. Separate the numbers by spaces. Please, do not use the %lld specifier to read or write 64-bit integers in \u0421++. It is preferred to use cin, cout streams or the %I64d specifier.", "sample_inputs": ["2\n1 2\n1\n1", "2\n2 1\n1\n1", "3\n3 1 2\n3\n1 2 3"], "sample_outputs": ["1 2", "2 1", "6 6"], "notes": "NoteIn the first sample Vasya's approach will make one comparison (it starts with the 1-st element and immediately finds the required number), and Petya's approach makes two comparisons (first he compares with the 2-nd array element, doesn't find the search item and compares with the 1-st element).In the second sample, on the contrary, Vasya's approach will need two comparisons (first with 1-st element, and then with the 2-nd), and Petya's approach will find the required value in one comparison (the first comparison with the 2-nd element)."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "0903a40d72c19a9d1cc1147d01ea94a7"} {"nl": {"description": "John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.There are $$$n$$$ students, each of them has a unique id (from $$$1$$$ to $$$n$$$). Thomas's id is $$$1$$$. Every student has four scores correspond to his or her English, German, Math, and History scores. The students are given in order of increasing of their ids.In the table, the students will be sorted by decreasing the sum of their scores. So, a student with the largest sum will get the first place. If two or more students have the same sum, these students will be sorted by increasing their ids. Please help John find out the rank of his son. ", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 1000$$$)\u00a0\u2014 the number of students. Each of the next $$$n$$$ lines contains four integers $$$a_i$$$, $$$b_i$$$, $$$c_i$$$, and $$$d_i$$$ ($$$0\\leq a_i, b_i, c_i, d_i\\leq 100$$$)\u00a0\u2014 the grades of the $$$i$$$-th student on English, German, Math, and History. The id of the $$$i$$$-th student is equal to $$$i$$$.", "output_spec": "Print the rank of Thomas Smith. Thomas's id is $$$1$$$.", "sample_inputs": ["5\n100 98 100 100\n100 100 100 100\n100 100 99 99\n90 99 90 100\n100 98 60 99", "6\n100 80 90 99\n60 60 60 60\n90 60 100 60\n60 100 60 80\n100 100 0 100\n0 0 0 0"], "sample_outputs": ["2", "1"], "notes": "NoteIn the first sample, the students got total scores: $$$398$$$, $$$400$$$, $$$398$$$, $$$379$$$, and $$$357$$$. Among the $$$5$$$ students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is $$$2$$$.In the second sample, the students got total scores: $$$369$$$, $$$240$$$, $$$310$$$, $$$300$$$, $$$300$$$, and $$$0$$$. Among the $$$6$$$ students, Thomas got the highest score, so his rank is $$$1$$$."}, "positive_code": [{"source_code": ""}, {"source_code": " $i,\n 'sum' =>($a+$b+$c+$d),\n );\n}\narray_multisort(array_column($aPoints, 'sum'), SORT_DESC,\n array_column($aPoints, 'id'), SORT_ASC,\n $aPoints);\n \nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPoints[$i]['id'] == 0){\n echo $i+1;\n break;\n }\n }\n}\n"}, {"source_code": " array_sum($a),\n 'id' => $i\n );\n}\n\nfunction cmp($a, $b) {\n if ($a['sum'] == $b['sum']) {\n return $a['id'] > $b['id'] ? 1 : -1;\n }\n return ($a > $b) ? -1 : 1;\n}\n\nuasort($aCount, 'cmp');\n// print_r($aCount);\n$iCount = 0;\nforeach($aCount AS $iK => $iC) {\n $iCount++;\n if($iK === 1) {\n break;\n }\n}\n\necho $iCount;\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": " $i,\n 'sum' => $sum,\n );\n}\nusort($aPrize, function($a, $b){\n return ($b['sum'] - $a['sum']);\n});\n$sergey = 0;\nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPrize[$i]['id'] == 0 && !$sergey){\n $sergey = $i+1;\n echo $sergey;\n }\n }\n}\n"}, {"source_code": " $i,\n 'sum' =>($a+$b+$c+$d),\n );\n}\nusort($aPoints, function($a, $b){\n return ($b['sum'] - $a['sum']);\n});\n$sergey = 0;\nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPoints[$i]['id'] == 0){\n $sergey = $i +1;\n break;\n }\n }\n}\necho $sergey;"}, {"source_code": " $i,\n 'sum' => $sum,\n );\n}\nusort($aPrize, function($a, $b){\n return ($b['sum'] - $a['sum']);\n});\n$sergey = 0;\nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPrize[$i]['id'] == 0){\n $sergey = $i;\n }\n }\n}\necho $sergey+1;\n"}, {"source_code": " $i,\n 'sum' => $sum,\n );\n}\nusort($aPrize, function($a, $b){\n return ($b['sum'] - $a['sum']);\n});\n$sergey = 0;\nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPrize[$i]['id'] == 0){\n $sergey = $i;\n }\n }\n}\necho $sergey+1;\n"}, {"source_code": " $i,\n 'sum' =>($a+$b+$c+$d),\n );\n}\nusort($aPoints, function($a, $b){\n return ($b['sum'] - $a['sum']);\n});\nfor($i = 0;$i< $n; $i++){\n for($j=0;$j<4;$j++){\n if($aPoints[$i]['id'] == 0){\n echo $i+1;\n break;\n }\n }\n}\n?>"}, {"source_code": " $b) ? -1 : 1;\n}\n\nuasort($aCount, 'cmp');\n// print_r($aCount);\n$iCount = 1;\nforeach($aCount AS $iK => $iC) {\n if($iK === 1) {\n break;\n }\n $iCount++;\n}\n\necho $iCount;\n?>"}, {"source_code": " array_sum($a),\n 'id' => $i\n );\n}\n\nfunction cmp($a, $b) {\n if ($a['sum'] == $b['sum']) {\n return $a['id'] > $b['id'] ? 1 : -1;\n }\n return ($a > $b) ? -1 : 1;\n}\n\nuasort($aCount, 'cmp');\nprint_r($aCount);\n$iCount = 0;\nforeach($aCount AS $iK => $iC) {\n $iCount++;\n if($iK === 1) {\n break;\n }\n}\n\necho $iCount;\n?>"}, {"source_code": " $iC) {\n if($iMax <= $iC) {\n $iMax = $iC;\n $iMaxIndex = $indexC;\n }\n}\n\necho $iMaxIndex;\n?>"}, {"source_code": "$n = fgets(STDIN);\n$n = (int)$n;\n\n$aData = array();\n$aCount = array();\nfor($i = 1; $i <= $n; $i++) {\n $s = fgets(STDIN);\n $a = explode(' ', (trim($s)));\n $aCount[$i] = array_sum($a);\n}\n\nfunction cmp($a, $b) {\n if ($a == $b) {\n return 0;\n }\n return ($a > $b) ? -1 : 1;\n}\n\nuasort($aCount, 'cmp');\nprint_r($aCount);\n$iCount = 1;\nforeach($aCount AS $iK => $iC) {\n if($iK === 1) {\n break;\n }\n $iCount++;\n}\n\necho $iCount;"}, {"source_code": " $iC) {\n if($iMax < $iC) {\n $iMax = $iC;\n $iMaxIndex = $indexC;\n }\n}\n\necho $iMaxIndex;\n?>"}, {"source_code": " array_sum($a),\n 'id' => $i\n );\n}\n\nfunction cmp($a, $b) {\n if ($a['sum'] == $b['sum']) {\n return $a['id'] > $b['id'] ? -1 : 1;\n }\n return ($a > $b) ? -1 : 1;\n}\n\nuasort($aCount, 'cmp');\n// print_r($aCount);\n$iCount = 0;\nforeach($aCount AS $iK => $iC) {\n $iCount++;\n if($iK === 1) {\n break;\n }\n}\n\necho $iCount;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "3c984366bba580993d1694d27982a773"} {"nl": {"description": "You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the player automatically proceeds to the next minute of the movie. Skip exactly x minutes of the movie (x is some fixed positive integer). If the player is now at the t-th minute of the movie, then as a result of pressing this button, it proceeds to the minute (t\u2009+\u2009x). Initially the movie is turned on in the player on the first minute, and you want to watch exactly n best moments of the movie, the i-th best moment starts at the li-th minute and ends at the ri-th minute (more formally, the i-th best moment consists of minutes: li,\u2009li\u2009+\u20091,\u2009...,\u2009ri). Determine, what is the minimum number of minutes of the movie you have to watch if you want to watch all the best moments?", "input_spec": "The first line contains two space-separated integers n, x (1\u2009\u2264\u2009n\u2009\u2264\u200950, 1\u2009\u2264\u2009x\u2009\u2264\u2009105) \u2014 the number of the best moments of the movie and the value of x for the second button. The following n lines contain the descriptions of the best moments of the movie, the i-th line of the description contains two integers separated by a space li, ri (1\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009105). It is guaranteed that for all integers i from 2 to n the following condition holds: ri\u2009-\u20091\u2009<\u2009li.", "output_spec": "Output a single number \u2014 the answer to the problem.", "sample_inputs": ["2 3\n5 6\n10 12", "1 1\n1 100000"], "sample_outputs": ["6", "100000"], "notes": "NoteIn the first sample, the player was initially standing on the first minute. As the minutes from the 1-st to the 4-th one don't contain interesting moments, we press the second button. Now we can not press the second button and skip 3 more minutes, because some of them contain interesting moments. Therefore, we watch the movie from the 4-th to the 6-th minute, after that the current time is 7. Similarly, we again skip 3 minutes and then watch from the 10-th to the 12-th minute of the movie. In total, we watch 6 minutes of the movie.In the second sample, the movie is very interesting, so you'll have to watch all 100000 minutes of the movie."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "0) {\n\t\tlist($l, $r) = explode(\" \", trim(fgets(STDIN)));\n\n\t\t$t = $l - ($l - $t) % $x;\n\t\t$ans += $r - $t + 1;\n\n\t\t$t = $r + 1;\n\t$n--;}\n\techo $ans;\n\n?>"}, {"source_code": "0){\n list($l,$r)=explode(\" \",trim(fgets(STDIN)));\n $x=$l-($l-$x)%$m;\n $ans+=$r-$x+1;\n $x=$r+1;\n $n--;\n}\necho $ans;\n?>"}, {"source_code": "0) {\n\t\tlist($l, $r) = explode(\" \", trim(fgets(STDIN)));\n\n\t\t$t = $l - ($l - $t) % $x;\n\t\t$ans += $r - $t + 1;\n\n\t\t$t = $r + 1;\n\t$n--;}\n\techo $ans;\n\n?>"}, {"source_code": " 0){\n list($l,$r) = explode(\" \", trim(fgets(STDIN)));\n $s = $l - ($l -$s) % $x;\n $ans += $r - $s + 1;\n\n $s = $r + 1;\n $n --; \n }\n echo $ans;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "0){\n list($l,$r)=explode(\" \",trim(fgets(STDIN)));\n $x=$l-($l-$x)%$m;\n $ans+=$r-$x;\n $x=$r;\n $n--;\n}\necho $ans;\n?>"}], "src_uid": "ac33b73da5aaf2139b348a9c237f93a4"} {"nl": {"description": "You've got a string $$$a_1, a_2, \\dots, a_n$$$, consisting of zeros and ones.Let's call a sequence of consecutive elements $$$a_i, a_{i\u2009+\u20091}, \\ldots,\u2009a_j$$$ ($$$1\\leq\u2009i\\leq\u2009j\\leq\u2009n$$$) a substring of string $$$a$$$. You can apply the following operations any number of times: Choose some substring of string $$$a$$$ (for example, you can choose entire string) and reverse it, paying $$$x$$$ coins for it (for example, \u00ab0101101\u00bb $$$\\to$$$ \u00ab0111001\u00bb); Choose some substring of string $$$a$$$ (for example, you can choose entire string or just one symbol) and replace each symbol to the opposite one (zeros are replaced by ones, and ones\u00a0\u2014 by zeros), paying $$$y$$$ coins for it (for example, \u00ab0101101\u00bb $$$\\to$$$ \u00ab0110001\u00bb). You can apply these operations in any order. It is allowed to apply the operations multiple times to the same substring.What is the minimum number of coins you need to spend to get a string consisting only of ones?", "input_spec": "The first line of input contains integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$1\u2009\\leq\u2009n\u2009\\leq\u2009300\\,000, 0 \\leq x, y \\leq 10^9$$$)\u00a0\u2014 length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring). The second line contains the string $$$a$$$ of length $$$n$$$, consisting of zeros and ones.", "output_spec": "Print a single integer\u00a0\u2014 the minimum total cost of operations you need to spend to get a string consisting only of ones. Print $$$0$$$, if you do not need to perform any operations.", "sample_inputs": ["5 1 10\n01000", "5 10 1\n01000", "7 2 3\n1111111"], "sample_outputs": ["11", "2", "0"], "notes": "NoteIn the first sample, at first you need to reverse substring $$$[1 \\dots 2]$$$, and then you need to invert substring $$$[2 \\dots 5]$$$. Then the string was changed as follows:\u00ab01000\u00bb $$$\\to$$$ \u00ab10000\u00bb $$$\\to$$$ \u00ab11111\u00bb.The total cost of operations is $$$1 + 10 = 11$$$.In the second sample, at first you need to invert substring $$$[1 \\dots 1]$$$, and then you need to invert substring $$$[3 \\dots 5]$$$. Then the string was changed as follows:\u00ab01000\u00bb $$$\\to$$$ \u00ab11000\u00bb $$$\\to$$$ \u00ab11111\u00bb.The overall cost is $$$1 + 1 = 2$$$.In the third example, string already consists only of ones, so the answer is $$$0$$$."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "b267f69cc4af3e319fc59e3ccd8b1c9d"} {"nl": {"description": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya has two strings a and b of the same length n. The strings consist only of lucky digits. Petya can perform operations of two types: replace any one digit from string a by its opposite (i.e., replace 4 by 7 and 7 by 4); swap any pair of digits in string a. Petya is interested in the minimum number of operations that are needed to make string a equal to string b. Help him with the task.", "input_spec": "The first and the second line contains strings a and b, correspondingly. Strings a and b have equal lengths and contain only lucky digits. The strings are not empty, their length does not exceed 105.", "output_spec": "Print on the single line the single number \u2014 the minimum number of operations needed to convert string a into string b.", "sample_inputs": ["47\n74", "774\n744", "777\n444"], "sample_outputs": ["1", "1", "3"], "notes": "NoteIn the first sample it is enough simply to swap the first and the second digit.In the second sample we should replace the second digit with its opposite.In the third number we should replace all three digits with their opposites."}, "positive_code": [{"source_code": " $b[$y])\n {\n $c++;\n }\n if($a[$x] < $b[$y])\n {\n $d++;\n }\n}\nprint max($c, $d);\n?>"}], "negative_code": [], "src_uid": "2d1609b434262d30f6bd030d41a71bd5"} {"nl": {"description": "Vasya has several phone books, in which he recorded the telephone numbers of his friends. Each of his friends can have one or several phone numbers.Vasya decided to organize information about the phone numbers of friends. You will be given n strings \u2014 all entries from Vasya's phone books. Each entry starts with a friend's name. Then follows the number of phone numbers in the current entry, and then the phone numbers themselves. It is possible that several identical phones are recorded in the same record.Vasya also believes that if the phone number a is a suffix of the phone number b (that is, the number b ends up with a), and both numbers are written by Vasya as the phone numbers of the same person, then a is recorded without the city code and it should not be taken into account.The task is to print organized information about the phone numbers of Vasya's friends. It is possible that two different people have the same number. If one person has two numbers x and y, and x is a suffix of y (that is, y ends in x), then you shouldn't print number x. If the number of a friend in the Vasya's phone books is recorded several times in the same format, it is necessary to take it into account exactly once.Read the examples to understand statement and format of the output better.", "input_spec": "First line contains the integer n (1\u2009\u2264\u2009n\u2009\u2264\u200920)\u00a0\u2014 number of entries in Vasya's phone books. The following n lines are followed by descriptions of the records in the format described in statement. Names of Vasya's friends are non-empty strings whose length does not exceed 10. They consists only of lowercase English letters. Number of phone numbers in one entry is not less than 1 is not more than 10. The telephone numbers consist of digits only. If you represent a phone number as a string, then its length will be in range from 1 to 10. Phone numbers can contain leading zeros.", "output_spec": "Print out the ordered information about the phone numbers of Vasya's friends. First output m\u00a0\u2014 number of friends that are found in Vasya's phone books. The following m lines must contain entries in the following format \"name number_of_phone_numbers phone_numbers\". Phone numbers should be separated by a space. Each record must contain all the phone numbers of current friend. Entries can be displayed in arbitrary order, phone numbers for one record can also be printed in arbitrary order.", "sample_inputs": ["2\nivan 1 00123\nmasha 1 00123", "3\nkarl 2 612 12\npetr 1 12\nkatya 1 612", "4\nivan 3 123 123 456\nivan 2 456 456\nivan 8 789 3 23 6 56 9 89 2\ndasha 2 23 789"], "sample_outputs": ["2\nmasha 1 00123 \nivan 1 00123", "3\nkatya 1 612 \npetr 1 12 \nkarl 1 612", "2\ndasha 2 23 789 \nivan 4 789 123 2 456"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "df7b16d582582e6756cdb2d6d856c873"} {"nl": {"description": "The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1,\u2009a2,\u2009...,\u2009ak (i.e. some prefix of the sequence) equal to zero for some fixed k (k\u2009<\u2009n), and this should be done in the smallest possible number of moves.One move is choosing an integer i (1\u2009\u2264\u2009i\u2009\u2264\u2009n) such that ai\u2009>\u20090 and an integer t (t\u2009\u2265\u20090) such that i\u2009+\u20092t\u2009\u2264\u2009n. After the values of i and t have been selected, the value of ai is decreased by 1, and the value of ai\u2009+\u20092t is increased by 1. For example, let n\u2009=\u20094 and a\u2009=\u2009(1,\u20090,\u20091,\u20092), then it is possible to make move i\u2009=\u20093, t\u2009=\u20090 and get a\u2009=\u2009(1,\u20090,\u20090,\u20093) or to make move i\u2009=\u20091, t\u2009=\u20091 and get a\u2009=\u2009(0,\u20090,\u20092,\u20092) (the only possible other move is i\u2009=\u20091, t\u2009=\u20090).You are given n and the initial sequence ai. The task is to calculate the minimum number of moves needed to make the first k elements of the original sequence equal to zero for each possible k (1\u2009\u2264\u2009k\u2009<\u2009n).", "input_spec": "The first input line contains a single integer n. The second line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009104), separated by single spaces. The input limitations for getting 20 points are: 1\u2009\u2264\u2009n\u2009\u2264\u2009300 The input limitations for getting 50 points are: 1\u2009\u2264\u2009n\u2009\u2264\u20092000 The input limitations for getting 100 points are: 1\u2009\u2264\u2009n\u2009\u2264\u2009105 ", "output_spec": "Print exactly n\u2009-\u20091 lines: the k-th output line must contain the minimum number of moves needed to make the first k elements of the original sequence ai equal to zero. Please do not use the %lld specifier to read or write 64-bit integers in \u0421++. It is preferred to use the cin, cout streams, or the %I64d specifier.", "sample_inputs": ["4\n1 0 1 2", "8\n1 2 3 4 5 6 7 8"], "sample_outputs": ["1\n1\n3", "1\n3\n6\n10\n16\n24\n40"], "notes": null}, "positive_code": [{"source_code": " 100000)\n {\n break;\n }\n else\n {\n $c[count($c)] = $e;\n }\n}\n$f = array_fill(1, $a, 1);\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($f[$c[$y] + $x] == NULL)\n {\n $f[$x] = $c[$y - 1] + $x;\n break;\n }\n }\n}\n$g = $b;\narray_unshift($g, \" \");\nunset($g[0]);\n$h = 0;\nfor($x = 1; $x < $a; $x++)\n{\n $h += $g[$x];\n print $h . \"\\n\";\n $g[$f[$x]] += $g[$x];\n}\n?>"}, {"source_code": "in();\n\tfor ($i = 1; $i <= $N; $i++) $A[$i] = (int)$Input->in();\n\t\n\t$sum = 0;\n\tfor ($k = 1; $k <= $N - 1; $k++) {\n\t\t$pow = 2;\n\t\t//while ($A[$k] + $pow < $N) {\n\t\twhile ($k + $pow <= $N) $pow *= 2;\n\t\t\n\t\t$A[$k + $pow / 2] += $A[$k];\n\t\t$sum += $A[$k];\n\t\t$A[$k] = 0;\n\n\t\tprint($sum.\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}, {"source_code": ""}, {"source_code": "in();\n\tfor ($i = 1; $i <= $N; $i++) $A[$i] = (int)$Input->in();\n\t\n\t$sum = 0;\n\tfor ($k = 1; $k <= $N - 1; $k++) {\n\t\t$pow = 2;\n\t\t//while ($A[$k] + $pow < $N) {\n\t\twhile ($k + $pow <= $N) $pow *= 2;\n\t\t\n\t\t$A[$k + $pow / 2] += $A[$k];\n\t\t$sum += $A[$k];\n\t\t$A[$k] = 0;\n\n\t\tprint($sum.\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}, {"source_code": " 100000)\n {\n break;\n }\n else\n {\n $c[count($c)] = $e;\n }\n}\n$f = array_fill(1, $a, 1);\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($f[$c[$y] + $x] == NULL)\n {\n $f[$x] = $c[$y - 1] + $x;\n break;\n }\n }\n}\n$g = $b;\narray_unshift($g, \" \");\nunset($g[0]);\n$h = 0;\nfor($x = 1; $x < $a; $x++)\n{\n $h += $g[$x];\n print $h . \"\\n\";\n $g[$f[$x]] += $g[$x];\n}\n?>"}, {"source_code": "in();\n\tfor ($i = 1; $i <= $N; $i++) $A[$i] = (int)$Input->in();\n\t\n\t$sum = 0;\n\tfor ($k = 1; $k <= $N - 1; $k++) {\n\t\t$pow = 2;\n\t\t//while ($A[$k] + $pow < $N) {\n\t\twhile ($k + $pow <= $N) $pow *= 2;\n\t\t\n\t\t$A[$k + $pow / 2] += $A[$k];\n\t\t$sum += $A[$k];\n\t\t$A[$k] = 0;\n\n\t\tprint($sum.\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "negative_code": [{"source_code": " 100000)\n {\n break;\n }\n else\n {\n $c[count($c)] = $e;\n }\n}\n$f = array_fill(1, $a, 1);\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($f[$c[$y] + $x] == NULL)\n {\n $f[$x] = $c[$y - 1] + $x;\n break;\n }\n }\n}\n$g = $b;\narray_unshift($g, \" \");\nunset($g[0]);\n$h = 0;\nfor($x = 1; $x < $a; $x++)\n{\n $h += $g[$x];\n print $h . \"\\n\";\n $g[$f[$x]] += $g[$x];\n}\n?>"}, {"source_code": " 110000)\n {\n break;\n }\n else\n {\n $c[count($c)] = $e;\n }\n}\n$f = array_fill(1, $a, 1);\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($f[$c[$y] + $x] == NULL)\n {\n $f[$x] = $c[$y - 1] + $x;\n break;\n }\n }\n}\n$g = $b;\narray_unshift($g, \" \");\nunset($g[0]);\n$h = 0;\nfor($x = 1; $x < $a; $x++)\n{\n $h = bcadd($h, $g[$x]);\n print $h . \"\\n\";\n $g[$f[$x]] += $g[$x];\n}\n?>"}, {"source_code": " 110000)\n {\n break;\n }\n else\n {\n $c[count($c)] = $e;\n }\n}\n$f = array_fill(1, $a, 1);\nfor($x = 1; $x <= $a; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($f[$c[$y] + $x] == NULL)\n {\n $f[$x] = $c[$y - 1] + $x;\n break;\n }\n }\n}\n$g = $b;\narray_unshift($g, \" \");\nunset($g[0]);\n$h = 0;\nfor($x = 1; $x < $a; $x++)\n{\n $h += $g[$x];\n print $h . \"\\n\";\n $g[$f[$x]] += $g[$x];\n}\n?>"}, {"source_code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.lang.Character;\nimport java.lang.Long;\nimport java.lang.Math;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.StringTokenizer;\nimport java.util.Arrays;\n\npublic class TaskC {\n\tBufferedReader reader;\n\tStringTokenizer tokenizer = new StringTokenizer(\"\");\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tnew TaskC().run();\n\t}\n\n\tprivate void run() throws IOException {\n\t\ttokenizer = null;\n\t\treader = new BufferedReader(new InputStreamReader(System.in));\n\t\tsolve();\n\t}\n\n\tpublic static int divide_by_two(int x, int y){\n\n\t\tif (y == 0) return 0;\n\t\n\t\tx = x - y;\n\t\tint r = 1;\n\t\tint c = 0;\n\t\twhile(x != 0){\n\t\t\tr = x % 2;\n\t\t\tx = (int)(x / 2);\t\n\t\t\tif (r == 1) c++;\n\t\t}\n\t\treturn c;\n\t}\n\n\tprivate void solve() throws IOException {\n\t\tint N = nextInt();\n\t\tint[] A = new int[Integer.MAX_VALUE];\n\t\tint[] dp = new int[N];\n\t\tint[] ans = new int[N];\n\t\tfor (int i = 0; i < A.length; i++) {\n\t\t\tA[i] = 0;\n\t\t}\n\t\tfor (int i = 0; i < dp.length; i++) {\n\t\t\tdp[i] = 0;\n\t\t\tans[i] = 0;\n\t\t}\n\t\tfor (int i = 1; i <= N; i++) A[i] = nextInt();\n\n\t\tfor (int k = N - 1; k >= 1; k--) {\n\t\t\tint sum = 0;\n\t\t\tfor (int index = 1; index <= k; index++) {\n\t\t\t\tint min = Integer.MAX_VALUE;\n\t\t\t\tint temp = 0;\n\t\t\t\tfor (int n = N; n >= k + 1; n--) {\n\t\t\t\t\tif (dp[index] > n) {\n\t\t\t\t\t\tmin = 1;\n\t\t\t\t\tsum += A[index];\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\ttemp = divide_by_two(n, index);\n\t\t\t\t\tmin = Math.min(min, temp);\n\t\t\t\t\tif (min == 1) {\n\t\t\t\t\t\tsum += A[index];\n\t\t\t\t\t\tdp[index] = n;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (min != 1) sum += A[index] * min;\n\t\t}\n\t\tans[k] = sum;\n\t}\n\t\n\t\tfor (int i = 1; i <= N - 1; i++) {\n\t\t\tSystem.out.print(ans[i]);\n\t\t\tif (i != N - 1) System.out.print(\"\\n\");\n\t\t}\n\t}\n\t\n\tString nextToken() throws IOException {\n\t\twhile (tokenizer == null || !tokenizer.hasMoreTokens())\n\t\t\ttokenizer = new StringTokenizer(reader.readLine());\n\t\treturn tokenizer.nextToken();\n\t}\n\n\tint nextInt() throws IOException {\n\t\treturn Integer.parseInt(nextToken());\n\t}\n\n\tlong nextLong() throws IOException {\n\t\treturn Long.parseLong(nextToken());\n\t}\n}"}, {"source_code": "in();\n\tfor ($i = 1; $i <= $N; $i++) $A[$i] = (int)$Input->in();\n\t\n\t$sum = 0;\n\tfor ($k = 1; $k <= $N - 1; $k++) {\n\n\t\t$pow = 2;\n\t\twhile ($A[$k] + $pow <= $N) {\n\t\t\t$pow *= 2;\n\t\t}\n\t\t\n\t\t$A[$k + $pow / 2] += $A[$k];\n\t\t$sum += $A[$k];\n\t\t$A[$k] = 0;\n\n\t\tprint($sum);\n\t\tif ($i !== $N - 2) print(\"\\n\");\n\t}\n}\n\nclass Input{\n\tprivate $handle = \"\";\n\tprivate $values = array();\n\tprivate $index = 0;\n\n\tpublic function __construct($localfile){\n\n\t\tif (is_file($localfile)) {\n\t\t\t\n\t\t\t$this->handle = fopen($localfile, \"r\");\n\t\t\t$contents = stream_get_contents($this->handle);\n\t\t\n\t\t} else {\n\t\t\n\t\t\t$contents = stream_get_contents(STDIN);\n\t\t\n\t\t}\n\t\t\n\t\t$no_newlines = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->values = explode(\" \", $no_newlines);\n\t}\n\t\n\tpublic function in(){\n\t\n\t\treturn $this->values[$this->index++];\n\t\n\t}\n\t\n\tpublic function close(){\n\t\t\n\t\tif (is_file($localfile) && feof($this->handle)) fclose($this->handle);\n\t\t\n\t}\n}\n\n?>"}], "src_uid": "c7e49c643dd8738f273c0d24e56c505f"} {"nl": {"description": "Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?", "input_spec": "The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \\le n \\le 10^{5}$$$, $$$1 \\le L \\le 10^{9}$$$, $$$1 \\le a \\le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \\le t_{i} \\le L - 1$$$, $$$1 \\le l_{i} \\le L$$$). It is guaranteed that $$$t_{i} + l_{i} \\le t_{i + 1}$$$ and $$$t_{n} + l_{n} \\le L$$$.", "output_spec": "Output one integer \u00a0\u2014 the maximum number of breaks.", "sample_inputs": ["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"], "sample_outputs": ["3", "2", "0"], "notes": "NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks."}, "positive_code": [{"source_code": " $e)\n {\n $d[count($d)] = $f - $e;\n }\n $e = $f + $g;\n}\nif($b > $e)\n{\n $d[count($d)] = $b - $e;\n}\n$h = 0;\nfor($x = 0; $x < count($d); $x++)\n{\n $i = floor($d[$x] / $c);\n $h += $i;\n}\nprint $h;\n?>"}], "negative_code": [], "src_uid": "00acb3b54975820989a788b9389c7c0b"} {"nl": {"description": "Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely accidentally got a piece of ancient parchment on which an array of numbers was written. He immediately thought that the numbers in this array were not random. As a result of extensive research Valera worked out a wonderful property that a magical array should have: an array is defined as magic if its minimum and maximum coincide.He decided to share this outstanding discovery with you, but he asks you for help in return. Despite the tremendous intelligence and wit, Valera counts very badly and so you will have to complete his work. All you have to do is count the number of magical subarrays of the original array of numbers, written on the parchment. Subarray is defined as non-empty sequence of consecutive elements.", "input_spec": "The first line of the input data contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105). The second line contains an array of original integers a1,\u2009a2,\u2009...,\u2009an (\u2009-\u2009109\u2009\u2264\u2009ai\u2009\u2264\u2009109). ", "output_spec": "Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).", "sample_inputs": ["4\n2 1 1 4", "5\n-2 -2 -2 0 1"], "sample_outputs": ["5", "8"], "notes": "NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3]. "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "0b229ddf583949d43d6f1728e38c3cad"} {"nl": {"description": "There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.There was a request to each of the workers to tell how how many superiors (not only immediate). Worker's superiors are his immediate superior, the immediate superior of the his immediate superior, and so on. For example, if there are three workers in the company, from which the first is the chief, the second worker's immediate superior is the first, the third worker's immediate superior is the second, then the third worker has two superiors, one of them is immediate and one not immediate. The chief is a superior to all the workers except himself.Some of the workers were in a hurry and made a mistake. You are to find the minimum number of workers that could make a mistake.", "input_spec": "The first line contains two positive integers n and s (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105, 1\u2009\u2264\u2009s\u2009\u2264\u2009n)\u00a0\u2014 the number of workers and the id of the chief. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u2009n\u2009-\u20091), where ai is the number of superiors (not only immediate) the worker with id i reported about.", "output_spec": "Print the minimum number of workers that could make a mistake.", "sample_inputs": ["3 2\n2 0 2", "5 3\n1 0 0 4 1"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first example it is possible that only the first worker made a mistake. Then: the immediate superior of the first worker is the second worker, the immediate superior of the third worker is the first worker, the second worker is the chief. "}, "positive_code": [{"source_code": " $i)\n {\n break;\n }\n elseif($y == $i)\n {\n if($d == 0)\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n }\n }\n else\n {\n for($z = 1; $z <= $d; $z++)\n {\n $c[$y - 1]++;\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n break;\n }\n }\n }\n break;\n }\n else\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n $y++;\n }\n else\n {\n if($d > 0)\n {\n $c[$y - 1]++;\n $d--;\n }\n else\n {\n $c[$y - 1]++;\n $i--;\n }\n }\n }\n }\n print $h;\n}\nelse\n{\n $w = max($c);\n $c[$b - 1] = 0;\n sort($c);\n $d = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] == 0)\n {\n $d++;\n }\n else\n {\n break;\n }\n }\n $d--;\n $e = 1;\n $f = 0;\n for($y = $x; $y < $a; $y++)\n {\n if($c[$y] == $f)\n {\n $e++;\n }\n elseif($c[$y] == $f + 1)\n {\n $e++;\n $f++;\n }\n else\n {\n break;\n }\n }\n $g = $a - $e;\n $h = $g;\n $i = $a - 1;\n while(TRUE)\n {\n if($y > $i)\n {\n break;\n }\n elseif($y == $i)\n {\n if($d == 0)\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n }\n }\n else\n {\n for($z = 1; $z <= $d; $z++)\n {\n $c[$y - 1]++;\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n break;\n }\n }\n }\n break;\n }\n else\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n $y++;\n }\n else\n {\n if($d > 0)\n {\n $c[$y - 1]++;\n $d--;\n }\n else\n {\n $c[$y - 1]++;\n $i--;\n }\n }\n }\n }\n print $h + 1;\n}\n?>"}], "negative_code": [{"source_code": " $i)\n {\n break;\n }\n elseif($y == $i)\n {\n if($d == 0)\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n }\n }\n else\n {\n for($z = 1; $z <= $d; $z++)\n {\n $c[$y - 1]++;\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n break;\n }\n }\n }\n break;\n }\n else\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n $y++;\n }\n else\n {\n if($d > 0)\n {\n $c[$y - 1]++;\n $d--;\n }\n else\n {\n $c[$y - 1]++;\n $i--;\n }\n }\n }\n }\n print $h;\n}\nelse\n{\n $w = max($c);\n $c[$b - 1] = 0;\n sort($c);\n $d = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($c[$x] == 0)\n {\n $d++;\n }\n else\n {\n break;\n }\n }\n $d--;\n $e = 1;\n $f = 1;\n for($y = $x; $y < $a; $y++)\n {\n if($c[$y] == $f)\n {\n $e++;\n }\n elseif($c[$y] + 1 == $f)\n {\n $e++;\n $f++;\n }\n else\n {\n break;\n }\n }\n $g = $a - $e;\n $h = $g;\n $i = $a - 1;\n while(TRUE)\n {\n if($y > $i)\n {\n break;\n }\n elseif($y == $i)\n {\n if($d == 0)\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n }\n }\n else\n {\n for($z = 1; $z <= $d; $z++)\n {\n $c[$y - 1]++;\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n break;\n }\n }\n }\n break;\n }\n else\n {\n if(($c[$y] == $c[$y - 1]) || ($c[$y] == $c[$y - 1] + 1))\n {\n $h--;\n $y++;\n }\n else\n {\n if($d > 0)\n {\n $c[$y - 1]++;\n $d--;\n }\n else\n {\n $c[$y - 1]++;\n $i--;\n }\n }\n }\n }\n print $h + 1;\n}\n?>"}], "src_uid": "3def8503f4e7841d33be5b4890065526"} {"nl": {"description": "Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai\u2009+\u20091 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well?", "input_spec": "The first line contains two space-separated integers n and v (1\u2009\u2264\u2009n,\u2009v\u2009\u2264\u20093000) \u2014 the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1\u2009\u2264\u2009ai,\u2009bi\u2009\u2264\u20093000) \u2014 the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree.", "output_spec": "Print a single integer \u2014 the maximum number of fruit that Valera can collect. ", "sample_inputs": ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"], "sample_outputs": ["8", "60"], "notes": "NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither."}, "positive_code": [{"source_code": "= $b)\n {\n $c += $b;\n $e[$x + 1] = $d[$x];\n }\n else\n {\n $c += $e[$x];\n $h = $b - $e[$x];\n if($d[$x] >= $h)\n {\n $c += $h;\n $i = $d[$x] - $h;\n $e[$x + 1] = $i;\n }\n else\n {\n $c += $d[$x];\n }\n }\n}\nprint $c;\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $b)\n {\n $c += $b;\n $e[$x + 1] = $d[$x];\n }\n else\n {\n $c += $e[$x];\n $h = $b - $e[$x];\n if($d[$x] >= $h)\n {\n $c += $h;\n $i = $d[$x] - $h;\n $e[$x + 1] = $i;\n }\n else\n {\n $c += $d[$x];\n }\n }\n}\nprint $c;\n?>"}, {"source_code": ""}], "src_uid": "848ead2b878f9fd8547e1d442e2f85ff"} {"nl": {"description": "Nikolay got a string $$$s$$$ of even length $$$n$$$, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from $$$1$$$ to $$$n$$$.He wants to modify his string so that every its prefix of even length has an equal amount of letters 'a' and 'b'. To achieve that, Nikolay can perform the following operation arbitrary number of times (possibly, zero): choose some position in his string and replace the letter on this position with the other letter (i.e. replace 'a' with 'b' or replace 'b' with 'a'). Nikolay can use no letters except 'a' and 'b'.The prefix of string $$$s$$$ of length $$$l$$$ ($$$1 \\le l \\le n$$$) is a string $$$s[1..l]$$$.For example, for the string $$$s=$$$\"abba\" there are two prefixes of the even length. The first is $$$s[1\\dots2]=$$$\"ab\" and the second $$$s[1\\dots4]=$$$\"abba\". Both of them have the same number of 'a' and 'b'.Your task is to calculate the minimum number of operations Nikolay has to perform with the string $$$s$$$ to modify it so that every its prefix of even length has an equal amount of letters 'a' and 'b'.", "input_spec": "The first line of the input contains one even integer $$$n$$$ $$$(2 \\le n \\le 2\\cdot10^{5})$$$ \u2014 the length of string $$$s$$$. The second line of the input contains the string $$$s$$$ of length $$$n$$$, which consists only of lowercase Latin letters 'a' and 'b'.", "output_spec": "In the first line print the minimum number of operations Nikolay has to perform with the string $$$s$$$ to modify it so that every its prefix of even length has an equal amount of letters 'a' and 'b'. In the second line print the string Nikolay obtains after applying all the operations. If there are multiple answers, you can print any of them.", "sample_inputs": ["4\nbbbb", "6\nababab", "2\naa"], "sample_outputs": ["2\nabba", "0\nababab", "1\nba"], "notes": "NoteIn the first example Nikolay has to perform two operations. For example, he can replace the first 'b' with 'a' and the last 'b' with 'a'. In the second example Nikolay doesn't need to do anything because each prefix of an even length of the initial string already contains an equal amount of letters 'a' and 'b'."}, "positive_code": [{"source_code": ""}, {"source_code": "\r\n\r\n\r\n"}, {"source_code": " $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}\r\n\r\nclass Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;\r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n\r\n return $d == $n;\r\n }\r\n\r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n\r\n}\r\n\r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;\r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n\r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n\r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i 0; $i--) {\r\n $length = readline();\r\n\r\n $arr = explode(\" \", readline());\r\n\r\n $size = count($arr);\r\n\r\n $u_values = array_unique($arr);\r\n\r\n if (($size - count($u_values)) % 2 == 0) {\r\n echo count($u_values).\"\\n\";\r\n }else{\r\n echo count($u_values)-1 .\"\\n\";\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": "\r\n\r\n\r\n"}, {"source_code": "\r\n\r\n\r\n"}, {"source_code": " $v) {\r\n if($v > 2) {\r\n $delete += $v-2;\r\n }\r\n }\r\n if((count($tt) % 2)== 0) {\r\n $delete += count($tt);\r\n } else {\r\n $delete += count($tt) + 1;\r\n }\r\n\r\n\r\n\r\n IO::pr($n - $delete );\r\n\r\n\r\n\r\n}\r\n\r\n\r\nclass IO {\r\n public static function getInt()\r\n {\r\n return trim(fgets(STDIN));\r\n }\r\n\r\n public static function getArray()\r\n {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n public static function pr($s)\r\n {\r\n echo $s, PHP_EOL;\r\n }\r\n public static function prArray($s)\r\n {\r\n echo implode( ' ', $s), PHP_EOL;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n}\r\n\r\nclass Algor {\r\n public static function efclidLcm($a, $b) {\r\n return ($a / self::efclidGcd($a, $b)) * $b;\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return $b > 0 ? self::efclidGcd($b, $a % $b) : $a;\r\n }\r\n public static function isPrime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n $d += 1;\r\n }\r\n\r\n return $d == $n;\r\n }\r\n\r\n public static function fabicon($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n function getRotate($a, $s, $e, $ind) {\r\n $ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n $ar[$i] = $a[$i];\r\n $j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n // echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\";\r\n $a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n }\r\n\r\n}\r\n\r\nclass bigOperation {\r\n public static function efclidLcm($a, $b) {\r\n return bcmul(bcdiv($a, self::efclidGcd($a, $b)), $b);\r\n }\r\n public static function efclidGcd($a, $b) {\r\n return bccomp($b, 0) == 1 ? self::efclidGcd($b, bcmod($a, $b)) : $a;\r\n }\r\n public static function isBigNumber($n)\r\n {\r\n return bccomp($n, INTMAXVALUE) == 1;\r\n }\r\n // bcadd \u2014 \u0421\u043b\u043e\u0436\u0438\u0442\u044c 2 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcAdd($x, $y)\r\n {\r\n return bcadd($x, $y);\r\n }\r\n// bccomp \u2014 \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n//return 1 if x>y, 0= x==y, -1 x < y\r\n public static function bcComp($x, $y)\r\n {\r\n return bccomp($x, $y);\r\n }\r\n// bcdiv \u2014 \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438\r\n public static function bcDiv($x, $y)\r\n {\r\n return bcdiv($x, $y);\r\n }\r\n// bcmod \u2014 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMod($x, $y)\r\n {\r\n return bcmod($x, $y);\r\n }\r\n// bcmul \u2014 \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcMul($x, $y)\r\n {\r\n return bcmul($x, $y);\r\n }\r\n// bcpow \u2014 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcPow($x, $y)\r\n {\r\n return bcpow($x, $y);\r\n }\r\n// bcpowmod \u2014 \u0412\u043e\u0437\u0432\u043e\u0434\u0438\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0447\u0438\u0441\u043b\u043e\r\n// bcscale \u2014 \u0417\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 bc math \u0444\u0443\u043d\u043a\u0446\u0438\u0439.\r\n// bcsqrt \u2014 \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e\r\n public static function bcSqrt($x, $y)\r\n {\r\n return bcsqrt($x, $y);\r\n }\r\n// bcsub \u2014 \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e\r\n public static function bcSub($x, $y)\r\n {\r\n return bcsub($x, $y);\r\n }\r\n public static function getMaxValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n public static function getMinValue($x, $y) {\r\n return bccomp($x, $y) == 1 ? $y : $x;\r\n }\r\n\r\n public static function getDareje($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, self::getDareje($n, $k-1));\r\n }\r\n}\r\n\r\nclass Sorting\r\n{\r\n public static function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i];\r\n }\r\n for($i = $n; $i 0; $i--) {\r\n $length = readline();\r\n $arr = explode(\" \",readline());\r\n\r\n echo count(array_unique($arr)).\"\\n\" ;\r\n\r\n}\r\n\r\n?>"}], "src_uid": "ab7ab67941783da5c16f6294eb1910d9"} {"nl": {"description": "The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case?", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109), the number of answer variants to question i.", "output_spec": "Print a single number \u2014 the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in \u0421++. It is preferred to use the cin, cout streams or the %I64d specificator.", "sample_inputs": ["2\n1 1", "2\n2 2", "1\n10"], "sample_outputs": ["2", "5", "10"], "notes": "NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. "}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $v) {\n foreach ($ar as $j => $v2) {\n if ($j > $i) {\n continue;\n }\n\n if (1 === gcd($v, $v2)) {\n $res = max($res, $i + $j);\n }\n }\n }\n\n echo ($res + 2).PHP_EOL;\n}\n\nfunction gcd($a, $b): int\n{\n while ($a && $b) {\n if ($a > $b) {\n $a %= $b;\n } else {\n $b %= $a;\n }\n }\n\n return $a + $b;\n}\n/*\n\n1\n4\n10 11 11 10\n\n1\n5\n1 2 2 3 6\n */\n"}, {"source_code": " $v) {\n foreach ($ar as $j => $v2) {\n if ($j > $i) {\n continue;\n }\n\n if (1 === gcd($v, $v2)) {\n $res = max($res, $i + $j);\n }\n }\n }\n\n echo ($res + 2).PHP_EOL;\n}\n\nfunction gcd($a, $b): int\n{\n while ($a && $b) {\n if ($a > $b) {\n $a %= $b;\n } else {\n $b %= $a;\n }\n }\n\n return $a | $b;\n}\n/*\n\n1\n4\n10 11 11 10\n\n1\n5\n1 2 2 3 6\n */\n"}, {"source_code": " $v) {\n foreach ($ar as $j => $v2) {\n if ($j > $i) {\n continue;\n }\n\n if (1 === gcd($v, $v2)) {\n $res = max($res, $i + $j);\n }\n }\n }\n\n echo ($res + 2).PHP_EOL;\n}\n\nfunction gcd($a, $b)\n{\n while ($a && $b) {\n if ($a > $b) {\n $a %= $b;\n } else {\n $b %= $a;\n }\n }\n\n return $a | $b;\n}\n/*\n\n1\n4\n10 11 11 10\n\n1\n5\n1 2 2 3 6\n */\n"}, {"source_code": " $v) {\n foreach ($ar as $j => $v2) {\n if ($j > $i) {\n continue;\n }\n\n if (1 === gcd($v, $v2)) {\n $res = max($res, $i + $j);\n }\n }\n }\n\n echo ($res + 2).PHP_EOL;\n}\n\nfunction gcd($a, $b)\n{\n while ($a && $b) {\n if ($a > $b) {\n $a %= $b;\n } else {\n $b %= $a;\n }\n }\n\n return $a + $b;\n}\n/*\n\n1\n4\n10 11 11 10\n\n1\n5\n1 2 2 3 6\n */\n"}], "negative_code": [], "src_uid": "d665ecbf36cc0c0ddd148137fb693bf2"} {"nl": {"description": "$$$n$$$ students attended the first meeting of the Berland SU programming course ($$$n$$$ is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.Each student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. Your task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains one integer $$$n$$$ ($$$2 \\le n \\le 1\\,000$$$)\u00a0\u2014 the number of students. The $$$i$$$-th of the next $$$n$$$ lines contains $$$5$$$ integers, each of them is $$$0$$$ or $$$1$$$. If the $$$j$$$-th integer is $$$1$$$, then the $$$i$$$-th student can attend the lessons on the $$$j$$$-th day of the week. If the $$$j$$$-th integer is $$$0$$$, then the $$$i$$$-th student cannot attend the lessons on the $$$j$$$-th day of the week. Additional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed $$$10^5$$$.", "output_spec": "For each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print \"YES\" (without quotes). Otherwise, print \"NO\" (without quotes). ", "sample_inputs": ["2\n4\n1 0 0 1 0\n0 1 0 0 1\n0 0 0 1 0\n0 1 0 1 0\n2\n0 0 0 1 0\n0 0 0 1 0"], "sample_outputs": ["YES\nNO"], "notes": "NoteIn the first testcase, there is a way to meet all the constraints. For example, the first group can consist of the first and the third students, they will attend the lessons on Thursday (the fourth day); the second group can consist of the second and the fourth students, and they will attend the lessons on Tuesday (the second day).In the second testcase, it is impossible to divide the students into groups so they attend the lessons on different days."}, "positive_code": [{"source_code": "= $n / 2) && ($b >= $n / 2)){\r\n\t\t\t\t$f = 1;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif ($f == 1) {\r\n\t echo 'YES'.PHP_EOL;\r\n\t} else {\r\n\t echo 'NO'.PHP_EOL;\r\n\t}\r\n}\r\n\r\n?>"}], "negative_code": [{"source_code": " 0);\r\n $y += ($a[$k][$m] > 0);\r\n }\r\n $f += ($d >= $n / 2 && $y >= $n / 2 && !$z);\r\n }\r\n }\r\n }\r\n if ($f > 0) {\r\n echo 'YES'.PHP_EOL;\r\n } else {\r\n echo 'NO'.PHP_EOL;\r\n }\r\n}\r\n\r\n?>\r\n"}, {"source_code": "= $n / 2) {\r\n $c++;\r\n }\r\n }\r\n if ($c >= 2) { echo 'YES'.PHP_EOL; }\r\n else {\r\n echo 'NO'.PHP_EOL;\r\n }\r\n }\r\n \r\n}\r\n\r\n?>"}, {"source_code": "= $n / 2) {\r\n $c++;\r\n }\r\n }\r\n if ($c >= 2) { echo 'YES'.PHP_EOL; }\r\n }\r\n \r\n}\r\n\r\n?>"}, {"source_code": "= $n / 2) {\r\n $c++;\r\n }\r\n }\r\n if ($c >= 2) { echo 'YES'.PHP_EOL; }\r\n }\r\n \r\n}\r\n\r\n?>"}], "src_uid": "068cbfb901aadcd15f794dbbf3dfd453"} {"nl": {"description": "You are given a number $$$k$$$ and a string $$$s$$$ of length $$$n$$$, consisting of the characters '.' and '*'. You want to replace some of the '*' characters with 'x' characters so that the following conditions are met: The first character '*' in the original string should be replaced with 'x'; The last character '*' in the original string should be replaced with 'x'; The distance between two neighboring replaced characters 'x' must not exceed $$$k$$$ (more formally, if you replaced characters at positions $$$i$$$ and $$$j$$$ ($$$i < j$$$) and at positions $$$[i+1, j-1]$$$ there is no \"x\" symbol, then $$$j-i$$$ must be no more than $$$k$$$). For example, if $$$n=7$$$, $$$s=$$$.**.*** and $$$k=3$$$, then the following strings will satisfy the conditions above: .xx.*xx; .x*.x*x; .xx.xxx. But, for example, the following strings will not meet the conditions: .**.*xx (the first character '*' should be replaced with 'x'); .x*.xx* (the last character '*' should be replaced with 'x'); .x*.*xx (the distance between characters at positions $$$2$$$ and $$$6$$$ is greater than $$$k=3$$$). Given $$$n$$$, $$$k$$$, and $$$s$$$, find the minimum number of '*' characters that must be replaced with 'x' in order to meet the above conditions.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 500$$$). Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 50$$$). The second line of each test case contains a string $$$s$$$ of length $$$n$$$, consisting of the characters '.' and '*'. It is guaranteed that there is at least one '*' in the string $$$s$$$. It is guaranteed that the distance between any two neighboring '*' characters does not exceed $$$k$$$.", "output_spec": "For each test case output the minimum number of '*' characters that must be replaced with 'x' characters in order to satisfy the conditions above.", "sample_inputs": ["5\n7 3\n.**.***\n5 1\n..*..\n5 2\n*.*.*\n3 2\n*.*\n1 1\n*"], "sample_outputs": ["3\n1\n3\n2\n1"], "notes": null}, "positive_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $k) = IO::arr();\r\n $s = str_split(IO::str());\r\n $res = 0;\r\n $last = -1;\r\n $lastdigit = 0;\r\n $l = [];\r\n for($i = 0; $i < $n; $i++) {\r\n if($s[$i] == '*') {\r\n $lastdigit = $i;\r\n }\r\n if ($last == -1 && $s[$i] == '*') {\r\n $last = $i;\r\n $res++;\r\n $l[$lastdigit] = 1;\r\n } elseif ($i - $last == $k && $last != -1) {\r\n if($s[$i] == '*') {\r\n $last = $i;\r\n $res++;\r\n $l[$i] = 1;\r\n } elseif(!isset($l[$lastdigit])) {\r\n $last = $lastdigit;\r\n $res++;\r\n $l[$lastdigit] = 1;\r\n }\r\n }\r\n }\r\n if ($lastdigit != end(array_keys($l))) {\r\n $res++;\r\n }\r\n IO::line($res);\r\n\r\n}\r\n\r\n?>"}, {"source_code": " $current_pos; $i--) {\r\n if ($str[$i] == '*') {\r\n $str[$i] = 'x';\r\n $count++;\r\n $current_pos = $i;\r\n break;\r\n }\r\n }*/\r\n\r\n $temp = substr($str, $current_pos, $k + 1);\r\n $temp_last_pos = strrpos($temp, '*');\r\n $current_pos += $temp_last_pos;\r\n $count++;\r\n }\r\n\r\n echo $count.PHP_EOL;\r\n //echo \"
\u0421\u0447\u0435\u0442\u0447\u0438\u043a: \" . $count . \"
\";\r\n }\r\n}"}], "negative_code": [], "src_uid": "874e22d4fd8e35f7e0eade2b469ee5dc"} {"nl": {"description": "Eugeny has n cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and that all these numbers would be distinct. Nikolay has m cards, distinct numbers from 1 to m are written on them, one per card. It means that Nikolay has exactly one card with number 1, exactly one card with number 2 and so on. A single exchange is a process in which Eugeny gives one card to Nikolay and takes another one from those Nikolay has. Your task is to find the minimum number of card exchanges and determine which cards Eugeny should exchange.", "input_spec": "The first line contains two integers n and m (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7105, 1\u2009\u2264\u2009m\u2009\u2264\u2009109)\u00a0\u2014 the number of cards Eugeny has and the number of cards Nikolay has. It is guaranteed that n is even. The second line contains a sequence of n positive integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the numbers on Eugeny's cards.", "output_spec": "If there is no answer, print -1. Otherwise, in the first line print the minimum number of exchanges. In the second line print n integers\u00a0\u2014 Eugeny's cards after all the exchanges with Nikolay. The order of cards should coincide with the card's order in the input data. If the i-th card wasn't exchanged then the i-th number should coincide with the number from the input data. Otherwise, it is considered that this card was exchanged, and the i-th number should be equal to the number on the card it was exchanged to. If there are multiple answers, it is allowed to print any of them.", "sample_inputs": ["6 2\n5 6 7 9 4 5", "8 6\n7 7 7 7 8 8 8 8", "4 1\n4 2 1 10"], "sample_outputs": ["1\n5 6 7 9 4 2", "6\n7 2 4 6 8 1 3 5", "-1"], "notes": null}, "positive_code": [{"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n $p = 0;\n if(($a == 200000) && ($b == 200000))\n {\n print $k . \" \" . $g . \"\\n\";\n }\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $p = 1;\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n else\n {\n $P = 0;\n }\n if(($k > 0) && ($p == 0))\n {\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\nif(($a == 5000) && ($b == 5000))\n{\n print $e . \" \" . $f . \" \" . $g . \"\\n\";\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\nif(($a == 200000) && ($b == 200000))\n{\n print $e . \" \" . $f . \" \" . $g . \"\\n\";\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\nif(($a == 1000) && ($b == 300))\n{\n print $e . \" \" . $f . \" \" . $g . \"\\n\";\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n $g++;\n }\n else\n {\n $h = $c[$x] % 2;\n if($h == 0)\n {\n $e++;\n }\n else\n {\n $f++;\n }\n }\n}\n$i = 0;\nif($e < $f)\n{\n $j = $f - $e;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($f - ($e + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 1)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print ($o) . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\nelseif($e == $f)\n{\n $l = 1;\n $m = 2;\n $n = 0;\n $p = $g;\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n }\n else\n {\n break;\n }\n }\n if($g > 0)\n {\n print \"-1\";\n }\n else\n {\n print $p . \"\\n\";\n print implode(\" \", $c);\n }\n}\nelseif($e > $f)\n{\n $j = $e - $f;\n if($g >= $j)\n {\n $k = $g - $j;\n $l = 1;\n $m = 2;\n $n = 0;\n for($x = 0; $x < $a; $x++)\n {\n if($j > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $j--;\n break;\n }\n }\n }\n }\n elseif(($j == 0) && ($k > 0))\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n $o = $n % 2;\n $n++;\n if($o == 0)\n {\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $k--;\n break;\n }\n }\n }\n else\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n }\n elseif(($j == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($j > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $g . \"\\n\";\n print implode(\" \", $c);\n }\n }\n else\n {\n $k = ($e - ($f + $g)) / 2;\n $l = 1;\n $m = 2;\n $n = 0;\n $o = $g + $k;\n if(($a == 200000) && ($b == 200000))\n {\n print $k . \" \" . $g . \"\\n\";\n }\n for($x = 0; $x < $a; $x++)\n {\n if($g > 0)\n {\n if($d[$c[$x]] > 1)\n {\n $d[$c[$x]]--;\n for($y = $m; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $m = $y + 2;\n $g--;\n break;\n }\n }\n }\n }\n if($k > 0)\n {\n if($c[$x] % 2 == 0)\n {\n for($y = $l; $y <= $b; $y += 2)\n {\n if($d[$y] == FALSE)\n {\n $c[$x] = $y;\n $l = $y + 2;\n $k--;\n break;\n }\n }\n }\n }\n elseif(($g == 0) && ($k == 0))\n {\n break;\n }\n }\n if(($g > 0) || ($k > 0))\n {\n print \"-1\";\n }\n else\n {\n print $o . \"\\n\";\n print implode(\" \", $c);\n }\n }\n}\n?>"}], "src_uid": "86bf9688b92ced5238009eefd051387d"} {"nl": {"description": "By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.In 2312 there was a startling discovery: a collider's activity is safe if and only if all numbers of activated colliders are pairwise relatively prime to each other (two numbers are relatively prime if their greatest common divisor equals 1)! If two colliders with relatively nonprime numbers are activated, it will cause a global collapse.Upon learning this, physicists rushed to turn the colliders on and off and carry out all sorts of experiments. To make sure than the scientists' quickness doesn't end with big trouble, the Large Hadron Colliders' Large Remote Control was created. You are commissioned to write the software for the remote (well, you do not expect anybody to operate it manually, do you?).Initially, all colliders are deactivated. Your program receives multiple requests of the form \"activate/deactivate the i-th collider\". The program should handle requests in the order of receiving them. The program should print the processed results in the format described below.To the request of \"+ i\" (that is, to activate the i-th collider), the program should print exactly one of the following responses: \"Success\" if the activation was successful. \"Already on\", if the i-th collider was already activated before the request. \"Conflict with j\", if there is a conflict with the j-th collider (that is, the j-th collider is on, and numbers i and j are not relatively prime). In this case, the i-th collider shouldn't be activated. If a conflict occurs with several colliders simultaneously, you should print the number of any of them. The request of \"- i\" (that is, to deactivate the i-th collider), should receive one of the following responses from the program: \"Success\", if the deactivation was successful. \"Already off\", if the i-th collider was already deactivated before the request. You don't need to print quotes in the output of the responses to the requests.", "input_spec": "The first line contains two space-separated integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009105) \u2014 the number of colliders and the number of requests, correspondingly. Next m lines contain numbers of requests, one per line, in the form of either \"+ i\" (without the quotes) \u2014 activate the i-th collider, or \"-\u00a0i\" (without the quotes) \u2014 deactivate the i-th collider (1\u2009\u2264\u2009i\u2009\u2264\u2009n).", "output_spec": "Print m lines \u2014 the results of executing requests in the above given format. The requests should be processed in the order, in which they are given in the input. Don't forget that the responses to the requests should be printed without quotes.", "sample_inputs": ["10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3"], "sample_outputs": ["Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on"], "notes": "NoteNote that in the sample the colliders don't turn on after the second and ninth requests. The ninth request could also receive response \"Conflict with 3\"."}, "positive_code": [{"source_code": " $v)\n {\n if (isset($cc[$ii]))\n {\n $ci = $cc[$ii];\n break;\n }\n }\n if ($ci == -1)\n {\n $on[$t] = true;\n foreach ($c[$t] as $ii => $v) $cc[$ii] = $t;\n fprintf(STDOUT, \"Success\\n\");\n }\n else\n {\n fprintf(STDOUT, \"Conflict with %d\\n\", $ci);\n }\n }\n }\n else\n {\n if (isset($on[$t]))\n {\n unset($on[$t]);\n foreach ($c[$t] as $ii => $v) unset($cc[$ii]);\n fprintf(STDOUT, \"Success\\n\");\n }\n else\n {\n fprintf(STDOUT, \"Already off\\n\");\n }\n }\n}\n"}], "negative_code": [], "src_uid": "6cec3662101b419fb734b7d6664fdecd"} {"nl": {"description": "There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all programmers in the team must be at least $$$x$$$.Each programmer should belong to at most one team. Some programmers may be left without a team.Calculate the maximum number of teams that you can assemble.", "input_spec": "The first line contains the integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\le n \\le 10^5; 1 \\le x \\le 10^9$$$)\u00a0\u2014 the number of programmers and the restriction of team skill respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots , a_n$$$ ($$$1 \\le a_i \\le 10^9$$$), where $$$a_i$$$ is the skill of the $$$i$$$-th programmer. The sum of $$$n$$$ over all inputs does not exceed $$$10^5$$$.", "output_spec": "For each test case print one integer \u2014 the maximum number of teams that you can assemble. ", "sample_inputs": ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"], "sample_outputs": ["2\n1\n0"], "notes": null}, "positive_code": [{"source_code": "= $c)\n {\n $e++;\n $f = 1;\n }\n else\n {\n $f++;\n }\n }\n print $e . \"\\n\";\n}\n?>"}], "negative_code": [], "src_uid": "8a6953a226abef41a44963c9b4998a25"} {"nl": {"description": "Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length $$$k$$$ is vowelly if there are positive integers $$$n$$$ and $$$m$$$ such that $$$n\\cdot m = k$$$ and when the word is written by using $$$n$$$ rows and $$$m$$$ columns (the first row is filled first, then the second and so on, with each row filled from left to right), every vowel of the English alphabet appears at least once in every row and every column.You are given an integer $$$k$$$ and you must either print a vowelly word of length $$$k$$$ or print $$$-1$$$ if no such word exists.In this problem the vowels of the English alphabet are 'a', 'e', 'i', 'o' ,'u'.", "input_spec": "Input consists of a single line containing the integer $$$k$$$ ($$$1\\leq k \\leq 10^4$$$)\u00a0\u2014 the required length.", "output_spec": "The output must consist of a single line, consisting of a vowelly word of length $$$k$$$ consisting of lowercase English letters if it exists or $$$-1$$$ if it does not. If there are multiple possible words, you may output any of them.", "sample_inputs": ["7", "36"], "sample_outputs": ["-1", "agoeuioaeiruuimaeoieauoweouoiaouimae"], "notes": "NoteIn the second example, the word \"agoeuioaeiruuimaeoieauoweouoiaouimae\" can be arranged into the following $$$6 \\times 6$$$ grid: It is easy to verify that every row and every column contain all the vowels."}, "positive_code": [{"source_code": " $a)\n {\n break;\n }\n }\n if($b == 1)\n {\n break;\n }\n }\n if($b == 0)\n {\n print \"-1\";\n }\n else\n {\n $d = array(\"aeiou\", \"eioua\", \"iouae\", \"ouaei\", \"uaeio\");\n $e = array();\n $f = \"\";\n for($z = 1; $z <= $x; $z++)\n {\n $g = ($z + 4) % 5;\n $h = floor($y / 5);\n for($z2 = 1; $z2 <= $h; $z2++)\n {\n $f .= $d[$g];\n }\n $i = substr($d[$g], 0, $y % 5);\n $f .= $i;\n }\n print $f;\n }\n}\n?>"}, {"source_code": "= 25){\n $n = -1;\n $m = -1;\n for ($i = 5; $i < $k; $i++){\n if($k % $i == 0){\n $n = $i;\n $m = $k / $i;\n break;\n }\n }\n if($n < 5 || $m < 5){\n echo '-1';\n exit;\n }\n $aGlas = ['a', 'e', 'i', 'o', 'u'];\n $x = 0;\n $aWord = [];\n $sWord = '';\n for($i = 0; $i < $n; $i++) {\n $y = 0;\n for($j = 0; $j < $m; $j++){\n $aWord[$i][$j] = $aGlas[$y];\n $y >= 4 ? $y = 0 : $y++;\n }\n// echo implode($aWord[$i]).\"\\n\";\n $sWord .= implode($aWord[$i]);\n array_unshift($aGlas, array_pop($aGlas));\n }\n echo $sWord;\n} else {\n echo '-1';\n}"}, {"source_code": "= 5)) {$m = (int)$_m; break;}\n}\nif ($m === 0) {die('-1');}\n$str = '';\nfor ($i = 0; $i < $n; $i++) {\n for ($j = 0; $j < $m; $j++) {\n $str .= $letters[($i + $j) % 5];\n }\n}\necho $str;\n"}, {"source_code": "= 5)) {$m = (int)$_m; break;}\n}\nif ($m === 0) {die('-1');}\n$str = '';\nfor ($i = 0; $i < $n; $i++) {\n for ($j = 0; $j < $m; $j++) {\n $str .= $letters[($i + $j) % 5];\n }\n}\necho $str;\n"}, {"source_code": " 'a', '2'=> 'e', '3'=>'i', '4'=>'o', '5'=>'u');\n$b = array( '1'=> 'aeiou', '2'=> 'eioua', '3'=>'iouae', '4'=>'ouaei', '5'=>'uaeio');\n$s= ''; $k1 = 0; $k2=0;\nfor($i = 5; $i<= $k/5 ; $i++){\n if($k%$i==0 && $k/$i>=5){\n $k1 = $i;\n $k2 = $k/$i;\n break;\n }\n}\n\n\nif($k1>0 && $k2>0){\n for($i=1; $i<=$k2; $i++){\n if($i<=5){\n $s.=$b[$i];\n for($d=1; $d<=($k1-5); $d++){\n $s.= $a[$i];\n }\n } else {\n $s.=$b[1];\n for($d=1; $d<=($k1-5); $d++){\n $s.='a';\n }\n }\n \n }\n echo $s;\n} else {\n echo '-1';\n}\n\n\n\n?>"}, {"source_code": " array('a', 'o', 'e', 'u', 'i'),\n 1 => array('o', 'e', 'u', 'i', 'a'),\n 2 => array('e', 'u', 'i', 'a', 'o'),\n 3 => array('u', 'i', 'a', 'o', 'e'),\n 4 => array('i', 'a', 'o', 'e', 'u')\n );\n $s = '';\n for ($x=0; $x < $m; $x++) {\n for ($y = 0; $y < $n; $y++) {\n if ($x < 5 && $y < 5) {\n $s .= $a[$x][$y];\n } else if ($x < 5) {\n $s .= $a[$x][$y%5];\n } else if ($y < 5) {\n $s .= $a[$x%5][$y];\n } else {\n $s .= $a[$x%5][$y%5];\n }\n }\n }\n echo $s;\n?>"}], "negative_code": [{"source_code": " $a)\n {\n break;\n }\n }\n if($b == 1)\n {\n break;\n }\n }\n if($b == 0)\n {\n print \"-1\";\n }\n else\n {\n $d = array(\"aeiou\", \"eioua\", \"iouae\", \"ouaei\", \"uaeio\");\n $e = array();\n $f = \"\";\n for($z = 1; $z <= $x; $z++)\n {\n $g = ($z + 4) % 5;\n $h = floor($y / 5);\n for($z2 = 1; $z2 <= $h; $z2++)\n {\n $f .= $d[$g];\n }\n $i = substr($d[$g], 0, $y - $x);\n $f .= $i;\n }\n print $f;\n }\n}\n?>"}, {"source_code": "= 25){\n $n = -1;\n $m = -1;\n for ($i = 5; $i < $k; $i++){\n if($k % $i == 0){\n $n = $i;\n $m = $k / $i;\n break;\n }\n }\n if($n >= 5 || $m >= 5){\n echo '-1';\n exit;\n }\n $aGlas = ['a', 'e', 'i', 'o', 'u'];\n $x = 0;\n $aWord = [];\n $sWord = '';\n for($i = 0; $i < $n; $i++) {\n $y = 0;\n for($j = 0; $j < $m; $j++){\n $aWord[$i][$j] = $aGlas[$y];\n $y >= 4 ? $y = 0 : $y++;\n }\n// echo implode($aWord[$i]).\"\\n\";\n $sWord .= implode($aWord[$i]);\n array_unshift($aGlas, array_pop($aGlas));\n }\n echo $sWord;\n} else {\n echo '-1';\n}\n\n"}, {"source_code": " 25){\n $n = -1;\n $m = -1;\n for ($i = 5; $i < $k; $i++){\n if($k % $i == 0){\n $n = $i;\n $m = $k / $i;\n break;\n }\n }\n if($n < 5 || $m < 5){\n echo '-1';\n exit;\n }\n $aGlas = ['a', 'e', 'i', 'o', 'u'];\n $x = 0;\n $aWord = [];\n $sWord = '';\n for($i = 0; $i < $n; $i++) {\n $y = 0;\n for($j = 0; $j < $m; $j++){\n $aWord[$i][$j] = $aGlas[$y];\n $y >= 4 ? $y = 0 : $y++;\n }\n// echo implode($aWord[$i]).\"\\n\";\n $sWord .= implode($aWord[$i]);\n array_unshift($aGlas, array_pop($aGlas));\n }\n echo $sWord;\n} else {\n echo '-1';\n}\n\n"}, {"source_code": "= 25){\n for ($i = 5; $i < $k; $i++){\n if($k % $i == 0){\n $n = $i;\n $m = $k / $i;\n break;\n }\n }\n if($n >= 5 || $m >= 5){\n echo '-1';\n exit;\n }\n $aGlas = ['a', 'e', 'i', 'o', 'u'];\n $x = 0;\n $aWord = [];\n $sWord = '';\n for($i = 0; $i < $n; $i++) {\n $y = 0;\n for($j = 0; $j < $m; $j++){\n $aWord[$i][$j] = $aGlas[$y];\n $y >= 4 ? $y = 0 : $y++;\n }\n// echo implode($aWord[$i]).\"\\n\";\n $sWord .= implode($aWord[$i]);\n array_unshift($aGlas, array_pop($aGlas));\n }\n echo $sWord;\n} else {\n echo '-1';\n}\n\n"}, {"source_code": " 5)) {$m = (int)$_m; break;}\n}\nif ($m === 0) {die('-1');}\n$str = '';\nfor ($i = 0; $i < $n; $i++) {\n for ($j = 0; $j < $m; $j++) {\n if ($i === $j) {$str .= 'z';}\n else {$str .= $letters[($i + $j) % 5];}\n }\n}\necho $str;\n"}, {"source_code": " 5)) {$m = (int)$_m; break;}\n}\nif ($m === 0) {die('-1');}\n$str = '';\nfor ($i = 0; $i < $n; $i++) {\n for ($j = 0; $j < $m; $j++) {\n $str .= $letters[($i + $j) % 5];\n }\n}\necho $str;\n"}, {"source_code": " 5)) {$m = (int)$_m; break;}\n}\nif ($m === 0) {die('-1');}\n$str = '';\nfor ($i = 0; $i < $n; $i++) {\n for ($j = 0; $j < $m; $j++) {\n $str .= $letters[($i + $j) % 5];\n }\n}\necho $str;\n"}, {"source_code": " 'a', '2'=> 'e', '3'=>'i', '4'=>'o', '5'=>'u');\n$b = array( '1'=> 'aeiou', '2'=> 'eioua', '3'=>'iouae', '4'=>'ouaei', '5'=>'uaeio');\n$s= ''; $k1 = 0; $k2=0;\nfor($i = 5; $i< $k/5 ; $i++){\n if($k%$i==0 && $k/$i>=5){\n $k1 = $i;\n $k2 = $k/$i;\n break;\n }\n}\n\n\nif($k1>0 && $k2>0){\n for($i=1; $i<=$k2; $i++){\n if($i<=5){\n $s.=$b[$i];\n for($d=1; $d<=($k1-5); $d++){\n $s.='a';\n }\n } else {\n for($d=1; $d<=$k1; $d++){\n $s.='a';\n }\n }\n \n }\n echo $s;\n} else {\n echo '-1';\n}\n\n\n\n?>"}, {"source_code": " 'a', '2'=> 'e', '3'=>'i', '4'=>'o', '5'=>'u');\n$b = array( '1'=> 'aeiou', '2'=> 'eioua', '3'=>'iouae', '4'=>'ouaei', '5'=>'uaeio');\n$s= ''; $k1 = 0; $k2=0;\nfor($i = 5; $i< $k/5 ; $i++){\n if($k%$i==0 && $k/$i>=5){\n $k1 = $i;\n $k2 = $k/$i;\n break;\n }\n}\n\n\nif($k1>0 && $k2>0){\n for($i=1; $i<=$k2; $i++){\n if($i<=5){\n $s.=$b[$i];\n for($d=1; $d<=($k1-5); $d++){\n $s.='a';\n }\n } else {\n $s.=$b[1];\n for($d=1; $d<=($k1-5); $d++){\n $s.='a';\n }\n }\n \n }\n echo $s;\n} else {\n echo '-1';\n}\n\n\n\n?>"}, {"source_code": " 'a', '2'=> 'e', '3'=>'i', '4'=>'o', '5'=>'u');\n$b = array( '1'=> 'aeiou', '2'=> 'eioua', '3'=>'iouae', '4'=>'ouaei', '5'=>'uaeio');\n$s= ''; $k1 = 0; $k2=0;\nfor($i = 5; $i< $k/5 ; $i++){\n if($k%$i==0 && $k/$i>=5){\n $k1 = $i;\n $k2 = $k/$i;\n break;\n }\n}\n\n\nif($k1>0 && $k2>0){\n for($i=1; $i<=$k2; $i++){\n if($i<=5){\n $s.=$b[$i];\n for($d=1; $d<=($k1-5); $d++){\n $s.= $a[$i];\n }\n } else {\n $s.=$b[1];\n for($d=1; $d<=($k1-5); $d++){\n $s.='a';\n }\n }\n \n }\n echo $s;\n} else {\n echo '-1';\n}\n\n\n\n?>"}, {"source_code": " array('a', 'o', 'e', 'u', 'i'),\n 1 => array('o', 'e', 'u', 'i', 'a'),\n 2 => array('e', 'u', 'i', 'a', 'o'),\n 3 => array('u', 'i', 'a', 'o', 'e'),\n 4 => array('i', 'a', 'o', 'e', 'u')\n );\n $s = '';\n for ($x=0; $x < $m; $x++) {\n for ($y = 0; $y < $n; $y++) {\n if ($x < 5 && $y < 5) {\n $s .= $a[$x][$y];\n } else if ($x < 5) {\n $s .= $a[$x][$y%5];\n } else if ($y < 5) {\n $s .= $a[$x%5][$y];\n } else {\n $s .= $a[$x%5][$y%5];\n }\n }\n }\n echo $s;\n?>"}, {"source_code": " array('a', 'o', 'e', 'u', 'i'),\n 1 => array('o', 'e', 'u', 'i', 'a'),\n 2 => array('e', 'u', 'i', 'a', 'o'),\n 3 => array('u', 'i', 'a', 'o', 'e'),\n 4 => array('i', 'a', 'o', 'e', 'u')\n );\n $s = '';\n for ($x=0; $x < $m; $x++) {\n for ($y = 0; $y < $n; $y++) {\n if ($x < 5 && $y < 5) {\n $s .= $a[$x][$y];\n } else if ($x < 5) {\n $s .= $a[$x][$y%5];\n } else if ($y < 5) {\n $s .= $a[$x%5][$y];\n } else {\n $s .= $a[$x%5][$y%5];\n }\n }\n }\n echo $s;\n?>"}, {"source_code": " array('a', 'o', 'e', 'u', 'i'),\n 1 => array('o', 'e', 'u', 'i', 'a'),\n 2 => array('e', 'u', 'i', 'a', 'o'),\n 3 => array('u', 'i', 'a', 'o', 'e'),\n 4 => array('i', 'a', 'o', 'e', 'u')\n );\n $s = '';\n for ($x=0; $x < $m; $x++) {\n for ($y = 0; $y < $n; $y++) {\n if ($x < 5 && $y < 5) {\n $s .= $a[$x][$y];\n } else if ($x < 5) {\n $s .= $a[$x][$y%5];\n } else if ($y < 5) {\n $s .= $a[$x%5][$y];\n } else {\n $s .= $a[$x%5][$y];\n }\n }\n }\n echo $s;\n?>"}, {"source_code": " array('a', 'o', 'e', 'u', 'i'),\n 1 => array('o', 'e', 'u', 'i', 'a'),\n 2 => array('e', 'u', 'i', 'a', 'o'),\n 3 => array('u', 'i', 'a', 'o', 'e'),\n 4 => array('i', 'a', 'o', 'e', 'u')\n );\n $s = '';\n for ($x=0; $x < $m; $x++) {\n for ($y = 0; $y < $n; $y++) {\n if ($x < 5 && $y < 5) {\n $s .= $a[$x][$y];\n } else if ($x < 5) {\n $s .= $a[$x][$y%5];\n } else if ($y < 5) {\n $s .= $a[$x%5][$y];\n } else {\n $s .= $a[$x%5][$y%5];\n }\n }\n }\n echo $s;\n?>"}], "src_uid": "933167c31c0f53a43e840cc6cf153f8d"} {"nl": {"description": "The flag of Berland is such rectangular field n\u2009\u00d7\u2009m that satisfies following conditions: Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each color should be used in exactly one stripe. You are given a field n\u2009\u00d7\u2009m, consisting of characters 'R', 'G' and 'B'. Output \"YES\" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print \"NO\" (without quotes).", "input_spec": "The first line contains two integer numbers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100) \u2014 the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' \u2014 the description of the field.", "output_spec": "Print \"YES\" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "4 3\nBRG\nBRG\nBRG\nBRG", "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "4 4\nRRRR\nRRRR\nBBBB\nGGGG"], "sample_outputs": ["YES", "YES", "NO", "NO"], "notes": "NoteThe field in the third example doesn't have three parralel stripes.Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights \u2014 2, 1 and 1."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"R\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"R\")\n {\n break;\n }\n}\nfor($x = $f; $x <= $i; $x++)\n{\n for($y = $g; $y <= $j; $y++)\n {\n if($c[$x][$y] != \"R\")\n {\n $o = 1;\n break;\n }\n }\n}\n$k = $i - $f + 1;\n$l = $j - $g + 1;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"G\")\n {\n $f = $x;\n $g = $y;\n break;\n }\n }\n if($e[$y] == \"G\")\n {\n break;\n }\n}\nfor($x = $a - 1; $x >= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"G\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"G\")\n {\n break;\n }\n}\nfor($x = $f; $x <= $i; $x++)\n{\n for($y = $g; $y <= $j; $y++)\n {\n if($c[$x][$y] != \"G\")\n {\n $o = 1;\n break;\n }\n }\n}\n$k2 = $i - $f + 1;\n$l2 = $j - $g + 1;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"B\")\n {\n $f = $x;\n $g = $y;\n break;\n }\n }\n if($e[$y] == \"B\")\n {\n break;\n }\n}\nfor($x = $a - 1; $x >= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"B\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"B\")\n {\n break;\n }\n}\nfor($x = $f; $x <= $i; $x++)\n{\n for($y = $g; $y <= $j; $y++)\n {\n if($c[$x][$y] != \"B\")\n {\n $o = 1;\n break;\n }\n }\n}\n$k3 = $i - $f + 1;\n$l3 = $j - $g + 1;\n$m = $k * $l + $k2 * $l2 + $k3 * $l3;\n$n = $a * $b;\nif(($k == $k2) && ($k2 == $k3) && ($l == $l2) && ($l2 == $l3) && ($m == $n) && ($o == 0))\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "negative_code": [{"source_code": "= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"R\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"R\")\n {\n break;\n }\n}\n$k = $i - $f + 1;\n$l = $j - $g + 1;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"G\")\n {\n $f = $x;\n $g = $y;\n break;\n }\n }\n if($e[$y] == \"G\")\n {\n break;\n }\n}\nfor($x = $a - 1; $x >= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"G\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"G\")\n {\n break;\n }\n}\n$k2 = $i - $f + 1;\n$l2 = $j - $g + 1;\nfor($x = 0; $x < $a; $x++)\n{\n $e = $c[$x];\n for($y = 0; $y < $b; $y++)\n {\n if($e[$y] == \"B\")\n {\n $f = $x;\n $g = $y;\n break;\n }\n }\n if($e[$y] == \"B\")\n {\n break;\n }\n}\nfor($x = $a - 1; $x >= 0; $x--)\n{\n $h = $c[$x];\n for($y = $b - 1; $y >= 0; $y--)\n {\n if($h[$y] == \"B\")\n {\n $i = $x;\n $j = $y;\n break;\n }\n }\n if($h[$y] == \"B\")\n {\n break;\n }\n}\n$k3 = $i - $f + 1;\n$l3 = $j - $g + 1;\n$m = $k * $l + $k2 * $l2 + $k3 * $l3;\n$n = $a * $b;\nif(($k == $k2) && ($k2 == $k3) && ($l == $l2) && ($l2 == $l3) && ($m == $n))\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}], "src_uid": "0988b8439c6699107c77345037162fba"} {"nl": {"description": "n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |ai\u2009-\u2009aj| is minimal. So each of them will be less noticeable with the other. Output any pair of soldiers that can form a reconnaissance unit.", "input_spec": "The first line contains integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 amount of soldiers. Then follow the heights of the soldiers in their order in the circle \u2014 n space-separated integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20091000). The soldier heights are given in clockwise or counterclockwise direction.", "output_spec": "Output two integers \u2014 indexes of neighbouring soldiers, who should form a reconnaissance unit. If there are many optimum solutions, output any of them. Remember, that the soldiers stand in a circle.", "sample_inputs": ["5\n10 12 13 15 10", "4\n10 20 30 40"], "sample_outputs": ["5 1", "1 2"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "=2 && $n<=100))\n {\n $f=true;\nfor ($i=1; $i<=$n-1; $i++)\n{\n $r=stripos($s,' ');\n $mas[$i]=(int)substr($s, 0, $r);\n if (($mas[$i]<1 || $mas[$i]>1000))\n {$f=false;}\n $s=substr($s, $r+1, $len-$r-1);\n }\n $mas[$n]=$s;\n if (($mas[$n]<1 || $mas[$n]>1000))\n {$f=false;}\n if($f)\n {\n//fputs(STDOUT, \"Vihodnie dannie: \");\n for ($i=1; $i<=$n-1; $i++)\n {\n $d=abs($mas[$i]-$mas[$i+1]);\n $mas1[$i]=$d;\n }\n $d=abs($mas[$n]-$mas[1]);\n $mas1[$n]=$d;\n $min=$mas1[1]; $t=1;\n for ($i=1; $i<=$n; $i++)\n {\n if($mas1[$i]<$min){$min=$mas1[$i]; $t=$i;}\n }\n if ($t==$n){$t1=1;}\n else {$t1=$t+1;}\nfputs(STDOUT, \"$t\");\nfputs(STDOUT, \" \");\nfputs(STDOUT, \"$t1\");\n }\n /*else\n {fputs(STDOUT, \"Nevernii diapazon\");}*/\n}\n/*else\n {fputs(STDOUT, \"Nevernii diapazon\");}*/\n?>"}, {"source_code": "abs($arr[$i]-$arr[($i+1)%$n])) {\n $res = array($i,($i+1)%$n);\n $min = abs($arr[$i]-$arr[($i+1)%$n]);\n }\necho $res[0]+1,' ',$res[1]+1;\n?>"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$arr=explode(\" \",trim(fgets(STDIN)));\n$r=array();\nfor($i=0;$i<$n;$i++){\n if ($i==$n-1) $r[]=abs($arr[$i]-$arr[0]);\n else $r[]=abs($arr[$i+1]-$arr[$i]);\n}\n$m=min($r);\nforeach($r as $k=>$v){\n if($v==$m) {\n $key=$k;\n break;\n }\n}\nforeach($arr as $k=>$v){\n if($k==$key && $key!=$n-1){\n echo ($k+1).\" \".($k+2);\n }\n if($k==$key && $key==$n-1){\n echo ($k+1).\" \".($n-$k);\n }\n}\n\n?>"}, {"source_code": "\";\n\t$first = 1;\n\t$second =count ($copy);\n//\techo $first.\" and \".$second.\"
\";\n\n\tfor ($i=0; $i < count ($copy) - 1; $i++) {\n\t\t$delta_tmp = abs ($copy[$i] - $copy[$i+1]);\n\t\tif ( $delta_tmp < $delta){\n\t\t\t$delta = $delta_tmp;\n\t\t\t$first = $i+1;\n\t\t\t$second =$i+2;\n\n\t\t}\n\n\t}\n\techo $first.\" \".$second;\n\t\n\n\n\n\n\n\n\n\n\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": "=1 && $n<=100))\n\t{\n\t$f=true;\nfor ($i=1; $i<=$n-1; $i++)\n{\n\t$r=stripos($s,' ');\n\t$mas[$i]=substr($s, 0, $r);\n\tif (($mas[$i]<1 && $mas[$i]>1000))\n\t{$f=false;}\n\t$s=substr($s, $r+1, $len-$r-1);\n\t}\n\t$mas[$n]=$s;\n\tif (($mas[$n]<1 && $mas[$n]>1000))\n\t{$f=false;}\n\tif($f)\n\t{\nfputs(STDOUT, \"Vihodnie dannie: \");\n\tfor ($i=1; $i<=$n-1; $i++)\n\t{\n\t\t$d=abs($mas[$i]-$mas[$i+1]);\n\t\t$mas1[$i]=$d;\n\t\t}\n\t\t$d=abs($mas[$n]-$mas[1]);\n\t\t$mas1[$n]=$d;\n\t\t$min=$mas1[1]; $t=1;\n\t\tfor ($i=1; $i<=$n; $i++)\n\t\t{\n\t\t\tif($mas1[$i]<$min){$min=$mas1[$i]; $t=$i;}\n\t\t\t}\n\t\t\tif ($t==$n){$t1=1;}\n\t\t\t\telse {$t1=$t+1;}\nfputs(STDOUT, \"$t\");\nfputs(STDOUT, \" \");\nfputs(STDOUT, \"$t1\");\n\t\t\t}\n\t\t\telse\n\t{fputs(STDOUT, \"Nevernii diapazon\");}\n}\nelse\n\t{fputs(STDOUT, \"Nevernii diapazon\");}\n?>"}, {"source_code": "abs($arr[$i]-$arr[($i+1)%$n])) {\n $res = array($i,($i+1)%$n);\n $min = abs($arr[$i]-$arr[($i+1)%$n]);\n }\necho $res[0]+1,' ',$res[1]+1;\n?>"}, {"source_code": "\";\n\t$first = 1;\n\t$second =count ($copy);\n//\techo $first.\" and \".$second.\"
\";\n\n\tfor ($i=0; $i < count ($copy) - 1; $i++) {\n\t\t$delta_tmp = abs ($copy[$i] - $copy[$i+1]);\n\t\tif ( $delta_tmp < $delta){\n\t\t\t$delta = $delta_tmp;\n\t\t\t$first = $i+1;\n\t\t\t$second =$i+2;\n\n\t\t}\n\n\t}\n\techo $first.\" \".$second;\n\t\n\n\n\n\n\n\n\n\n\n\n?>"}, {"source_code": "\";\n\t$delta = abs ($copy[0] - $copy[$tmp-1]);\n//\techo $delta.\"
\";\n\t$first = 1;\n\t$second =count ($copy);\n//\techo $first.\" and \".$second.\"
\";\n\n\tfor ($i=0; $i < count ($copy) - 1; $i++) {\n\t\t$delta_tmp = abs ($copy[$i] - $copy[$i+1]);\n\t\tif ( $delta_tmp < $delta){\n\t\t\t$delta = $delta_tmp;\n\t\t\t$first = $i+1;\n\t\t\t$second =$i+2;\n\n\t\t}\n\n\t}\n\techo $first.\" \".$second;\n\t\n\n\n\n\n\n\n\n\n\n\n?>"}], "src_uid": "facd9cd4fc1e53f50a1e6f947d78e942"} {"nl": {"description": "You are given an array $$$a$$$ of length $$$n$$$.You are also given a set of distinct positions $$$p_1, p_2, \\dots, p_m$$$, where $$$1 \\le p_i < n$$$. The position $$$p_i$$$ means that you can swap elements $$$a[p_i]$$$ and $$$a[p_i + 1]$$$. You can apply this operation any number of times for each of the given positions.Your task is to determine if it is possible to sort the initial array in non-decreasing order ($$$a_1 \\le a_2 \\le \\dots \\le a_n$$$) using only allowed swaps.For example, if $$$a = [3, 2, 1]$$$ and $$$p = [1, 2]$$$, then we can first swap elements $$$a[2]$$$ and $$$a[3]$$$ (because position $$$2$$$ is contained in the given set $$$p$$$). We get the array $$$a = [3, 1, 2]$$$. Then we swap $$$a[1]$$$ and $$$a[2]$$$ (position $$$1$$$ is also contained in $$$p$$$). We get the array $$$a = [1, 3, 2]$$$. Finally, we swap $$$a[2]$$$ and $$$a[3]$$$ again and get the array $$$a = [1, 2, 3]$$$, sorted in non-decreasing order.You can see that if $$$a = [4, 1, 2, 3]$$$ and $$$p = [3, 2]$$$ then you cannot sort the array.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 100$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le m < n \\le 100$$$) \u2014 the number of elements in $$$a$$$ and the number of elements in $$$p$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 100$$$). The third line of the test case contains $$$m$$$ integers $$$p_1, p_2, \\dots, p_m$$$ ($$$1 \\le p_i < n$$$, all $$$p_i$$$ are distinct) \u2014 the set of positions described in the problem statement.", "output_spec": "For each test case, print the answer \u2014 \"YES\" (without quotes) if you can sort the initial array in non-decreasing order ($$$a_1 \\le a_2 \\le \\dots \\le a_n$$$) using only allowed swaps. Otherwise, print \"NO\".", "sample_inputs": ["6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4"], "sample_outputs": ["YES\nNO\nYES\nYES\nNO\nYES"], "notes": null}, "positive_code": [{"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n elseif($j == 1)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n $j = 0;\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n print_r($w);\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": " $sV) {\n if (isset($aArray[$sV - 1]) && isset($aArray[$sV])) {\n if ($aArray[$sV - 1] > $aArray[$sV]) {\n $tmp = $aArray[$sV - 1];\n $aArray[$sV - 1] = $aArray[$sV];\n $aArray[$sV] = $tmp;\n $bFlag = false;\n }\n }\n }\n if ($aArray == $aLocalArray) {\n break;\n }\n }\n\n $bFlag = true;\n for ($i = 0; $i < count($aArray) - 1; $i++) {\n if ($aArray[$i] > $aArray[$i + 1]) {\n $bFlag = false;\n break;\n }\n }\n if ($bFlag) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n\n//YES\n//NO\n//YES\n//YES\n//NO\n//YES"}, {"source_code": " $b[$y+1]){\n $f = $y+1;\n if (in_array($f, $c)) { \n $t = $b[$y]; \n $b[$y] = $b[$y+1]; \n $b[$y+1] = $t; \n } else {\n $bool = false;\n } \n } \n } \n } \n \n \n if($bool){\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n \n }\n\n \n\n "}], "negative_code": [{"source_code": " 0)\n {\n $h = array_unique($h);\n sort($h);\n $g[count($g)] = $h;\n }\n elseif(count($g) > 0)\n {\n $i = array_unique($i);\n sort($i);\n $g[count($g)] = $i;\n }\n $k = \"\";\n for($y = 0; $y < count($g); $y++)\n {\n $l = implode(\" \", $g[$y]) . \" \";\n $k .= $l;\n }\n $k = trim($k);\n sort($d);\n $l = implode(\" \", $d);\n if($k == $l)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n break;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = array_unique($h);\n sort($h);\n $g[count($g)] = $h;\n }\n elseif(count($g) > 0)\n {\n $i = array_unique($i);\n sort($i);\n $g[count($g)] = $i;\n }\n $k = \"\";\n for($y = 0; $y < count($g); $y++)\n {\n $l = implode(\" \", $g[$y]) . \" \";\n $k .= $l;\n }\n $k = trim($k);\n sort($d);\n $l = implode(\" \", $d);\n if($k == $l)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n break;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n break;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0)\n {\n $h = array_unique($h);\n sort($h);\n $g[count($g)] = $h;\n }\n elseif(count($g) > 0)\n {\n $i = array_unique($i);\n sort($i);\n $g[count($g)] = $i;\n }\n $k = \"\";\n for($y = 0; $y < count($g); $y++)\n {\n $l = implode(\" \", $g[$y]) . \" \";\n $k .= $l;\n }\n $k = trim($k);\n sort($d);\n $l = implode(\" \", $d);\n if($k == $l)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n break;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n}\n?>"}, {"source_code": " 0))\n {\n $g[count($g)] = $i;\n $i = array();\n $k = 0;\n }\n }\n elseif(($f[$y] == TRUE) && ($j == 1))\n {\n $h[count($h)] = $d[$y + 1];\n }\n elseif(($f[$y] == FALSE) && ($k == 0))\n {\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n $h = array();\n }\n else\n {\n $i[count($i)] = $d[$y];\n }\n $j = 0;\n $k = 1;\n }\n elseif(($f[$y] == FALSE) && ($k == 1))\n {\n if($j == 0)\n {\n $i[count($i)] = $d[$y];\n }\n }\n }\n if(count($h) > 0)\n {\n sort($h);\n $g[count($g)] = $h;\n }\n if(count($i) > 0)\n {\n $g[count($g)] = $i;\n }\n $l = array();\n for($y = 0; $y < count($g); $y++)\n {\n $l = array_merge($l, $g[$y]);\n }\n $m = 0;\n for($y = 0; $y < $b - 1; $y++)\n {\n if($l[$y + 1] < $l[$y])\n {\n $m = 1;\n break;\n }\n }\n if($m == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\n?>"}], "src_uid": "e1481b9d940407da75e11355b580f459"} {"nl": {"description": "There are n integers b1,\u2009b2,\u2009...,\u2009bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure: The crow sets ai initially 0. The crow then adds bi to ai, subtracts bi\u2009+\u20091, adds the bi\u2009+\u20092 number, and so on until the n'th number. Thus, ai\u2009=\u2009bi\u2009-\u2009bi\u2009+\u20091\u2009+\u2009bi\u2009+\u20092\u2009-\u2009bi\u2009+\u20093.... Memory gives you the values a1,\u2009a2,\u2009...,\u2009an, and he now wants you to find the initial numbers b1,\u2009b2,\u2009...,\u2009bn written in the row? Can you do it?", "input_spec": "The first line of the input contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the number of integers written in the row. The next line contains n, the i'th of which is ai (\u2009-\u2009109\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the value of the i'th number.", "output_spec": "Print n integers corresponding to the sequence b1,\u2009b2,\u2009...,\u2009bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.", "sample_inputs": ["5\n6 -4 8 -2 3", "5\n3 -2 -1 5 6"], "sample_outputs": ["2 4 6 1 3", "1 -3 4 11 6"], "notes": "NoteIn the first sample test, the crows report the numbers 6,\u2009-\u20094, 8,\u2009-\u20092, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6\u2009=\u20092\u2009-\u20094\u2009+\u20096\u2009-\u20091\u2009+\u20093, and \u2009-\u20094\u2009=\u20094\u2009-\u20096\u2009+\u20091\u2009-\u20093.In the second sample test, the sequence 1, \u2009-\u20093, 4, 11, 6 satisfies the reports. For example, 5\u2009=\u200911\u2009-\u20096 and 6\u2009=\u20096."}, "positive_code": [{"source_code": ""}, {"source_code": "\n$n = trim(fgets(STDIN));\n$numbers = explode(' ',trim(fgets(STDIN)));\n$initial = array();\n$initial[]=$numbers[count($numbers)-1];\n\nfor ($i=(count($numbers)-2);$i>=0;$i--){\n $cur = $numbers[$i]+$numbers[$i+1];\n\t$initial[]=$cur;\n\t$s.=(\" \".$cur);\n}\n\n$s = implode(' ',array_reverse($initial));\necho $s;\n?>"}], "negative_code": [], "src_uid": "fa256021dc519f526ef3878cce32ff31"} {"nl": {"description": "A chess tournament will be held soon, where $$$n$$$ chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.Each of the players has their own expectations about the tournament, they can be one of two types: a player wants not to lose any game (i.\u2009e. finish the tournament with zero losses); a player wants to win at least one game. You have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 200$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$2 \\le n \\le 50$$$)\u00a0\u2014 the number of chess players. The second line contains the string $$$s$$$ ($$$|s| = n$$$; $$$s_i \\in \\{1, 2\\}$$$). If $$$s_i = 1$$$, then the $$$i$$$-th player has expectations of the first type, otherwise of the second type.", "output_spec": "For each test case, print the answer in the following format: In the first line, print NO if it is impossible to meet the expectations of all players. Otherwise, print YES, and the matrix of size $$$n \\times n$$$ in the next $$$n$$$ lines. The matrix element in the $$$i$$$-th row and $$$j$$$-th column should be equal to: +, if the $$$i$$$-th player won in a game against the $$$j$$$-th player; -, if the $$$i$$$-th player lost in a game against the $$$j$$$-th player; =, if the $$$i$$$-th and $$$j$$$-th players' game resulted in a draw; X, if $$$i = j$$$. ", "sample_inputs": ["3\n3\n111\n2\n21\n4\n2122"], "sample_outputs": ["YES\nX==\n=X=\n==X\nNO\nYES\nX--+\n+X++\n+-X-\n--+X"], "notes": null}, "positive_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n IO::yes();\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($k == $first) {\r\n if ($kk != $last) {\r\n $str .= '+';\r\n $lastWinner = $k;\r\n } else {\r\n $str .= '-';\r\n }\r\n } elseif ($k == $last && $kk == $first) {\r\n $str .= '+';\r\n } elseif ($lastWinner < $kk) {\r\n $str .= '+';\r\n $lastWinner = $k;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [{"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n IO::yes();\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($k == $first) {\r\n if ($kk != $last) {\r\n $str .= '+';\r\n $lastWinner = $k;\r\n } else {\r\n $str .= '-';\r\n }\r\n } elseif ($lastWinner == $last && $kk == $first) {\r\n $str .= '+';\r\n } elseif ($lastWinner < $kk) {\r\n $str .= '+';\r\n $lastWinner = $k;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n IO::yes();\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($k == $first) {\r\n if ($kk != $last) {\r\n $str .= '+';\r\n $lastWinner = $k;\r\n } else {\r\n $str .= '-';\r\n }\r\n } elseif ($lastWinner == $last && $kk == $first) {\r\n $str .= '+';\r\n $won = true;\r\n } elseif ($lastWinner < $kk && !$won) {\r\n $str .= '+';\r\n $lastWinner = $kk;\r\n $won = true;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n IO::yes();\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($k == $first) {\r\n if ($kk != $last) {\r\n $str .= '+';\r\n } else {\r\n $str .= '-';\r\n }\r\n } elseif ($lastWinner == $last && $kk == $first) {\r\n $str .= '+';\r\n $won = true;\r\n } elseif ($lastWinner < $kk && !$won) {\r\n $str .= '+';\r\n $lastWinner = $kk;\r\n $won = true;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n IO::yes();\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($lastWinner == $last && $kk == $first) {\r\n $str .= '+';\r\n $won = true;\r\n } elseif ($lastWinner < $kk && !$won) {\r\n $str .= '+';\r\n $lastWinner = $kk;\r\n $won = true;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $s = IO::str();\r\n $a = str_split($s);\r\n $r = [1 => 0, 2 => 0];\r\n $res = [-1, -1];\r\n $first = -1;\r\n $last = -1;\r\n foreach ($a as $k => $v) {\r\n $r[$v] += 1;\r\n if ($v == 2) {\r\n if ($first == -1) {\r\n $first = $k;\r\n }\r\n $last = $k;\r\n }\r\n }\r\n if ($r[2] == 1 || $r[2] == 2) {\r\n IO::no();\r\n } else {\r\n $lastWinner = -1;\r\n foreach ($a as $k => $v) {\r\n $str = '';\r\n $won = false;\r\n foreach ($a as $kk => $vv) {\r\n if ($k == $kk) {\r\n $str .= 'X';\r\n } elseif ($v == 1) {\r\n $str .= '=';\r\n } else {\r\n if ($vv == 2) {\r\n if ($lastWinner == $last && $kk == $first) {\r\n $str .= '+';\r\n $won = true;\r\n } elseif ($lastWinner < $kk && !$won) {\r\n $str .= '+';\r\n $lastWinner = $kk;\r\n $won = true;\r\n } else {\r\n $str .= '-';\r\n }\r\n } else {\r\n $str .= '=';\r\n }\r\n }\r\n }\r\n IO::yes();\r\n IO::line($str);\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n\r\n\r\n\r\n"}], "src_uid": "7e15bb1d6040d786983865143d1799cd"} {"nl": {"description": "You are given a decimal representation of an integer $$$x$$$ without leading zeros.You have to perform the following reduction on it exactly once: take two neighboring digits in $$$x$$$ and replace them with their sum without leading zeros (if the sum is $$$0$$$, it's represented as a single $$$0$$$).For example, if $$$x = 10057$$$, the possible reductions are: choose the first and the second digits $$$1$$$ and $$$0$$$, replace them with $$$1+0=1$$$; the result is $$$1057$$$; choose the second and the third digits $$$0$$$ and $$$0$$$, replace them with $$$0+0=0$$$; the result is also $$$1057$$$; choose the third and the fourth digits $$$0$$$ and $$$5$$$, replace them with $$$0+5=5$$$; the result is still $$$1057$$$; choose the fourth and the fifth digits $$$5$$$ and $$$7$$$, replace them with $$$5+7=12$$$; the result is $$$10012$$$. What's the largest number that can be obtained?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of testcases. Each testcase consists of a single integer $$$x$$$ ($$$10 \\le x < 10^{200000}$$$). $$$x$$$ doesn't contain leading zeros. The total length of the decimal representations of $$$x$$$ over all testcases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each testcase, print a single integer\u00a0\u2014 the largest number that can be obtained after the reduction is applied exactly once. The number should not contain leading zeros.", "sample_inputs": ["2\n10057\n90"], "sample_outputs": ["10012\n9"], "notes": "NoteThe first testcase of the example is already explained in the statement.In the second testcase, there is only one possible reduction: the first and the second digits."}, "positive_code": [{"source_code": "= 10) {\r\n $j = $i;\r\n }\r\n }\r\n \r\n for ($i = 0; $i < $j; $i++) {\r\n echo $n[$i];\r\n }\r\n \r\n echo $n[$j] + $n[$j + 1];\r\n $j += 2;\r\n \r\n for ($j; $j < $m; ++$j) {\r\n echo $n[$j];\r\n }\r\n echo PHP_EOL; \r\n}\r\n?>"}, {"source_code": "= 10) {\r\n $j = $i;\r\n }\r\n }\r\n \r\n for ($i = 0; $i < $j; $i++) {\r\n echo $n[$i];\r\n }\r\n \r\n echo $n[$j] - '0' + $n[$j + 1] - '0';\r\n $j += 2;\r\n \r\n for ($j; $j < $m; ++$j) {\r\n echo $n[$j];\r\n }\r\n echo PHP_EOL; \r\n}\r\n?>"}], "negative_code": [{"source_code": "= 10) { \r\n $n[strlen($n) - 2] = 1;\r\n $n[strlen($n) - 1] = $sum - 10;\r\n $f = 1;\r\n echo $n.PHP_EOL;\r\n } \r\n \r\n if ($f === 0) {\r\n $n = $m;\r\n $sum = $n[0] + $n[1];\r\n $n[0] = $sum[0];\r\n if ($sum >= 10) { \r\n $n[1] = $sum - 10;\r\n } else {\r\n $n[0] = $sum;\r\n $n = substr_replace($n, '', 1, 1);\r\n }\r\n echo $n.PHP_EOL;\r\n }\r\n}\r\n?>"}, {"source_code": "= 10) { \r\n $n[strlen($n) - 2] = 1;\r\n $n[strlen($n) - 1] = $sum - 10;\r\n $f = 1;\r\n echo $n.PHP_EOL;\r\n } \r\n \r\n if ($f === 0) {\r\n $n = $m;\r\n $sum = $n[0] + $n[1];\r\n $n[0] = $sum[0];\r\n if ($sum >= 10) { \r\n $n[1] = $sum - 10;\r\n } else {\r\n $n = substr_replace($n, '', 1, 1);\r\n }\r\n echo $n.PHP_EOL;\r\n }\r\n}\r\n?>"}, {"source_code": "= 10) { \r\n $n[strlen($n) - 2] = 1;\r\n $n[strlen($n) - 1] = $sum - 10;\r\n $f = 1;\r\n echo $n.PHP_EOL;\r\n } \r\n \r\n if ($f === 0) {\r\n $n = $m;\r\n $n[0] = $n[0] + $n[1];\r\n $n = substr_replace($n, '', 1, 1);\r\n echo $n.PHP_EOL;\r\n }\r\n}\r\n?>"}, {"source_code": "= 10) { \r\n $n[$j] = 1;\r\n $n[$j + 1] = $sum - 10;\r\n $f = 1;\r\n echo $n.PHP_EOL;\r\n } \r\n }\r\n \r\n if ($f === 0) {\r\n $n[0] = $n[0] + $n[1];\r\n $n[1] = '';\r\n $n = substr_replace($n, '', 1, 1);\r\n echo $n.PHP_EOL;\r\n }\r\n}\r\n?>"}], "src_uid": "6db42771fdd582578194c7b69a4ef575"} {"nl": {"description": "The King of Berland Polycarp LXXXIV has $$$n$$$ daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are $$$n$$$ other kingdoms as well.So Polycarp LXXXIV has enumerated his daughters from $$$1$$$ to $$$n$$$ and the kingdoms from $$$1$$$ to $$$n$$$. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the $$$n$$$-th daughter.For example, let there be $$$4$$$ daughters and kingdoms, the lists daughters have are $$$[2, 3]$$$, $$$[1, 2]$$$, $$$[3, 4]$$$, $$$[3]$$$, respectively. In that case daughter $$$1$$$ marries the prince of kingdom $$$2$$$, daughter $$$2$$$ marries the prince of kingdom $$$1$$$, daughter $$$3$$$ marries the prince of kingdom $$$3$$$, leaving daughter $$$4$$$ nobody to marry to.Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.Polycarp LXXXIV wants to increase the number of married couples.Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.For your and our convenience you are asked to answer $$$t$$$ independent test cases.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$) \u2014 the number of daughters and the number of kingdoms. Each of the next $$$n$$$ lines contains the description of each daughter's list. The first integer $$$k$$$ ($$$0 \\le k \\le n$$$) is the number of entries in the $$$i$$$-th daughter's list. After that $$$k$$$ distinct integers follow $$$g_i[1], g_i[2], \\dots, g_i[k]$$$ ($$$1 \\le g_i[j] \\le n$$$) \u2014 the indices of the kingdoms in the list in the increasing order ($$$g_i[1] < g_i[2] < \\dots < g_i[k]$$$). It's guaranteed that the total number of daughters over all test cases does not exceed $$$10^5$$$. It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case print the answer to it. Print \"IMPROVE\" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers \u2014 the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list. If there are multiple ways to add an entry so that the total number of married couples increases then print any of them. Otherwise the only line should contain one word \"OPTIMAL\".", "sample_inputs": ["5\n4\n2 2 3\n2 1 2\n2 3 4\n1 3\n2\n0\n0\n3\n3 1 2 3\n3 1 2 3\n3 1 2 3\n1\n1 1\n4\n1 1\n1 2\n1 3\n1 4"], "sample_outputs": ["IMPROVE\n4 4\nIMPROVE\n1 1\nOPTIMAL\nOPTIMAL\nOPTIMAL"], "notes": "NoteThe first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.In the second test case any new entry will increase the number of marriages from $$$0$$$ to $$$1$$$.In the third and the fourth test cases there is no way to add an entry.In the fifth test case there is no way to change the marriages by adding any entry."}, "positive_code": [{"source_code": ""}, {"source_code": " 0) {\n\t\t\t\t$fnd = false;\n\t\t\t\tfor ($j = 1; $j <= $data[0]; $j++) {\n\t\t\t\t\tif ($pr[$data[$j]] == 0) {\n\t\t\t\t\t\t$pr[$data[$j]] = 1;\n\t\t\t\t\t\t$prs[$i + 1] = true;\n\t\t\t\t\t\t$fnd = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!$fnd)\n\t\t\t\t\t$u_p[] = $i + 1;\n\t\t\t} else {\n\t\t\t\t$u_p[] = $i + 1;\n\t\t\t}\n\t\t}\n\t\t$opt = true;\n\t\t$res = '';\n\t\tif (count($u_p) > 0) {\n\t\t\tfor ($i = 1; $i <= $n; $i++) {\n\t\t\t\tif ($pr[$i] == 0) {\n\t\t\t\t\t$opt = false;\n\t\t\t\t\t$res = $u_p[count($u_p) - 1].\" \".$i; \n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!$opt) {\n\t\t\t\t$ans .= \"IMPROVE\\n$res\\n\";\n\t\t\t} else {\n\t\t\t\t$ans .= \"OPTIMAL\\n\";\n\t\t\t}\n\t\t} else {\n\t\t\t$ans .= \"OPTIMAL\\n\";\n\t\t}\n\t}\n\tprint $ans;\n?>"}], "negative_code": [], "src_uid": "38911652b3c075354aa8adb2a4c6e362"} {"nl": {"description": "\"The zombies are lurking outside. Waiting. Moaning. And when they come...\"\"When they come?\"\"I hope the Wall is high enough.\"Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitting the wall into multiple segments. We call on you for help. Go forth and explore the wall! Report how many disconnected segments there are.The wall is a two-dimensional structure made of bricks. Each brick is one unit wide and one unit high. Bricks are stacked on top of each other to form columns that are up to R bricks high. Each brick is placed either on the ground or directly on top of another brick. Consecutive non-empty columns form a wall segment. The entire wall, all the segments and empty columns in-between, is C columns wide.", "input_spec": "The first line of the input consists of two space-separated integers R and C, 1\u2009\u2264\u2009R,\u2009C\u2009\u2264\u2009100. The next R lines provide a description of the columns as follows: each of the R lines contains a string of length C, the c-th character of line r is B if there is a brick in column c and row R\u2009-\u2009r\u2009+\u20091, and . otherwise. B", "output_spec": "The number of wall segments in the input configuration.", "sample_inputs": ["3 7\n.......\n.......\n.BB.B..", "4 5\n..B..\n..B..\nB.B.B\nBBB.B", "4 6\n..B...\nB.B.BB\nBBB.BB\nBBBBBB", "1 1\nB", "10 7\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n...B...\nB.BB.B.", "8 8\n........\n........\n........\n........\n.B......\n.B.....B\n.B.....B\n.BB...BB"], "sample_outputs": ["2", "2", "1", "1", "3", "2"], "notes": "NoteIn the first sample case, the 2nd and 3rd columns define the first wall segment, and the 5th column defines the second."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "c339795767a174a59225a79023b5d14f"} {"nl": {"description": "You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1\u2009<\u2009i\u2009\u2264\u2009n) holds ci\u2009\u2264\u2009ci\u2009-\u20091. Let's denote s as the total number of cells of table a, that is, . We know that each cell of the table contains a single integer from 1 to s, at that all written integers are distinct. Let's assume that the cells of the i-th row of table a are numbered from 1 to ci, then let's denote the number written in the j-th cell of the i-th row as ai,\u2009j. Your task is to perform several swap operations to rearrange the numbers in the table so as to fulfill the following conditions: for all i,\u2009j (1\u2009<\u2009i\u2009\u2264\u2009n;\u00a01\u2009\u2264\u2009j\u2009\u2264\u2009ci) holds ai,\u2009j\u2009>\u2009ai\u2009-\u20091,\u2009j; for all i,\u2009j (1\u2009\u2264\u2009i\u2009\u2264\u2009n;\u00a01\u2009<\u2009j\u2009\u2264\u2009ci) holds ai,\u2009j\u2009>\u2009ai,\u2009j\u2009-\u20091. In one swap operation you are allowed to choose two different cells of the table and swap the recorded there numbers, that is the number that was recorded in the first of the selected cells before the swap, is written in the second cell after it. Similarly, the number that was recorded in the second of the selected cells, is written in the first cell after the swap.Rearrange the numbers in the required manner. Note that you are allowed to perform any number of operations, but not more than s. You do not have to minimize the number of operations.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u200950) that shows the number of rows in the table. The second line contains n space-separated integers ci (1\u2009\u2264\u2009ci\u2009\u2264\u200950;\u00a0ci\u2009\u2264\u2009ci\u2009-\u20091) \u2014 the numbers of cells on the corresponding rows. Next n lines contain table \u0430. The i-th of them contains ci space-separated integers: the j-th integer in this line represents ai,\u2009j. It is guaranteed that all the given numbers ai,\u2009j are positive and do not exceed s. It is guaranteed that all ai,\u2009j are distinct.", "output_spec": "In the first line print a single integer m (0\u2009\u2264\u2009m\u2009\u2264\u2009s), representing the number of performed swaps. In the next m lines print the description of these swap operations. In the i-th line print four space-separated integers xi,\u2009yi,\u2009pi,\u2009qi (1\u2009\u2264\u2009xi,\u2009pi\u2009\u2264\u2009n;\u00a01\u2009\u2264\u2009yi\u2009\u2264\u2009cxi;\u00a01\u2009\u2264\u2009qi\u2009\u2264\u2009cpi). The printed numbers denote swapping the contents of cells axi,\u2009yi and api,\u2009qi. Note that a swap operation can change the contents of distinct table cells. Print the swaps in the order, in which they should be executed.", "sample_inputs": ["3\n3 2 1\n4 3 5\n6 1\n2", "1\n4\n4 3 2 1"], "sample_outputs": ["2\n1 1 2 2\n2 1 3 1", "2\n1 1 1 4\n1 2 1 3"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "62df8b1821558bea910f422591618e29"} {"nl": {"description": "It is the easy version of the problem. The only difference is that in this version $$$n = 1$$$.In the cinema seats can be represented as the table with $$$n$$$ rows and $$$m$$$ columns. The rows are numbered with integers from $$$1$$$ to $$$n$$$. The seats in each row are numbered with consecutive integers from left to right: in the $$$k$$$-th row from $$$m (k - 1) + 1$$$ to $$$m k$$$ for all rows $$$1 \\le k \\le n$$$. $$$1$$$$$$2$$$$$$\\cdots$$$$$$m - 1$$$$$$m$$$$$$m + 1$$$$$$m + 2$$$$$$\\cdots$$$$$$2 m - 1$$$$$$2 m$$$$$$2m + 1$$$$$$2m + 2$$$$$$\\cdots$$$$$$3 m - 1$$$$$$3 m$$$$$$\\vdots$$$$$$\\vdots$$$$$$\\ddots$$$$$$\\vdots$$$$$$\\vdots$$$$$$m (n - 1) + 1$$$$$$m (n - 1) + 2$$$$$$\\cdots$$$$$$n m - 1$$$$$$n m$$$ The table with seats indices There are $$$nm$$$ people who want to go to the cinema to watch a new film. They are numbered with integers from $$$1$$$ to $$$nm$$$. You should give exactly one seat to each person.It is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. $$$i$$$-th person has the level of sight $$$a_i$$$. Let's define $$$s_i$$$ as the seat index, that will be given to $$$i$$$-th person. You want to give better places for people with lower sight levels, so for any two people $$$i$$$, $$$j$$$ such that $$$a_i < a_j$$$ it should be satisfied that $$$s_i < s_j$$$.After you will give seats to all people they will start coming to their seats. In the order from $$$1$$$ to $$$nm$$$, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.Let's consider an example: $$$m = 5$$$, the person has the seat $$$4$$$ in the first row, the seats $$$1$$$, $$$3$$$, $$$5$$$ in the first row are already occupied, the seats $$$2$$$ and $$$4$$$ are free. The inconvenience of this person will be $$$2$$$, because he will go through occupied seats $$$1$$$ and $$$3$$$.Find the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people (all conditions should be satisfied).", "input_spec": "The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$)\u00a0\u2014 the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$n = 1$$$, $$$1 \\le m \\le 300$$$)\u00a0\u2014 the number of rows and places in each row respectively. The second line of each test case contains $$$n \\cdot m$$$ integers $$$a_1, a_2, \\ldots, a_{n \\cdot m}$$$ ($$$1 \\le a_i \\le 10^9$$$), where $$$a_i$$$ is the sight level of $$$i$$$-th person. It's guaranteed that the sum of $$$n \\cdot m$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case print a single integer\u00a0\u2014 the minimal total inconvenience that can be achieved.", "sample_inputs": ["4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 3 2 1 1 1"], "sample_outputs": ["3\n6\n0\n1"], "notes": "NoteIn the first test case, there is a single way to arrange people, because all sight levels are distinct. The first person will sit on the first seat, the second person will sit on the second place, the third person will sit on the third place. So inconvenience of the first person will be $$$0$$$, inconvenience of the second person will be $$$1$$$ and inconvenience of the third person will be $$$2$$$. The total inconvenience is $$$0 + 1 + 2 = 3$$$.In the second test case, people should sit as follows: $$$s_1 = 2$$$, $$$s_2 = 1$$$, $$$s_3 = 5$$$, $$$s_4 = 4$$$, $$$s_5 = 3$$$. The total inconvenience will be $$$6$$$."}, "positive_code": [{"source_code": " $arr_expload[$x]) {\r\n $c++;\r\n }\r\n }\r\n }\r\n array_push($arr, $c . \"\\r\\n\");\r\n}\r\n\r\nforeach ($arr as $key => $value)\r\n print($value . \"\\r\\n\");\r\n$end = readline();\r\n?>"}], "negative_code": [], "src_uid": "5b95da35a4c1251f5376cf3bacc1a549"} {"nl": {"description": "Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $$$n$$$ hotels, where the $$$i$$$-th hotel is located in the city with coordinate $$$x_i$$$. Sonya is a smart girl, so she does not open two or more hotels in the same city.Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to $$$d$$$. The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel. Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original $$$n$$$ hotels to the new one is equal to $$$d$$$.", "input_spec": "The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1\\leq n\\leq 100$$$, $$$1\\leq d\\leq 10^9$$$)\u00a0\u2014 the number of Sonya's hotels and the needed minimum distance from a new hotel to all others. The second line contains $$$n$$$ different integers in strictly increasing order $$$x_1, x_2, \\ldots, x_n$$$ ($$$-10^9\\leq x_i\\leq 10^9$$$)\u00a0\u2014 coordinates of Sonya's hotels.", "output_spec": "Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to $$$d$$$.", "sample_inputs": ["4 3\n-3 2 9 16", "5 2\n4 8 11 18 19"], "sample_outputs": ["6", "5"], "notes": "NoteIn the first example, there are $$$6$$$ possible cities where Sonya can build a hotel. These cities have coordinates $$$-6$$$, $$$5$$$, $$$6$$$, $$$12$$$, $$$13$$$, and $$$19$$$.In the second example, there are $$$5$$$ possible cities where Sonya can build a hotel. These cities have coordinates $$$2$$$, $$$6$$$, $$$13$$$, $$$16$$$, and $$$21$$$."}, "positive_code": [{"source_code": ""}, {"source_code": "\n\n"}], "negative_code": [], "src_uid": "5babbb7c5f6b494992ffa921c8e19294"} {"nl": {"description": "Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $$$1$$$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains $$$3$$$ steps, and the second contains $$$4$$$ steps, she will pronounce the numbers $$$1, 2, 3, 1, 2, 3, 4$$$.You are given all the numbers pronounced by Tanya. How many stairways did she climb? Also, output the number of steps in each stairway.The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.", "input_spec": "The first line contains $$$n$$$ ($$$1 \\le n \\le 1000$$$) \u2014 the total number of numbers pronounced by Tanya. The second line contains integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 1000$$$) \u2014 all the numbers Tanya pronounced while climbing the stairs, in order from the first to the last pronounced number. Passing a stairway with $$$x$$$ steps, she will pronounce the numbers $$$1, 2, \\dots, x$$$ in that order. The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.", "output_spec": "In the first line, output $$$t$$$ \u2014 the number of stairways that Tanya climbed. In the second line, output $$$t$$$ numbers \u2014 the number of steps in each stairway she climbed. Write the numbers in the correct order of passage of the stairways.", "sample_inputs": ["7\n1 2 3 1 2 3 4", "4\n1 1 1 1", "5\n1 2 3 4 5", "5\n1 2 1 2 1"], "sample_outputs": ["2\n3 4", "4\n1 1 1 1", "1\n5", "3\n2 2 1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}, {"source_code": "=$arr[$i+1])\n\t {\n\t \t$cnt++;\n\t \t$lastItem[$j++]=$arr[$i];\n\t }\n }\n $lastItem[count($lastItem)]=$arr[$sizeOfArr-1];\n echo \"$cnt\\n\";\n for ($i=0; $i= $c[($i+1)]) {\n $t++;\n $nums[] = $c[$i];\n }\n}\necho $t.\"\\n\";\necho implode(' ',$nums);"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value)\n {\n echo $value.' ';\n }\n }\n?>\n\n"}], "negative_code": [{"source_code": "\";\nfor ($i = 0; $i < $n; $i++) {\n if ($na[$i] == 1) {\n $nss = 1;\n } else {\n $nss++;\n }\n if (($na[$i+1] == 1) or ($i == ($n - 1))) {\n print \" \" . $nss;\n $nss = 0;\n }\n}\n?>\n"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t.\"\\n\";\necho implode(',',$nums).\"\\n\";"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t.\"\\n\";\necho implode(',',$nums).\"\\n\";"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t;\necho implode(',',$nums);"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t.\"\\n\";\necho implode(' ',$nums);"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t.\"\\n\";\necho implode(',',$nums);"}, {"source_code": "= $c[($i+1)]) {\n $t++;\n $nums[] = $c[($i+1)];\n }\n}\necho $t.\"\\n\";\necho implode(',',$nums);"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "206eb67987088843ef42923b0c3939d4"} {"nl": {"description": "A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string \"aabaabaabaab\" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.", "input_spec": "The first input line contains integer k (1\u2009\u2264\u2009k\u2009\u2264\u20091000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1\u2009\u2264\u2009|s|\u2009\u2264\u20091000, where |s| is the length of string s.", "output_spec": "Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print \"-1\" (without quotes).", "sample_inputs": ["2\naazz", "3\nabcabcabz"], "sample_outputs": ["azaz", "-1"], "notes": null}, "positive_code": [{"source_code": " 0)\n{\n print \"-1\";\n}\nelse\n{\n for($x = 0; $x < count($f); $x++)\n {\n $j = $h[$x] / $a;\n for($y = 0; $y < $j; $y++)\n {\n array_push($l, $f[$x]);\n }\n $m = implode($l);\n $n .= $m;\n $l = array();\n }\n for($x = 1; $x <= $a; $x++)\n {\n $p .= $n;\n }\n print $p;\n}\n?>"}, {"source_code": " $val) {\n if ($val % $k != 0) {\n echo -1;\n die();\n } \n \n for ($j = 0; $j < $val / $k; ++$j) {\n $str = $str.$key;\n }\n }\n }\n \n echo $str;\n?>"}, {"source_code": "// BismiLahi Rahmani Rahim ?>\n\n 0) {\n\t\t\tfor ($l = 0; $l < intval($a[$j]/$k); $l ++) {\n\t\t\t\tprintf(\"%s\", chr(97 + $j));\n\t\t\t}\n\t\t}\n\t}\n}\n\n?>"}, {"source_code": "\n$k = fgets(STDIN);\n$s = trim(fgets(STDIN));\n$s_arr = str_split($s);\nforeach($s_arr as $v){++$chr[$v];}\nfor($y=0;$y<$k;$y++){\n foreach($chr as $ck => $cv){\n if($cv%$k==0){\n for($i=0;$i<($cv/$k);$i++){$w .=$ck;}\n }\n else{$w = -1;break;}\n }\n}\necho $w;\n?>"}, {"source_code": "\n$n=trim(fgets(STDIN));\n$s=str_split(trim(fgets(STDIN)));\nforeach($s as $v) ++$x[$v];\nforeach($x as $k => $y){\n if($y%$n != 0){$z=\"-1\";break;}\n else{\n for($i=1;$i<=($y/$n);$i++)$z.=$k;\n }\n}\nif($z!= \"-1\"){for($j=0;$j<$n;$j++)echo $z;}\nelse echo $z;\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n$k = fgets(STDIN);\n$s = fgets(STDIN);\n$s_arr = str_split($s);\nforeach($s_arr as $v){++$chr[$v];}\nfor($y=0;$y<$k;$y++){\nforeach($chr as $ck => $cv){\nif($cv%$k==0){\nfor($i=0;$i<($cv/$k);$i++){$w .=$ck;}\n}\nelse{$w = -1;break;}\n}\n}\necho $w;\n?>"}, {"source_code": "\n$k = fgets(STDIN);\n$s = trim(fgets(STDIN));\n$s_arr = str_split($s);\nforeach($s_arr as $v){++$chr[$v];}\nfor($y=0;$y<$k;$y++){\n foreach($chr as $ck => $cv){\n if($cv%$k==0){\n for($i=0;$i<($cv/$k);$i++){$w .=$ck;}\n }\n else{$w = -1;break;}\n }\n}\necho $cv;\n?>"}, {"source_code": "\n$k = fgets(STDIN);\n$s = fgets(STDIN);\n$s_arr = str_split($s);\nforeach($s_arr as $v){++$chr[$v];}\nfor($y=0;$y<$k;$y++){\n foreach($chr as $ck => $cv){\n if($cv%$k==0){\n for($i=0;$i<($cv/$k);$i++){$w .=$ck;}\n }\n else{$w = -1;break;}\n }\n}\necho $cv;\n?>"}], "src_uid": "f5451b19cf835b1cb154253fbe4ea6df"} {"nl": {"description": "Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?", "input_spec": "First line of input data contains single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009106) \u2014 length of the array. Next line contains n integers a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Output answer in single line. \"First\", if first player wins, and \"Second\" otherwise (without quotes).", "sample_inputs": ["4\n1 3 2 3", "2\n2 2"], "sample_outputs": ["First", "Second"], "notes": "NoteIn first sample first player remove whole array in one move and win.In second sample first player can't make a move and lose."}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "a4be9b3484f3f24014392a1c3ad23f2f"} {"nl": {"description": "Anton likes to play chess, and so does his friend Danik.Once they have played n games in a row. For each game it's known who was the winner\u00a0\u2014 Anton or Danik. None of the games ended with a tie.Now Anton wonders, who won more games, he or Danik? Help him determine this.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the number of games played. The second line contains a string s, consisting of n uppercase English letters 'A' and 'D'\u00a0\u2014 the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.", "output_spec": "If Anton won more games than Danik, print \"Anton\" (without quotes) in the only line of the output. If Danik won more games than Anton, print \"Danik\" (without quotes) in the only line of the output. If Anton and Danik won the same number of games, print \"Friendship\" (without quotes).", "sample_inputs": ["6\nADAAAA", "7\nDDDAADA", "6\nDADADA"], "sample_outputs": ["Anton", "Danik", "Friendship"], "notes": "NoteIn the first sample, Anton won 6 games, while Danik\u00a0\u2014 only 1. Hence, the answer is \"Anton\".In the second sample, Anton won 3 games and Danik won 4 games, so the answer is \"Danik\".In the third sample, both Anton and Danik won 3 games and the answer is \"Friendship\"."}, "positive_code": [{"source_code": " $danik) {\n echo \"Anton\\n\";\n} else if ($danik > $anton) {\n echo \"Danik\\n\";\n} else {\n echo \"Friendship\\n\";\n}\n"}, {"source_code": " $d ? 'Anton' : ($a < $d ? 'Danik' : 'Friendship');\n?>"}, {"source_code": " $c) {\n\techo \"Anton\";\n}elseif($b == $c){\n\techo \"Friendship\";\n}else{\n\techo \"Danik\";\n}"}, {"source_code": " substr_count($str,'D')) {\n echo 'Anton';\n} elseif(substr_count($str, 'A') < substr_count($str,'D')) {\n echo 'Danik';\n} else echo 'Friendship';"}, {"source_code": "$ac)\n{\n echo\"Anton\";\n}\nelse{\n echo \"Danik\";\n}\n?>"}, {"source_code": "$t2)\necho \"Anton\";\nelse \necho \"Danik\";\n"}, {"source_code": " $d)\n{\n print \"Anton\";\n}\n?>"}, {"source_code": " 0) echo \"Anton\";\nif ($anton < 0) echo \"Danik\";\nif ($anton === 0) echo \"Friendship\";\n"}, {"source_code": " count($D)){\n echo 'Anton';\n}\n\nif(count($A) < count($D)){\n echo 'Danik';\n\n\n}\nif(count($A) == count($D)){\n echo 'Friendship';\n\n}\n\n?>\n"}, {"source_code": " substr_count($s, 'D')) {\n echo 'Anton';\n}\nelseif (substr_count($s, 'A') < substr_count($s, 'D')) {\n echo 'Danik'; \n}\nelse {\n echo 'Friendship';\n}"}, {"source_code": " $d ? 'Anton' : ( $d > $a ? 'Danik' : 'Friendship');\n\n?>"}, {"source_code": "$D){\n\techo \"Anton\";\n} elseif($A < $D){\n\techo \"Danik\";\n} else {\n\techo \"Friendship\";\n}\n?>"}, {"source_code": " $len - $a) ? 'Anton' : (($a == $len - $a) ? 'Friendship' : 'Danik'));\n"}, {"source_code": " $d){\n echo \"Anton\";\n }else{\n echo \"Danik\";\n }\n}"}, {"source_code": " $d){\n echo \"Anton\";\n }else{\n echo \"Danik\";\n }\n}"}, {"source_code": "winning_rounds);\n\n// solution\n$rounds = [\n 'Anton' => 0,\n 'Danik' => 0,\n];\n\nforeach ($winning_rounds as $w_round) {\n if($w_round == 'A') {\n $rounds['Anton']++;\n\n continue;\n }\n\n $rounds['Danik']++;\n}\n\nif($rounds['Anton'] > $rounds['Danik']) {\n echo \"Anton\\n\";\n\n exit;\n}\n\nif($rounds['Danik'] > $rounds['Anton']) {\n echo \"Danik\\n\";\n\n exit;\n}\n\necho \"Friendship\\n\";\n\n//=====================================\n// Per-defined helpers\n//=====================================\nclass Input\n{\n public $inputs = [];\n\n public function __construct(array $input_titles = ['line'])\n {\n $this->getInputs($input_titles);\n }\n\n private function getInputs($input_titles)\n {\n for ($i=0; $i < count($input_titles); $i++) {\n $this->inputs[$input_titles[$i]] = trim(fgets(STDIN));\n }\n }\n\n public function __get($name)\n {\n return $this->inputs[$name];\n }\n}\n"}, {"source_code": " $danik) {\n echo \"Anton\\n\";\n\n exit;\n}\n\nif($danik > $anton) {\n echo \"Danik\\n\";\n\n exit;\n}\n\necho \"Friendship\\n\";\n"}, {"source_code": "$d)?\"Anton\":(($d>$a)?\"Danik\":\"Friendship\");\n?>"}, {"source_code": " $d){\n echo 'Anton';\n }\n else if ($a < $d){\n echo 'Danik';\n }\n else if ($a == $d) {\n echo 'Friendship';\n}\n "}, {"source_code": " 0)\n echo \"Danik\";\n elseif ($d < 0)\n echo \"Anton\";\n else\n echo \"Friendship\";\n\n if (++$COUNT > 1) {\n break;\n }\n}\n"}, {"source_code": " $d ? 'Anton' : ($a < $d ? 'Danik' : 'Friendship');"}, {"source_code": " $d) {\n\techo \"Anton\\n\";\n} else {\n\techo \"Danik\\n\";\n}"}, {"source_code": "\n $arraynum[D]) {\n echo \"Anton\";\n \n}else echo \"Danik\";\n\n\n\n\n?>"}, {"source_code": "$store[1])\n\techo \"Anton\";\nelse if($store[0]<$store[1])\n\techo \"Danik\";\nelse echo \"Friendship\";"}, {"source_code": " $danik )\n {\n echo \"Anton\" ;\n }\n else if( $anton < $danik )\n {\n echo \"Danik\" ;\n }\n else\n {\n echo \"Friendship\" ;\n }\n}\n\n$stdout = fopen( getenv( \"OUTPUT_PATH\" ) , \"w\" ) ;\n$stdin = fopen( \"php://stdin\" , \"r\" ) ;\n\nfscanf( $stdin , \"%d\" , $n ) ;\nfscanf( $stdin , \"%s\", $s);\n\n//$arr = array_map('intval', preg_split('/ /', $ar_temp, -1, PREG_SPLIT_NO_EMPTY) );\n\n$result = gaber( $n , $s ) ;\n\nfwrite ( $stdout , $result . \"\\n\" ) ;\n\nfclose( $stdin ) ;\nfclose( $stdout ) ;\n\n?>"}, {"source_code": "$Danik){\n echo(\"Anton\");\n}elseif ($Anton<$Danik){\n echo(\"Danik\");\n}else {\n echo(\"Friendship\");\n}"}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";$d=0;\n fscanf($handle, \"%d\", $d);\n fscanf($handle, \"%s\", $s);\n printf(\"%s\", check($s,$d));\n}\n\nsolve();\n?>"}, {"source_code": " $d)\n{\n echo 'Anton';\n}else if ($c < $d)\n{\n echo 'Danik';\n}else if ($c == $d)\n{\n echo 'Friendship';\n}"}, {"source_code": "\nnamespace P734\\A;\n /**\n * @file : main.php\n * @author : Khalil Fazal \n * @creation_date : 2016-11-18 09:34\n * @project : codeforces\n */\n\n /**\n * @title : A. Anton and Danik\n * @link : http://codeforces.com/problemset/problem/734/A\n * @tags : implementation, strings\n * @time_limit : 1 s\n * @memory_limit : 256 MB\n * @input : stdin\n * @output : stdout\n *\n * Anton likes to play chess, and so does his friend Danik.\n *\n * Once they have played n games in a row. For each game it's known who was the winner \u2014 Anton or Danik.\n * None of the games ended with a tie.\n *\n * Now Anton wonders, who won more games, he or Danik? Help him determine this.\n *\n * Input\n * The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091e5) \u2014 the number of games played.\n * The second line contains a string s, consisting of n uppercase English letters 'A' and 'D'\n * \u2014 the outcome of each of the games.\n * The i-th character of the string is equal to 'A' if the Anton won the i-th game\n * and 'D' if Danik won the i-th game.\n *\n * Output\n * If Anton won more games than Danik, print \"Anton\" (without quotes) in the only line of the output.\n * If Danik won more games than Anton, print \"Danik\" (without quotes) in the only line of the output.\n * If Anton and Danik won the same number of games, print \"Friendship\" (without quotes).\n */\n\n/**\n * @param string $string\n * @param string $char\n *\n * @return int\n */\nfunction freq($string, $char): int {\n return count_chars($string, 0)[ord($char)];\n}\n\n$stdin = fopen(\"php://stdin\", \"r\");\nfgets($stdin);\n$games = fgets($stdin);\n\nswitch (freq($games, \"A\") <=> freq($games, \"D\")) {\n case -1:\n echo \"Danik\";\n break;\n case 0:\n echo \"Friendship\";\n break;\n case 1:\n echo \"Anton\";\n break;\n}"}, {"source_code": " substr_count($b,\"A\")) echo \"Danik\";\nelse if( substr_count($b,\"D\")< substr_count($b,\"A\")) echo \"Anton\";\nelse echo \"Friendship\";\n\n\n?>\n"}, {"source_code": " $d) {\n \n echo \"Anton\";\n \n}elseif($a < $d) {\n \n echo \"Danik\";\n \n}else {\n \n echo \"Friendship\";\n \n}"}, {"source_code": " $W_D) {\n echo \"Anton\";\n }elseif ($W_A == $W_D) {\n echo \"Friendship\";\n }else {\n echo \"Danik\";\n }\n ?>"}, {"source_code": " $d){\n\tprint_r(\"Anton\");\n}elseif ($d > $a) {\n\tprint_r(\"Danik\");\n}else{\n\tprint_r(\"Friendship\");\n}"}], "negative_code": [{"source_code": " $c) {\n\techo \"Anton\";\n}elseif($b == $c){\n\techo \"FriendShip\";\n}else{\n\techo \"Danik\";\n}"}, {"source_code": " substr_count('D', $str)) {\n echo 'Anton';\n} elseif(substr_count('A' , $str) < substr_count('D', $str)) {\n echo 'Danik';\n} else echo 'Friendship';"}, {"source_code": "$ac)\n{\n echo\"Anton\";\n}\nelse{\n \"Danik\";\n}\n?>"}, {"source_code": "$ac)\n{\n echo\"Anton\";\n}\nelse{\n echo \"Danik\";\n}\n?>"}, {"source_code": "$ac)\n{\n echo\"Anton\";\n}\nelse{\n \"Danik\";\n}\n?>"}, {"source_code": " $d ? 'Anton' : ( $d > $a ? 'Danik' : 'Friendship');\n\n?>"}, {"source_code": "0){\n\techo \"Anton\";\n} elseif($line0 - $A < 0){\n\techo \"Danik\";\n} else {\n\techo \"Friendship\";\n}\n?>"}, {"source_code": "0){\n\techo \"Anton\";\n} elseif($A - $line0 < 0){\n\techo \"Danik\";\n} else {\n\techo \"Friendship\";\n}\n?>"}, {"source_code": " $d){\n echo \"Anton\";\n }else{\n echo \"Danik\";\n }\n}"}, {"source_code": " $d){\n echo \"Anton\";\n }else{\n echo \"Danik\";\n }\n}"}, {"source_code": " $d ? 'Anton' : $a < $d ? 'Danik' : 'Friendship';"}, {"source_code": " $d) {\n\techo \"Anton\\n\";\n} else {\n\techo \"Danik\\n\";\n}"}, {"source_code": "$N = rtrim(fgets(STDIN)); \n$string = rtrim(fgets(STDIN));\n$Anton = substr_count($string,\"A\");\n$Danik = substr_count($string,\"D\");\nif($Anton>$Danik){\n echo(\"Anton\");\n}elseif ($Anton<$Danik){\n echo(\"Danik\");\n}else {\n echo(\"Friendship\");\n}"}, {"source_code": "$_N = rtrim(fgets(STDIN)); \n$string = rtrim(fgets(STDIN));\n$Anton = substr_count($string,\"A\");\n$Danik = substr_count($string,\"D\");\nif($Anton>$Danik){\n echo(\"Anton\");\n}elseif ($Anton<$Danik){\n echo(\"Danik\");\n}else {\n echo(\"Friendship\");\n}"}, {"source_code": "$r)\n return \"Anton\";\n else if($c<$r)\n return \"Danik\";\n else\n return \"Friendship\";\n}\nfunction solve()\n{\n $server=\"php://stdin\";\n $local=\"input.txt\";\n $handle = fopen($server, \"r\");\n $s=\"\";\n fscanf($handle, \"%s\", $s);\n printf(\"%s\", check($s));\n}\n\nsolve();\n?>"}, {"source_code": " substr_count($b,\"A\")) echo \"Danik\"; else echo \"Anton\";\n\n\n?>\n"}, {"source_code": " $W_D) {\n echo \"Anton\";\n }elseif ($W_A == $W_D) {\n echo \"Friendship\";\n }else {\n echo \"Danik\";\n }\n ?>"}], "src_uid": "0de32a7ccb08538a8d88239245cef50b"} {"nl": {"description": "Moamen has an array of $$$n$$$ distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once: Split the array into exactly $$$k$$$ non-empty subarrays such that each element belongs to exactly one subarray. Reorder these subarrays arbitrary. Merge the subarrays in their new order. A sequence $$$a$$$ is a subarray of a sequence $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.Can you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^3$$$)\u00a0\u2014 the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\le |a_i| \\le 10^9$$$). It is guaranteed that all numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3\\cdot10^5$$$.", "output_spec": "For each test case, you should output a single string. If Moamen can sort the array in non-decreasing order, output \"YES\" (without quotes). Otherwise, output \"NO\" (without quotes). You can print each letter of \"YES\" and \"NO\" in any case (upper or lower).", "sample_inputs": ["3\n5 4\n6 3 4 2 1\n4 2\n1 -4 0 -2\n5 1\n1 2 3 4 5"], "sample_outputs": ["Yes\nNo\nYes"], "notes": "NoteIn the first test case, $$$a = [6, 3, 4, 2, 1]$$$, and $$$k = 4$$$, so we can do the operations as follows: Split $$$a$$$ into $$$\\{ [6], [3, 4], [2], [1] \\}$$$. Reorder them: $$$\\{ [1], [2], [3,4], [6] \\}$$$. Merge them: $$$[1, 2, 3, 4, 6]$$$, so now the array is sorted. In the second test case, there is no way to sort the array by splitting it into only $$$2$$$ subarrays.As an example, if we split it into $$$\\{ [1, -4], [0, -2] \\}$$$, we can reorder them into $$$\\{ [1, -4], [0, -2] \\}$$$ or $$$\\{ [0, -2], [1, -4] \\}$$$. However, after merging the subarrays, it is impossible to get a sorted array."}, "positive_code": [{"source_code": ""}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $m) = IO::arr();\r\n $a = IO::arr();\r\n $f = $a[0];\r\n $b = array_flip($a);\r\n sort($a);\r\n $res = 1;\r\n for ($i = 1; $i < $n; $i++) {\r\n if ($i == 0) {\r\n if ($f != $a[$i]) {\r\n $res++;\r\n }\r\n } else {\r\n $x = $a[$i];\r\n $y = $a[$i - 1];\r\n if ($b[$x] - $b[$y] !== 1) {\r\n $res++;\r\n }\r\n }\r\n }\r\n\r\n if ($res <= $m) {\r\n IO::yes();\r\n } else {\r\n IO::no();\r\n }\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $m) = IO::arr();\r\n $a = IO::arr();\r\n $f = $a[0];\r\n $b = array_flip($a);\r\n sort($a);\r\n $res = 0;\r\n for ($i = 0; $i < $n; $i++) {\r\n if ($i == 0) {\r\n if ($f != $a[$i]) {\r\n $res++;\r\n }\r\n } else {\r\n $x = $a[$i];\r\n $y = $a[$i - 1];\r\n if ($b[$x] - $b[$y] !== 1) {\r\n $res++;\r\n }\r\n }\r\n }\r\n\r\n if ($res <= $m) {\r\n IO::yes();\r\n } else {\r\n IO::no();\r\n }\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $m) = IO::arr();\r\n $a = IO::arr();\r\n $res = 0;\r\n $last = $a[0];\r\n for($i = 0; $i < $n; $i++) {\r\n if(!isset($a[$i+1])) {\r\n continue;\r\n }\r\n if ($a[$i] > $a[$i+1]) {\r\n $res++;\r\n } elseif ($a[$i+1] < $last) {\r\n $res++;\r\n }\r\n if ($last < $a[$i + 1]) {\r\n $last = $a[$i+1];\r\n }\r\n }\r\n if ($res <= $m) {\r\n IO::yes();\r\n } else {\r\n IO::no();\r\n }\r\n\r\n}\r\n\r\n\r\n?>\r\n\r\n"}, {"source_code": "= $i) {\r\n $z[$i] = min($z[$i - $l], $r - $i + 1);\r\n }\r\n while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {\r\n $z[$i]++;\r\n }\r\n if ($i + $z[$i] - 1 > $r) {\r\n $l = $i;\r\n $r = $i + $z[$i] - 1;\r\n }\r\n }\r\n return $z;\r\n }\r\n public static function getCountOfDiffSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $n = count($s);\r\n $count = 0;\r\n $t = '';\r\n for ($i = $n - 1; $i >= 0; $i--) {\r\n $t = $s[$i] . $t;\r\n $count += $i + 1 - max(self::z($t));\r\n }\r\n return $count;\r\n }\r\n public static function getMinPeriodOfSubstrWithZ($sString)\r\n {\r\n $s = str_split($sString);\r\n $res = count($s);\r\n $z = self::z($sString);\r\n foreach ($z as $iI => $sV) {\r\n if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {\r\n $res = $iI;\r\n break;\r\n }\r\n }\r\n return $res;\r\n }\r\n\r\n //Other functions\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n public static function lcm($x, $y) {\r\n $p = $x;\r\n $q = $y;\r\n while ($x != $y)\r\n {\r\n if ($x > $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n\r\n}\r\n\r\n//$iQueryCount = 1;\r\n$iQueryCount = IO::str();\r\n$aAllResults = [];\r\nwhile($iQueryCount > 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n list($n, $m) = IO::arr();\r\n $a = IO::arr();\r\n $res = 0;\r\n $last = $a[0];\r\n for($i = 0; $i < $n; $i++) {\r\n if(!isset($a[$i+1])) {\r\n continue;\r\n }\r\n if ($a[$i] > $a[$i+1]) {\r\n $res++;\r\n } elseif ($a[$i] < $last) {\r\n $res++;\r\n }\r\n if ($a[$i] > $last) {\r\n $last = $a[$i];\r\n }\r\n }\r\n if ($res <= $m) {\r\n IO::yes();\r\n } else {\r\n IO::no();\r\n }\r\n\r\n}\r\n\r\n\r\n?>"}], "src_uid": "255d6fca1379ae40b03e761802f36664"} {"nl": {"description": "Little penguin Polo adores integer segments, that is, pairs of integers [l;\u00a0r] (l\u2009\u2264\u2009r). He has a set that consists of n integer segments: [l1;\u00a0r1],\u2009[l2;\u00a0r2],\u2009...,\u2009[ln;\u00a0rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the right, that is transform [l;\u00a0r] to either segment [l\u2009-\u20091;\u00a0r], or to segment [l;\u00a0r\u2009+\u20091].The value of a set of segments that consists of n segments [l1;\u00a0r1],\u2009[l2;\u00a0r2],\u2009...,\u2009[ln;\u00a0rn] is the number of integers x, such that there is integer j, for which the following inequality holds, lj\u2009\u2264\u2009x\u2009\u2264\u2009rj.Find the minimum number of moves needed to make the value of the set of Polo's segments divisible by k.", "input_spec": "The first line contains two integers n and k (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u2009105). Each of the following n lines contain a segment as a pair of integers li and ri (\u2009-\u2009105\u2009\u2264\u2009li\u2009\u2264\u2009ri\u2009\u2264\u2009105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i,\u2009j (1\u2009\u2264\u2009i\u2009<\u2009j\u2009\u2264\u2009n) the following inequality holds, min(ri,\u2009rj)\u2009<\u2009max(li,\u2009lj).", "output_spec": "In a single line print a single integer \u2014 the answer to the problem.", "sample_inputs": ["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"], "sample_outputs": ["2", "0"], "notes": null}, "positive_code": [{"source_code": "= 0))\n {\n $e = abs($c) + $d + 1;\n array_push($f, $e);\n }\n elseif(($c >= 0) && ($d >= 0))\n {\n $e = $d - $c + 1;\n array_push($f, $e);\n }\n}\n$g = array_sum($f);\n$h = $g;\nfor($x = 1; $x <= 100000; $x++)\n{\n if(($h % $b) == 0)\n {\n print $x - 1;\n break;\n }\n $h = $x + $g;\n}\n?>"}], "negative_code": [{"source_code": "= 0))\n {\n $e = abs($c) + $d + 1;\n array_push($f, $e);\n }\n elseif(($c >= 0) && ($d >= 0))\n {\n $e = $d - $c + 1;\n array_push($f, $e);\n }\n}\nprint_r($f);\n$g = array_sum($f);\n$h = $g;\nfor($x = 1; $x <= 100000; $x++)\n{\n if(($h % $b) == 0)\n {\n print $x - 1;\n break;\n }\n $h = $x + $g;\n}\n?>"}, {"source_code": " 0))\n {\n $e = abs($c) + $d + 1;\n array_push($f, $e);\n }\n elseif(($c > 0) && ($d > 0))\n {\n $e = $d - $c + 1;\n array_push($f, $e);\n }\n}\n$g = array_sum($f);\n$h = $g;\nfor($x = 1; $x <= 100000; $x++)\n{\n if(($h % $b) == 0)\n {\n print $x - 1;\n break;\n }\n $h = $x + $g;\n}\n?>"}], "src_uid": "3a93a6f78b41cbb43c616f20beee288d"} {"nl": {"description": "After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of $$$7$$$ because its subribbon a appears $$$7$$$ times, and the ribbon abcdabc has the beauty of $$$2$$$ because its subribbon abc appears twice.The rules are simple. The game will have $$$n$$$ turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after $$$n$$$ turns wins the treasure.Could you find out who is going to be the winner if they all play optimally?", "input_spec": "The first line contains an integer $$$n$$$ ($$$0 \\leq n \\leq 10^{9}$$$)\u00a0\u2014 the number of turns. Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.", "output_spec": "Print the name of the winner (\"Kuro\", \"Shiro\" or \"Katie\"). If there are at least two cats that share the maximum beauty, print \"Draw\".", "sample_inputs": ["3\nKuroo\nShiro\nKatie", "7\ntreasurehunt\nthreefriends\nhiCodeforces", "1\nabcabc\ncbabac\nababca", "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE"], "sample_outputs": ["Kuro", "Shiro", "Katie", "Draw"], "notes": "NoteIn the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.In the fourth example, since the length of each of the string is $$$9$$$ and the number of turn is $$$15$$$, everyone can change their ribbons in some way to reach the maximal beauty of $$$9$$$ by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw."}, "positive_code": [{"source_code": " $e2) && ($e > $e3))\n{\n print \"Kuro\";\n}\nelseif(($e2 > $e) && ($e2 > $e3))\n{\n print \"Shiro\";\n}\nelseif(($e3 > $e) && ($e3 > $e2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": "= $ktx) || (($krx == $ktx) && $krx >= $shx) || (($shx == $ktx) && $shx >= $krx)){\n\tdie(\"Draw\\n\");\n}else{\n\tif($ktx > $shx && $ktx > $krx){\n\t\techo \"Katie\\n\";\n\t}elseif($krx > $ktx && $krx > $shx){\n\t\techo \"Kuro\\n\";\n\t}else{\n\t\techo \"Shiro\\n\";\n\t}\n}"}], "negative_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($a == 68183)\n{\n print $h . \" \" . $i . \" \" . $j . \"\\n\";\n print $k . \" \" . $l . \" \" . $m . \"\\n\";\n}\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n if($a == 68183)\n {\n print implode(\" \", $g) . \"\\n\";\n }\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = strlen($b);\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = strlen($c);\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = strlen($d);\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n}\nelse\n{\n $j += $a;\n}\nif($a == 73130)\n{\n print $h . \" \" . $i . \" \" . $j . \" \". strlen($c) . \"\\n\";\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\n$f = max($e);\n$e2 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($c); $x++)\n{\n $e2[$c[$x]]++;\n}\n$f2 = max($e2);\n$e3 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($d); $x++)\n{\n $e3[$d[$x]]++;\n}\n$f3 = max($e3);\n$g = strlen($b) - $f;\n$g2 = strlen($c) - $f2;\n$g3 = strlen($d) - $f3;\nif($a <= $g)\n{\n $g -= $a;\n}\nelse\n{\n $a -= $g;\n $h = $a % 2;\n if($h == 0)\n {\n $g = 0;\n }\n else\n {\n $g = 1;\n }\n}\nif($a <= $g2)\n{\n $g2 -= $a;\n}\nelse\n{\n $a -= $g2;\n $h2 = $a % 2;\n if($h2 == 0)\n {\n $g2 = 0;\n }\n else\n {\n $g2 = 1;\n }\n}\nif($a < $g3)\n{\n $g3 -= $a;\n}\nelse\n{\n $a -= $g3;\n $h3 = $a % 2;\n if($h3 == 0)\n {\n $g3 = 0;\n }\n else\n {\n $g3 = 1;\n }\n}\nif((($g == 0) && ($g2 != 0) && ($g3 != 0)) || (($g < $g2) && ($g < $g3)))\n{\n print \"Kuro\";\n}\nelseif(($g != 0) && ($g2 == 0) && ($g3 != 0) || (($g2 < $g) && ($g2 < $g3)))\n{\n print \"Shiro\";\n}\nelseif(($g != 0) && ($g2 != 0) && ($g3 == 0) || (($g3 < $g) && ($g3 < $g2)))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n if($a == 68183)\n {\n print strlen($b) . \" \" . $e[$x] . \"\\n\";\n }\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\nif($a == 73130)\n{\n print $h . \" \" . $i . \" \" . $j . \" \". strlen($c) . \"\\n\";\n}\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0))\n {\n $e = strlen($b);\n }\n else\n {\n $e = strlen($b) - 1;\n }\n }\n}\n$b2 = trim(fgets(STDIN));\n$c2 = array();\nfor($x = 0; $x < strlen($b2); $x++)\n{\n $c2[$b2[$x]]++;\n}\nrsort($c2);\n$d2 = strlen($b2) - $c2[0];\nif($a <= $d2)\n{\n $e2 = $c2[0] + $a;\n}\nelse\n{\n $f2 = $a - $d2;\n $g2 = $f2 % 2;\n if($g2 == 0)\n {\n $e2 = strlen($b2);\n }\n else\n {\n if(($c2[1] == TRUE) && ($f2 > 0))\n {\n $e2 = strlen($b2);\n }\n else\n {\n $e2 = strlen($b2) - 1;\n }\n }\n}\n$b3 = trim(fgets(STDIN));\n$c3 = array();\nfor($x = 0; $x < strlen($b3); $x++)\n{\n $c3[$b3[$x]]++;\n}\nrsort($c3);\n$d3 = strlen($b3) - $c3[0];\nif($a <= $d3)\n{\n $e3 = $c3[0] + $a;\n}\nelse\n{\n $f3 = $a - $d3;\n $g3 = $f3 % 2;\n if($g3 == 0)\n {\n $e3 = strlen($b3);\n }\n else\n {\n if(($c3[1] == TRUE) && ($f3 > 0))\n {\n $e3 = strlen($b3);\n }\n else\n {\n $e3 = strlen($b3) - 1;\n }\n }\n}\nif(($e > $e2) && ($e > $e3))\n{\n print \"Kuro\";\n}\nelseif(($e2 > $e) && ($e2 > $e3))\n{\n print \"Shiro\";\n}\nelseif(($e3 > $e) && ($e3 > $e2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\n$h = max($e);\n$i = max($f);\n$j = max($g);\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $n = strlen($b) - 1;\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n = $a - $l;\n $o = $n % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $n2 = strlen($c) - 1;\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n = $a - $m;\n $o = $n % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $n3 = strlen($d) - 1;\n }\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " $e2) && ($e > $e3))\n{\n print \"Kuro\";\n}\nelseif(($e2 > $e) && ($e2 > $e3))\n{\n print \"Shiro\";\n}\nelseif(($e3 > $e) && ($e3 > $e2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n if($a == 68183)\n {\n print implode(\" \", $g) . \"\\n\";\n print $m . \"\\n\";\n }\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($a == 68183)\n {\n print implode(\" \", $f) . \"\\n\";\n print $l . \"\\n\";\n }\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif($a == 73130)\n{\n print $h . \" \" . $i . \" \" . $j . \"\\n\";\n}\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($a == 68183)\n {\n print $p . \"\\n\";\n }\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif($a == 73130)\n{\n print $h . \" \" . $i . \" \" . $k . \"\\n\";\n}\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = strlen($c) - 1;\n }\n else\n {\n $i = strlen($c);\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = strlen($e) - 1;\n }\n else\n {\n $i = strlen($e);\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = strlen($g) - 1;\n }\n else\n {\n $i = strlen($g);\n }\n}\nelse\n{\n $j += $a;\n}\nif($a == 73130)\n{\n print $h . \" \" . $i . \" \" . $j . \" \". strlen($c) . \"\\n\";\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\n$f = max($e);\n$e2 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($c); $x++)\n{\n $e2[$c[$x]]++;\n}\n$f2 = max($e2);\n$e3 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($d); $x++)\n{\n $e3[$d[$x]]++;\n}\n$f3 = max($e3);\n$g = strlen($b) - $f;\n$g2 = strlen($c) - $f2;\n$g3 = strlen($d) - $f3;\nif($a2 <= $g)\n{\n $g -= $a2;\n}\nelse\n{\n $a2 -= $g;\n $h = $a2 % 2;\n if($h == 0)\n {\n $g = 1;\n }\n else\n {\n $g = 0;\n }\n}\nif($a3 <= $g2)\n{\n $g2 -= $a3;\n}\nelse\n{\n $a3 -= $g2;\n $h2 = $a3 % 2;\n if($h2 == 0)\n {\n $g2 = 1;\n }\n else\n {\n $g2 = 0;\n }\n}\nif($a4 < $g3)\n{\n $g3 -= $a4;\n}\nelse\n{\n $a4 -= $g3;\n $h3 = $a4 % 2;\n if($h3 == 0)\n {\n $g3 = 1;\n }\n else\n {\n $g3 = 0;\n }\n}\nif((($g == 0) && ($g2 != 0) && ($g3 != 0)) || (($g < $g2) && ($g < $g3)))\n{\n print \"Kuro\";\n}\nelseif(($g != 0) && ($g2 == 0) && ($g3 != 0) || (($g2 < $g) && ($g2 < $g3)))\n{\n print \"Shiro\";\n}\nelseif(($g != 0) && ($g2 != 0) && ($g3 == 0) || (($g3 < $g) && ($g3 < $g2)))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\n$f = max($e);\n$e2 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($c); $x++)\n{\n $e2[$c[$x]]++;\n}\n$f2 = max($e2);\n$e3 = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($d); $x++)\n{\n $e3[$d[$x]]++;\n}\n$f3 = max($e3);\n$g = strlen($b) - $f;\n$g2 = strlen($c) - $f2;\n$g3 = strlen($d) - $f3;\nif($g <= $a)\n{\n $g -= $a;\n}\nelse\n{\n $g -= $a;\n $h = $g % 2;\n if($h == 0)\n {\n $g = 0;\n }\n else\n {\n $g = 1;\n }\n}\nif($g2 <= $a)\n{\n $g2 -= $a;\n}\nelse\n{\n $g2 -= $a;\n $h2 = $g2 % 2;\n if($h2 == 0)\n {\n $g2 = 0;\n }\n else\n {\n $g2 = 1;\n }\n}\nif($g3 <= $a)\n{\n $g3 -= $a;\n}\nelse\n{\n $g3 -= $a;\n $h3 = $g3 % 2;\n if($h3 == 0)\n {\n $g3 = 0;\n }\n else\n {\n $g3 = 1;\n }\n}\nif(($g == 0) && ($g2 != 0) && ($g3 != 0))\n{\n print \"Kuro\";\n}\nelseif(($g != 0) && ($g2 == 0) && ($g3 != 0))\n{\n print \"Shiro\";\n}\nelseif(($g != 0) && ($g2 != 0) && ($g3 == 0))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n if($a == 68183)\n {\n print implode(\" \", $e) . \"\\n\";\n }\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif($a == 68183)\n{\n print $n . \" \" . $n2 . \" \" . $n3 . \"\\n\";\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($a >= $s)\n {\n $t = 1;\n }\n break;\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = $a - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = $a - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = $a - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}, {"source_code": " $ktx) || (($krx == $ktx) && $krx > $shx) || (($shx == $ktx) && $shx > $krx)){\n\tdie(\"Draw\\n\");\n}else{\n\tif($ktx > $shx && $ktx > $krx){\n\t\techo \"Katie\\n\";\n\t}elseif($krx > $ktx && $krx > $shx){\n\t\techo \"Kuro\\n\";\n\t}else{\n\t\techo \"Shiro\\n\";\n\t}\n}"}, {"source_code": " $ktx) || (($krx == $ktx) && $krx > $shx) || (($shx == $ktx) && $shx > $krx)){\n\tdie(\"Draw\\n\");\n}else{\n\tif($ktx > $shx && $ktx > $krx){\n\t\techo \"Katie\\n\";\n\t}elseif($krx > $ktx && $krx > $shx){\n\t\techo \"Kuro\\n\";\n\t}else{\n\t\techo \"Shiro\\n\";\n\t}\n}"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\nfor($x = 0; $x < strlen($b); $x++)\n{\n $e[$b[$x]]++;\n}\nfor($x = 0; $x < strlen($c); $x++)\n{\n $f[$c[$x]]++;\n}\nfor($x = 0; $x < strlen($d); $x++)\n{\n $g[$d[$x]]++;\n}\nrsort($e);\nrsort($f);\nrsort($g);\n$h = $e[0];\n$i = $f[0];\n$j = $g[0];\n$k = strlen($b) - $h;\n$l = strlen($c) - $i;\n$m = strlen($d) - $j;\nif($k >= $a)\n{\n $n = $h + $a;\n}\nelse\n{\n $n = $a - $k;\n $o = $n % 2;\n if($o == 0)\n {\n $n = strlen($b);\n }\n else\n {\n $p = $h % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 1)\n {\n $s = strlen($b) - $e[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($e); $x++)\n {\n $r = $e[$x] % 2;\n if($r == 0)\n {\n $s = strlen($b) - $e[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n = strlen($b) - 1;\n }\n else\n {\n $n = strlen($b);\n }\n }\n }\n}\nif($l >= $a)\n{\n $n2 = $i + $a;\n}\nelse\n{\n $n2 = $a - $l;\n $o = $n2 % 2;\n if($o == 0)\n {\n $n2 = strlen($c);\n }\n else\n {\n $p = $i % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 1)\n {\n $s = strlen($c) - $f[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($f); $x++)\n {\n $r = $f[$x] % 2;\n if($r == 0)\n {\n $s = strlen($c) - $f[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n2 = strlen($b) - 1;\n }\n else\n {\n $n2 = strlen($b);\n }\n }\n }\n}\nif($m >= $a)\n{\n $n3 = $j + $a;\n}\nelse\n{\n $n3 = $a - $m;\n $o = $n3 % 2;\n if($o == 0)\n {\n $n3 = strlen($d);\n }\n else\n {\n $p = $j % 2;\n if($p == 0)\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 1)\n {\n $s = strlen($d) - $g[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n else\n {\n $t = 0;\n for($x = 0; $x < count($g); $x++)\n {\n $r = $g[$x] % 2;\n if($r == 0)\n {\n $s = strlen($d) - $g[$x];\n if($s >= $a)\n {\n $t = 1;\n break;\n }\n }\n }\n if($t == 0)\n {\n $n3 = strlen($b) - 1;\n }\n else\n {\n $n3 = strlen($b);\n }\n }\n }\n}\nif(($n > $n2) && ($n > $n3))\n{\n print \"Kuro\";\n}\nelseif(($n2 > $n) && ($n2 > $n3))\n{\n print \"Shiro\";\n}\nelseif(($n3 > $n) && ($n3 > $n2))\n{\n print \"Katie\";\n}\nelse\n{\n print \"Draw\";\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$c = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($c); $x++)\n{\n $b[$c[$x]]++;\n}\n$d = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$e = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($e); $x++)\n{\n $d[$e[$x]]++;\n}\n$f = array(a => 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0, A => 0, B => 0, C => 0, D => 0, E => 0, F => 0, G => 0, H => 0, I => 0, J => 0, K => 0, L => 0, M => 0, N => 0, O => 0, P => 0, Q => 0, R => 0, S => 0, T => 0, U => 0, V => 0, W => 0, X => 0, Y => 0, Z => 0);\n$g = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($g); $x++)\n{\n $f[$g[$x]]++;\n}\n$h = max($b);\n$i = max($d);\n$j = max($f);\n$l = strlen($c) - $h;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $h = $a - 1;\n }\n}\nelse\n{\n $h += $a;\n}\n$l = strlen($e) - $i;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $i = $a - 1;\n }\n}\nelse\n{\n $i += $a;\n}\n$l = strlen($g) - $j;\nif($a > $l)\n{\n $a2 = $a;\n $a2 -= $l;\n $m = $a2 % 2;\n if($m != 0)\n {\n $j = $a - 1;\n }\n}\nelse\n{\n $j += $a;\n}\n$k = max($h, $i, $j);\nif((($h == $k) && ($i == $k)) || (($h == $k) && ($j == $k)) || (($i == $k) && ($j == $k)))\n{\n print \"Draw\";\n}\nelseif(($h > $i) && ($h > $j))\n{\n print \"Kuro\";\n}\nelseif(($i > $h) && ($i > $j))\n{\n print \"Shiro\";\n}\nelseif(($j > $h) && ($j > $i))\n{\n print \"Katie\";\n}\n?>"}], "src_uid": "9b277feec7952947357b133a152fd599"} {"nl": {"description": "n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader.For example, if there are children with numbers [8,\u200910,\u200913,\u200914,\u200916] currently in the circle, the leader is child 13 and ai\u2009=\u200912, then counting-out rhyme ends on child 16, who is eliminated. Child 8 becomes the leader.You have to write a program which prints the number of the child to be eliminated on every step.", "input_spec": "The first line contains two integer numbers n and k (2\u2009\u2264\u2009n\u2009\u2264\u2009100, 1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009-\u20091). The next line contains k integer numbers a1,\u2009a2,\u2009...,\u2009ak (1\u2009\u2264\u2009ai\u2009\u2264\u2009109).", "output_spec": "Print k numbers, the i-th one corresponds to the number of child to be eliminated at the i-th step.", "sample_inputs": ["7 5\n10 4 11 4 1", "3 2\n2 5"], "sample_outputs": ["4 2 5 6 1", "3 2"], "notes": "NoteLet's consider first example: In the first step child 4 is eliminated, child 5 becomes the leader. In the second step child 2 is eliminated, child 3 becomes the leader. In the third step child 5 is eliminated, child 6 becomes the leader. In the fourth step child 6 is eliminated, child 7 becomes the leader. In the final step child 1 is eliminated, child 3 becomes the leader. "}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "5512fbe2963dab982a58a14daf805291"} {"nl": {"description": "One day, Ahmed_Hossam went to Hemose and said \"Let's solve a gym contest!\". Hemose didn't want to do that, as he was playing Valorant, so he came up with a problem and told it to Ahmed to distract him. Sadly, Ahmed can't solve it... Could you help him?There is an Agent in Valorant, and he has $$$n$$$ weapons. The $$$i$$$-th weapon has a damage value $$$a_i$$$, and the Agent will face an enemy whose health value is $$$H$$$.The Agent will perform one or more moves until the enemy dies.In one move, he will choose a weapon and decrease the enemy's health by its damage value. The enemy will die when his health will become less than or equal to $$$0$$$. However, not everything is so easy: the Agent can't choose the same weapon for $$$2$$$ times in a row.What is the minimum number of times that the Agent will need to use the weapons to kill the enemy?", "input_spec": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \\leq t \\leq 10^5)$$$. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$H$$$ $$$(2 \\leq n \\leq 10^3, 1 \\leq H \\leq 10^9)$$$ \u2014 the number of available weapons and the initial health value of the enemy. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ $$$(1 \\leq a_i \\leq 10^9)$$$ \u2014 the damage values of the weapons. It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_spec": "For each test case, print a single integer \u2014 the minimum number of times that the Agent will have to use the weapons to kill the enemy.", "sample_inputs": ["3\n2 4\n3 7\n2 6\n4 2\n3 11\n2 1 7"], "sample_outputs": ["1\n2\n3"], "notes": "NoteIn the first test case, the Agent can use the second weapon, making health value of the enemy equal to $$$4-7=-3$$$. $$$-3 \\le 0$$$, so the enemy is dead, and using weapon $$$1$$$ time was enough.In the second test case, the Agent can use the first weapon first, and then the second one. After this, the health of enemy will drop to $$$6-4-2 = 0$$$, meaning he would be killed after using weapons $$$2$$$ times.In the third test case, the Agent can use the weapons in order (third, first, third), decreasing the health value of enemy to $$$11 - 7 - 2 - 7 = -5$$$ after using the weapons $$$3$$$ times. Note that we can't kill the enemy by using the third weapon twice, as even though $$$11-7-7<0$$$, it's not allowed to use the same weapon twice in a row."}, "positive_code": [{"source_code": " 0 ) {\r\n if($kaldyk <= $max) {\r\n $res += 1;\r\n } else {\r\n $res += 2;\r\n }\r\n }\r\n }\r\n \r\n }\r\n echo $res, $inter;\r\n }\r\n \r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n}"}], "negative_code": [{"source_code": "= $h) {\r\n $res = 1;\r\n } else {\r\n $res = ceil($h / (($max + $a[$n-2])/2));\r\n }\r\n \r\n \r\n echo $res . \"\\n\";\r\n \r\n }"}, {"source_code": "0) {\r\n $res++;\r\n if($el == 0 ){\r\n $h = $h - $a[0];\r\n \r\n $el = 1;\r\n } else {\r\n $h = $h - $a[1];\r\n \r\n $el = 0;\r\n }\r\n }\r\n \r\n echo $res . \"\\n\";\r\n }\r\n "}], "src_uid": "4d5457d9f053556c78c102f5c32f7542"} {"nl": {"description": "A sky scraper with 1000 floors has been built in the city of N. It has modern superfast elevators to help to travel from one floor to another. Each elevator has two doors, the front one and the back one. If one goes in through the front door, he goes out through the back one and vice versa. The elevator has two rails numbered with numbers 1 and 2. Rail 1 is located to the left of the entrance to the front door (or correspondingly, to the right of the entrance to the back door). Rail 2 is located opposite it, to the right of the entrance to the front door and to the left of the entrance to the back door. We know that each person in the city of N holds at a rail with the strongest hand. One day a VIP person visited the city and of course, he took a look at the skyscraper and took a ride in the elevator. We know the door through which he entered and the rail he was holding at. Now we need to determine as soon as possible whether he is left-handed or right-handed.", "input_spec": "The first line indicates the door through which the very important person entered the elevator. It contains \"front\" if the person enters the elevator through the front door and \"back\" if he entered the elevator through the back door. The second line contains integer a (1\u2009\u2264\u2009a\u2009\u2264\u20092) which denotes the number of the rail at which the person was holding.", "output_spec": "Print character \"R\" if the VIP is right-handed or \"L\" if he is left-handed.", "sample_inputs": ["front\n1"], "sample_outputs": ["L"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\n$lines=file_get_contents(\"input.txt\");\n$lines = trim($lines);\n\n\n$lines=explode(\"\\n\", $lines);\n\n$dir=trim($lines[0]);\n$por=trim($lines[1]);\n\nif ($dir==\"front\")\n $res=($por==1)?\"L\":\"R\";\nif ($dir==\"back\")\n $res=($por==1)?\"R\":\"L\";\nfile_put_contents(\"output.txt\", $res);\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "77093f12ff56d5f404e9c87650d4aeb4"} {"nl": {"description": "Polycarp has a string $$$s$$$ consisting of lowercase Latin letters.He encodes it using the following algorithm.He goes through the letters of the string $$$s$$$ from left to right and for each letter Polycarp considers its number in the alphabet: if the letter number is single-digit number (less than $$$10$$$), then just writes it out; if the letter number is a two-digit number (greater than or equal to $$$10$$$), then it writes it out and adds the number 0 after. For example, if the string $$$s$$$ is code, then Polycarp will encode this string as follows: 'c'\u00a0\u2014 is the $$$3$$$-rd letter of the alphabet. Consequently, Polycarp adds 3 to the code (the code becomes equal to 3); 'o'\u00a0\u2014 is the $$$15$$$-th letter of the alphabet. Consequently, Polycarp adds 15 to the code and also 0 (the code becomes 3150); 'd'\u00a0\u2014 is the $$$4$$$-th letter of the alphabet. Consequently, Polycarp adds 4 to the code (the code becomes 31504); 'e'\u00a0\u2014 is the $$$5$$$-th letter of the alphabet. Therefore, Polycarp adds 5 to the code (the code becomes 315045). Thus, code of string code is 315045.You are given a string $$$t$$$ resulting from encoding the string $$$s$$$. Your task is to decode it (get the original string $$$s$$$ by $$$t$$$).", "input_spec": "The first line of the input contains an integer $$$q$$$ ($$$1 \\le q \\le 10^4$$$) \u2014 the number of test cases in the input. The descriptions of the test cases follow. The first line of description of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 50$$$) \u2014 the length of the given code. The second line of the description of each test case contains a string $$$t$$$ of length $$$n$$$ \u2014 the given code. It is guaranteed that there exists such a string of lowercase Latin letters, as a result of encoding which the string $$$t$$$ is obtained.", "output_spec": "For each test case output the required string $$$s$$$ \u2014 the string that gives string $$$t$$$ as the result of encoding. It is guaranteed that such a string always exists. It can be shown that such a string is always unique.", "sample_inputs": ["9\n\n6\n\n315045\n\n4\n\n1100\n\n7\n\n1213121\n\n6\n\n120120\n\n18\n\n315045615018035190\n\n7\n\n1111110\n\n7\n\n1111100\n\n5\n\n11111\n\n4\n\n2606"], "sample_outputs": ["code\naj\nabacaba\nll\ncodeforces\naaaak\naaaaj\naaaaa\nzf"], "notes": "NoteThe first test case is explained above.In the second test case, the answer is aj. Indeed, the number of the letter a is equal to $$$1$$$, so 1 will be appended to the code. The number of the letter j is $$$10$$$, so 100 will be appended to the code. The resulting code is 1100.There are no zeros in the third test case, which means that the numbers of all letters are less than $$$10$$$ and are encoded as one digit. The original string is abacaba.In the fourth test case, the string $$$s$$$ is equal to ll. The letter l has the number $$$12$$$ and is encoded as 120. So ll is indeed 120120."}, "positive_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = -1;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n}\n$e = trim(fgets(STDIN));\nif($d == \"-1\")\n{\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\nelse\n{\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z <= $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = -1;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n}\n$e = trim(fgets(STDIN));\nif(($b == \"y\") && ($c[0] == \"a\"))\n{\n print strlen($c) . \" \" . $d . \"\\n\";\n for($x = 1; $x <= 8; $x++)\n {\n $f = trim(fgets(STDIN));\n if($x == 8)\n {\n print strlen($f) . \"\\n\";\n print $f . \"\\n\";\n }\n }\n}\nif($d == \"-1\")\n{\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\nelse\n{\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = -1;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n}\n$e = trim(fgets(STDIN));\nif($d == \"-1\")\n{\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\nelse\n{\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = 0;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = 1;\n $e = $x;\n $e2 = $x - 1;\n $e3 = $x + 1;\n break;\n }\n}\n$f = trim(fgets(STDIN));\nfor($x = 0; $x < $f; $x++)\n{\n $g = trim(fgets(STDIN));\n if($d == 0)\n {\n if(strlen($c) != strlen($g))\n {\n print \"NO\\n\";\n }\n else\n {\n $h = 0;\n for($y = 0; $y < strlen($g); $y++)\n {\n if($c[$y] == \"?\")\n {\n if($a[$g[$y]] == 0)\n {\n $h = 1;\n break;\n }\n }\n else\n {\n if($c[$y] != $g[$y])\n {\n $h = 1;\n break;\n }\n }\n }\n if($h == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n if(strlen($g) < strlen($c) - 1)\n {\n print \"NO\\n\";\n }\n else\n {\n if(strlen($c) - 1 == strlen($g))\n {\n $j = substr($c, 0, $e);\n $k = substr($c, $e + 1);\n $c = $j . $k;\n }\n $i = 0;\n $l = strlen($g) - $e3;\n $m = 1;\n for($y = 0; $y < strlen($g); $y++)\n {\n if(($y >= 0) && ($y <= $e2))\n {\n if($c[$y] == \"?\")\n {\n if($a[$g[$y]] == 0)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n if($c[$y] != $g[$y])\n {\n $i = 1;\n break;\n }\n }\n }\n elseif($y >= $l)\n {\n if($c[$y - $m + 1] == \"?\")\n {\n if($a[$g[$y]] == 0)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n if($c[$y - $m + 1] != $g[$y])\n {\n $i = 1;\n break;\n }\n }\n }\n elseif($y > $e2)\n {\n if(strlen($g) - strlen($c) != 1)\n {\n $m++;\n if($a[$g[$y]] == 1)\n {\n $i = 1;\n break;\n }\n }\n else\n {\n $m--;\n }\n }\n }\n if($i == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = -1;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n}\n$e = trim(fgets(STDIN));\nif(($b == \"y\") && ($c[0] == \"a\"))\n{\n print strlen($c) . \" \" . $d . \"\\n\";\n for($x = 1; $x <= 8; $x++)\n {\n $f = trim(fgets(STDIN));\n if($x == 8)\n {\n print $f . \"\\n\";\n }\n }\n}\nif($d == \"-1\")\n{\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\nelse\n{\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\nif($b == \"y\")\n{\n print strlen($c) . \"\\n\";\n}\nelse\n{\n $d = -1;\n for($x = 0; $x < strlen($c); $x++)\n {\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n }\n $e = trim(fgets(STDIN));\n if($d == \"-1\")\n {\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\nif(($b == \"y\") && ($c[0] == \"a\"))\n{\n print strlen($c) . \"\\n\";\n}\nelse\n{\n $d = -1;\n for($x = 0; $x < strlen($c); $x++)\n {\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n }\n $e = trim(fgets(STDIN));\n if($d == \"-1\")\n {\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 0, b => 0, c => 0, d => 0, e => 0, f => 0, g => 0, h => 0, i => 0, j => 0, k => 0, l => 0, m => 0, n => 0, o => 0, p => 0, q => 0, r => 0, s => 0, t => 0, u => 0, v => 0, w => 0, x => 0, y => 0, z => 0);\n$b = trim(fgets(STDIN));\nfor($x = 0; $x < strlen($b); $x++)\n{\n $a[$b[$x]] = 1;\n}\n$c = trim(fgets(STDIN));\n$d = -1;\nfor($x = 0; $x < strlen($c); $x++)\n{\n if($c[$x] == \"*\")\n {\n $d = $x;\n break;\n }\n}\nif(($b == \"y\") && ($c[0] == \"a\"))\n{\n print strlen($c) . \" \" . $d . \"\\n\";\n}\n$e = trim(fgets(STDIN));\nif($d == \"-1\")\n{\n for($x = 1; $x <= $e; $x++)\n {\n $f = trim(fgets(STDIN));\n if(strlen($c) == strlen($f))\n {\n $g = 0;\n for($y = 0; $y < strlen($f); $y++)\n {\n if(($c[$y] == \"?\") && ($a[$f[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $f[$y]))\n {\n $g = 1;\n break;\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n else\n {\n print \"NO\\n\";\n }\n }\n}\nelse\n{\n if($d == 0)\n {\n $c = strrev($c);\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = strrev(trim(fgets(STDIN)));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n elseif($d == strlen($c) - 1)\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < strlen($c) - 1; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($z = $y; $z < strlen($h); $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n else\n {\n for($x = 1; $x <= $e; $x++)\n {\n $g = 0;\n $h = trim(fgets(STDIN));\n $i = 0;\n if(strlen($h) < strlen($c) - 1)\n {\n $g = 1;\n }\n else\n {\n for($y = 0; $y < $d; $y++)\n {\n if(($c[$y] == \"?\") && ($a[$h[$y]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[$y] != \"?\") && ($c[$y] != $h[$y]))\n {\n $g = 1;\n break;\n }\n }\n for($y2 = strlen($h) - 1; $y2 > strlen($h) - (strlen($c) - $d); $y2--)\n {\n if(($c[strlen($c) - 1 - $i] == \"?\") && ($a[$h[$y2]] == 0))\n {\n $g = 1;\n break;\n }\n elseif(($c[strlen($c) - 1 - $i] != \"?\") && ($c[strlen($c) - 1 - $i] != $h[$y2]))\n {\n $g = 1;\n break;\n }\n $i++;\n }\n for($z = $y; $z < $y2; $z++)\n {\n if($a[$h[$z]] == 1)\n {\n $g = 1;\n break;\n }\n }\n }\n if($g == 0)\n {\n print \"YES\\n\";\n }\n else\n {\n print \"NO\\n\";\n }\n }\n }\n}\n?>"}], "src_uid": "c6633581d7424d670eaa0f8a5c8cc366"} {"nl": {"description": "You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array; For each $$$i$$$ from $$$1$$$ to $$$k$$$ all elements colored in the $$$i$$$-th color should be distinct. Obviously, such coloring might be impossible. In this case, print \"NO\". Otherwise print \"YES\" and any coloring (i.e. numbers $$$c_1, c_2, \\dots c_n$$$, where $$$1 \\le c_i \\le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions above. If there are multiple answers, you can print any.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 5000$$$) \u2014 the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 5000$$$) \u2014 elements of the array $$$a$$$.", "output_spec": "If there is no answer, print \"NO\". Otherwise print \"YES\" and any coloring (i.e. numbers $$$c_1, c_2, \\dots c_n$$$, where $$$1 \\le c_i \\le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can print any.", "sample_inputs": ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"], "sample_outputs": ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"], "notes": "NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples."}, "positive_code": [{"source_code": " $b)\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\\n\";\n asort($c);\n $f = array_keys($c);\n $g = 1;\n for($x = 0; $x < $a; $x++)\n {\n if($g > $b)\n {\n $g = 1;\n }\n $c[$f[$x]] = $g;\n $g++;\n }\n ksort($c);\n print implode(\" \", $c);\n}\n?>"}, {"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n$a = $ir->readArrayOfInt($n);\n$b = [];\n\nfor ($i=0; $i<$n; $i++) {\n\tif (!isset($b[$a[$i]])) {\n\t\t$b[$a[$i]] = [];\n\t}\n\t\n\t$b[$a[$i]][] = $i;\n}\n\n\n$d = 0;\n$cs = $a;\nforeach ($b as $v=>$g) {\n\tif (count($g) > $k) {\n\t\techo \"NO\";\n\t\texit();\n\t}\n\t\n\tforeach ($g as $ind) {\n\t\t$cs[$ind] = ($d%$k)+1;\n\t\t$d++;\n\t}\n}\n\nif ($d>=$k) {\n\techo \"YES\\n\";\n\techo implode(' ', $cs);\n} else {\n\techo \"NO\\n\";\n}\n"}], "negative_code": [{"source_code": "_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\nlist($n, $k) = $ir->readArrayOfInt(2);\n$a = $ir->readArrayOfInt($n);\n\n$cs = [];\nfor ($i=0; $i<$n; $i++) {\n\tif (!isset($cs[$a[$i]])) {\n\t\t$cs[$a[$i]] = 1;\n\t}\n\t\n\t$cs[$a[$i]]++;\n\t$a[$i] = $cs[$a[$i]]-1;\n}\n\n$m = max($cs);\nif ($m==$k+1) {\n\techo \"YES\\n\";\n\techo implode(' ', $a);\n} else {\n\techo \"NO\\n\";\n}\n"}], "src_uid": "3d4df21eebf32ce15841179bb85e6f2f"} {"nl": {"description": "In the $$$2022$$$ year, Mike found two binary integers $$$a$$$ and $$$b$$$ of length $$$n$$$ (both of them are written only by digits $$$0$$$ and $$$1$$$) that can have leading zeroes. In order not to forget them, he wanted to construct integer $$$d$$$ in the following way: he creates an integer $$$c$$$ as a result of bitwise summing of $$$a$$$ and $$$b$$$ without transferring carry, so $$$c$$$ may have one or more $$$2$$$-s. For example, the result of bitwise summing of $$$0110$$$ and $$$1101$$$ is $$$1211$$$ or the sum of $$$011000$$$ and $$$011000$$$ is $$$022000$$$; after that Mike replaces equal consecutive digits in $$$c$$$ by one digit, thus getting $$$d$$$. In the cases above after this operation, $$$1211$$$ becomes $$$121$$$ and $$$022000$$$ becomes $$$020$$$ (so, $$$d$$$ won't have equal consecutive digits). Unfortunately, Mike lost integer $$$a$$$ before he could calculate $$$d$$$ himself. Now, to cheer him up, you want to find any binary integer $$$a$$$ of length $$$n$$$ such that $$$d$$$ will be maximum possible as integer.Maximum possible as integer means that $$$102 > 21$$$, $$$012 < 101$$$, $$$021 = 21$$$ and so on.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$1 \\leq n \\leq 10^5$$$)\u00a0\u2014 the length of $$$a$$$ and $$$b$$$. The second line of each test case contains binary integer $$$b$$$ of length $$$n$$$. The integer $$$b$$$ consists only of digits $$$0$$$ and $$$1$$$. It is guaranteed that the total sum of $$$n$$$ over all $$$t$$$ test cases doesn't exceed $$$10^5$$$.", "output_spec": "For each test case output one binary integer $$$a$$$ of length $$$n$$$. Note, that $$$a$$$ or $$$b$$$ may have leading zeroes but must have the same length $$$n$$$.", "sample_inputs": ["5\n1\n0\n3\n011\n3\n110\n6\n111000\n6\n001011"], "sample_outputs": ["1\n110\n100\n101101\n101110"], "notes": "NoteIn the first test case, $$$b = 0$$$ and choosing $$$a = 1$$$ gives $$$d = 1$$$ as a result.In the second test case, $$$b = 011$$$ so: if you choose $$$a = 000$$$, $$$c$$$ will be equal to $$$011$$$, so $$$d = 01$$$; if you choose $$$a = 111$$$, $$$c$$$ will be equal to $$$122$$$, so $$$d = 12$$$; if you choose $$$a = 010$$$, you'll get $$$d = 021$$$. If you select $$$a = 110$$$, you'll get $$$d = 121$$$. We can show that answer $$$a = 110$$$ is optimal and $$$d = 121$$$ is maximum possible.In the third test case, $$$b = 110$$$. If you choose $$$a = 100$$$, you'll get $$$d = 210$$$ and it's the maximum possible $$$d$$$.In the fourth test case, $$$b = 111000$$$. If you choose $$$a = 101101$$$, you'll get $$$d = 212101$$$ and it's maximum possible $$$d$$$.In the fifth test case, $$$b = 001011$$$. If you choose $$$a = 101110$$$, you'll get $$$d = 102121$$$ and it's maximum possible $$$d$$$."}, "positive_code": [{"source_code": ""}, {"source_code": "= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcdiv($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 + $bigint2\r\n */\r\n public static function add($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcadd($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcadd($bigint1, $bigint2);\r\n return bcsub(bcadd($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcadd($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 - $bigint2\r\n */\r\n public static function sub($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcsub($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcsub($bigint1, $bigint2);\r\n return bcsub(bcsub($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsub($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @param string $scale (ceil or floor or round)\r\n * @return string $bigint1 * $bigint2\r\n */\r\n public static function mul($bigint1, $bigint2, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcmul($bigint1, $bigint2);\r\n case 'round':\r\n $sResult = bcmul($bigint1, $bigint2);\r\n return bcsub(bcmul($bigint1, $bigint2, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcmul ($bigint1, $bigint2);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint1\r\n * @param string $bigint2\r\n * @return string $bigint1 % $bigint2\r\n */\r\n public static function mod($bigint1, $bigint2) {\r\n return bcmod($bigint1, $bigint2);\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $scale (ceil or floor or round)\r\n * @return string sqrt($bigint)\r\n */\r\n public static function sqrt($bigint, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n return bcadd(bcsqrt ($bigint), 1);\r\n case 'floor':\r\n return bcsqrt($bigint);\r\n case 'round':\r\n $sResult = bcsqrt($bigint);\r\n return bcsub(bcsqrt($bigint, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcsqrt($bigint);\r\n }\r\n }\r\n\r\n /**\r\n * @param string $bigint\r\n * @param string $exponent\r\n * @param string $scale (ceil or floor or round)\r\n * @return string pow($bigint, $exponent)\r\n */\r\n public static function pow($bigint, $exponent, $scale = '') {\r\n switch ($scale) {\r\n case 'ceil':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) == 0 ? $sResult : bcadd($sResult, 1);\r\n case 'floor':\r\n return bcpow($bigint, $exponent);\r\n case 'round':\r\n $sResult = bcpow($bigint, $exponent);\r\n return bcsub(bcpow($bigint, $exponent, 2), $sResult, 2) >= 0.5 ? bcadd($sResult, 1) : $sResult;\r\n default:\r\n return bcpow ($bigint, $exponent);\r\n }\r\n }\r\n}\r\n\r\nclass Algorithms\r\n{\r\n\r\n /** \u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f - \u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438\r\n * @param int $n\r\n * @return array\r\n */\r\n public static function factorization($n)\r\n {\r\n $a = [];\r\n for ($i = 2; $i * $i <= $n; ++$i) {\r\n $cnt = 0;\r\n while (bcmod($n, $i) == 0) {\r\n ++$cnt;\r\n $n = bcdiv($n, $i);\r\n }\r\n if ($cnt > 0) {\r\n $a[$i] = $cnt;\r\n }\r\n }\r\n if ($n > 1) {\r\n $a[$n] = 1;\r\n }\r\n\r\n return $a;\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (\u041d\u041e\u0414)\r\n */\r\n public static function gcd($a, $b)\r\n {\r\n if ($b == 0) {\r\n return $a;\r\n } else {\r\n $a = $a % $b;\r\n return self::gcd($b, $a);\r\n }\r\n }\r\n\r\n /**\r\n * @param int $a\r\n * @param int $b\r\n * @return int \u041d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u0440\u0430\u0442\u043d\u043e\u0435 (\u041d\u041e\u041a)\r\n */\r\n public static function lcm($a, $b)\r\n {\r\n return abs($a * $b) / self::gcd($a, $b);\r\n }\r\n\r\n /**\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987\r\n * return \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438{n}\r\n * @param int $n\r\n * @return int\r\n */\r\n public static function fibonacci($n)\r\n {\r\n $a = [0, 1];\r\n\r\n for ($i = 2; $i <= $n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n\r\n return $a[$n];\r\n }\r\n\r\n}\r\n\r\n?>"}, {"source_code": " $value)\r\n\t{\r\n\t\tif($LAST == -1 || $LAST == 0)\r\n\t\t\t$X = 1;\r\n\t\telse if($LAST == 1)\r\n\t\t{\r\n\t\t\tif($value == 1)\r\n\t\t\t\t$X = 1;\r\n\t\t\telse\r\n\t\t\t\t$X = 0;\r\n\t\t}\r\n\t\telse if($LAST == 2)\r\n\t\t{\r\n\t\t\tif($value == 1)\r\n\t\t\t\t$X = 0;\r\n\t\t\telse\r\n\t\t\t\t$X = 1;\r\n\t\t}\r\n\t\t$a .= $X;\r\n\t\t$LAST = $value + $X;\t\t\r\n\t}\r\n\tprint($a.\"\\n\");\r\n}\r\n//$end = readline();\r\n?>"}, {"source_code": " 0) {\r\n $iQueryCount--;\r\n solve();\r\n}\r\nfunction solve() {\r\n $n = IO::str();\r\n $b = str_split(IO::str());\r\n $last = -1;\r\n $res = '';\r\n for ($i = 0; $i < $n; $i++) {\r\n $r = 1;\r\n if ($last != -1) {\r\n if ($last == $r + $b[$i]) {\r\n $r = 0;\r\n }\r\n }\r\n $res .= $r;\r\n $last = $b[$i] + $r;\r\n }\r\n IO::line($res);\r\n}\r\n"}], "negative_code": [{"source_code": " 1))\n{\n print \"NO\";\n}\nelseif($a < count($g))\n{\n print \"NO\";\n}\nelse\n{\n for($x = 0; $x < $b; $x++)\n {\n $e[count($e)] = $x + 1;\n $f[count($f)] = $x + 2;\n }\n $h = $b + 2;\n $i = 1;\n $j = $b - 1;\n $k = 1;\n while(TRUE)\n {\n if($i < $j)\n {\n $l = $c - 2;\n if($l != 0)\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$j];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n }\n }\n }\n elseif($i == $j)\n {\n $l = $c - 2;\n if($l != 0)\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n break;\n }\n elseif($i > $j)\n {\n break;\n }\n $i++;\n $j--;\n $k++;\n }\n if($a >= $h)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$j];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n }\n }\n }\n elseif($i == $j)\n {\n $l = $c - 2;\n if($l != 0)\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n break;\n }\n elseif($i > $j)\n {\n break;\n }\n $i++;\n $j--;\n $k++;\n }\n if($a > $h)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$j];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n }\n }\n }\n elseif($i == $j)\n {\n $l = $c - 2;\n if($l != 0)\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n break;\n }\n elseif($i > $j)\n {\n break;\n }\n $i++;\n $j--;\n $k++;\n }\n if($a >= $h)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$j];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n }\n }\n }\n elseif($i == $j)\n {\n $l = $c - 2;\n if($l != 0)\n {\n $m = array();\n for($x = 0; $x < $l; $x++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $g[$i];\n $f[count($f)] = $h;\n $m[count($m)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n for($x = 0; $x < $k - 1; $x++)\n {\n $n = array();\n for($y = 0; $y < count($m); $y++)\n {\n for($z = 0; $z < $c - 1; $z++)\n {\n if($h > $a)\n {\n break;\n }\n else\n {\n $e[count($e)] = $m[$y];\n $f[count($f)] = $h;\n $n[count($n)] = $h;\n $h++;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n if($h > $a)\n {\n break;\n }\n else\n {\n $m = $n;\n }\n }\n if($h > $a)\n {\n break;\n }\n }\n }\n break;\n }\n elseif($i > $j)\n {\n break;\n }\n $i++;\n $j--;\n $k++;\n }\n if($a >= $h)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\\n\";\n for($x = 0; $x < count($e); $x++)\n {\n print $e[$x] . \" \" . $f[$x] . \"\\n\";\n }\n }\n}\n?>"}], "src_uid": "a4849505bca48b408a5e8fb5aebf5cb6"} {"nl": {"description": "You are given an array $$$a[0 \\ldots n-1]$$$ of length $$$n$$$ which consists of non-negative integers. Note that array indices start from zero.An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $$$i$$$ ($$$0 \\le i \\le n - 1$$$) the equality $$$i \\bmod 2 = a[i] \\bmod 2$$$ holds, where $$$x \\bmod 2$$$ is the remainder of dividing $$$x$$$ by 2.For example, the arrays [$$$0, 5, 2, 1$$$] and [$$$0, 17, 0, 3$$$] are good, and the array [$$$2, 4, 6, 7$$$] is bad, because for $$$i=1$$$, the parities of $$$i$$$ and $$$a[i]$$$ are different: $$$i \\bmod 2 = 1 \\bmod 2 = 1$$$, but $$$a[i] \\bmod 2 = 4 \\bmod 2 = 0$$$.In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).Find the minimum number of moves in which you can make the array $$$a$$$ good, or say that this is not possible.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of test cases in the test. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \\le n \\le 40$$$)\u00a0\u2014 the length of the array $$$a$$$. The next line contains $$$n$$$ integers $$$a_0, a_1, \\ldots, a_{n-1}$$$ ($$$0 \\le a_i \\le 1000$$$)\u00a0\u2014 the initial array.", "output_spec": "For each test case, output a single integer\u00a0\u2014 the minimum number of moves to make the given array $$$a$$$ good, or -1 if this is not possible.", "sample_inputs": ["4\n4\n3 2 7 6\n3\n3 2 6\n1\n7\n7\n4 9 2 1 18 3 0"], "sample_outputs": ["2\n1\n-1\n0"], "notes": "NoteIn the first test case, in the first move, you can swap the elements with indices $$$0$$$ and $$$1$$$, and in the second move, you can swap the elements with indices $$$2$$$ and $$$3$$$.In the second test case, in the first move, you need to swap the elements with indices $$$0$$$ and $$$1$$$.In the third test case, you cannot make the array good."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "942123e43a83d5a4cea95a6781064e28"} {"nl": {"description": "A string is called beautiful if no two consecutive characters are equal. For example, \"ababcb\", \"a\" and \"abab\" are beautiful strings, while \"aaaaaa\", \"abaa\" and \"bb\" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace each character '?' with one of the three characters 'a', 'b' or 'c', such that the resulting string is beautiful. Please help him!More formally, after replacing all characters '?', the condition $$$s_i \\neq s_{i+1}$$$ should be satisfied for all $$$1 \\leq i \\leq |s| - 1$$$, where $$$|s|$$$ is the length of the string $$$s$$$.", "input_spec": "The first line contains positive integer $$$t$$$ ($$$1 \\leq t \\leq 1000$$$)\u00a0\u2014 the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ has at least one character '?'. The sum of lengths of strings $$$s$$$ in all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print \"-1\" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. ", "sample_inputs": ["3\na???cb\na??bbc\na?b?c"], "sample_outputs": ["ababcb\n-1\nacbac"], "notes": "NoteIn the first test case, all possible correct answers are \"ababcb\", \"abcacb\", \"abcbcb\", \"acabcb\" and \"acbacb\". The two answers \"abcbab\" and \"abaabc\" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful string, because the $$$4$$$-th and $$$5$$$-th characters will be always equal.In the third test case, the only answer is \"acbac\"."}, "positive_code": [{"source_code": ""}, {"source_code": " true, 'b' => true, 'c' => true];\n\tif($i > 0) {\n\t\tif(isset($avail[$arr[$i - 1]])) {\n\t\t\tunset($avail[$arr[$i - 1]]);\n\t\t}\n\t}\n\t\n\tif($i < (strlen($arr) - 1)) {\n\t\t$q = $arr[$i + 1];\n\t\tif(isset($avail[$q])) {\n\t\t\tunset($avail[$q]);\n\t\t}\n\t}\n\treturn array_keys($avail)[0];\n}\n\nfgets(STDIN);\n\nwhile($f = trim(fgets(STDIN))){\n\t$a = [];\n\t//$f = str_explode($f);\n for($i = 0; $i < strlen($f); $i++) {\n \tif($f[$i] != \"?\") {\n \t\t$a[] = $f[$i];\n \t\tif($i === 0) {\n \t\t\tcontinue;\n \t\t}\n \t\t\n \t\tif($f[$i - 1] == $f[$i]) {\n \t\t\t$a = null;\n \t\t\tbreak;\n \t\t}\n \t} else {\n \t\t$f[$i] = getAllowed($f, $i);\n \t\t$a[] = $f[$i];\n \t}\n }\n \n echo ($a) ? implode('', $a) : \"-1\";\n echo PHP_EOL;\n}"}, {"source_code": " $val)\n { \n if($k == 0 || $val == \"?\") {\n if($val == \"?\") $prev = \"?\";\n continue;\n } \n \n if($val == $prev && $prev != \"?\")\n return false;\n $prev = $chars[$k];\n }\n return true;\n}\n\nfunction makeNice($string)\n{\n $chars = str_split($string);\n unset($chars[count($chars) - 1]);\n $prev = \"\";\n $lastChanged = -1;\n foreach($chars as $k => $val)\n {\n if($val == \"?\")\n { \n $first = \"a\";\n if($k != count($chars) - 1)\n $last = $chars[$k + 1];\n else\n $last = $first;\n \n if($k == 0) \n $first = $last;\n else\n $first = $chars[$k - 1];\n \n $fl = array($first, $last);\n if(!in_array(\"a\", $fl))\n $val = \"a\";\n if(!in_array(\"b\", $fl))\n $val = \"b\";\n if(!in_array(\"c\", $fl))\n $val = \"c\";\n \n \n $chars[$k] = $val; \n }\n $prev = $val;\n }\n return implode(\"\", $chars);\n}\n?>\n"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": " $val)\n {\n if($k == 0 || $val == \"?\") continue;\n //echo $val.\" \".$prev;\n if($val == $prev && $prev != \"?\")\n return false;\n $prev = $chars[$k];\n }\n return true;\n}\n\nfunction makeNice($string)\n{\n $chars = str_split($string);\n unset($chars[count($chars) - 1]);\n $prev = \"\";\n $lastChanged = -1;\n foreach($chars as $k => $val)\n {\n if($val == \"?\")\n {\n /*switch($prev)\n {\n case \"\":\n $val = \"a\";\n break;\n case \"a\":\n $val = \"b\";\n break;\n case \"b\":\n $val = \"c\";\n break;\n case \"c\":\n $val = \"a\";\n break;\n } */\n if($k == 0)\n $val = \"a\";\n else { \n $first = $chars[$k - 1]; \n $last = $chars[$k + 1];\n \n $fl = array($first, $last);\n if(!in_array(\"a\", $fl))\n $val = \"a\";\n if(!in_array(\"b\", $fl))\n $val = \"b\";\n if(!in_array(\"c\", $fl))\n $val = \"c\";\n \n }\n $chars[$k] = $val; \n }\n $prev = $val;\n }\n return implode(\"\", $chars);\n}\n?>\n"}, {"source_code": " $val)\n {\n if($val == \"?\") $prev = \"?\";\n if($k == 0 || $val == \"?\") continue;\n \n if($val == $prev && $prev != \"?\")\n return false;\n $prev = $chars[$k];\n }\n return true;\n}\n\nfunction makeNice($string)\n{\n $chars = str_split($string);\n unset($chars[count($chars) - 1]);\n $prev = \"\";\n $lastChanged = -1;\n foreach($chars as $k => $val)\n {\n if($val == \"?\")\n {\n if($k == 0)\n $val = \"a\";\n else { \n $first = $chars[$k - 1]; \n $last = $chars[$k + 1];\n \n $fl = array($first, $last);\n if(!in_array(\"a\", $fl))\n $val = \"a\";\n if(!in_array(\"b\", $fl))\n $val = \"b\";\n if(!in_array(\"c\", $fl))\n $val = \"c\";\n \n }\n $chars[$k] = $val; \n }\n $prev = $val;\n }\n return implode(\"\", $chars);\n}\n?>\n"}, {"source_code": " $val)\n { \n if($k == 0 || $val == \"?\") {\n if($val == \"?\") $prev = \"?\";\n continue;\n } \n \n if($val == $prev && $prev != \"?\")\n return false;\n $prev = $chars[$k];\n }\n return true;\n}\n\nfunction makeNice($string)\n{\n $chars = str_split($string);\n unset($chars[count($chars) - 1]);\n $prev = \"\";\n $lastChanged = -1;\n foreach($chars as $k => $val)\n {\n if($val == \"?\")\n {\n if($k == 0)\n $val = \"a\";\n else { \n $first = $chars[$k - 1];\n if($k != count($chars) - 1)\n $last = $chars[$k + 1];\n else\n $last = $first;\n \n $fl = array($first, $last);\n if(!in_array(\"a\", $fl))\n $val = \"a\";\n if(!in_array(\"b\", $fl))\n $val = \"b\";\n if(!in_array(\"c\", $fl))\n $val = \"c\";\n \n }\n $chars[$k] = $val; \n }\n $prev = $val;\n }\n return implode(\"\", $chars);\n}\n?>\n"}, {"source_code": ""}, {"source_code": "1 && $s[strlen($s)-1]==$s[strlen($s)-2])\n {\n $ok=false;\n }\n if(strlen($s)==1)\n {\n echo 'a';\n }else if($ok)\n {echo $s;\n }else\n {\n echo \"-1\";\n }\n echo \"\\n\";\n }\n}\n\nsolve();\n?>"}, {"source_code": ""}, {"source_code": "1 && $s[strlen($s)-1]==$s[strlen($s)-2])\n {\n $ok=false;\n }\n if($ok)\n {echo $s;\n }else\n {\n echo \"-1\";\n }\n echo \"\\n\";\n }\n}\n\nsolve();\n?>"}, {"source_code": "1 && $s[strlen($s)-1]==$s[strlen($s)-2])\n {\n $ok=false;\n }\n if($ok)\n {echo $s;}else\n {\n echo \"-1\";\n }\n echo \"\\n\";\n }\n}\n\nsolve();\n?>"}], "src_uid": "98c08a3b5e5b5bb78804ff797ba24d87"} {"nl": {"description": "Timur has a stairway with $$$n$$$ steps. The $$$i$$$-th step is $$$a_i$$$ meters higher than its predecessor. The first step is $$$a_1$$$ meters higher than the ground, and the ground starts at $$$0$$$ meters. The stairs for the first test case. Timur has $$$q$$$ questions, each denoted by an integer $$$k_1, \\dots, k_q$$$. For each question $$$k_i$$$, you have to print the maximum possible height Timur can achieve by climbing the steps if his legs are of length $$$k_i$$$. Timur can only climb the $$$j$$$-th step if his legs are of length at least $$$a_j$$$. In other words, $$$k_i \\geq a_j$$$ for each step $$$j$$$ climbed.Note that you should answer each question independently.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$)\u00a0\u2014 the number of test cases. The first line of each test case contains two integers $$$n, q$$$ ($$$1 \\leq n, q \\leq 2\\cdot10^5$$$)\u00a0\u2014 the number of steps and the number of questions, respectively. The second line of each test case contains $$$n$$$ integers ($$$1 \\leq a_i \\leq 10^9$$$)\u00a0\u2014 the height of the steps. The third line of each test case contains $$$q$$$ integers ($$$0 \\leq k_i \\leq 10^9$$$)\u00a0\u2014 the numbers for each question. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2\\cdot10^5$$$, and the sum of $$$q$$$ does not exceed $$$2\\cdot10^5$$$.", "output_spec": "For each test case, output a single line containing $$$q$$$ integers, the answer for each question. Please note, that the answer for some questions won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).", "sample_inputs": ["3\n\n4 5\n\n1 2 1 5\n\n1 2 4 9 10\n\n2 2\n\n1 1\n\n0 1\n\n3 1\n\n1000000000 1000000000 1000000000\n\n1000000000"], "sample_outputs": ["1 4 4 9 9 \n0 2 \n3000000000"], "notes": "NoteConsider the first test case, pictured in the statement. If Timur's legs have length $$$1$$$, then he can only climb stair $$$1$$$, so the highest he can reach is $$$1$$$ meter. If Timur's legs have length $$$2$$$ or $$$4$$$, then he can only climb stairs $$$1$$$, $$$2$$$, and $$$3$$$, so the highest he can reach is $$$1+2+1=4$$$ meters. If Timur's legs have length $$$9$$$ or $$$10$$$, then he can climb the whole staircase, so the highest he can reach is $$$1+2+1+5=9$$$ meters. In the first question of the second test case, Timur has no legs, so he cannot go up even a single step. :("}, "positive_code": [{"source_code": " $item) {\n $heights[$k] = $heights[$k - 1] + $item;\n }\n\n foreach ($ar as $k => $a) {\n $maxStairs[$k] = max($maxStairs[$k - 1], $a);\n }\n\n $res = [];\n\n foreach ($qr as $q) {\n // find last item, which is less than q + 1\n // find first item which is greater than\n // upper bound algorithm\n\n $ptr = 0;\n $count = $n;\n\n while ($count > 0) {\n $half = $count >> 1;\n $midPtr = $ptr + $half;\n\n if ($maxStairs[$midPtr] <= $q) {\n $ptr = $midPtr + 1;\n $count -= $half + 1;\n } else {\n $count = $half;\n }\n }\n\n $res[] = $heights[$ptr - 1];\n }\n\n fprintf(STDOUT, $qFormat.PHP_EOL, ...$res);\n}\n\n/*\n1\n3 1\n100 7 10\n8\n// 0\n\n2\n1 1\n1\n1\n3 1\n1 1 1\n0\n\n// 1, 0\n\n\n1\n5 5\n1 2 1 5 1\n1 2 0 5 6\n// 1 4 0 10 10\n\n\n1\n4 1\n1 2 2 3\n2\n// 5\n\n\n1\n5 1\n1 2 3 4 3\n3\n// 6\n\n1\n3 1\n3 4 1\n1\n// 0\n\n\n1\n5 6\n1 2 3 4 5\n3 2 0 4 5 1\n\n// 117 117 117 117 117 0\n\n */\n"}, {"source_code": " $item) {\n $heights[$k] = $heights[$k - 1] + $item;\n }\n\n foreach ($ar as $k => $a) {\n $maxStairs[$k] = max($maxStairs[$k - 1], $a);\n }\n\n $res = [];\n\n foreach ($qr as $q) {\n // find last item, which is less than q + 1\n // find first item which is greater than\n // upper bound algorithm\n\n $ptr = 0;\n $count = $n;\n\n while ($count > 0) {\n $half = $count >> 1;\n $midPtr = $ptr + $half;\n\n if ($maxStairs[$midPtr] <= $q) {\n $ptr = $midPtr + 1;\n $count -= $half + 1;\n } else {\n $count = $half;\n }\n }\n\n $res[] = $heights[$ptr - 1];\n }\n\n fprintf(STDOUT, $qFormat.PHP_EOL, ...$res);\n}\n\n/*\n1\n3 1\n100 7 10\n8\n// 0\n\n2\n1 1\n1\n1\n3 1\n1 1 1\n0\n\n// 1, 0\n\n\n1\n5 5\n1 2 1 5 1\n1 2 0 5 6\n// 1 4 0 10 10\n\n\n1\n4 1\n1 2 2 3\n2\n// 5\n\n\n1\n5 1\n1 2 3 4 3\n3\n// 6\n\n1\n3 1\n3 4 1\n1\n// 0\n\n\n1\n5 6\n1 2 3 4 5\n3 2 0 4 5 1\n\n// 117 117 117 117 117 0\n\n */\n"}], "negative_code": [{"source_code": " $item) {\n $heights[$k] = $heights[$k - 1] + $item;\n }\n\n // keep track of where new level starts the first time\n $newLevelStarts = array_flip(array_reverse($ar, true));\n ksort($newLevelStarts);\n\n $stairs = array_keys($newLevelStarts);\n\n $iL = 0;\n $iR = count($stairs) - 1;\n\n // for every question find the first item, which is greater than a $q\n\n $res = [];\n\n foreach ($qr as $q) {\n $l = $iL;\n $r = $iR;\n // what if null?\n $prevAltitude = end($stairs);\n\n // l is the result\n while ($l <= $r) {\n $m = ($l + $r) >> 1;\n $altitude = $stairs[$m];\n\n if ($altitude <= $q) {\n $l = $m + 1;\n } elseif ($prevAltitude > $q) {\n $r = $m - 1;\n } else {\n // found\n $l = $r = $m;\n break;\n }\n\n $prevAltitude = $altitude;\n }\n\n if ($l > $iR) {\n // out of bounds, max value\n $res[] = end($heights);\n continue;\n }\n\n $resId = $newLevelStarts[$stairs[$l]] - 1;\n\n $res[] = $heights[$resId];\n }\n\n fprintf(STDOUT, $qFormat . PHP_EOL, ...$res);\n}\n\n/*\n2\n1 1\n1\n1\n3 1\n1 1 1\n0\n// 1, 0\n\n\n1\n5 5\n1 2 1 5 1\n1 2 0 5 6\n// 1 4 0 10 10\n\n */\n"}], "src_uid": "d5f7228d8d674b8233937702ca044cb0"} {"nl": {"description": "There are one cat, $$$k$$$ mice, and one hole on a coordinate line. The cat is located at the point $$$0$$$, the hole is located at the point $$$n$$$. All mice are located between the cat and the hole: the $$$i$$$-th mouse is located at the point $$$x_i$$$ ($$$0 < x_i < n$$$). At each point, many mice can be located.In one second, the following happens. First, exactly one mouse moves to the right by $$$1$$$. If the mouse reaches the hole, it hides (i.e. the mouse will not any more move to any point and will not be eaten by the cat). Then (after that the mouse has finished its move) the cat moves to the right by $$$1$$$. If at the new cat's position, some mice are located, the cat eats them (they will not be able to move after that). The actions are performed until any mouse hasn't been hidden or isn't eaten.In other words, the first move is made by a mouse. If the mouse has reached the hole, it's saved. Then the cat makes a move. The cat eats the mice located at the pointed the cat has reached (if the cat has reached the hole, it eats nobody).Each second, you can select a mouse that will make a move. What is the maximum number of mice that can reach the hole without being eaten?", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of two lines. The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\le n \\le 10^9$$$, $$$1 \\le k \\le 4 \\cdot 10^5$$$). The second line contains $$$k$$$ integers $$$x_1, x_2, \\dots x_k$$$ ($$$1 \\le x_i < n$$$) \u2014 the initial coordinates of the mice. It is guaranteed that the sum of all $$$k$$$ given in the input doesn't exceed $$$4 \\cdot 10^5$$$.", "output_spec": "For each test case output on a separate line an integer $$$m$$$ ($$$m \\ge 0$$$) \u2014 the maximum number of mice that can reach the hole without being eaten.", "sample_inputs": ["3\n10 6\n8 7 5 4 9 4\n2 8\n1 1 1 1 1 1 1 1\n12 11\n1 2 3 4 5 6 7 8 9 10 11"], "sample_outputs": ["3\n1\n4"], "notes": null}, "positive_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list ($n, $k) = IO::arr();\r\n $mv = $n;\r\n $arr = IO::arr();\r\n\r\n sort($arr);\r\n $farr = array_reverse($arr);\r\n\r\n $sv = 0;\r\n $cnt = 0;\r\n $s = 0;\r\n $turn = 1;\r\n $koshka = 0;\r\n foreach ($farr as $a) {\r\n if ($a > $koshka) {\r\n $cnt += 1;\r\n $koshka += $n - $a;\r\n }\r\n }\r\n $res[] = $cnt;\r\n}\r\n\r\nforeach ($res as $r) {\r\n echo $r . \"\\n\";\r\n}\r\n"}, {"source_code": " $n - 1) {\r\n break;\r\n } else {\r\n $k += $n - $aArray[$i];\r\n $iCount++;\r\n }\r\n }\r\n echo $iCount . \"\\n\";\r\n}"}], "negative_code": [{"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list ($n, $k) = IO::arr();\r\n $mv = $n;\r\n $arr = IO::arr();\r\n\r\n sort($arr);\r\n $farr = array_reverse($arr);\r\n\r\n $sv = 0;\r\n $cnt = 0;\r\n $s = 0;\r\n $turn = 1;\r\n foreach ($farr as $a) {\r\n\r\n if ($sv < $k) {\r\n $s = $mv - $a;\r\n $sv = $sv + $s;\r\n if ($sv > $k) {\r\n break;\r\n }\r\n $cnt++;\r\n } else {\r\n if ($sv == $k) {\r\n $s = $mv - $a;\r\n if ($s <= $mv - $sv) {\r\n $cnt++;\r\n }\r\n }\r\n break;\r\n }\r\n\r\n $turn++;\r\n if ($turn == $n) {\r\n break;\r\n }\r\n }\r\n if ($cnt == 0) {\r\n $cnt = 1;\r\n }\r\n $res[] = $cnt;\r\n}\r\n\r\nforeach ($res as $r) {\r\n echo $r . \"\\n\";\r\n}\r\n"}, {"source_code": " $y)\r\n $x = $x - $y;\r\n else\r\n $y = $y - $x;\r\n }\r\n return ($p*$q)/$x;\r\n }\r\n public static function gcd($a, $b) {\r\n return ($a % $b) ? self::gcd($b,$a % $b) : $b;\r\n }\r\n\r\n public static function res($res) {\r\n foreach ($res as $r) {\r\n echo $r . \"\\n\";\r\n }\r\n }\r\n\r\n public static function dd($val){\r\n echo $val; exit;\r\n }\r\n}\r\n\r\n$t = IO::str();\r\n$res = array();\r\nwhile ($t--) {\r\n list ($n, $k) = IO::arr();\r\n $mv = $n;\r\n $arr = IO::arr();\r\n\r\n sort($arr);\r\n $farr = array_reverse($arr);\r\n\r\n $sv = 0;\r\n $cnt = 0;\r\n $s = 0;\r\n $turn = 1;\r\n foreach ($farr as $a) {\r\n\r\n if ($sv < $k) {\r\n $s = $mv - $a;\r\n $sv = $sv + $s;\r\n if ($sv > $k) {\r\n break;\r\n }\r\n $cnt++;\r\n } else {\r\n if ($sv == $k) {\r\n $s = $mv - $a;\r\n if ($s <= $mv - $sv) {\r\n $cnt++;\r\n }\r\n }\r\n break;\r\n }\r\n\r\n $turn++;\r\n if ($turn == $n) {\r\n break;\r\n }\r\n }\r\n $res[] = $cnt;\r\n}\r\n\r\nforeach ($res as $r) {\r\n echo $r . \"\\n\";\r\n}\r\n"}], "src_uid": "fd1b846c46a074f6afa1fa6e2844c3e2"} {"nl": {"description": "A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasya and decided to teach him a lesson. He gave the lazy student a seemingly easy task: You are given an idle body in space and the forces that affect it. The body can be considered as a material point with coordinates (0; 0; 0). Vasya had only to answer whether it is in equilibrium. \"Piece of cake\" \u2014 thought Vasya, we need only to check if the sum of all vectors is equal to 0. So, Vasya began to solve the problem. But later it turned out that there can be lots and lots of these forces, and Vasya can not cope without your help. Help him. Write a program that determines whether a body is idle or is moving by the given vectors of forces.", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100), then follow n lines containing three integers each: the xi coordinate, the yi coordinate and the zi coordinate of the force vector, applied to the body (\u2009-\u2009100\u2009\u2264\u2009xi,\u2009yi,\u2009zi\u2009\u2264\u2009100).", "output_spec": "Print the word \"YES\" if the body is in equilibrium, or the word \"NO\" if it is not.", "sample_inputs": ["3\n4 1 7\n-2 4 -1\n1 -5 -3", "3\n3 -1 7\n-5 2 -4\n2 -1 -3"], "sample_outputs": ["NO", "YES"], "notes": null}, "positive_code": [{"source_code": "\n$n=trim(fgets(STDIN));\nfor($i=0;$i<$n;$i++){\n $arr[]=explode(' ',trim(fgets(STDIN)));\n}\nfor($i=0;$i<$n;$i++){\n $r1+=$arr[$i][0];\n $r2+=$arr[$i][1];\n $r3+=$arr[$i][2];\n}\n$res=($r1==0 && $r2==0 && $r3==0) ? 'YES' : 'NO';\necho $res;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n$fp=fopen('php://stdin', 'r');\n$lines=stream_get_contents($fp);\n$lines=trim($lines);\n$lines=explode(\"\\n\", $lines);\n\n$sum_x=$sum_y=$sum_z=0;\nfor($i=1; $i "}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\nmain();\n\nfunction main(){\n $file = fopen(\"php://stdin\", \"r\");\n \n $n = fgets($file);\n $x = $y = $z = 0;\n for($i=0;$i<$n;$i++){\n\t$a = explode(\" \", fgets($file));\n\t$x+=$a[0];\n\t$y+=$a[1];\n\t$z+=$a[2];\n }\n \n if ($x == 0 && $y == 0 && $z == 0) echo 'YES';\n else echo 'NO';\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "';print_r($var);echo '
'; print_r($var); echo '';}\n function read_str(){return trim(fgets($GLOBALS['file']));}\n function read_array(){return explode(' ', read_str());}\n /***************************************************************/\n $arr = read_array();\n $n = $arr[0];\n $m = $arr[1];\n $c = $arr[2];\n $GLOBALS['c'] = $c;\n \n $a = read_array();\n $b = read_array();\n\n $k = $n - $m + 1;\n \n function add($a, $b)\n {\n return ($a+$b)%$GLOBALS['c'];\n }\n \n for($i=0; $i<$k; $i++)\n {\n for($j=0; $j<$m; $j++)\n {\n $a[$j+$i] = add($a[$j+$i], $b[$j]);\n }\n }\n \n foreach($a as $n) echo $n, ' '; \n?>"}], "negative_code": [], "src_uid": "9a6ee18e144a38935d7c06e73f2e6384"} {"nl": {"description": "Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called \"chizhik\". One has to pay in chizhiks to buy a coconut now.Sasha and Masha are about to buy some coconuts which are sold at price $$$z$$$ chizhiks per coconut. Sasha has $$$x$$$ chizhiks, Masha has $$$y$$$ chizhiks. Each girl will buy as many coconuts as she can using only her money. This way each girl will buy an integer non-negative number of coconuts.The girls discussed their plans and found that the total number of coconuts they buy can increase (or decrease) if one of them gives several chizhiks to the other girl. The chizhiks can't be split in parts, so the girls can only exchange with integer number of chizhiks.Consider the following example. Suppose Sasha has $$$5$$$ chizhiks, Masha has $$$4$$$ chizhiks, and the price for one coconut be $$$3$$$ chizhiks. If the girls don't exchange with chizhiks, they will buy $$$1 + 1 = 2$$$ coconuts. However, if, for example, Masha gives Sasha one chizhik, then Sasha will have $$$6$$$ chizhiks, Masha will have $$$3$$$ chizhiks, and the girls will buy $$$2 + 1 = 3$$$ coconuts. It is not that easy to live on the island now, so Sasha and Mash want to exchange with chizhiks in such a way that they will buy the maximum possible number of coconuts. Nobody wants to have a debt, so among all possible ways to buy the maximum possible number of coconuts find such a way that minimizes the number of chizhiks one girl gives to the other (it is not important who will be the person giving the chizhiks).", "input_spec": "The first line contains three integers $$$x$$$, $$$y$$$ and $$$z$$$ ($$$0 \\le x, y \\le 10^{18}$$$, $$$1 \\le z \\le 10^{18}$$$)\u00a0\u2014 the number of chizhics Sasha has, the number of chizhics Masha has and the price of a coconut. ", "output_spec": "Print two integers: the maximum possible number of coconuts the girls can buy and the minimum number of chizhiks one girl has to give to the other.", "sample_inputs": ["5 4 3", "6 8 2"], "sample_outputs": ["3 1", "7 0"], "notes": "NoteThe first example is described in the statement. In the second example the optimal solution is to dot exchange any chizhiks. The girls will buy $$$3 + 4 = 7$$$ coconuts."}, "positive_code": [{"source_code": " $f)\n{\n $i = bcmod($a, $c);\n $j = bcmod($b, $c);\n print $h . \" \" . min(bcsub($c, $i), bcsub($c, $j));\n}\nelse\n{\n print $f . \" 0\";\n}\n?>"}, {"source_code": "= $c) {\n $r = bcadd($c, bcmul(max($sf, $mf), '-1'));\n $n = bcadd($n, '1');\n}\necho $n . ' ' . $r;\n"}, {"source_code": "= $c) {\n $refund = bcadd($c, bcmul(max($sFree, $mFree), '-1'));\n $nuts = bcadd($nuts, '1');\n}\necho $nuts . ' ' . $refund;\n"}], "negative_code": [{"source_code": " $f)\n{\n $i = bcmod($a, $c);\n $j = bcmod($b, $c);\n print $h . \" \" . min($c - $i, $c - $j);\n}\nelse\n{\n print $f . \" 0\";\n}\n?>"}, {"source_code": " $f)\n{\n $i = bcmod($a, $c);\n $j = bcmod($b, $c);\n print $h . \" \" . min($i, $j);\n}\nelse\n{\n print $f . \" 0\";\n}\n?>"}, {"source_code": "= $c) {\n $refund = $c - max($sFree, $mFree);\n $nuts++;\n}\necho $nuts . ' ' . $refund;\n"}, {"source_code": "= $c) {\n $refund = $c - max($sFree, $mFree);\n $nuts++;\n}\necho $nuts . ' ' . $refund;\n"}], "src_uid": "863a8124d46bb09b49fc88939fb5f364"} {"nl": {"description": "Andryusha is an orderly boy and likes to keep things in their place.Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe.Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? ", "input_spec": "The first line contains the single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014 the number of sock pairs. The second line contains 2n integers x1,\u2009x2,\u2009...,\u2009x2n (1\u2009\u2264\u2009xi\u2009\u2264\u2009n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair.", "output_spec": "Print single integer\u00a0\u2014 the maximum number of socks that were on the table at the same time.", "sample_inputs": ["1\n1 1", "3\n2 1 1 3 2 3"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.In the second example Andryusha behaved as follows: Initially the table was empty, he took out a sock from pair 2 and put it on the table. Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. Socks (1,\u20092) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. Socks (2,\u20093) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time."}, "positive_code": [{"source_code": ""}, {"source_code": "$cont)$cont=count($b);\n\tif(!isset($b[$arr[$i]])){\n\t\t$b[$arr[$i]]=1;\n\t}else{\n\t\tunset($b[$arr[$i]]);\n\t}\n}\nprint $cont;"}, {"source_code": " $max){\n $max = $current;\n }\n }else{\n $current--;\n }\n\n}\necho $max;\n\n/**\n * I/O samples\n *\n * trim(fgets($stdin));\n * fscanf($stdin, \"%d %d %d\", $n, $m, $k);\n * array_filter(explode(' ', trim(fgets($stdin))));\n *\n * print();\n *\n */\n"}], "negative_code": [], "src_uid": "7f98c9258f3e127a782041c421d6317b"} {"nl": {"description": "You have $$$n$$$ students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the $$$i$$$-th student skill is denoted by an integer $$$a_i$$$ (different students can have the same skills).So, about the teams. Firstly, these two teams should have the same size. Two more constraints: The first team should consist of students with distinct skills (i.e. all skills in the first team are unique). The second team should consist of students with the same skills (i.e. all skills in the second team are equal). Note that it is permissible that some student of the first team has the same skill as a student of the second team.Consider some examples (skills are given): $$$[1, 2, 3]$$$, $$$[4, 4]$$$ is not a good pair of teams because sizes should be the same; $$$[1, 1, 2]$$$, $$$[3, 3, 3]$$$ is not a good pair of teams because the first team should not contain students with the same skills; $$$[1, 2, 3]$$$, $$$[3, 4, 4]$$$ is not a good pair of teams because the second team should contain students with the same skills; $$$[1, 2, 3]$$$, $$$[3, 3, 3]$$$ is a good pair of teams; $$$[5]$$$, $$$[6]$$$ is a good pair of teams. Your task is to find the maximum possible size $$$x$$$ for which it is possible to compose a valid pair of teams, where each team size is $$$x$$$ (skills in the first team needed to be unique, skills in the second team should be the same between them). A student cannot be part of more than one team.You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$) \u2014 the number of students. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$), where $$$a_i$$$ is the skill of the $$$i$$$-th student. Different students can have the same skills. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$ ($$$\\sum n \\le 2 \\cdot 10^5$$$).", "output_spec": "For each test case, print the answer \u2014 the maximum possible size $$$x$$$ for which it is possible to compose a valid pair of teams, where each team size is $$$x$$$.", "sample_inputs": ["4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 4 3\n1\n1\n4\n1 1 1 3"], "sample_outputs": ["3\n1\n0\n2"], "notes": "NoteIn the first test case of the example, it is possible to construct two teams of size $$$3$$$: the first team is $$$[1, 2, 4]$$$ and the second team is $$$[4, 4, 4]$$$. Note, that there are some other ways to construct two valid teams of size $$$3$$$."}, "positive_code": [{"source_code": " 1)\n {\n if(count($d) > $h)\n {\n print min(floor($b / 2), count($d), $h) . \"\\n\";\n }\n else\n {\n print min(floor($b / 2), count($d), $h - 1) . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " 0; $t--){\n\n\t$n = intval(fgets(STDIN));\n\n\t$a = explode(' ', trim(fgets(STDIN)));\n\n\t$counts = [];\n\tforeach ($a as $ai) {\n\t\t$counts[$ai]++;\n\t}\n\n\t$m1 = max($counts);\n\t$m2 = count($counts);\n\tif($m1 == $m2){\n\t\t$m = $m1 - 1;\n\t} else {\n\t\t$m = min($m1, $m2);\n\t}\n\n\techo min(floor(count($a) / 2), $m) . \"\\n\";\n\n\n}\n"}, {"source_code": "= $count[$i]) $ans = max($ans, $count[$i]) ;\n if($total_cnt >= $count[$i] - 1) $ans = max($ans, $count[$i] - 1) ;\n if($total_cnt <= $count[$i] - 1) $ans = max($ans, $total_cnt) ;\n }\n \n echo $ans . \"\\n\" ;\n }\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " 1)\n {\n print min(floor($b / 2), count($d), $h - 1) . \"\\n\";\n }\n}\n?>"}, {"source_code": " 1)\n {\n if(count($d) >= $h)\n {\n print min(floor($b / 2), count($d), $h) . \"\\n\";\n }\n else\n {\n print min(floor($b / 2), count($d), $h - 1) . \"\\n\";\n }\n }\n}\n?>"}, {"source_code": " 1)\n {\n print min(floor($b / 2), count($d), $h) . \"\\n\";\n }\n}\n?>"}, {"source_code": "= $count[$i]) $ans = max($ans, $count[$i]) ;\n if($total_cnt >= $count[$i] - 1) $ans = max($ans, $count[$i] - 1) ;\n }\n \n echo $ans . \"\\n\" ;\n }\n?>"}], "src_uid": "a1951e7d11b504273765fc9fb2f18a5e"} {"nl": {"description": "On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.To win the level, after all the moves, the number in the cell at the i-th row and j-th column should be equal to gi,\u2009j.Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task!", "input_spec": "The first line of input contains two integers, n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi,\u2009j (0\u2009\u2264\u2009gi,\u2009j\u2009\u2264\u2009500).", "output_spec": "If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must be done: row x, (1\u2009\u2264\u2009x\u2009\u2264\u2009n) describing a move of the form \"choose the x-th row\". col x, (1\u2009\u2264\u2009x\u2009\u2264\u2009m) describing a move of the form \"choose the x-th column\". If there are multiple optimal solutions, output any one of them.", "sample_inputs": ["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1"], "sample_outputs": ["4\nrow 1\nrow 1\ncol 4\nrow 3", "-1", "3\nrow 1\nrow 2\nrow 3"], "notes": "NoteIn the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required to only have one 1 in the center.In the third test case, Karen has a grid with 3 rows and 3 columns. She can perform the following 3 moves to beat the level: Note that this is not the only solution; another solution, among others, is col 1, col 2, col 3."}, "positive_code": [{"source_code": "= 0; $y--)\n {\n $u[count($u)] = $c[$y][$x];\n }\n $t[$x] = $u;\n }\n $c = $t;\n $e = array();\n for($x = 0; $x < $a; $x++)\n {\n $f = 0;\n for($y = 0; $y < $b; $y++)\n {\n $f = max($f, $c[$y][$x]);\n }\n $e[$x] = $f;\n }\n $g = array();\n $h = array_fill(0, $a, 0);\n for($x = 0; $x < $b; $x++)\n {\n $g[$x] = $h;\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = $c[$x];\n $k = min($j);\n for($y = 0; $y < $k; $y++)\n {\n $l = \"col \" . ($x + 1);\n $i[count($i)] = $l;\n }\n for($y = 0; $y < $k; $y++)\n {\n for($z = 0; $z < $a; $z++)\n {\n $g[$x][$z] += 1;\n }\n }\n }\n $m = array();\n for($x = 0; $x < $a; $x++)\n {\n $n = 0;\n for($y = 0; $y < $b; $y++)\n {\n $n = max($n, $g[$y][$x]);\n }\n $m[$x] = $n;\n }\n for($x = 0; $x < $a; $x++)\n {\n $o = $e[$x] - $m[$x];\n for($y = 0; $y < $o; $y++)\n {\n $p = \"row \" . ($a - $x);\n $i[count($i)] = $p;\n }\n for($y = 0; $y < $o; $y++)\n {\n for($z = 0; $z < $b; $z++)\n {\n $g[$z][$x] += 1;\n }\n }\n }\n $q = 0;\n for($x = 0; $x < $b; $x++)\n {\n $r = implode($c[$x]);\n $s = implode($g[$x]);\n if($r != $s)\n {\n $q = 1;\n break;\n }\n }\n if($q == 0)\n {\n print count($i) . \"\\n\";\n for($x = 0; $x < count($i); $x++)\n {\n print $i[$x] . \"\\n\";\n }\n }\n else\n {\n print \"-1\";\n }\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": "= 0; $y--)\n {\n $u[count($u)] = $c[$y][$x];\n }\n $t[$x] = $u;\n }\n $c = $t;\n $e = array();\n for($x = 0; $x < $b; $x++)\n {\n $f = 0;\n for($y = 0; $y < $a; $y++)\n {\n $f = max($f, $c[$y][$x]);\n }\n $e[$x] = $f;\n }\n $g = array();\n $h = array_fill(0, $a, 0);\n for($x = 0; $x < $b; $x++)\n {\n $g[$x] = $h;\n }\n $i = array();\n for($x = 0; $x < $b; $x++)\n {\n $j = $c[$x];\n $k = min($j);\n for($y = 0; $y < $k; $y++)\n {\n $l = \"col \" . ($x + 1);\n $i[count($i)] = $l;\n }\n for($y = 0; $y < $k; $y++)\n {\n for($z = 0; $z < $a; $z++)\n {\n $g[$x][$z] += 1;\n }\n }\n }\n $m = array();\n for($x = 0; $x < $a; $x++)\n {\n $n = 0;\n for($y = 0; $y < $b; $y++)\n {\n $n = max($n, $g[$y][$x]);\n }\n $m[$x] = $n;\n }\n for($x = 0; $x < $a; $x++)\n {\n $o = $e[$x] - $m[$x];\n for($y = 0; $y < $o; $y++)\n {\n $p = \"row \" . ($a - $x);\n $i[count($i)] = $p;\n }\n for($y = 0; $y < $o; $y++)\n {\n for($z = 0; $z < $b; $z++)\n {\n $g[$z][$x] += 1;\n }\n }\n }\n $q = 0;\n for($x = 0; $x < $b; $x++)\n {\n $r = implode($c[$x]);\n $s = implode($g[$x]);\n if($r != $s)\n {\n $q = 1;\n break;\n }\n }\n if($q == 0)\n {\n print count($i) . \"\\n\";\n for($x = 0; $x < count($i); $x++)\n {\n print $i[$x] . \"\\n\";\n }\n }\n else\n {\n print \"-1\";\n }\n}\n?>"}], "src_uid": "b19ab2db46484f0c9b49cf261502bf64"} {"nl": {"description": "User ainta has a permutation p1,\u2009p2,\u2009...,\u2009pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1,\u2009a2,\u2009...,\u2009an is prettier than permutation b1,\u2009b2,\u2009...,\u2009bn, if and only if there exists an integer k (1\u2009\u2264\u2009k\u2009\u2264\u2009n) where a1\u2009=\u2009b1,\u2009a2\u2009=\u2009b2,\u2009...,\u2009ak\u2009-\u20091\u2009=\u2009bk\u2009-\u20091 and ak\u2009<\u2009bk all holds.As known, permutation p is so sensitive that it could be only modified by swapping two distinct elements. But swapping two elements is harder than you think. Given an n\u2009\u00d7\u2009n binary matrix A, user ainta can swap the values of pi and pj (1\u2009\u2264\u2009i,\u2009j\u2009\u2264\u2009n, i\u2009\u2260\u2009j) if and only if Ai,\u2009j\u2009=\u20091.Given the permutation p and the matrix A, user ainta wants to know the prettiest permutation that he can obtain.", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009300) \u2014 the size of the permutation p. The second line contains n space-separated integers p1,\u2009p2,\u2009...,\u2009pn \u2014 the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line contains n characters '0' or '1' and describes the i-th row of A. The j-th character of the i-th line Ai,\u2009j is the element on the intersection of the i-th row and the j-th column of A. It is guaranteed that, for all integers i,\u2009j where 1\u2009\u2264\u2009i\u2009<\u2009j\u2009\u2264\u2009n, Ai,\u2009j\u2009=\u2009Aj,\u2009i holds. Also, for all integers i where 1\u2009\u2264\u2009i\u2009\u2264\u2009n, Ai,\u2009i\u2009=\u20090 holds.", "output_spec": "In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.", "sample_inputs": ["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"], "sample_outputs": ["1 2 4 3 6 7 5", "1 2 3 4 5"], "notes": "NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1,\u2009p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1,\u2009p3),\u2009(p4,\u2009p5),\u2009(p3,\u2009p4). A permutation p is a sequence of integers p1,\u2009p2,\u2009...,\u2009pn, consisting of n distinct positive integers, each of them doesn't exceed n. The i-th element of the permutation p is denoted as pi. The size of the permutation p is denoted as n."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 200; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n {\n if($b[$c[$y]] > $b[$d[$y]])\n {\n $h = $b[$c[$y]];\n $i = $b[$d[$y]];\n $b[$c[$y]] = $i;\n $b[$d[$y]] = $h;\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 200; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 301] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 301] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 301] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 301] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "if($a == 217)\n{\n print implode(\" \", $c[121]) . \"\\n\";\n print implode(\" \", $c[122]) . \"\\n\";\n print implode(\" \", $c[123]) . \"\\n\";\n print implode(\" \", $c[124]) . \"\\n\";\n print implode(\" \", $c[125]) . \"\\n\";\n print implode(\" \", $c[126]) . \"\\n\";\n print implode(\" \", $c[127]) . \"\\n\";\n print implode(\" \", $c[128]) . \"\\n\";\n print implode(\" \", $c[129]) . \"\\n\";\n print implode(\" \", $c[130]) . \"\\n\";\n print implode(\" \", $c[131]) . \"\\n\";\n print implode(\" \", $c[132]) . \"\\n\";\n print implode(\" \", $c[133]) . \"\\n\";\n print implode(\" \", $c[134]) . \"\\n\";\n print implode(\" \", $c[135]) . \"\\n\";\n print implode(\" \", $c[136]) . \"\\n\";\n print implode(\" \", $c[137]) . \"\\n\";\n print implode(\" \", $c[138]) . \"\\n\";\n print implode(\" \", $c[139]) . \"\\n\";\n print implode(\" \", $c[140]) . \"\\n\";\n print implode(\" \", $c[141]) . \"\\n\";\n print implode(\" \", $c[142]) . \"\\n\";\n print implode(\" \", $c[143]) . \"\\n\";\n print implode(\" \", $c[144]) . \"\\n\";\n print implode(\" \", $c[145]) . \"\\n\";\n print implode(\" \", $c[146]) . \"\\n\";\n print implode(\" \", $c[147]) . \"\\n\";\n print implode(\" \", $c[148]) . \"\\n\";\n print implode(\" \", $c[149]) . \"\\n\";\n print implode(\" \", $c[150]) . \"\\n\";\n print implode(\" \", $c[151]) . \"\\n\";\n print implode(\" \", $c[152]) . \"\\n\";\n print implode(\" \", $c[153]) . \"\\n\";\n print implode(\" \", $c[154]) . \"\\n\";\n print implode(\" \", $c[155]) . \"\\n\";\n print implode(\" \", $c[156]) . \"\\n\";\n print implode(\" \", $c[157]) . \"\\n\";\n print implode(\" \", $c[158]) . \"\\n\";\n print implode(\" \", $c[159]) . \"\\n\";\n print implode(\" \", $c[160]) . \"\\n\";\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 200; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 1] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 1] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 200] = $c[$y];\n $h[$y + 300] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[count($g) - $y - 1];\n $h[$y + 500] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 100] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 600] = $c[$m];\n $h[$y + 700] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 200] = $c[$y];\n $h[$y + 300] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[count($g) - $y - 1];\n $h[$y + 500] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 100] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 600] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nif($a == 288)\n{\n print count($k) . \"\\n\";\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 200] = $c[$y];\n $h[$y + 300] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[count($g) - $y - 1];\n $h[$y + 500] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 100] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 600] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nif($a == 300)\n{\n print count($k) . \"\\n\";\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 200; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 1] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 1] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 100; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n { \n if($c[$y] === $c[$y + 1])\n {\n $h = 1;\n for($z = $y; $z < count($c); $z++)\n {\n if($c[$z] == $c[$z + 1])\n {\n $h++;\n }\n else\n {\n break;\n }\n }\n $i = array();\n for($z = $y; $z < $y + $h; $z++)\n {\n $i[$z] = $b[$d[$z]];\n }\n\n asort($i);\n $k = array_keys($i);\n $l = $d[$k[0]];\n $s = $b[$c[$y]];\n $o = $b[$l];\n if($b[$c[$y]] > $o)\n {\n $b[$c[$y]] = $o;\n $b[$l] = $s;\n }\n for($z = 1; $z <= $h - 1; $z++)\n {\n $y++;\n }\n }\n else\n {\n if($b[$c[$y]] > $b[$d[$y]])\n {\n $m = $b[$c[$y]];\n $n = $b[$d[$y]];\n $b[$c[$y]] = $n;\n $b[$d[$y]] = $m;\n }\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "if($a == 217)\n{\n print implode(\" \", $c[41]) . \"\\n\";\n print implode(\" \", $c[42]) . \"\\n\";\n print implode(\" \", $c[43]) . \"\\n\";\n print implode(\" \", $c[44]) . \"\\n\";\n print implode(\" \", $c[45]) . \"\\n\";\n print implode(\" \", $c[46]) . \"\\n\";\n print implode(\" \", $c[47]) . \"\\n\";\n print implode(\" \", $c[48]) . \"\\n\";\n print implode(\" \", $c[49]) . \"\\n\";\n print implode(\" \", $c[50]) . \"\\n\";\n print implode(\" \", $c[51]) . \"\\n\";\n print implode(\" \", $c[52]) . \"\\n\";\n print implode(\" \", $c[53]) . \"\\n\";\n print implode(\" \", $c[54]) . \"\\n\";\n print implode(\" \", $c[55]) . \"\\n\";\n print implode(\" \", $c[56]) . \"\\n\";\n print implode(\" \", $c[57]) . \"\\n\";\n print implode(\" \", $c[58]) . \"\\n\";\n print implode(\" \", $c[59]) . \"\\n\";\n print implode(\" \", $c[60]) . \"\\n\";\n print implode(\" \", $c[61]) . \"\\n\";\n print implode(\" \", $c[62]) . \"\\n\";\n print implode(\" \", $c[63]) . \"\\n\";\n print implode(\" \", $c[64]) . \"\\n\";\n print implode(\" \", $c[65]) . \"\\n\";\n print implode(\" \", $c[66]) . \"\\n\";\n print implode(\" \", $c[67]) . \"\\n\";\n print implode(\" \", $c[68]) . \"\\n\";\n print implode(\" \", $c[69]) . \"\\n\";\n print implode(\" \", $c[70]) . \"\\n\";\n print implode(\" \", $c[71]) . \"\\n\";\n print implode(\" \", $c[72]) . \"\\n\";\n print implode(\" \", $c[73]) . \"\\n\";\n print implode(\" \", $c[74]) . \"\\n\";\n print implode(\" \", $c[75]) . \"\\n\";\n print implode(\" \", $c[76]) . \"\\n\";\n print implode(\" \", $c[77]) . \"\\n\";\n print implode(\" \", $c[78]) . \"\\n\";\n print implode(\" \", $c[79]) . \"\\n\";\n print implode(\" \", $c[80]) . \"\\n\";\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 100; $x++)\n{\n $j = 0;\n $k = array();\n for($y = 0; $y < count($c); $y++)\n {\n if(($b[$c[$y]] > $b[$d[$y]]) && ($c[$y] == $c[$y + 1]))\n {\n $j = 1;\n array_push($k, $d[$y]);\n array_push($k, $d[$y + 1]);\n $p = $b[$c[$y]];\n $s = $c[$y];\n }\n elseif(($b[$c[$y]] > $b[$d[$y]]) && ($c[$y] != $c[$y + 1]) && ($j == 0))\n {\n $h = $b[$c[$y]];\n $i = $b[$d[$y]];\n $b[$c[$y]] = $i;\n $b[$d[$y]] = $h;\n }\n elseif(($b[$c[$y]] > $b[$d[$y]]) && ($c[$y] != $c[$y + 1]) && ($j == 1))\n {\n $l = array_unique($k);\n sort($l);\n $m = array();\n for($z = 0; $z < count($l); $z++)\n {\n array_push($m, $b[$l[$z]]);\n }\n asort($m);\n $n = array_keys($m);\n $o = $l[$n[0]];\n $j = 0;\n $k = array();\n $r = $b[$o];\n $b[$s] = $r;\n $b[$d[$y]] = $r;\n $b[$o] = $p;\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[$y];\n $h[$y + 600] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 800] = $c[count($g) - $y - 1];\n $h[$y + 1000] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 200] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n if($a == 288)\n {\n print implode(\" \", $n) . \"\\n\";\n }\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 10; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 1] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 1] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 100; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n { \n if($c[$y] == $c[$y + 1])\n {\n $h = 1;\n for($z = $y; $z < count($c); $z++)\n {\n if($c[$z] == $c[$z + 1])\n {\n $h++;\n }\n else\n {\n break;\n }\n }\n $i = array();\n for($z = $y; $z < $y + $h; $z++)\n {\n $i[$z] = $b[$d[$z]];\n }\n\n asort($i);\n $k = array_keys($i);\n $l = $d[$k[0]];\n $s = $b[$c[$y]];\n $o = $b[$l];\n if($b[$c[$y]] > $o)\n {\n $b[$c[$y]] = $o;\n $b[$l] = $s;\n }\n for($z = 1; $z <= $h - 1; $z++)\n {\n $y++;\n }\n }\n else\n {\n if($b[$c[$y]] > $b[$d[$y]])\n {\n $m = $b[$c[$y]];\n $n = $b[$d[$y]];\n $b[$c[$y]] = $n;\n $b[$d[$y]] = $m;\n }\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[$y];\n $h[$y + 600] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 800] = $c[count($g) - $y - 1];\n $h[$y + 1000] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 200] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 1200] = $c[$m];\n $h[$y + 1400] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if($a == 288)\n {\n print implode(\" \", $h) . \"\\n\";\n }\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": " 0) && ($x != $y))\n {\n $c[$x] = array_merge($c[$x], $c[$y]);\n unset($c[$y]);\n }\n $f = array_intersect($c[$x], $c[count($c) - $y - 1]);\n if((count($f) > 0) && ($x != $y))\n {\n $c[$x] = array_merge($c[$x], $c[count($c) - $y - 1]);\n unset($c[$y]);\n }\n }\n}\nsort($c);\nfor($x = 0; $x < count($c); $x++)\n{\n $g = array_unique($c[$x]);\n $c[$x] = $g;\n $h = $c[$x];\n sort($h);\n $c[$x] = $h;\n}\nfor($x = 0; $x < count($c); $x++)\n{\n $i = array();\n if(count($c[$x]) != 1)\n {\n for($y = 0; $y < count($c[$x]); $y++)\n {\n $i[$y] = $b[$c[$x][$y] - 1];\n }\n sort($i);\n for($y = 0; $y < count($c[$x]); $y++)\n {\n $b[$c[$x][$y] - 1] = $i[$y];\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 200] = $c[$y];\n $h[$y + 300] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[count($g) - $y - 1];\n $h[$y + 500] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 100] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 600] = $c[$m];\n $h[$y + 700] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 100; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n { \n if($c[$y] === $c[$y + 1])\n {\n $h = 1;\n for($z = $y; $z < count($c); $z++)\n {\n if($c[$z] == $c[$z + 1])\n {\n $h++;\n }\n else\n {\n break;\n }\n }\n $i = array();\n for($z = $y; $z < $y + $h; $z++)\n {\n $i[$z] = $b[$d[$z]];\n }\n\n asort($i);\n $k = array_keys($i);\n $l = $d[$k[0]];\n $s = $b[$c[$y]];\n $o = $b[$l];\n if($b[$c[$y]] > $o)\n {\n $b[$c[$y]] = $o;\n $b[$l] = $s;\n }\n for($z = 1; $z <= $h - 1; $z++)\n {\n $y++;\n }\n }\n else\n {\n if($b[$c[$y]] > $b[$d[$y]])\n {\n $m = $b[$c[$y]];\n $n = $b[$d[$y]];\n $b[$c[$y]] = $n;\n $b[$d[$y]] = $m;\n }\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 10; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 1] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 1] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[$y];\n $h[$y + 600] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 800] = $c[count($g) - $y - 1];\n $h[$y + 1000] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 200] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n if($a == 288)\n {\n print implode(\" \", $n) . \"\\n\";\n }\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": "= 0; $y--)\n {\n $e = array_intersect($c[$x], $c[$y]);\n if($e == TRUE)\n {\n $c[$x] += $c[$y];\n }\n }\n}\nfor($x = 0; $x < count($c); $x++)\n{\n $e = array_unique($c[$x]);\n $c[$x] = $e;\n $f = $c[$x];\n sort($f);\n $c[$x] = $f;\n}\nfor($x = 0; $x < count($c); $x++)\n{\n $i = array();\n if(count($c[$x]) != 1)\n {\n for($y = 0; $y < count($c[$x]); $y++)\n {\n $i[$y] = $b[$c[$x][$y] - 1];\n }\n sort($i);\n for($y = 0; $y < count($c[$x]); $y++)\n {\n $b[$c[$x][$y] - 1] = $i[$y];\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\nfor($x = 1; $x <= 100; $x++)\n{\n for($y = 0; $y < count($c); $y++)\n { \n if($c[$y] === $c[$y + 1])\n {\n $h = 1;\n for($z = $y; $z < count($c); $z++)\n {\n if($c[$z] == $c[$z + 1])\n {\n $h++;\n }\n else\n {\n break;\n }\n }\n $i = array();\n for($z = $y; $z < $y + $h; $z++)\n {\n $i[$z] = $b[$d[$z]];\n }\n\n asort($i);\n $k = array_keys($i);\n $l = $d[$k[0]];\n $s = $b[$c[$y]];\n $o = $b[$l];\n if($b[$c[$y]] > $o)\n {\n $b[$c[$y]] = $o;\n $b[$l] = $s;\n }\n for($z = 1; $z <= $h - 1; $z++)\n {\n $y++;\n }\n }\n else\n {\n if($b[$c[$y]] > $b[$d[$y]])\n {\n $m = $b[$c[$y]];\n $n = $b[$d[$y]];\n $b[$c[$y]] = $n;\n $b[$d[$y]] = $m;\n }\n }\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 100; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 400] = $c[$y];\n $h[$y + 600] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y + 800] = $c[count($g) - $y - 1];\n $h[$y + 1000] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 200] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n if(count($c) == 0)\n {\n break;\n }\n}\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n if($a == 288)\n {\n print implode(\" \", $n) . \"\\n\";\n }\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}, {"source_code": "= $d[$x])\n {\n unset($c[$x]);\n unset($d[$x]);\n }\n}\n$g = range(0, count($c) - 1);\n$c = array_combine($g, $c);\n$d = array_combine($g, $d);\n$k = array();\nfor($x = 1; $x <= 230; $x++)\n{\n $h = array();\n $m = floor(count($c) / 2);\n for($y = 0; $y < count($g); $y++)\n {\n if(count($h) != 0)\n {\n $i = in_array($c[$y], $h);\n $j = in_array($d[$y], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n $i = in_array($c[count($g) - $y - 1], $h);\n $j = in_array($d[count($g) - $y - 1], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[count($g) - $y - 1];\n $h[$y + 1] = $d[count($g) - $y - 1];\n unset($c[count($g) - $y - 1]);\n unset($d[count($g) - $y - 1]);\n }\n }\n elseif($c[$y] == TRUE)\n {\n $h[$y] = $c[$y];\n $h[$y + 1] = $d[$y];\n unset($c[$y]);\n unset($d[$y]);\n }\n }\n $i = in_array($c[$m], $h);\n $j = in_array($d[$m], $h);\n if(($i == TRUE) || ($j == TRUE))\n {\n $h[$y] = $c[$m];\n $h[$y + 1] = $d[$m];\n unset($c[$m]);\n unset($d[$m]);\n } \n $h = array_unique($h);\n sort($h);\n array_push($k, $h);\n}\n$k = array_filter($k);\nfor($x = 0; $x < count($k); $x++)\n{\n $n = array();\n for($y = 0; $y < count($k[$x]); $y++)\n {\n array_push($n, $b[$k[$x][$y] - 1]);\n }\n sort($n);\n for($y = 0; $y < count($k[$x]); $y++)\n {\n $b[$k[$x][$y] - 1] = $n[$y];\n }\n}\nprint implode(\" \", $b);\n?>"}], "src_uid": "a67ea891cd6084ceeaace8894cf18e60"} {"nl": {"description": "Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1,\u2009s2,\u2009...,\u2009sn. All those strings consist of uppercase and lowercase Latin letters. String w has the length of |w|, its characters are numbered from 1 to |w|.First Petya should find all the occurrences of forbidden substrings in the w string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings \"aBC\" and \"ABc\" are considered equal.After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position i should be replaced by any other one if for position i in string w there exist pair of indices l,\u2009r (1\u2009\u2264\u2009l\u2009\u2264\u2009i\u2009\u2264\u2009r\u2009\u2264\u2009|w|) such that substring w[l\u00a0...\u00a0r] is contained in the collection s1,\u2009s2,\u2009...,\u2009sn, when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.Letter letter (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the letter occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.", "input_spec": "The first line contains the only integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of forbidden substrings in the collection. Next n lines contain these substrings. The next line contains string w. All those n\u2009+\u20091 lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed 100. The last line contains a lowercase letter letter.", "output_spec": "Output the only line \u2014 Petya's resulting string with the maximum number of letters letter. If there are several answers then output the one that comes first lexicographically. The lexicographical comparison is performed by the standard < operator in modern programming languages. The line a is lexicographically smaller than the line b, if a is a prefix of b, or there exists such an i (1\u2009\u2264\u2009i\u2009\u2264\u2009|a|), that ai\u2009<\u2009bi, and for any j (1\u2009\u2264\u2009j\u2009<\u2009i) aj\u2009=\u2009bj. |a| stands for the length of string a.", "sample_inputs": ["3\nbers\nucky\nelu\nPetrLoveLuckyNumbers\nt", "4\nhello\nparty\nabefglghjdhfgj\nIVan\npetrsmatchwin\na", "2\naCa\ncba\nabAcaba\nc"], "sample_outputs": ["PetrLovtTttttNumtttt", "petrsmatchwin", "abCacba"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "258753b00e378df9c6e06692026aadad"} {"nl": {"description": "A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least one of the following is true: Employee A is the immediate manager of employee B Employee B has an immediate manager employee C such that employee A is the superior of employee C. The company will not have a managerial cycle. That is, there will not exist an employee who is the superior of his/her own immediate manager.Today the company is going to arrange a party. This involves dividing all n employees into several groups: every employee must belong to exactly one group. Furthermore, within any single group, there must not be two employees A and B such that A is the superior of B.What is the minimum number of groups that must be formed?", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092000) \u2014 the number of employees. The next n lines contain the integers pi (1\u2009\u2264\u2009pi\u2009\u2264\u2009n or pi\u2009=\u2009-1). Every pi denotes the immediate manager for the i-th employee. If pi is -1, that means that the i-th employee does not have an immediate manager. It is guaranteed, that no employee will be the immediate manager of him/herself (pi\u2009\u2260\u2009i). Also, there will be no managerial cycles.", "output_spec": "Print a single integer denoting the minimum number of groups that will be formed in the party.", "sample_inputs": ["5\n-1\n1\n2\n1\n-1"], "sample_outputs": ["3"], "notes": "NoteFor the first example, three groups are sufficient, for example: Employee 1 Employees 2 and 4 Employees 3 and 5 "}, "positive_code": [{"source_code": "\n"}, {"source_code": "=($tolevel-1)) {\n $leveltable[$table[$i]]=$tolevel; \n $operate = true; \n }\n return $operate;\n}\n\n$tolevel = 1;\nwhile (GradeLevels($leveltable,$table,$cnt, $tolevel))\n $tolevel++;\n \necho max($leveltable);\n \n?>"}, {"source_code": ""}, {"source_code": "= 1; $x--)\n{\n if($b[$x] != \"-1\")\n {\n $e = $x;\n $f = 1;\n while(TRUE)\n {\n if($b[$e] == \"-1\")\n {\n break;\n }\n else\n {\n $e = $b[$e];\n $f++;\n }\n }\n $d = max($d, $f);\n }\n}\nprint $d;\n?>"}, {"source_code": "$maxCount){\n $maxCount = $count;\n }\n if (isset($a[$i]['parents'])){\n foreach($a[$i]['parents'] as $k=>$item){\n spusk($item,$count);\n }\n }\n}\n\nspusk(-1,0);\necho $maxCount-1;\n//print_r($maxCount);\n\n\n"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "=($tolevel-1)) {\n \t\t$leveltable[$table[$i]]=$tolevel; \n \t\t$operate = true; \n \t\t}\n \treturn $operate;\n}\n\n$tolevel = 1;\nwhile (GradeLevels($leveltable,$table,$cnt, $tolevel))\n\t$tolevel++;\n\t\necho max($leveltable);\n \n?>"}], "negative_code": [{"source_code": "import java.util.*;\n\npublic class Solution\n{\n public static void main(String[] args)\n {\n new Solution().calc();\n }\n\n int[] boss;\n void calc()\n {\n\n Scanner cin = new Scanner(System.in);\n int n = cin.nextInt();\n boss = new int[n];\n for (int i = 0; i < n; i++)\n {\n boss[i] = cin.nextInt();\n if (boss[i] != -1) boss[i]--;\n }\n int ret = 1;\n for (int i = 0; i < n; i++)\n {\n ret = Math.max(ret, dfs(i));\n }\n System.out.println(ret);\n }\n\n int dfs(int a)\n {\n if (boss[a] == -1) return 1;\n return dfs(boss[a]) + 1;\n }\n}\n"}, {"source_code": "=($tolevel-1)) {\n $leveltable[$table[$i]]=$tolevel; \n $operate = true; \n }\n return $operate;\n}\n\n$tolevel = 1;\nwhile (GradeLevels($leveltable,$tolevel,$tolevel)){\n $tolevel++;\n} \n\necho $tolevel+1;\n \n?>"}, {"source_code": "=4){\n echo 3;\n exit;\n }\n if ($count>$maxCount){\n $maxCount = $count;\n }\n if (isset($a[$i]['parents'])){\n foreach($a[$i]['parents'] as $k=>$item){\n spusk($item,$count);\n }\n }\n}\n\nspusk(-1,0);\necho $maxCount-1;\n//print_r($maxCount);\n\n\n"}], "src_uid": "8d911f79dde31f2c6f62e73b925e6996"} {"nl": {"description": "You and your friend are participating in a TV show \"Run For Your Prize\".At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend \u2014 at position 106 (and there is no prize in any of these two positions). You have to work as a team and collect all prizes in minimum possible time, in any order.You know that it takes exactly 1 second to move from position x to position x\u2009+\u20091 or x\u2009-\u20091, both for you and your friend. You also have trained enough to instantly pick up any prize, if its position is equal to your current position (and the same is true for your friend). Carrying prizes does not affect your speed (or your friend's speed) at all.Now you may discuss your strategy with your friend and decide who will pick up each prize. Remember that every prize must be picked up, either by you or by your friend.What is the minimum number of seconds it will take to pick up all the prizes?", "input_spec": "The first line contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of prizes. The second line contains n integers a1, a2, ..., an (2\u2009\u2264\u2009ai\u2009\u2264\u2009106\u2009-\u20091) \u2014 the positions of the prizes. No two prizes are located at the same position. Positions are given in ascending order.", "output_spec": "Print one integer \u2014 the minimum number of seconds it will take to collect all prizes.", "sample_inputs": ["3\n2 3 9", "2\n2 999995"], "sample_outputs": ["8", "5"], "notes": "NoteIn the first example you take all the prizes: take the first at 1, the second at 2 and the third at 8.In the second example you take the first prize in 1 second and your friend takes the other in 5 seconds, you do this simultaneously, so the total time is 5."}, "positive_code": [{"source_code": " $e)\n {\n if($c < $e)\n {\n $c = $e;\n }\n break;\n }\n}\nprint $c;\n?>"}], "negative_code": [], "src_uid": "f530e6f720dafaf8bff9324289b90b28"} {"nl": {"description": "A $$$\\mathbf{0}$$$-indexed array $$$a$$$ of size $$$n$$$ is called good if for all valid indices $$$i$$$ ($$$0 \\le i \\le n-1$$$), $$$a_i + i$$$ is a perfect square$$$^\\dagger$$$.Given an integer $$$n$$$. Find a permutation$$$^\\ddagger$$$ $$$p$$$ of $$$[0,1,2,\\ldots,n-1]$$$ that is good or determine that no such permutation exists.$$$^\\dagger$$$ An integer $$$x$$$ is said to be a perfect square if there exists an integer $$$y$$$ such that $$$x = y^2$$$.$$$^\\ddagger$$$ An array $$$b$$$ is a permutation of an array $$$a$$$ if $$$b$$$ consists of the elements of $$$a$$$ in arbitrary order. For example, $$$[4,2,3,4]$$$ is a permutation of $$$[3,2,4,4]$$$ while $$$[1,2,2]$$$ is not a permutation of $$$[1,2,3]$$$.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases. The only line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$) \u2014 the length of the permutation $$$p$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case, output $$$n$$$ distinct integers $$$p_0, p_1, \\dots, p_{n-1}$$$ ($$$0 \\le p_i \\le n-1$$$) \u2014 the permutation $$$p$$$ \u2014 if the answer exists, and $$$-1$$$ otherwise.", "sample_inputs": ["3\n\n3\n\n4\n\n7"], "sample_outputs": ["1 0 2 \n0 3 2 1 \n1 0 2 6 5 4 3"], "notes": "NoteIn the first test case, we have $$$n=3$$$. The array $$$p = [1, 0, 2]$$$ is good since $$$1 + 0 = 1^2$$$, $$$0 + 1 = 1^2$$$, and $$$2 + 2 = 2^2$$$In the second test case, we have $$$n=4$$$. The array $$$p = [0, 3, 2, 1]$$$ is good since $$$0 + 0 = 0^2$$$, $$$3 + 1 = 2^2$$$, $$$2+2 = 2^2$$$, and $$$1+3 = 2^2$$$."}, "positive_code": [{"source_code": " $perm */\n$perm = array_fill(0, 2 * N, []);\n\n$perm[0] = [0, 0];\n$perm[1] = [1, 0];\n$perm[2] = [2, 2];\n\n$q = 0;\nfor ($i = 0; $i < N; ++$i) {\n $s = $q * $q;\n\n if (isset($sq[$i])) {\n ++$q;\n }\n\n $perm[$i] = [$i, $s - $i];\n}\n\nfscanf(STDIN, '%u', $t);\n\nwhile ($t--) {\n fscanf(STDIN, '%u', $n);\n\n $resPerm = [];\n $i = $n - 1;\n\n while (~$i) {\n $p = $perm[$i];\n $resPerm[] = $p;\n $i = $p[1] - 1;\n }\n\n $resPerm = array_reverse($resPerm);\n\n $res = [];\n foreach ($resPerm as [$st, $en]) {\n $res[] = range($st, $en);\n }\n\n $res = array_merge(...$res);\n\n fprintf(STDOUT, str_repeat('%u ', count($res)).PHP_EOL, ...$res);\n}\n/*\n\n3\n1 0 2\n0 1 2\n1 1 4\n\n4\n\n0 3 2 1\n0 1 2 3\n\n0 4 4 4\n\n\n7\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 1 4 9 9 9 9\n\n8\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n9|4|1|0 9|4|1 9|4 9|4 9|4 9 9 9\n\n\n11\n | 10 9 8 7 6\n0 1 2 3 4 5 | 6 7 8 9 10\n | 16 16 16 16 16\n\n\n | 5 4\n0 1 2 3 | 4 5\n | 9 9\n\n | 2 1 - not possible because of 1 here\n0 1 | 2 3\n | 4 4\n\n0 3 2 1\n0 1 2 3\n\n\n0\n0\n\n1 0\n0 1\n\n1 0 2\n0 1 2\n\n0 3 2 1\n0 1 2 3\n\n4 3 2 1 0\n0 1 2 3 4\n\n0 3 2 1 5 4\n0 1 2 3 4 5\n\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n\n0 8 7 6 5 4 3 2 1\n0 1 2 3 4 5 6 7 8\n\n9 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9\n\n0, 1, 4, 9, 16, 25, 36, 49, 64, 81\n */\n"}, {"source_code": "> $perm */\n$perm = array_fill(0, 2 * N, []);\n\n$perm[0] = [0, 0];\n$perm[1] = [1, 0];\n$perm[2] = [2, 2];\n\n$q = 0;\nfor ($i = 0; $i < N; ++$i) {\n $s = $q * $q;\n\n if (isset($sq[$i])) {\n ++$q;\n }\n\n $perm[$i] = [$i, $s - $i];\n}\n\nfscanf(STDIN, '%u', $t);\n\nwhile ($t--) {\n fscanf(STDIN, '%u', $n);\n\n $resPerm = [];\n $i = $n - 1;\n\n while (~$i) {\n $p = $perm[$i];\n $resPerm[] = $p;\n $i = $p[1] - 1;\n }\n\n $resPerm = array_reverse($resPerm);\n\n $res = [];\n foreach ($resPerm as [$st, $en]) {\n $res[] = range($st, $en);\n }\n\n $res = array_merge(...$res);\n\n fprintf(STDOUT, str_repeat('%u ', count($res)).PHP_EOL, ...$res);\n}\n/*\n\n3\n1 0 2\n0 1 2\n1 1 4\n\n4\n\n0 3 2 1\n0 1 2 3\n\n0 4 4 4\n\n\n7\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 1 4 9 9 9 9\n\n8\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n9|4|1|0 9|4|1 9|4 9|4 9|4 9 9 9\n\n\n11\n | 10 9 8 7 6\n0 1 2 3 4 5 | 6 7 8 9 10\n | 16 16 16 16 16\n\n\n | 5 4\n0 1 2 3 | 4 5\n | 9 9\n\n | 2 1 - not possible because of 1 here\n0 1 | 2 3\n | 4 4\n\n0 3 2 1\n0 1 2 3\n\n\n0\n0\n\n1 0\n0 1\n\n1 0 2\n0 1 2\n\n0 3 2 1\n0 1 2 3\n\n4 3 2 1 0\n0 1 2 3 4\n\n0 3 2 1 5 4\n0 1 2 3 4 5\n\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n\n0 8 7 6 5 4 3 2 1\n0 1 2 3 4 5 6 7 8\n\n9 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9\n\n0, 1, 4, 9, 16, 25, 36, 49, 64, 81\n */\n"}, {"source_code": "> $perm */\n$perm = array_fill(0, 2 * N, []);\n\n$perm[0] = [0, 0];\n$perm[1] = [1, 0];\n$perm[2] = [2, 2];\n\n$q = 0;\nfor ($i = 0; $i < N; ++$i) {\n $s = $q * $q;\n\n if (isset($sq[$i])) {\n ++$q;\n }\n\n $perm[$i] = [$i, $s - $i];\n}\n\nfscanf(STDIN, '%u', $t);\n\nwhile ($t--) {\n fscanf(STDIN, '%u', $n);\n\n $resPerm = [];\n $i = $n - 1;\n\n while (~$i) {\n $p = $perm[$i];\n $resPerm[] = $p;\n $i = $p[1] - 1;\n }\n\n $resPerm = array_reverse($resPerm);\n\n $res = [];\n foreach ($resPerm as [$st, $en]) {\n $res[] = range($st, $en);\n }\n\n $res = array_merge(...$res);\n\n fprintf(STDOUT, str_repeat('%u ', count($res)).PHP_EOL, ...$res);\n}\n\n/*\n\n3\n1 0 2\n0 1 2\n1 1 4\n\n4\n\n0 3 2 1\n0 1 2 3\n\n0 4 4 4\n\n\n7\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 1 4 9 9 9 9\n\n8\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n9|4|1|0 9|4|1 9|4 9|4 9|4 9 9 9\n\n\n11\n | 10 9 8 7 6\n0 1 2 3 4 5 | 6 7 8 9 10\n | 16 16 16 16 16\n\n\n | 5 4\n0 1 2 3 | 4 5\n | 9 9\n\n | 2 1 - not possible because of 1 here\n0 1 | 2 3\n | 4 4\n\n0 3 2 1\n0 1 2 3\n\n\n0\n0\n\n1 0\n0 1\n\n1 0 2\n0 1 2\n\n0 3 2 1\n0 1 2 3\n\n4 3 2 1 0\n0 1 2 3 4\n\n0 3 2 1 5 4\n0 1 2 3 4 5\n\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n\n0 8 7 6 5 4 3 2 1\n0 1 2 3 4 5 6 7 8\n\n9 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9\n\n0, 1, 4, 9, 16, 25, 36, 49, 64, 81,\n\n */\n"}, {"source_code": "> $perm */\n$perm = array_fill(0, 2 * N, []);\n\n$perm[0] = [0, 0];\n$perm[1] = [1, 0];\n$perm[2] = [2, 2];\n\n$q = 0;\nfor ($i = 0; $i < N; ++$i) {\n $s = $q * $q;\n\n if (isset($sq[$i])) {\n ++$q;\n }\n\n $perm[$i] = [$i, $s - $i];\n}\n\nfscanf(STDIN, '%u', $t);\n\nwhile ($t--) {\n fscanf(STDIN, '%u', $n);\n\n $resPerm = [];\n $i = $n - 1;\n\n while (~$i) {\n $p = $perm[$i];\n $resPerm[] = $p;\n $i = $p[1] - 1;\n }\n\n $resPerm = array_reverse($resPerm);\n\n $res = [];\n foreach ($resPerm as [$st, $en]) {\n $res[] = range($st, $en);\n }\n\n $res = array_merge(...$res);\n\n fprintf(STDOUT, '%s' . PHP_EOL, implode(' ', $res));\n}\n\n/*\n\n3\n1 0 2\n0 1 2\n1 1 4\n\n4\n\n0 3 2 1\n0 1 2 3\n\n0 4 4 4\n\n\n7\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 1 4 9 9 9 9\n\n8\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n9|4|1|0 9|4|1 9|4 9|4 9|4 9 9 9\n\n\n11\n | 10 9 8 7 6\n0 1 2 3 4 5 | 6 7 8 9 10\n | 16 16 16 16 16\n\n\n | 5 4\n0 1 2 3 | 4 5\n | 9 9\n\n | 2 1 - not possible because of 1 here\n0 1 | 2 3\n | 4 4\n\n0 3 2 1\n0 1 2 3\n\n\n0\n0\n\n1 0\n0 1\n\n1 0 2\n0 1 2\n\n0 3 2 1\n0 1 2 3\n\n4 3 2 1 0\n0 1 2 3 4\n\n0 3 2 1 5 4\n0 1 2 3 4 5\n\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n\n0 8 7 6 5 4 3 2 1\n0 1 2 3 4 5 6 7 8\n\n9 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9\n\n0, 1, 4, 9, 16, 25, 36, 49, 64, 81,\n\n */\n"}, {"source_code": "> $perm */\n$perm = array_fill(0, 2 * N, []);\n\n$perm[0] = [0, 0];\n$perm[1] = [1, 0];\n$perm[2] = [2, 2];\n\n$q = 0;\nfor ($i = 0; $i < N; ++$i) {\n $s = $q * $q;\n\n if (isset($sq[$i])) {\n ++$q;\n }\n\n $perm[$i] = [$i, $s - $i];\n}\n\nfscanf(STDIN, '%u', $t);\n\nwhile ($t--) {\n fscanf(STDIN, '%u', $n);\n\n $resPerm = [];\n $i = $n - 1;\n\n while (~$i) {\n $p = $perm[$i];\n $resPerm[] = $p;\n $i = $p[1] - 1;\n }\n\n $resPerm = array_reverse($resPerm);\n\n $res = [];\n foreach ($resPerm as [$st, $en]) {\n $res[] = range($st, $en);\n }\n\n $res = array_merge(...$res);\n\n fprintf(STDOUT, '%s' . PHP_EOL, implode(' ', $res));\n}\n/*\n\n3\n1 0 2\n0 1 2\n1 1 4\n\n4\n\n0 3 2 1\n0 1 2 3\n\n0 4 4 4\n\n\n7\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 1 4 9 9 9 9\n\n8\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n9|4|1|0 9|4|1 9|4 9|4 9|4 9 9 9\n\n\n11\n | 10 9 8 7 6\n0 1 2 3 4 5 | 6 7 8 9 10\n | 16 16 16 16 16\n\n\n | 5 4\n0 1 2 3 | 4 5\n | 9 9\n\n | 2 1 - not possible because of 1 here\n0 1 | 2 3\n | 4 4\n\n0 3 2 1\n0 1 2 3\n\n\n0\n0\n\n1 0\n0 1\n\n1 0 2\n0 1 2\n\n0 3 2 1\n0 1 2 3\n\n4 3 2 1 0\n0 1 2 3 4\n\n0 3 2 1 5 4\n0 1 2 3 4 5\n\n1 0 2 6 5 4 3\n0 1 2 3 4 5 6\n\n1 0 7 6 5 4 3 2\n0 1 2 3 4 5 6 7\n\n0 8 7 6 5 4 3 2 1\n0 1 2 3 4 5 6 7 8\n\n9 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9\n\n0, 1, 4, 9, 16, 25, 36, 49, 64, 81,\n\n */\n"}], "negative_code": [], "src_uid": "f7ed88c0f33ad9cb1ede2abf185d9ece"} {"nl": {"description": "A piece of paper contains an array of n integers a1,\u2009a2,\u2009...,\u2009an. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations \u2014 choose an arbitrary element from the array and add 1 to it. In other words, you are allowed to increase some array element by 1 no more than k times (you are allowed to increase the same element of the array multiple times).Your task is to find the maximum number of occurrences of some number in the array after performing no more than k allowed operations. If there are several such numbers, your task is to find the minimum one.", "input_spec": "The first line contains two integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u2009105; 0\u2009\u2264\u2009k\u2009\u2264\u2009109) \u2014 the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,\u2009a2,\u2009...,\u2009an (|ai|\u2009\u2264\u2009109) \u2014 the initial array. The numbers in the lines are separated by single spaces.", "output_spec": "In a single line print two numbers \u2014 the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces.", "sample_inputs": ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"], "sample_outputs": ["3 4", "3 5", "4 2"], "notes": "NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,\u20094,\u20094,\u20090,\u20094, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing, we get array 5,\u20095,\u20095, if we increase each by one, we get 6,\u20096,\u20096. In both cases the maximum number of occurrences equals 3. So we should do nothing, as number 5 is less than number 6.In the third sample we should increase the second array element once and the fifth element once. Thus, we get sequence 3,\u20092,\u20092,\u20092,\u20092, where number 2 occurs 4 times."}, "positive_code": [{"source_code": "$k)\n\t{\n\t\t$used-=$a[$i]-$a[$j];\n\t\t$j++;\n\t}\n\tif ($i-$j+1>$ans)\n\t{\n\t\t$ans=$i-$j+1;\n\t\t$ansn=$a[$i];\n\t}\n}\necho \"$ans $ansn\";\n?>"}], "negative_code": [], "src_uid": "3791d1a504b39eb2e72472bcfd9a7e22"} {"nl": {"description": "Polycarp has an integer $$$n$$$ that doesn't contain the digit 0. He can do the following operation with his number several (possibly zero) times: Reverse the prefix of length $$$l$$$ (in other words, $$$l$$$ leftmost digits) of $$$n$$$. So, the leftmost digit is swapped with the $$$l$$$-th digit from the left, the second digit from the left swapped with ($$$l-1$$$)-th left, etc. For example, if $$$n=123456789$$$ and $$$l=5$$$, then the new value of $$$n$$$ will be $$$543216789$$$.Note that for different operations, the values of $$$l$$$ can be different. The number $$$l$$$ can be equal to the length of the number $$$n$$$\u00a0\u2014 in this case, the whole number $$$n$$$ is reversed.Polycarp loves even numbers. Therefore, he wants to make his number even. At the same time, Polycarp is very impatient. He wants to do as few operations as possible.Help Polycarp. Determine the minimum number of operations he needs to perform with the number $$$n$$$ to make it even or determine that this is impossible.You need to answer $$$t$$$ independent test cases.", "input_spec": "The first line contains the number $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. Each of the following $$$t$$$ lines contains one integer $$$n$$$ ($$$1 \\le n < 10^9$$$). It is guaranteed that the given number doesn't contain the digit 0.", "output_spec": "Print $$$t$$$ lines. On each line print one integer\u00a0\u2014 the answer to the corresponding test case. If it is impossible to make an even number, print -1.", "sample_inputs": ["4\n3876\n387\n4489\n3"], "sample_outputs": ["0\n2\n1\n-1"], "notes": "NoteIn the first test case, $$$n=3876$$$, which is already an even number. Polycarp doesn't need to do anything, so the answer is $$$0$$$.In the second test case, $$$n=387$$$. Polycarp needs to do $$$2$$$ operations: Select $$$l=2$$$ and reverse the prefix $$$\\underline{38}7$$$. The number $$$n$$$ becomes $$$837$$$. This number is odd. Select $$$l=3$$$ and reverse the prefix $$$\\underline{837}$$$. The number $$$n$$$ becomes $$$738$$$. This number is even.It can be shown that $$$2$$$ is the minimum possible number of operations that Polycarp needs to do with his number to make it even.In the third test case, $$$n=4489$$$. Polycarp can reverse the whole number (choose a prefix of length $$$l=4$$$). It will become $$$9844$$$ and this is an even number.In the fourth test case, $$$n=3$$$. No matter how hard Polycarp tried, he would not be able to make an even number."}, "positive_code": [{"source_code": "\r\n\r\n$n = trim(fgets(STDIN));\r\n\r\nfor($i=0;$i<$n;$i++){\r\n\t$currDigit = trim(fgets(STDIN));\r\n\tif($currDigit%2==0){\r\n\t\techo \"0\\n\";\r\n\t}else{\r\n\t\t$out = -1;\r\n\t\t$arr = str_split($currDigit);\r\n\t\t$k = 0;\r\n\t\tforeach($arr as $oneDigit){\r\n\t\t\tif($oneDigit%2==0){\r\n\t\t\t\tif($k==0){\r\n\t\t\t\t\t$out = 1;\r\n\t\t\t\t}else{\r\n\t\t\t\t\t$out = 2;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t$k++;\r\n\t\t}\r\n\t\techo $out.\"\\n\";\r\n\t}\r\n}"}, {"source_code": " $digit) {\r\n if ($digit % 2 == 0) {\r\n if ($key == 0) {\r\n return 1;\r\n }\r\n\r\n return 2;\r\n }\r\n }\r\n\r\n return -1;\r\n}\r\n"}], "negative_code": [{"source_code": "\r\n$n = trim(fgets(STDIN));\r\n\r\nfor($i=0;$i<$n;$i++){\r\n\t$currDigit = trim(fgets(STDIN));\r\n\tif($currDigit%2==0){\r\n\t\techo \"0\\n\";\r\n\t}else{\r\n\t\t$out = -1;\r\n\t\t$arr = str_split($currDigit);\r\n\t\tforeach($arr as $oneDigit){\r\n\t\t\tif($oneDigit%2==0){\r\n\t\t\t\t$out = 2;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\techo $out.\"\\n\";\r\n\t}\r\n}"}, {"source_code": "\r\n$n = trim(fgets(STDIN));\r\n\r\nfor($i=0;$i<$n;$i++){\r\n\t$currDigit = trim(fgets(STDIN));\r\n\tif($currDigit%2==0){\r\n\t\techo \"0\\n\";\r\n\t}else{\r\n\t\t$out = -1;\r\n\t\t$arr = explode(\"\",$currDigit);\r\n\t\tforeach($arr as $oneDigit){\r\n\t\t\tif($oneDigit%2==0){\r\n\t\t\t\t$out = 2;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\techo $out.\"\\n\";\r\n\t}\r\n}"}], "src_uid": "03e5f71810b10318fed344878d226a10"} {"nl": {"description": "You are given sequence a1,\u2009a2,\u2009...,\u2009an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You should write a program which finds sum of the best subsequence.", "input_spec": "The first line contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009105). The second line contains n integer numbers a1,\u2009a2,\u2009...,\u2009an (\u2009-\u2009104\u2009\u2264\u2009ai\u2009\u2264\u2009104). The sequence contains at least one subsequence with odd sum.", "output_spec": "Print sum of resulting subseqeuence.", "sample_inputs": ["4\n-2 2 -3 1", "3\n2 -5 -3"], "sample_outputs": ["3", "-1"], "notes": "NoteIn the first example sum of the second and the fourth elements is 3."}, "positive_code": [{"source_code": " 0)\n {\n $d[count($d)] = $b[$x];\n }\n}\nrsort($c);\nsort($d);\n$e = array_sum($d);\n$f = $e % 2;\nif($f == 0)\n{\n $h = 1000000;\n $j = 1000000;\n for($x = 0; $x < count($d); $x++)\n {\n $g = $d[$x] % 2;\n if($g == 1)\n {\n $h = $d[$x];\n break;\n }\n }\n for($x = 0; $x < count($c); $x++)\n {\n $i = abs($c[$x]) % 2;\n if($i == 1)\n {\n $j = $c[$x];\n break;\n }\n }\n $k = abs($j);\n if($h == 1000000)\n {\n $l = $e - $k;\n }\n elseif($j == 1000000)\n {\n $l = $e - $h;\n }\n else\n {\n if($h < $k)\n {\n $l = $e - $h;\n }\n else\n {\n $l = $e - $k;\n }\n }\n print $l;\n}\nelse\n{\n print $e;\n}\n?>"}], "negative_code": [], "src_uid": "76dd49c5545770a1dfbb2da4140199c1"} {"nl": {"description": "A group of $$$n$$$ friends decide to go to a restaurant. Each of the friends plans to order meals for $$$x_i$$$ burles and has a total of $$$y_i$$$ burles ($$$1 \\le i \\le n$$$). The friends decide to split their visit to the restaurant into several days. Each day, some group of at least two friends goes to the restaurant. Each of the friends visits the restaurant no more than once (that is, these groups do not intersect). These groups must satisfy the condition that the total budget of each group must be not less than the amount of burles that the friends in the group are going to spend at the restaurant. In other words, the sum of all $$$x_i$$$ values in the group must not exceed the sum of $$$y_i$$$ values in the group.What is the maximum number of days friends can visit the restaurant?For example, let there be $$$n = 6$$$ friends for whom $$$x$$$ = [$$$8, 3, 9, 2, 4, 5$$$] and $$$y$$$ = [$$$5, 3, 1, 4, 5, 10$$$]. Then: first and sixth friends can go to the restaurant on the first day. They will spend $$$8+5=13$$$ burles at the restaurant, and their total budget is $$$5+10=15$$$ burles. Since $$$15 \\ge 13$$$, they can actually form a group. friends with indices $$$2, 4, 5$$$ can form a second group. They will spend $$$3+2+4=9$$$ burles at the restaurant, and their total budget will be $$$3+4+5=12$$$ burles ($$$12 \\ge 9$$$). It can be shown that they will not be able to form more groups so that each group has at least two friends and each group can pay the bill.So, the maximum number of groups the friends can split into is $$$2$$$. Friends will visit the restaurant for a maximum of two days. Note that the $$$3$$$-rd friend will not visit the restaurant at all.Output the maximum number of days the friends can visit the restaurant for given $$$n$$$, $$$x$$$ and $$$y$$$.", "input_spec": "The first line of the input contains an integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) \u2014 the number of test cases in the test. The descriptions of the test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^5$$$) \u2014 the number of friends. The second line of each test case contains exactly $$$n$$$ integers $$$x_1, x_2, \\dots, x_n$$$ ($$$1 \\le x_i \\le 10^9$$$). The value of $$$x_i$$$ corresponds to the number of burles that the friend numbered $$$i$$$ plans to spend at the restaurant. The third line of each test case contains exactly $$$n$$$ integers $$$y_1, y_2, \\dots, y_n$$$ ($$$1 \\le y_i \\le 10^9$$$). The value $$$y_i$$$ corresponds to the number of burles that the friend numbered $$$i$$$ has. It is guaranteed that the sum of $$$n$$$ values over all test cases does not exceed $$$10^5$$$.", "output_spec": "For each test case, print the maximum number of days to visit the restaurant. If friends cannot form even one group to visit the restaurant, print 0.", "sample_inputs": ["6\n\n6\n\n8 3 9 2 4 5\n\n5 3 1 4 5 10\n\n4\n\n1 2 3 4\n\n1 1 2 2\n\n3\n\n2 3 7\n\n1 3 10\n\n6\n\n2 3 6 9 5 7\n\n3 2 7 10 6 10\n\n6\n\n5 4 2 1 8 100\n\n1 1 1 1 1 200\n\n6\n\n1 4 1 2 4 2\n\n1 3 3 2 3 4"], "sample_outputs": ["2\n0\n1\n3\n1\n3"], "notes": "NoteThe first test case in explained in the problem statement.In the second test case, friends cannot form at least one group of two or more people.In the third test case, one way to visit the restaurant in one day is to go in a group of all three friends ($$$1+3+10 \\ge 2+3+7$$$). Note that they do not have the option of splitting into two groups."}, "positive_code": [{"source_code": " $possesses) {\n $d[$k] = $possesses - $x[$k];\n }\n\n array_multisort($d, SORT_DESC, $x, $y);\n\n $g = 0;\n for ($l = 0, $r = $n - 1; $l < $r; ++$l, --$r) {\n $lv = $d[$l];\n $rv = $d[$r];\n $sum = $lv + $rv;\n\n while ($sum < 0 && $r - 1 > $l) {\n $rv = $d[--$r];\n $sum = $lv + $rv;\n }\n\n if ($sum < 0) {\n break;\n }\n\n ++$g;\n }\n\n fprintf(STDOUT, '%u'.PHP_EOL, $g);\n}\n\n/*\n\n1\n5\n5 4 3 2 1\n1 2 3 4 4\n// 2\n\n1\n4\n5 4 3 2\n1 2 3 4\n// 1\n\n\n6\n6\n8 3 9 2 4 5\n5 3 1 4 5 10\n4\n1 2 3 4\n1 1 2 2\n3\n2 3 7\n1 3 10\n6\n2 3 6 9 5 7\n3 2 7 10 6 10\n6\n5 4 2 1 8 100\n1 1 1 1 1 200\n6\n1 4 1 2 4 2\n1 3 3 2 3 4\n// 2 0 1 3 1 3\n\n */\n"}], "negative_code": [{"source_code": " $possesses) {\n $d[$k] = $possesses - $x[$k];\n }\n\n array_multisort($d, SORT_DESC, $x, $y);\n\n $g = 0;\n for ($l = 0, $r = $n - 1; $l < $r; ++$l, --$r) {\n $lv = $d[$l];\n $rv = $d[$r];\n $sum = $lv + $rv;\n\n while ($sum < 0 && $r > $l) {\n $rv = $d[--$r];\n $sum = $lv + $rv;\n }\n\n if ($sum < 0) {\n break;\n }\n\n ++$g;\n }\n\n fprintf(STDOUT, '%u'.PHP_EOL, $g);\n}\n\n/*\n\n1\n5\n5 4 3 2 1\n1 2 3 4 4\n\n1\n4\n5 4 3 2\n1 2 3 4\n\n */\n"}], "src_uid": "7c8884b72dcc3c51e0696eec8d6aa8ef"} {"nl": {"description": "The title is a reference to the very first Educational Round from our writers team, Educational Round 18.There is a bag, containing colored balls. There are $$$n$$$ different colors of balls, numbered from $$$1$$$ to $$$n$$$. There are $$$\\mathit{cnt}_i$$$ balls of color $$$i$$$ in the bag. The total amount of balls in the bag is odd (e.\u2009g. $$$\\mathit{cnt}_1 + \\mathit{cnt}_2 + \\dots + \\mathit{cnt}_n$$$ is odd).In one move, you can choose two balls with different colors and take them out of the bag.At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.Find any possible color of the remaining balls.", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u00a0\u2014 the number of testcases. The first line of each testcase contains a single integer $$$n$$$ ($$$1 \\le n \\le 20$$$)\u00a0\u2014 the number of colors. The second line contains $$$n$$$ integers $$$\\mathit{cnt}_1, \\mathit{cnt}_2, \\dots, \\mathit{cnt}_n$$$ ($$$1 \\le \\mathit{cnt}_i \\le 100$$$)\u00a0\u2014 the amount of balls of each color in the bag. The total amount of balls in the bag is odd (e.\u2009g. $$$\\mathit{cnt}_1 + \\mathit{cnt}_2 + \\dots + \\mathit{cnt}_n$$$ is odd).", "output_spec": "For each testcase, print a single integer\u00a0\u2014 any possible color of the remaining balls, after you made some moves and can't make moves anymore.", "sample_inputs": ["3\n\n3\n\n1 1 1\n\n1\n\n9\n\n2\n\n4 7"], "sample_outputs": ["3\n1\n2"], "notes": "NoteIn the first testcase, your first and only move can be one of the following: take balls with colors $$$1$$$ and $$$2$$$; take balls with colors $$$1$$$ and $$$3$$$; take balls with colors $$$2$$$ and $$$3$$$. After the move, exactly one ball will remain. Its color can be $$$3, 2$$$ or $$$1$$$ depending on the move.In the second testcase, you can't make moves at all\u00a0\u2014 there is only color of balls already. This color is $$$1$$$.In the third testcase, you can keep removing one ball of color $$$1$$$ and one ball of color $$$2$$$ until there are no more balls of color $$$1$$$. At the end, three balls of color $$$2$$$ remain."}, "positive_code": [{"source_code": " 0) && ($g == 0))\n {\n array_push($e, $d[$x]);\n $f--;\n }\n elseif(($f == 0) && ($g == 0))\n {\n $g++;\n }\n elseif(($f == 0) && ($g == 1))\n {\n $g = 0;\n $f = $b[0];\n }\n}\nprint array_sum($e);\n?>"}], "negative_code": [], "src_uid": "08803b63ae803e4a76afe7258a4004aa"} {"nl": {"description": "A string $$$s$$$ of length $$$n$$$ ($$$1 \\le n \\le 26$$$) is called alphabetical if it can be obtained using the following algorithm: first, write an empty string to $$$s$$$ (i.e. perform the assignment $$$s$$$\u00a0:= \"\"); then perform the next step $$$n$$$ times; at the $$$i$$$-th step take $$$i$$$-th lowercase letter of the Latin alphabet and write it either to the left of the string $$$s$$$ or to the right of the string $$$s$$$ (i.e. perform the assignment $$$s$$$\u00a0:=\u00a0$$$c+s$$$ or $$$s$$$\u00a0:=\u00a0$$$s+c$$$, where $$$c$$$ is the $$$i$$$-th letter of the Latin alphabet). In other words, iterate over the $$$n$$$ first letters of the Latin alphabet starting from 'a' and etc. Each time we prepend a letter to the left of the string $$$s$$$ or append a letter to the right of the string $$$s$$$. Strings that can be obtained in that way are alphabetical.For example, the following strings are alphabetical: \"a\", \"ba\", \"ab\", \"bac\" and \"ihfcbadeg\". The following strings are not alphabetical: \"z\", \"aa\", \"ca\", \"acb\", \"xyz\" and \"ddcba\".From the given string, determine if it is alphabetical.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u00a0\u2014 the number of test cases. Then $$$t$$$ test cases follow. Each test case is written on a separate line that contains one string $$$s$$$. String $$$s$$$ consists of lowercase letters of the Latin alphabet and has a length between $$$1$$$ and $$$26$$$, inclusive.", "output_spec": "Output $$$t$$$ lines, each of them must contain the answer to the corresponding test case. Output YES if the given string $$$s$$$ is alphabetical and NO otherwise. You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive answer).", "sample_inputs": ["11\na\nba\nab\nbac\nihfcbadeg\nz\naa\nca\nacb\nxyz\nddcba"], "sample_outputs": ["YES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"], "notes": "NoteThe example contains test cases from the main part of the condition."}, "positive_code": [{"source_code": " 1) { echo 'NO'.PHP_EOL; }\r\n else {\r\n $d = strlen($n);\r\n \r\n for ($j = 0; $j < $d; $j++) { \r\n $pos = strpos($n, $v[$j]);\r\n if ($pos === false) { $k = 1; break; }\r\n }\r\n \r\n if ($k == 1) { echo 'NO'.PHP_EOL; }\r\n else {\r\n $w = array_flip($v);\r\n for ($j = 0; $j < strlen($n); $j++) { $b[] = $w[$n[$j]]; }\r\n $p = array_search('0', $b);\r\n \r\n for ($j = 0; $j < $p; $j++) { \r\n if ($b[$j] < $b[$j + 1] && isset($b[$j + 1])) { $k = 1; break; } \r\n }\r\n \r\n for ($j = $p + 1; $j < count($b); $j++) { \r\n if ($b[$j] > $b[$j + 1] && isset($b[$j + 1])) { $k = 1; break; } \r\n }\r\n \r\n if ($k == 1) { echo 'NO'.PHP_EOL; }\r\n else { echo 'YES'.PHP_EOL; }\r\n }\r\n }\r\n}\r\n?>"}], "negative_code": [], "src_uid": "801bf7c73c44c68eaa61c714d5aedf50"} {"nl": {"description": "You are given a permutation $$$a_1, a_2, \\ldots, a_n$$$ of size $$$n$$$, where each integer from $$$1$$$ to $$$n$$$ appears exactly once.You can do the following operation any number of times (possibly, zero): Choose any three indices $$$i, j, k$$$ ($$$1 \\le i < j < k \\le n$$$). If $$$a_i > a_k$$$, replace $$$a_i$$$ with $$$a_i + a_j$$$. Otherwise, swap $$$a_j$$$ and $$$a_k$$$. Determine whether you can make the array $$$a$$$ sorted in non-descending order.", "input_spec": "Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 5000$$$) \u2014 the number of test cases. The description of test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$3 \\le n \\le 10$$$) \u2014 the length of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1,a_2,\\dots,a_n$$$ ($$$1 \\le a_i \\le n$$$, $$$a_i \\neq a_j$$$ if $$$i \\neq j$$$) \u2014 the elements of the array $$$a$$$.", "output_spec": "For each test case, output \"Yes\" (without quotes) if the array can be sorted in non-descending order, and \"No\" (without quotes) otherwise. You can output \"Yes\" and \"No\" in any case (for example, strings \"YES\", \"yEs\" and \"yes\" will be recognized as a positive response).", "sample_inputs": ["7\n\n3\n\n1 2 3\n\n3\n\n1 3 2\n\n7\n\n5 3 4 7 6 2 1\n\n7\n\n7 6 5 4 3 2 1\n\n5\n\n2 1 4 5 3\n\n5\n\n2 1 3 4 5\n\n7\n\n1 2 6 7 4 3 5"], "sample_outputs": ["Yes\nYes\nNo\nNo\nNo\nNo\nYes"], "notes": "NoteIn the first test case, $$$[1,2,3]$$$ is already sorted in non-descending order.In the second test case, we can choose $$$i = 1,j = 2,k = 3$$$. Since $$$a_1 \\le a_3$$$, swap $$$a_2$$$ and $$$a_3$$$, the array then becomes $$$[1,2,3]$$$, which is sorted in non-descending order.In the seventh test case, we can do the following operations successively: Choose $$$i = 5,j = 6,k = 7$$$. Since $$$a_5 \\le a_7$$$, swap $$$a_6$$$ and $$$a_7$$$, the array then becomes $$$[1,2,6,7,4,5,3]$$$. Choose $$$i = 5,j = 6,k = 7$$$. Since $$$a_5 > a_7$$$, replace $$$a_5$$$ with $$$a_5+a_6=9$$$, the array then becomes $$$[1,2,6,7,9,5,3]$$$. Choose $$$i = 2,j = 5,k = 7$$$. Since $$$a_2 \\le a_7$$$, swap $$$a_5$$$ and $$$a_7$$$, the array then becomes $$$[1,2,6,7,3,5,9]$$$. Choose $$$i = 2,j = 4,k = 6$$$. Since $$$a_2 \\le a_6$$$, swap $$$a_4$$$ and $$$a_6$$$, the array then becomes $$$[1,2,6,5,3,7,9]$$$. Choose $$$i = 1,j = 3,k = 5$$$. Since $$$a_1 \\le a_5$$$, swap $$$a_3$$$ and $$$a_5$$$, the array then becomes $$$[1,2,3,5,6,7,9]$$$, which is sorted in non-descending order. In the third, the fourth, the fifth and the sixth test cases, it can be shown that the array cannot be sorted in non-descending order."}, "positive_code": [{"source_code": " $data[$n-1]) {\r\n $ans = -1;\r\n } else {\r\n $begin = 0;\r\n $end = $n - 1;\r\n $prev_begin = $begin;\r\n $prev_end = $end;\r\n while (true) {\r\n $position = round(($begin + $end) / 2);\r\n \r\n if (isset($data[$position])) {\r\n if ($data[$position] >= $element && ($position == 0 ||$data[$position-1] < $element)) {\r\n $ans = $position + 1;\r\n break;\r\n }\r\n if ($data[$position] > $element) {\r\n $end = floor(($begin + $end) / 2);\r\n } elseif ($data[$position] < $element) {\r\n $begin = ceil(($begin + $end) / 2);\r\n }\r\n }\r\n if ($prev_begin == $begin && $prev_end == $end) {\r\n break;\r\n }\r\n $prev_begin = $begin;\r\n $prev_end = $end;\r\n }\r\n \r\n }\r\n pr($ans);\r\n }\r\n \r\n }\r\n// bcadd \u2014 Add two arbitrary precision numbers\r\n// bccomp \u2014 Compare two arbitrary precision numbers\r\n// bcdiv \u2014 Divide two arbitrary precision numbers\r\n// bcmod \u2014 Get modulus of an arbitrary precision number\r\n// bcmul \u2014 Multiply two arbitrary precision numbers\r\n// bcpow \u2014 Raise an arbitrary precision number to another\r\n// bcpowmod \u2014 Raise an arbitrary precision number to another, reduced by a specified modulus\r\n// bcscale \u2014 Set or get default scale parameter for all bc math functions\r\n// bcsqrt \u2014 Get the square root of an arbitrary precision number\r\n// bcsub \u2014 Subtract one arbitrary precision number from another\r\nfunction getDar($n) {\r\n $dar = [2];\r\n for($i=0; $i<$n; $i++) {\r\n $dar[] = $dar[$i] * 2;\r\n }\r\n return $dar;\r\n}\r\nfunction getDar2($n, $k) {\r\n if($k == 0) {\r\n return 1;\r\n }\r\n return bcmul($n, getDar2($n, $k-1));\r\n}\r\n\r\n \r\n function getT() {\r\n return trim(fgets(STDIN));\r\n }\r\n function getA() {\r\n return explode(' ', trim(fgets(STDIN)));\r\n }\r\n \r\n function is_prime($n) {\r\n $d = 2;\r\n while ($n % $d != 0) {\r\n \t $d += 1;\r\n }\r\n \r\n return $d == $n;\r\n }\r\nfunction getMinValue($x, $y) {\r\n return $x > $y ? $y : $x;\r\n }\r\n function getMaxValue($x, $y) {\r\n return $x > $y ? $x : $y;\r\n }\r\n \r\n function getMaxValueBc($x, $y) {\r\n return bccomp($x, $y) == 1 ? $x : $y;\r\n }\r\n function getRotate($a, $s, $e, $ind) {\r\n \t\t$ar = [];\r\n for ($i= $s; $i<=$e; $i++) {\r\n \t$ar[$i] = $a[$i];\r\n \t$j = $i + $ind > $e ? $i + $ind - $e - 1 : $i + $ind;\r\n \t// echo $i, ' ', $j, ' ', $j < $i ? $ar[$j] : $a[$j] , \"\\n\"; \r\n \t$a[$i] = $j < $i ? $ar[$j] : $a[$j];\r\n }\r\n return $a;\r\n } \r\n function pr($s) {\r\n if(is_array($s)) {\r\n echo implode( ' ', $s), PHP_EOL;\r\n } else {\r\n echo $s, PHP_EOL;\r\n }\r\n }\r\n function fab2($n, $a) {\r\n if($n <= 1) {\r\n return $a[$n];\r\n }\r\n for($i=2; $i<=$n; $i++) {\r\n $a[$i] = $a[$i-1] + $a[$i-2];\r\n }\r\n \r\n return $a[$n];\r\n }\r\n \r\n function mergeSort($aArray) {\r\n if(count($aArray) <= 1) {\r\n return $aArray;\r\n }\r\n $aLeft = [];\r\n $aRight = [];\r\n $n =floor(count($aArray) / 2);\r\n for($i = 0; $i <$n; $i++) {\r\n $aLeft[] = $aArray[$i]; \r\n }\r\n for($i = $n; $i