{"nl": {"description": "Lenny is playing a game on a 3\u2009\u00d7\u20093 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light.", "input_spec": "The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The j-th number in the i-th row is the number of times the j-th light of the i-th row of the grid is pressed.", "output_spec": "Print three lines, each containing three characters. The j-th character of the i-th line is \"1\" if and only if the corresponding light is switched on, otherwise it's \"0\".", "sample_inputs": ["1 0 0\n0 0 0\n0 0 1", "1 0 1\n8 8 8\n2 0 3"], "sample_outputs": ["001\n010\n100", "010\n011\n100"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"nl": {"description": "Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (a\u2009<\u2009b) and that the fraction is called irreducible if its numerator and its denominator are coprime (they do not have positive common divisors except 1).During his free time, Petya thinks about proper irreducible fractions and converts them to decimals using the calculator. One day he mistakenly pressed addition button (\u2009+\u2009) instead of division button (\u00f7) and got sum of numerator and denominator that was equal to n instead of the expected decimal notation. Petya wanted to restore the original fraction, but soon he realized that it might not be done uniquely. That's why he decided to determine maximum possible proper irreducible fraction such that sum of its numerator and denominator equals n. Help Petya deal with this problem. ", "input_spec": "In the only line of input there is an integer n (3\u2009\u2264\u2009n\u2009\u2264\u20091000), the sum of numerator and denominator of the fraction.", "output_spec": "Output two space-separated positive integers a and b, numerator and denominator of the maximum possible proper irreducible fraction satisfying the given sum.", "sample_inputs": ["3", "4", "12"], "sample_outputs": ["1 2", "1 3", "5 7"], "notes": null}, "positive_code": [{"source_code": " $h)\n {\n break;\n }\n else\n {\n $i = $h % $b[$g];\n if($i == 0)\n {\n $f[count($f)] = $b[$g];\n $h /= $b[$g];\n }\n else\n {\n $g++;\n }\n }\n }\n $j = array();\n $k = 0;\n $l = $e;\n while(TRUE)\n {\n if($b[$k] > $l)\n {\n break;\n }\n else\n {\n $m = $l % $b[$k];\n if($m == 0)\n {\n $j[count($j)] = $b[$k];\n $l /= $b[$k];\n }\n else\n {\n $k++;\n }\n }\n }\n $n = array_intersect($f, $j);\n if(count($n) == 0)\n {\n break;\n }\n else\n {\n $d--;\n $e++;\n }\n}\nprint $d . \" \" . $e;\n?>"}, {"source_code": " 0 && $b <> 0) {\n if ($a > $b)\n $a = $a % $b;\n else\n $b = $b % $a;\n }\n return abs($a + $b);\n}\n\n$input = rtrim(fgets(STDIN));\n$raw = explode(' ', $input);\n\n$n = (int)$raw[0];\n\nfor ($i = (int)($n / 2); $i > 0; $i--) {\n $a = $i;\n $b = $n - $i;\n\n if ($a >= $b) {\n continue;\n }\n\n $gcd = gcd($a, $b);\n\n if ($gcd == 1) {\n echo $a . ' ' . $b . PHP_EOL;\n die;\n }\n}"}], "negative_code": [{"source_code": " TRUE, \"3\" => TRUE, \"5\" => TRUE, \"7\" => TRUE, \"11\" => TRUE, \"13\" => TRUE, \"17\" => TRUE, \"19\" => TRUE, \"23\" => TRUE, \"29\" => TRUE, \"31\" => TRUE, \"37\" => TRUE, \"41\" => TRUE, \"43\" => TRUE, \"47\" => TRUE, \"53\" => TRUE, \"59\" => TRUE, \"61\" => TRUE, \"67\" => TRUE, \"71\" => TRUE, \"73\" => TRUE, \"79\" => TRUE, \"83\" => TRUE, \"89\" => TRUE, \"97\" => TRUE, \"101\" => TRUE, \"103\" => TRUE, \"107\" => TRUE, \"109\" => TRUE, \"113\" => TRUE, \"127\" => TRUE, \"131\" => TRUE, \"137\" => TRUE, \"139\" => TRUE, \"149\" => TRUE, \"151\" => TRUE, \"157\" => TRUE, \"163\" => TRUE, \"167\" => TRUE, \"173\" => TRUE, \"179\" => TRUE, \"181\" => TRUE, \"191\" => TRUE, \"193\" => TRUE, \"197\" => TRUE, \"199\" => TRUE, \"211\" => TRUE, \"223\" => TRUE, \"227\" => TRUE, \"229\" => TRUE, \"233\" => TRUE, \"239\" => TRUE, \"241\" => TRUE, \"251\" => TRUE, \"257\" => TRUE, \"263\" => TRUE, \"269\" => TRUE, \"271\" => TRUE, \"277\" => TRUE, \"281\" => TRUE, \"283\" => TRUE, \"293\" => TRUE, \"307\" => TRUE, \"311\" => TRUE, \"313\" => TRUE, \"317\" => TRUE, \"331\" => TRUE, \"337\" => TRUE, \"347\" => TRUE, \"349\" => TRUE, \"533\" => TRUE, \"359\" => TRUE, \"367\" => TRUE, \"373\" => TRUE, \"379\" => TRUE, \"383\" => TRUE, \"389\" => TRUE, \"397\" => TRUE, \"401\" => TRUE, \"409\" => TRUE, \"419\" => TRUE, \"421\" => TRUE, \"431\" => TRUE, \"433\" => TRUE, \"439\" => TRUE, \"443\" => TRUE, \"449\" => TRUE, \"457\" => TRUE, \"461\" => TRUE, \"463\" => TRUE, \"467\" => TRUE, \"479\" => TRUE, \"487\" => TRUE, \"491\" => TRUE, \"499\" => TRUE, \"503\" => TRUE, \"509\" => TRUE, \"521\" => TRUE, \"523\" => TRUE, \"541\" => TRUE, \"547\" => TRUE, \"557\" => TRUE, \"563\" => TRUE, \"569\" => TRUE, \"571\" => TRUE, \"577\" => TRUE, \"587\" => TRUE, \"593\" => TRUE, \"599\" => TRUE, \"601\" => TRUE, \"607\" => TRUE, \"613\" => TRUE, \"617\" => TRUE, \"619\" => TRUE, \"631\" => TRUE, \"641\" => TRUE, \"643\" => TRUE, \"647\" => TRUE, \"653\" => TRUE, \"659\" => TRUE, \"661\" => TRUE, \"673\" => TRUE, \"677\" => TRUE, \"683\" => TRUE, \"691\" => TRUE, \"701\" => TRUE, \"709\" => TRUE, \"719\" => TRUE, \"727\" => TRUE, \"733\" => TRUE, \"739\" => TRUE, \"743\" => TRUE, \"751\" => TRUE, \"757\" => TRUE, \"761\" => TRUE, \"769\" => TRUE, \"773\" => TRUE, \"787\" => TRUE, \"797\" => TRUE, \"809\" => TRUE, \"811\" => TRUE, \"821\" => TRUE, \"823\" => TRUE, \"827\" => TRUE, \"829\" => TRUE, \"839\" => TRUE, \"853\" => TRUE, \"857\" => TRUE, \"859\" => TRUE, \"863\" => TRUE, \"877\" => TRUE, \"881\" => TRUE, \"883\" => TRUE, \"887\" => TRUE, \"907\" => TRUE, \"911\" => TRUE, \"919\" => TRUE, \"929\" => TRUE, \"937\" => TRUE, \"941\" => TRUE, \"947\" => TRUE, \"953\" => TRUE, \"967\" => TRUE, \"971\" => TRUE, \"977\" => TRUE, \"983\" => TRUE, \"991\" => TRUE, \"997\" => TRUE);\nwhile(TRUE)\n{\n if(($b == TRUE) && ($c == TRUE))\n {\n break;\n }\n else\n {\n $b--;\n $c++;\n }\n}\nprint $b . \" \" . $c;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "0af3515ed98d9d01ce00546333e98e77"} {"nl": {"description": "Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.Embosser is a special devise that allows to \"print\" the text of a plastic tape. Text is printed sequentially, character by character. The device consists of a wheel with a lowercase English letters written in a circle, static pointer to the current letter and a button that print the chosen letter. At one move it's allowed to rotate the alphabetic wheel one step clockwise or counterclockwise. Initially, static pointer points to letter 'a'. Other letters are located as shown on the picture: After Grigoriy add new item to the base he has to print its name on the plastic tape and attach it to the corresponding exhibit. It's not required to return the wheel to its initial position with pointer on the letter 'a'.Our hero is afraid that some exhibits may become alive and start to attack him, so he wants to print the names as fast as possible. Help him, for the given string find the minimum number of rotations of the wheel required to print it.", "input_spec": "The only line of input contains the name of some exhibit\u00a0\u2014 the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters.", "output_spec": "Print one integer\u00a0\u2014 the minimum number of rotations of the wheel, required to print the name given in the input.", "sample_inputs": ["zeus", "map", "ares"], "sample_outputs": ["18", "35", "34"], "notes": "Note\u00a0 To print the string from the first sample it would be optimal to perform the following sequence of rotations: from 'a' to 'z' (1 rotation counterclockwise), from 'z' to 'e' (5 clockwise rotations), from 'e' to 'u' (10 rotations counterclockwise), from 'u' to 's' (2 counterclockwise rotations). In total, 1\u2009+\u20095\u2009+\u200910\u2009+\u20092\u2009=\u200918 rotations are required."}, "positive_code": [{"source_code": "= 13) {\n $actualStepsCount = count(CHARACTER_LIST) - $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n } else {\n $actualStepsCount = $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n }\n}\n\necho $steps;\n"}, {"source_code": " 0, \"b\" => 1, \"c\" => 2, \"d\" => 3, \"e\" => 4, \"f\" => 5, \"g\" => 6, \"h\" => 7, \"i\" => 8, \"j\" => 9, \"k\" => 10, \"l\" => 11, \"m\" => 12, \"n\" => 13, \"o\" => 14, \"p\" => 15, \"q\" => 16, \"r\" => 17, \"s\" => 18, \"t\" => 19, \"u\" => 20, \"v\" => 21, \"w\" => 22, \"x\" => 23, \"y\" => 24, \"z\" => 25);\n$c = 0;\n$d = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n $e = $b[$a[$x]];\n $f = abs($e - $d);\n $g = abs(26 - $f);\n $c += min($f, $g);\n $d = $e;\n}\nprint $c;\n?>"}, {"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$aPos = str_split('qzawsxedcrfvtgpbyhnujmiklo');\n\tsort($aPos);\n\t$aPos = implode('', $aPos);\n\t$totalLen = strlen($aPos);\n\n\t$inputStr = readString($stream);\n\t$return = 0;\n\twhile (!empty($inputStr)) {\n\t\t$char = $inputStr[0];\n\t\t$pos = strpos($aPos, $char);\n\t\t$left = $totalLen - $pos;\n\t\tif ($pos < $left) {\n\t\t\t$return+=$pos;\n\t\t} else {\n\t\t\t$return+=$left;\n\t\t}\n\t\t$aPos = substr($aPos, $pos) . substr($aPos, 0, $pos);\n\n\t\t$inputStr = substr($inputStr, 1);\n\t}\n\techo $return;\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": "13)\n {\n \t $k1[$i]=array_keys($split,$concate[$i]);\n \t // print_r($k1);\n \t //$key1=$k1[$i];\n \t //\n \t $k2[$i]=array_keys($split,$concate[$i+1]);\n \t //print_r($k2);\n \t //$key2=$k2[$i];\n \t if($k1[$i]>$k2[$i]){\n\n \t $temp[$i]=$k1[$i];\n \t $k1[$i]=$k2[$i];\n \t $k2[$i]=$temp[$i];\n\n \t }\n\n \t \n \t \n $count+=($k1[$i][0]+26)-$k2[$i][0];\n //echo \"plus=$count\\n\";\n }\n else\n {\n \t \t $k1[$i]=array_keys($split,$concate[$i]);\n \t //$key1=$k1[$i];\n \t //\n \t $k2[$i]=array_keys($split,$concate[$i+1]);\n \t //$key2=$k2[$i];\n\n \t \n $count+=abs($k1[$i][0]-$k2[$i][0]);\n //echo \"minus=$count\\n\";\n\n }\n //print_r($k1);\n // print_r($k2);\n\n}\necho \"$count\";\n\n//print_r($keyDistance);"}, {"source_code": " ord($b)){\n $tmp = $a;\n $a = $b;\n $b = $tmp;\n }\n $i = abs(intval(ord($a) - ord($b)));\n $j = abs(intval(ord($a) - ord('a'))) + abs(intval(ord('z')) - ord($b)) + 1;\n// echo \"a: $a b: $b\" . PHP_EOL;\n// echo \"i: $i j: $j \" . PHP_EOL;\n return min($i,$j);\n}\n$current = 'a';\n$sum = 0;\nforeach(str_split($line) as $c){\n $sum += dis($c,$current);\n $current = $c;\n}\necho $sum . PHP_EOL;"}, {"source_code": ""}, {"source_code": " 'a', 2 => 'b', 3 => 'c', 4 => 'd', 5 => 'e',\n 6 => 'f', 7 => 'g', 8 => 'h', 9 => 'i', 10 => 'j',\n 11 => 'k', 12 => 'l', 13 => 'm', 14 => 'n', 15 => 'o',\n 16 => 'p', 17 => 'q', 18 => 'r', 19 => 's', 20 => 't',\n 21 => 'u', 22 => 'v', 23 => 'w', 24 => 'x', 25 => 'y',\n 26 => 'z'];\n$stdin = fopen('php://stdin', 'r');\n\n$string = trim(fgets($stdin));\n$pos = 1;\n$count = 0;\nfor ($i = 0; $i < strlen($string); $i++) {\n $newPos = array_search($string[$i], $alphabet);\n if ($newPos > $pos) {\n if ($newPos - $pos > 13) {\n\n $count+= $pos + (26 - $newPos);\n }\n if ($newPos - $pos < 13) {\n\n $count+= $newPos - $pos;\n }\n if ($newPos - $pos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n }\n if ($newPos < $pos) {\n if ($pos - $newPos < 13) {\n $count += $pos - $newPos;\n }\n if ($pos - $newPos > 13) {\n $count+= $newPos + (26 - $pos);\n }\n if ($pos - $newPos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n }\n}\necho $count;\n"}, {"source_code": " 0, \"b\" => 1, \"c\" => 2, \"d\" => 3, \"e\" => 4, \"f\" => 5, \"g\" => 6, \"h\" => 7, \"i\" => 8, \"j\" => 9, \"k\" => 10, \"l\" => 11, \"m\" => 12, \"n\" => 13, \"o\" => 14, \"p\" => 15, \"q\" => 16, \"r\" => 17, \"s\" => 18, \"t\" => 19, \"u\" => 20, \"v\" => 21, \"w\" => 22, \"x\" => 23, \"y\" => 24, \"z\" => 25);\n\t$ans = 0;\n\t$d = 0;\n\tfor($x = 0; $x < strlen($a); $x++)\n\t{\n\t\t$e = $b[$a[$x]];\n\t\t$f = abs($e - $d);\n\t\t$g = 26 - $f;\n\t\t$ans += min($f, $g);\n\t\t$d = $e;\n\t}\n\tprint $ans;\n?>"}], "negative_code": [{"source_code": "= 13) {\n $actualStepsCount = count(CHARACTER_LIST) - $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n } else {\n $actualStepsCount = $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n }\n}\n\necho $steps;\n"}, {"source_code": "= 13) {\n $actualStepsCount = count(CHARACTER_LIST) - $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n } else {\n $actualStepsCount = $stepsCount;\n $steps += $actualStepsCount;\n\n $prevPosition = $letterNumber;\n }\n}\n\necho $steps;\n"}, {"source_code": " ord($b)){\n $tmp = $a;\n $a = $b;\n $b = $tmp;\n }\n $i = abs(intval(ord($a) - ord($b)));\n $j = abs(intval(ord($a) - ord('a'))) + abs(intval(ord('z')) - ord($b));\n// echo \"a: $a b: $b\" . PHP_EOL;\n// echo \"i: $i j: $j \" . PHP_EOL;\n return min($i,$j);\n}\n$current = 'a';\n$sum = 0;\nforeach(str_split($line) as $c){\n $sum += dis($c,$current);\n $current = $c;\n}\necho $sum . PHP_EOL;\nexit;"}, {"source_code": " 'a', 2 => 'b', 3 => 'c', 4 => 'd', 5 => 'e',\n 6 => 'f', 7 => 'g', 8 => 'h', 9 => 'i', 10 => 'j',\n 11 => 'k', 12 => 'l', 13 => 'm', 14 => 'n', 15 => 'o',\n 16 => 'p', 17 => 'q', 18 => 'r', 19 => 's', 20 => 't',\n 21 => 'u', 22 => 'v', 23 => 'w', 24 => 'x', 25 => 'y',\n 26 => 'z'];\n$string = trim($_POST['data']);\n$pos = 1;\n$count = 0;\nfor ($i = 0; $i < strlen($string); $i++) {\n $newPos = array_search($string[$i], $alphabet);\n if ($newPos > $pos) {\n if ($newPos - $pos > 13) {\n\n $count+= $pos + (26 - $newPos);\n }\n if ($newPos - $pos < 13) {\n\n $count+= $newPos - $pos;\n }\n if ($newPos - $pos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n }\n if ($newPos < $pos) {\n if ($pos - $newPos < 13) {\n $count += $pos - $newPos;\n }\n if ($pos - $newPos > 13) {\n $count+= $newPos + (26 - $pos);\n }\n if ($pos - $newPos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n }\n}\necho $count;\n"}, {"source_code": " 'a', 2 => 'b', 3 => 'c', 4 => 'd', 5 => 'e',\n 6 => 'f', 7 => 'g', 8 => 'h', 9 => 'i', 10 => 'j',\n 11 => 'k', 12 => 'l', 13 => 'm', 14 => 'n', 15 => 'o',\n 16 => 'p', 17 => 'q', 18 => 'r', 19 => 's', 20 => 't',\n 21 => 'u', 22 => 'v', 23 => 'w', 24 => 'x', 25 => 'y',\n 26 => 'z'];\n$stdin = fopen('php://stdin', 'r');\n$string = trim(fgets($stdin));\n$pos = 1;\n$count = 0;\nfor ($i = 0; $i < strlen($string); $i++) {\n $newPos = array_search($string[$i], $alphabet);\n if ($newPos > $pos) {\n if ($newPos - $pos > 13) {\n\n $count+= $pos + (26 - $newPos);\n }\n if ($newPos - $pos < 13) {\n\n $count+= $newPos - $pos;\n }\n if ($newPos - $pos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n }\n if ($newPos < $pos) {\n if ($pos - $newPos < 13) {\n $count += $pos - $newPos;\n }\n if ($pos - $newPos > 13) {\n $count+= $newPos + (26 - $pos);\n }\n if ($newPos - $pos == 13) {\n $count+=13;\n }\n $pos = $newPos;\n $count;\n }\n}\necho $count;\n"}], "src_uid": "ecc890b3bdb9456441a2a265c60722dd"} {"nl": {"description": "Bizon the Champion isn't just a bison. He also is a favorite of the \"Bizons\" team.At a competition the \"Bizons\" got the following problem: \"You are given two distinct words (strings of English letters), s and t. You need to transform word s into word t\". The task looked simple to the guys because they know the suffix data structures well. Bizon Senior loves suffix automaton. By applying it once to a string, he can remove from this string any single character. Bizon Middle knows suffix array well. By applying it once to a string, he can swap any two characters of this string. The guys do not know anything about the suffix tree, but it can help them do much more. Bizon the Champion wonders whether the \"Bizons\" can solve the problem. Perhaps, the solution do not require both data structures. Find out whether the guys can solve the problem and if they can, how do they do it? Can they solve it either only with use of suffix automaton or only with use of suffix array or they need both structures? Note that any structure may be used an unlimited number of times, the structures may be used in any order.", "input_spec": "The first line contains a non-empty word s. The second line contains a non-empty word t. Words s and t are different. Each word consists only of lowercase English letters. Each word contains at most 100 letters.", "output_spec": "In the single line print the answer to the problem. Print \"need tree\" (without the quotes) if word s cannot be transformed into word t even with use of both suffix array and suffix automaton. Print \"automaton\" (without the quotes) if you need only the suffix automaton to solve the problem. Print \"array\" (without the quotes) if you need only the suffix array to solve the problem. Print \"both\" (without the quotes), if you need both data structures to solve the problem. It's guaranteed that if you can solve the problem only with use of suffix array, then it is impossible to solve it only with use of suffix automaton. This is also true for suffix automaton.", "sample_inputs": ["automaton\ntomat", "array\narary", "both\nhot", "need\ntree"], "sample_outputs": ["automaton", "array", "both", "need tree"], "notes": "NoteIn the third sample you can act like that: first transform \"both\" into \"oth\" by removing the first character using the suffix automaton and then make two swaps of the string using the suffix array and get \"hot\"."}, "positive_code": [{"source_code": " $h[$x + 1])\n {\n $i = 1;\n }\n}\nif($e != count($d))\n{\n print \"need tree\";\n}\nelseif(($e == count($d)) && ($e != count($c)) && ($i != 0))\n{\n print \"both\";\n}\nelseif(($e == count($d)) && ($i != 0))\n{\n print \"array\";\n}\nelseif(($e == count($d)) && ($i == 0))\n{\n print \"automaton\";\n}\n?>"}, {"source_code": " $h[$x + 1])\n {\n $i = 1;\n }\n}\nif($e != count($d))\n{\n print \"need tree\";\n}\nelseif(($e == count($d)) && ($e != count($c)) && ($i != 0))\n{\n print \"both\";\n}\nelseif(($e == count($d)) && ($i != 0))\n{\n print \"array\";\n}\nelseif(($e == count($d)) && ($i == 0))\n{\n print \"automaton\";\n}\n?>"}, {"source_code": "= $c) && ($e <= $d)) && (($f >= $c) && ($f <= $d)))\n {\n $g = 1;\n break;\n }\n}\nif($g == 0)\n{\n print \"0\";\n}\nelse\n{\n print $x + 1;\n}\n?>"}, {"source_code": "$c1){\n if($k>$key+1){\n $b += $c1;\n }else{\n $a += $c1;\n }\n }\n if($b<$x || $b>$y || $a<$x || $a>$y){\n continue;\n }else{\n print $k;\n die();\n }\n}\nprint 0;"}, {"source_code": " $value){\n unset($chs[$key]);\n if($g1+$value<=$y && (array_sum($chs)>=$y||array_sum($chs)>=$x) && $g2==0) $g1+=$value;\n else {\n $g2+=$value;\n if($k==0) $k=$key+1;\n }\n}\nif(($g1<$x||$g1>$y)||($g2<$x||$g2>$y)) $k=0;\necho $k;\nfclose($in);"}], "negative_code": [{"source_code": " $value){\n if($g1<$x) $g1+=$value;\n else {\n $g2+=$value;\n if($k==0) $k=$key+1;\n }\n}\necho $k;\nfclose($in);"}, {"source_code": " $value){\n if($g1+$value<=$y && $g2==0) $g1+=$value;\n else {\n $g2+=$value;\n if($k==0) $k=$key+1;\n }\n}\nif(($g1<$x||$g1>$y)||($g2<$x||$g2>$y)) $k=0;\necho $k;\nfclose($in);"}, {"source_code": " $value){\n if($g1<$x) $g1+=$value;\n else {\n $g2+=$value;\n if($k==0) $k=$key+1;\n }\n}\nif(($g1<$x||$g1>$y)||($g2<$x||$g2>$y)) $k=0;\necho $k;\nfclose($in);"}], "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b"} {"nl": {"description": "The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n\u2009-\u20091 in the order from the beginning of the street to the end (in the picture: from left to right). The houses with even numbers are at the other side of the street and are numbered from 2 to n in the order from the end of the street to its beginning (in the picture: from right to left). The corresponding houses with even and odd numbers are strictly opposite each other, that is, house 1 is opposite house n, house 3 is opposite house n\u2009-\u20092, house 5 is opposite house n\u2009-\u20094 and so on. Vasya needs to get to house number a as quickly as possible. He starts driving from the beginning of the street and drives his car to house a. To get from the beginning of the street to houses number 1 and n, he spends exactly 1 second. He also spends exactly one second to drive the distance between two neighbouring houses. Vasya can park at any side of the road, so the distance between the beginning of the street at the houses that stand opposite one another should be considered the same.Your task is: find the minimum time Vasya needs to reach house a.", "input_spec": "The first line of the input contains two integers, n and a (1\u2009\u2264\u2009a\u2009\u2264\u2009n\u2009\u2264\u2009100\u2009000)\u00a0\u2014 the number of houses on the street and the number of the house that Vasya needs to reach, correspondingly. It is guaranteed that number n is even.", "output_spec": "Print a single integer \u2014 the minimum time Vasya needs to get from the beginning of the street to house a.", "sample_inputs": ["4 2", "8 5"], "sample_outputs": ["2", "3"], "notes": "NoteIn the first sample there are only four houses on the street, two houses at each side. House 2 will be the last at Vasya's right.The second sample corresponds to picture with n\u2009=\u20098. House 5 is the one before last at Vasya's left."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $c) && ($d >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && ($d < $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $b))\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($d > $c) && ($d >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && ($d < $a))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $a))\n {\n print \"Vasiliy\";\n }\n}\nelseif($c == 0)\n{\n if(($a + $b) <= $d)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif($d == 0)\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($d > $c) && ($d >= $a + $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && ($d < $a + $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $a + $b))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $a + $b))\n {\n print \"Vasiliy\";\n }\n}\n?>"}], "negative_code": [{"source_code": " $c) && (($c + $d - $c) >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $b))\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($d > $c) && (($c + $d - $c) >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $a))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $a))\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}, {"source_code": "= $b)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($c + $d - $c) >= $a)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}, {"source_code": " $c) && (($c + $d - $c) >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $b))\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($d > $c) && (($c + $d - $c) >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $a))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $a))\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= ($c + $d - $c))\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}, {"source_code": " $c) && ($d >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && ($d < $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $b))\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($d > $c) && ($d >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && ($d < $a))\n {\n print \"Vasiliy\";\n }\n elseif(($d <= $c) && ($c >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d <= $c) && ($c < $a))\n {\n print \"Vasiliy\";\n }\n}\nelseif($c == 0)\n{\n if(($a + $b) <= $d)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif($d == 0)\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}, {"source_code": "= $b)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if($c >= $a)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}, {"source_code": " $c) && (($c + $d - $c) >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $b))\n {\n print \"Vasiliy\";\n }\n elseif(($d < $c) && ($c >= $b))\n {\n print \"Polycarp\";\n }\n elseif(($d < $c) && ($c < $b))\n {\n print \"Vasiliy\";\n }\n}\nelseif($b == 0)\n{\n if(($d > $c) && (($c + $d - $c) >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d > $c) && (($c + $d - $c) < $a))\n {\n print \"Vasiliy\";\n }\n elseif(($d < $c) && ($c >= $a))\n {\n print \"Polycarp\";\n }\n elseif(($d < $c) && ($c < $a))\n {\n print \"Vasiliy\";\n }\n}\nelseif(($a <= $c) && ($b <= $d))\n{\n print \"Polycarp\";\n}\nelseif(($a >= $c) && ($b >= $d))\n{\n print \"Vasiliy\";\n}\nelse\n{\n if(($a + $b) <= $c)\n {\n print \"Polycarp\";\n }\n else\n {\n print \"Vasiliy\";\n }\n}\n?>"}], "src_uid": "2637d57f7809ff8f922549c617709074"} {"nl": {"description": "Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.", "input_spec": "The only line of the input is in one of the following two formats: \"x of week\" where x (1\u2009\u2264\u2009x\u2009\u2264\u20097) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday. \"x of month\" where x (1\u2009\u2264\u2009x\u2009\u2264\u200931) denotes the day of the month. ", "output_spec": "Print one integer\u00a0\u2014 the number of candies Limak will save in the year 2016.", "sample_inputs": ["4 of week", "30 of month"], "sample_outputs": ["52", "11"], "notes": "NotePolar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to \u2013 https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016\u00a0\u2014 all months but February. It means that Limak will save 11 candies in total."}, "positive_code": [{"source_code": ""}, {"source_code": " 7) {\n $cur_d = 1;\n }\n\n }\n}\nif ($word == \"month\") {\n for ($i = 0; $i < 12; $i++) {\n if ($n <= $m[$i]) {\n $s++;\n }\n }\n}\necho $s;\n?>"}, {"source_code": " 7) $cur_d = 1;\n }\n} else {\n for ($i = 0; $i < 12; $i++) {\n if ($n <= $m[$i]) $s++;\n }\n}\necho $s;\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": " 7) {\n $cur_d = 1;\n }\n\n }\n}\nif ($word = \"month\") {\n for ($i = 0; $i < 12; $i++) {\n if ($n <= $m[$i]) {\n $s++;\n }\n }\n}\necho $s;\n?>"}, {"source_code": " 7) {\n $cur_d = 1;\n }\n\n }\n}\nif ($word == \"month\") {\n for ($i = 0; $i < 12; $i++) {\n if ($n <= $m[$i]) {\n $s++;\n }\n }\n}\necho $s;\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"} {"nl": {"description": "This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called \"Take-It-Light\" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.To make a toast, each friend needs nl milliliters of the drink, a slice of lime and np grams of salt. The friends want to make as many toasts as they can, provided they all drink the same amount. How many toasts can each friend make?", "input_spec": "The first and only line contains positive integers n, k, l, c, d, p, nl, np, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space.", "output_spec": "Print a single integer \u2014 the number of toasts each friend can make.", "sample_inputs": ["3 4 5 10 8 100 3 1", "5 100 10 1 19 90 4 3", "10 1000 1000 25 23 1 50 1"], "sample_outputs": ["2", "3", "0"], "notes": "NoteA comment to the first sample: Overall the friends have 4\u2009*\u20095\u2009=\u200920 milliliters of the drink, it is enough to make 20\u2009/\u20093\u2009=\u20096 toasts. The limes are enough for 10\u2009*\u20098\u2009=\u200980 toasts and the salt is enough for 100\u2009/\u20091\u2009=\u2009100 toasts. However, there are 3 friends in the group, so the answer is min(6,\u200980,\u2009100)\u2009/\u20093\u2009=\u20092."}, "positive_code": [{"source_code": "= 0, $y >= 0, $z >= 0; $x--, $y--, $z--)\n{\n $i -= $g;\n $j -= 1;\n $f -= $h;\n if(($i < 0) || ($j < 0) || ($f < 0))\n {\n break;\n }\n else\n {\n $k++;\n }\n}\nprint floor($k / $a);\n?>"}, {"source_code": ""}, {"source_code": "nextInt();\n\t//$B_first = $Token->nextInt();\n\t\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t//$inp_arr = $Token->nextIntArray(8);\n\t$inp_arr = $Token->nextIntArray();\n\t\n\t$inp_f = $inp_arr[0];\n\t$inp_k = $inp_arr[1];\n\t$inp_l = $inp_arr[2];\n\t$inp_c = $inp_arr[3];\n\t$inp_d = $inp_arr[4];\n\t$inp_p = $inp_arr[5];\n\t$inp_nl = $inp_arr[6];\n\t$inp_np = $inp_arr[7];\n\n\t$drink = (int)(($inp_k * $inp_l) / $inp_nl);\n\t$salt = (int)($inp_p / $inp_np);\n\t$lime = $inp_c * $inp_d;\n\t/*$arr[] = $drink;\n\t$arr[] = $salt;\n\t$arr[] = $lime;\n\t\n\t//$min = min($arr);\n\tif (asort(&$arr) === false) {\n\t\tprint(-1);\n\t\treturn;\n\t}\n\t$min = $arr[0];\n\t\n\t*/\n\t//\ufffd\u014f\ufffd\ufffdl\ufffd\ufffd\ufffd\ufffd\ufffd\u07c2\u93c8\ufffd\ufffd\n\t//\ufffdf\ufffd[\ufffd^\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0182\ufffd\ufffdA$min = min($arr);\n\t$min = min($drink, $salt, $lime);\n\t$ans = (int)($min / $inp_f);\n\tprintf(\"%d\", $ans);\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 $_\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\t\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/*\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": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1"} {"nl": {"description": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.After practice competition, participant number i got a score of ai. Team score is defined as sum of scores of its participants. High school management is interested if it's possible to build two teams with equal scores. Your task is to answer that question.", "input_spec": "The single line contains six integers a1,\u2009...,\u2009a6 (0\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 scores of the participants", "output_spec": "Print \"YES\" (quotes for clarity), if it is possible to build teams with equal score, and \"NO\" otherwise. You can print each character either upper- or lowercase (\"YeS\" and \"yes\" are valid when the answer is \"YES\").", "sample_inputs": ["1 3 2 1 2 1", "1 1 1 1 1 99"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, first team can be composed of 1st, 2nd and 6th participant, second \u2014 of 3rd, 4th and 5th: team scores are 1\u2009+\u20093\u2009+\u20091\u2009=\u20092\u2009+\u20091\u2009+\u20092\u2009=\u20095.In the second sample, score of participant number 6 is too high: his team score will be definitely greater."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"} {"nl": {"description": "The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $$$n$$$ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are $$$m$$$ cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?Could you help her with this curiosity?You can see the examples and their descriptions with pictures in the \"Note\" section.", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\leq n \\leq 1000$$$, $$$0 \\leq m \\leq n$$$)\u00a0\u2014 the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.", "output_spec": "Print a single integer\u00a0\u2014 the maximum number of groups of cats at the moment Katie observes.", "sample_inputs": ["7 4", "6 2", "3 0", "2 2"], "sample_outputs": ["3", "2", "1", "0"], "notes": "NoteIn the first example, originally there are $$$7$$$ cats sitting as shown below, creating a single group: At the observed moment, $$$4$$$ cats have left the table. Suppose the cats $$$2$$$, $$$3$$$, $$$5$$$ and $$$7$$$ have left, then there are $$$3$$$ groups remaining. It is possible to show that it is the maximum possible number of groups remaining. In the second example, there are $$$6$$$ cats sitting as shown below: At the observed moment, $$$2$$$ cats have left the table. Suppose the cats numbered $$$3$$$ and $$$6$$$ left, then there will be $$$2$$$ groups remaining ($$$\\{1, 2\\}$$$ and $$$\\{4, 5\\}$$$). It is impossible to have more than $$$2$$$ groups of cats remaining. In the third example, no cats have left, so there is $$$1$$$ group consisting of all cats.In the fourth example, all cats have left the circle, so there are $$$0$$$ groups."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648"} {"nl": {"description": "PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n\u00b7m\u2009+\u20091 is a prime number\".Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is incorrect. Could you prove it wrong? Write a program that finds a counterexample for any n.", "input_spec": "The only number in the input is n (1\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 number from the PolandBall's hypothesis. ", "output_spec": "Output such m that n\u00b7m\u2009+\u20091 is not a prime number. Your answer will be considered correct if you output any suitable m such that 1\u2009\u2264\u2009m\u2009\u2264\u2009103. It is guaranteed the the answer exists.", "sample_inputs": ["3", "4"], "sample_outputs": ["1", "2"], "notes": "NoteA prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.For the first sample testcase, 3\u00b71\u2009+\u20091\u2009=\u20094. We can output 1.In the second sample testcase, 4\u00b71\u2009+\u20091\u2009=\u20095. We cannot output 1 because 5 is prime. However, m\u2009=\u20092 is okay since 4\u00b72\u2009+\u20091\u2009=\u20099, which is not a prime number."}, "positive_code": [{"source_code": ""}, {"source_code": "= 1 && $i <= 1000) {\n echo $i;\n break;\n }\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}], "negative_code": [{"source_code": " 1) {\n foreach (range(1, $n) as $i) {\n $res = $n*$i+1;\n if (!simple($res) && $i >= 1 && $i <= 1000) {\n //echo $res . \"=\" . $n . \"*\". $i . \"+1\" . \"\\n\";\n echo $i;\n break;\n }\n }\n} else {\n echo $i;\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": "= 1 && $res <= 1000) {\n //echo $res . \"=\" . $n . \"*\". $i . \"+1\" . \"\\n\";\n echo $i;\n break;\n }\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": "= 1 && $i <= 1000) {\n echo $i;\n break;\n }\n }\n\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": " 1) {\n foreach (range(1, $n) as $i) {\n $res = $n*$i+1;\n if (!simple($res) && $i >= 1 && $i <= 1000) {\n echo $i;\n break;\n }\n }\n} else {\n echo $i;\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": "= 1 && $res <= 1000) {\n //echo $res . \"=\" . $n . \"*\". $i . \"+1\" . \"\\n\";\n echo $i;\n break;\n }\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": " 2) {\n foreach (range(1, $n) as $i) {\n $res = $n*$i+1;\n if (!simple($res) && $i >= 1 && $i <= 1000) {\n echo $i;\n break;\n }\n }\n} else {\n echo $i;\n}\necho \"\\n\";\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": " 1) {\n foreach (range(1, $n) as $i) {\n $res = $n*$i+1;\n if (!simple($res) && $i >= 1 && $i <= 1000) {\n echo $i;\n break;\n }\n }\n} else {\n echo $i;\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}, {"source_code": " 2) {\n foreach (range(1, $n) as $i) {\n $res = $n*$i+1;\n if (!simple($res) && $i >= 1 && $i <= 1000) {\n// echo $i;\n fwrite(STDOUT, $i);\n break;\n }\n }\n} else {\n echo $i;\n}\n\nfunction simple($n)\n{\n for($i = 2; $i <= sqrt($n); $i++) {\n if (!($n % $i)) {\n return false;\n }\n }\n return true;\n}"}], "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"nl": {"description": "A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?", "input_spec": "The only line of the input contains five integers t1, t2, t3, t4 and t5 (1\u2009\u2264\u2009ti\u2009\u2264\u2009100)\u00a0\u2014 numbers written on cards.", "output_spec": "Print the minimum possible sum of numbers written on remaining cards.", "sample_inputs": ["7 3 7 3 20", "7 9 3 1 8", "10 10 10 10 10"], "sample_outputs": ["26", "28", "20"], "notes": "NoteIn the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following. Do nothing and the sum would be 7\u2009+\u20093\u2009+\u20097\u2009+\u20093\u2009+\u200920\u2009=\u200940. Remove two cards with a number 7. The remaining sum would be 3\u2009+\u20093\u2009+\u200920\u2009=\u200926. Remove two cards with a number 3. The remaining sum would be 7\u2009+\u20097\u2009+\u200920\u2009=\u200934. You are asked to minimize the sum so the answer is 26.In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7\u2009+\u20099\u2009+\u20091\u2009+\u20093\u2009+\u20098\u2009=\u200928.In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10\u2009+\u200910\u2009=\u200920."}, "positive_code": [{"source_code": ""}, {"source_code": "= 0; $i--) {\n if (($i >= 2) and ($t[$i] == $t[$i - 1]) and ($t[$i] == $t[$i - 2])) {\n $s[] = $t[$i] + $t[$i - 1] + $t[$i - 2];\n/* if ($i == 4) {\n break;\n }*/\n } else if (($i >= 1) and ($t[$i] == $t[$i - 1])) {\n $s[] = $t[$i] + $t[$i - 1];\n/* if ($i == 4) {\n break;\n }*/\n }\n}\nif (isset($s)) {\n sort($s);\n $j = count($s);\n $min -= $s[$j - 1];\n}\nprint $min . \"\\n\";\nob_flush(STDOUT);\nflush(STDOUT);\n?>\n\n\n"}, {"source_code": "$v){\n\t\n\tif($v>2){\n\t\tif(($k*3)>$max){\n\t\t\t$max=$k*3;\n\t\t}\n\t}elseif($v==2){\n\t\tif(($k*2)>$max){\n\t\t\t$max=$k*2;\n\t\t}\n\t}\n}\necho (array_sum($cards)-$max);"}, {"source_code": " $value) {\n\t\tif ($value != 1) {\n\t\t\tif ($value > 3) $value = 3;\n\t\t\tif ($key * $value > $max) $max = $key * $value;\n\t\t}\n\t}\n\t$asum = array_sum($a);\n\treturn $asum - $max;\n}\n$in = trim(fgets(STDIN));\n$cards = explode(' ', $in);\necho process($cards);\n?>"}, {"source_code": " $count) {\n if ($count > 3) {\n $count = 3;\n }\n if($count >= 2) {\n $values[] = $key * $count;\n }\n}\n\nif(!empty($values)) {\n echo $allSum - max($values);\n} else {\n echo $allSum;\n}"}, {"source_code": " $s - $t[$i] - $t[$j] - $t[$k])\n {\n $ans = $s - $t[$i] - $t[$j] - $t[$k];\n }\n }\n if($t[$i] == $t[$j] && $ans > $s - $t[$i] - $t[$j])\n {\n $ans = $s - $t[$i] - $t[$j];\n }\n }\n }\n print $ans;\n?>\n"}], "negative_code": [{"source_code": "= 0; $i--) {\n if (($i >= 2) and ($t[$i] == $t[$i - 1]) and ($t[$i] == $t[$i - 2])) {\n $s[] = $t[$i] + $t[$i - 1] + $t[$i - 2];\n if ($i == 4) {\n break;\n }\n } else if (($i >= 1) and ($t[$i] == $t[$i - 1])) {\n $s[] = $t[$i] + $t[$i - 1];\n if ($i == 4) {\n break;\n }\n }\n}\nif (isset($s)) {\n sort($s);\n $j = count($s);\n $min -= $s[$j - 1];\n}\nprint $min . \"\\n\";\nob_flush(STDOUT);\nflush(STDOUT);\n?>\n\n\n"}, {"source_code": "= 0; $i--) {\n if (($i >= 2) and ($t[$i] == $t[$i - 1]) and ($t[$i] == $t[$i - 2])) {\n $s[] = $t[$i] + $t[$i - 1] + $t[$i - 2];\n if ($i == 4) {\n break;\n }\n } else if (($i >= 1) and ($t[$i] == $t[$i - 1])) {\n $s[] = $t[$i] + $t[$i - 1];\n if ($i == 4) {\n break;\n }\n }\n}\nif (isset($s)) {\n sort($s);\n $j = count($s);\n $min -= $s[$j - 1];\n}\nprint $min;\nob_flush();\nflush();\n?>\n\n\n"}, {"source_code": "= 0; $i--) {\n if (($i >= 2) and ($t[$i] == $t[$i - 1]) and ($t[$i] == $t[$i - 2])) {\n $s[] = $t[$i] + $t[$i - 1] + $t[$i - 2];\n if ($i == 4) {\n break;\n }\n } else if (($i >= 1) and ($t[$i] == $t[$i - 1])) {\n $s[] = $t[$i] + $t[$i - 1];\n if ($i == 4) {\n break;\n }\n }\n}\nif (isset($s)) {\n sort($s);\n $j = count($s);\n $min -= $s[$j - 1];\n}\nprint $min;\n?>\n\n\n"}, {"source_code": ""}, {"source_code": " $count) {\n if ($count > 3) {\n $count = 3;\n }\n if($count >= 2) {\n $values[] = $key * $count;\n }\n}\n\nif(!empty($values)) {\n echo $allSum - max($values);\n} else {\n echo $allSum;\n}"}], "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a"} {"nl": {"description": "The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.", "input_spec": "The only line contains two integers p and y (2\u2009\u2264\u2009p\u2009\u2264\u2009y\u2009\u2264\u2009109).", "output_spec": "Output the number of the highest suitable branch. If there are none, print -1 instead.", "sample_inputs": ["3 6", "3 4"], "sample_outputs": ["5", "-1"], "notes": "NoteIn the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.It immediately follows that there are no valid branches in second sample case."}, "positive_code": [{"source_code": "= $p + 1; $i--){\n $stop = FALSE;\n for($j = 2 ; $j <= min(sqrt($i), $p); $j++){\n if($i % $j == 0){\n $stop = TRUE;\n break;\n }\n }\n if(!$stop){\n echo $i;\n exit;\n }\n}\necho '-1';"}, {"source_code": " $p; $n--) {\n $b = true;\n if ($n%2 == 0) {\n continue;\n }\n for ($i = 3; $i <= $p; $i = $i+2) {\n if ($n/$i < sqrt($n)) {\n break;\n } else if ($n%$i == 0) {\n $b = false;\n break;\n }\n }\n if ($n > $p && $b) {\n $k = $n;\n break;\n }\n }\n\n echo $k;\n \n?>"}], "negative_code": [{"source_code": " $p; $n--) {\n $b = true;\n if ($n%2 == 0) {\n continue;\n }\n for ($i = 3; $i <= $p; $i = $i+2) {\n if ($n/$i <= sqrt($n)) {\n break;\n } else if ($n%$i == 0) {\n $b = false;\n break;\n }\n }\n if ($n > $p && $b) {\n $k = $n;\n break;\n }\n }\n\n echo $k;\n \n?>"}, {"source_code": " $p; $n--) {\n if (method($n, $p, $y)) {\n continue;\n } else {\n $k = $n;\n break;\n }\n }\n echo $k;\n \n function method($s, $p, $y) {\n if ($s%2 == 0) {\n return true; \n }\n for ($i = $p; $i >= 2; $i--) {\n if ($s%$i) {\n return false;\n } else {\n if ($p < $s/$i && $s/$i <$y/$i) {\n return true;\n } else {\n return false;\n }\n }\n }\n \n return false;\n }\n \n?>"}], "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"nl": {"description": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.", "input_spec": "The single line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000) \u2014 the number that needs to be checked.", "output_spec": "In the only line print \"YES\" (without the quotes), if number n is almost lucky. Otherwise, print \"NO\" (without the quotes).", "sample_inputs": ["47", "16", "78"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteNote that all lucky numbers are almost lucky as any number is evenly divisible by itself.In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 0)\n echo (\"YES\");\n else \n echo (\"NO\");\n "}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0)echo \"YES\";\nelse echo \"NO\";"}, {"source_code": " 0) {\n echo \"YES\";\n} else {\n echo \"NO\";\n}"}, {"source_code": "4,\n\t1=>7,\n\t2=>47,\n\t3=>74,\n\t4=>447,\n\t5=>474,\n\t6=>477,\n\t7=>744,\n\t8=>774\n\n];\n$flag=0;\nfor($i=0;$i 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 0 ? \"YES\" : \"NO\");"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value) {\n\t\tif($input % $value == 0){\n\t\t\techo \"YES\";die();\n\t\t}\n\t}\n\techo \"NO\";\n?>"}, {"source_code": " 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 0) {\n\t\tforeach ($lucky as $l) {\n\t\t\tif ((int)$var % $l == 0) {\n\t\t\t\techo 'YES';\n\t\t\t\t$flag = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ($flag == false) echo 'NO';\n\t}\n\telse echo 'YES';"}, {"source_code": " 0) echo 'NO';\n\telse echo 'YES';"}, {"source_code": " 0 || substr_count($var, '7') > 0) echo 'YES';\n\telse echo 'NO';"}, {"source_code": " 0) echo 'NO';\n\telse echo 'YES';"}, {"source_code": " 0) {\n\t\tif ((int)$var % 4 == 0 || (int)$var % 7 == 0) echo 'YES';\n\t\techo 'NO';\n\t}\n\telse echo 'YES';"}, {"source_code": ""}, {"source_code": "\n"}, {"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": " $value) {\n\t\tif($input % $value == 0){\n\t\t\techo \"YES\";die();\n\t\t}\n\t}\n\techo \"NO\";\n?>"}, {"source_code": " $value) {\n\t\tif($input % $value == 0){\n\t\t\techo \"YES\";die();\n\t\t}\n\t}\n\techo \"NO\";\n?>"}, {"source_code": " $value) {\n\t\tif($input % $value == 0){\n\t\t\techo \"YES\";die();\n\t\t}\n\t}\n\techo \"NO\";\n?>"}, {"source_code": " 0) {\n\t\tif ((int)$var % 4 == 0 || (int)$var % 7 == 0) echo 'YES';\n\t\telse echo 'NO';\n\t}\n\telse echo 'YES';"}, {"source_code": " 0) echo 'NO';\n\telse echo 'YES';"}], "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d"} {"nl": {"description": "There is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more chance by his professor. The student has to play a game with the professor.The game is played on a square field consisting of n\u2009\u00d7\u2009n cells. Initially all cells are empty. On each turn a player chooses and paint an empty cell that has no common sides with previously painted cells. Adjacent corner of painted cells is allowed. On the next turn another player does the same, then the first one and so on. The player with no cells to paint on his turn loses.The professor have chosen the field size n and allowed the student to choose to be the first or the second player in the game. What should the student choose to win the game? Both players play optimally.", "input_spec": "The only line of the input contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091018) \u2014 the size of the field.", "output_spec": "Output number 1, if the player making the first turn wins when both players play optimally, otherwise print number 2.", "sample_inputs": ["1", "2"], "sample_outputs": ["1", "2"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "816ec4cd9736f3113333ef05405b8e81"} {"nl": {"description": "The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. \"Do I give such a hard task?\" \u2014 the HR manager thought. \"Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one cannot find the power using a calculator, but we need people who are able to think, not just follow the instructions.\"Could you pass the interview in the machine vision company in IT City?", "input_spec": "The only line of the input contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20092\u00b71018) \u2014 the power in which you need to raise number 5.", "output_spec": "Output the last two digits of 5n without spaces between them.", "sample_inputs": ["2"], "sample_outputs": ["25"], "notes": null}, "positive_code": [{"source_code": "25"}, {"source_code": ""}, {"source_code": "25\n"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25\n"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "25\n"}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": ""}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25\n"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25\n"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}, {"source_code": "25"}], "negative_code": [{"source_code": "p 25"}, {"source_code": "25 "}, {"source_code": "\n25"}, {"source_code": ""}, {"source_code": "25\n///"}, {"source_code": "#include\n#include\n#include\nusing namespace std;\nint main(){\n\tint n;\n\tcin>>n;\n\tcout<<25;\n\treturn 0;\n}\n"}, {"source_code": "echo 25"}, {"source_code": " 2) {\n echo $num[strlen($num) - 2] . $num[strlen($num) - 1];\n} elseif (strlen($num) == 2) {\n echo $num;\n}"}, {"source_code": "23"}, {"source_code": "echo 25"}, {"source_code": "echo (25)"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1,\n 1 => 1,\n 2 => 2,\n 3 => 6,\n 4 => 24,\n 5 => 120,\n 6 => 720,\n 7 => 5040,\n 8 => 40320,\n 9 => 362880,\n 10 => 3628800\n);\n\n$total = 0;\nfor($i=0;$i$total){\n echo \"0.000000000000\\n\";\n} else {\n $v = pow(0.5,$q)*$n[$q]/($n[$q-$range]*$n[$range]);\n echo $v;\n}\n\n\n\n\n\n\n\n\n"}, {"source_code": ""}], "negative_code": [{"source_code": " 0)) {\n\techo \"0.000000000000\";\n} else if ($p1 == $p2 && $m1 == $m2 && $r > 0) {\n\techo \"0.500000000000\";\n}\n?>"}, {"source_code": " 1,\n 2 => 2,\n 3 => 6,\n 4 => 24,\n 5 => 120,\n 6 => 720,\n 7 => 5040,\n 8 => 40320,\n 9 => 362880,\n 10 => 3628800\n);\n\n$total = 0;\nfor($i=0;$i 1,\n 1 => 1,\n 2 => 2,\n 3 => 6,\n 4 => 24,\n 5 => 120,\n 6 => 720,\n 7 => 5040,\n 8 => 40320,\n 9 => 362880,\n 10 => 3628800\n);\n\n$total = 0;\nfor($i=0;$i 1,\n 1 => 1,\n 2 => 2,\n 3 => 6,\n 4 => 24,\n 5 => 120,\n 6 => 720,\n 7 => 5040,\n 8 => 40320,\n 9 => 362880,\n 10 => 3628800\n);\n\n$total = 0;\nfor($i=0;$i"}], "src_uid": "f7f68a15cfd33f641132fac265bc5299"} {"nl": {"description": "Alice has a string $$$s$$$. She really likes the letter \"a\". She calls a string good if strictly more than half of the characters in that string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings, and \"baca\", \"awwwa\", \"\" (empty string) are not.Alice can erase some characters from her string $$$s$$$. She would like to know what is the longest string remaining after erasing some characters (possibly zero) to get a good string. It is guaranteed that the string has at least one \"a\" in it, so the answer always exists.", "input_spec": "The first line contains a string $$$s$$$ ($$$1 \\leq |s| \\leq 50$$$) consisting of lowercase English letters. It is guaranteed that there is at least one \"a\" in $$$s$$$.", "output_spec": "Print a single integer, the length of the longest good string that Alice can get after erasing some characters from $$$s$$$.", "sample_inputs": ["xaxxxxa", "aaabaa"], "sample_outputs": ["3", "6"], "notes": "NoteIn the first example, it's enough to erase any four of the \"x\"s. The answer is $$$3$$$ since that is the maximum number of characters that can remain.In the second example, we don't need to erase any characters."}, "positive_code": [{"source_code": " $b)\n{\n print strlen($a) - ($c - $b + 1);\n}\n?>"}, {"source_code": " strlen($s)/2) {\n echo strlen($s);\n}\nelse {\n $c = 0;\n for ($i = 0; $i < strlen($s); $i++) {\n if ($s[$i] == 'a') {\n $c++;\n }\n }\n echo $c*2 -1;\n}"}, {"source_code": "strlen($aa))\n\techo strlen($aa);\nelse echo $cnt+$cnt-1;"}, {"source_code": ""}, {"source_code": " strlen($s) ? strlen(trim($s)) : $r;"}, {"source_code": "$a[1] ? $a[0]+$a[1] : $a[0] * 2 - 1);\n"}, {"source_code": ""}, {"source_code": "$others)\n\t\techo strlen($str);\n\telse\n\t\techo ($count*2)-1;"}, {"source_code": ""}, {"source_code": "\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " ($len/2)) {\n\techo $len;\n}\nelse {\n\techo (ceil($len/2) - $as) + 1;\n}\n\n?>"}, {"source_code": ""}, {"source_code": " ($len/2)) {\n\techo $len;\n}\nelse {\n\tdo {\n\t $len--;\n\t}while ($as < ceil($len/2));\n\techo $len;\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"nl": {"description": "When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word \"tma\" (which now means \"too much to be counted\") used to stand for a thousand and \"tma tmyschaya\" (which literally means \"the tma of tmas\") used to stand for a million.Petya wanted to modernize the words we use for numbers and invented a word petricium that represents number k. Moreover, petricium la petricium stands for number k2, petricium la petricium la petricium stands for k3 and so on. All numbers of this form are called petriciumus cifera, and the number's importance is the number of articles la in its title.Petya's invention brought on a challenge that needed to be solved quickly: does some number l belong to the set petriciumus cifera? As Petya is a very busy schoolboy he needs to automate the process, he asked you to solve it.", "input_spec": "The first input line contains integer number k, the second line contains integer number l (2\u2009\u2264\u2009k,\u2009l\u2009\u2264\u2009231\u2009-\u20091).", "output_spec": "You should print in the first line of the output \"YES\", if the number belongs to the set petriciumus cifera and otherwise print \"NO\". If the number belongs to the set, then print on the seconds line the only number \u2014 the importance of number l.", "sample_inputs": ["5\n25", "3\n8"], "sample_outputs": ["YES\n1", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$l&&$l!=1){print 'NO';exit(0);}\n\n$r = 0;\nwhile($l>$k){if($l%$k!=0){print 'NO';exit(0);}$l=intval($l/$k);$r++;}\n\nif($l==$k)print \"YES\\r\\n$r\"; else print 'NO';\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$k){if($l%$k!=0){print 'NO';exit(0);}$l=intval($l/$k);$r++;}\n\nprint \"YES\\r\\n$r\";\n\n?>"}, {"source_code": "$l&&$l!=1){print 'NO';exit(0);}\n\n$r = 0;\nwhile($l>$k){if($l%$k!=0){print 'NO';exit(0);}$l=intval($l/$k);$r++;}\n\nprint \"YES\\r\\n$r\";\n\n?>"}], "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46"} {"nl": {"description": "You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...You are given an array of integers. Sort it in non-descending order.", "input_spec": "The input consists of a single line of space-separated integers. The first number is n (1\u2009\u2264\u2009n\u2009\u2264\u200910) \u2014 the size of the array. The following n numbers are the elements of the array (1\u2009\u2264\u2009ai\u2009\u2264\u2009100).", "output_spec": "Output space-separated elements of the sorted array.", "sample_inputs": ["3 3 1 2"], "sample_outputs": ["1 2 3"], "notes": "NoteRemember, this is a very important feature, and you have to make sure the customers appreciate it!"}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": "1 2 3\n"}], "src_uid": "29e481abfa9ad1f18e6157c9e833f16e"} {"nl": {"description": "You are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). Your task is to determine if the rectangles form a square. In other words, determine if the set of points inside or on the border of at least one rectangle is precisely equal to the set of points inside or on the border of some square.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20095). Next n lines contain four integers each, describing a single rectangle: x1, y1, x2, y2 (0\u2009\u2264\u2009x1\u2009<\u2009x2\u2009\u2264\u200931400,\u20090\u2009\u2264\u2009y1\u2009<\u2009y2\u2009\u2264\u200931400) \u2014 x1 and x2 are x-coordinates of the left and right edges of the rectangle, and y1 and y2 are y-coordinates of the bottom and top edges of the rectangle. No two rectangles overlap (that is, there are no points that belong to the interior of more than one rectangle).", "output_spec": "In a single line print \"YES\", if the given rectangles form a square, or \"NO\" otherwise.", "sample_inputs": ["5\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n2 2 3 3", "4\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "f63fc2d97fd88273241fce206cc217f2"} {"nl": {"description": "Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color x. He can insert his ball at any position in the row (probably, between two other balls). If at any moment there are three or more contiguous balls of the same color in the row, they are destroyed immediately. This rule is applied multiple times, until there are no more sets of 3 or more contiguous balls of the same color. For example, if Iahub has the row of balls [black, black, white, white, black, black] and a white ball, he can insert the ball between two white balls. Thus three white balls are destroyed, and then four black balls become contiguous, so all four balls are destroyed. The row will not contain any ball in the end, so Iahub can destroy all 6 balls.Iahub wants to destroy as many balls as possible. You are given the description of the row of balls, and the color of Iahub's ball. Help Iahub train for the IOI by telling him the maximum number of balls from the row he can destroy.", "input_spec": "The first line of input contains three integers: n (1\u2009\u2264\u2009n\u2009\u2264\u2009100), k (1\u2009\u2264\u2009k\u2009\u2264\u2009100) and x (1\u2009\u2264\u2009x\u2009\u2264\u2009k). The next line contains n space-separated integers c1,\u2009c2,\u2009...,\u2009cn (1\u2009\u2264\u2009ci\u2009\u2264\u2009k). Number ci means that the i-th ball in the row has color ci. It is guaranteed that the initial row of balls will never contain three or more contiguous balls of the same color. ", "output_spec": "Print a single integer \u2014 the maximum number of balls Iahub can destroy.", "sample_inputs": ["6 2 2\n1 1 2 2 1 1", "1 1 1\n1"], "sample_outputs": ["6", "0"], "notes": null}, "positive_code": [{"source_code": "= 0; $y--)\n {\n if($h[$y - 1] == $h[$y - 2])\n {\n $i++;\n }\n else\n {\n $i++;\n array_push($j, $i);\n $i = 0;\n array_push($k, $h[$y - 1]);\n }\n }\n $l = 0;\n $m = array();\n $n = array();\n for($y = $e[$x]; $y < $a; $y++)\n {\n if($h[$y + 2] == $h[$y + 3])\n {\n $l++;\n }\n else\n {\n $l++;\n array_push($m, $l);\n $l = 0;\n array_push($n, $h[$y + 2]);\n }\n }\n for($y = 0; $y < min(count($j), count($m)); $y++)\n {\n if(($k[$y] == $n[$y]) && (($j[$y] + $m[$y]) >= 3))\n {\n $g += ($j[$y] + $m[$y]);\n }\n else\n {\n break;\n }\n }\n array_push($f, $g);\n }\n print max($f);\n}\n?>"}], "negative_code": [], "src_uid": "d73d9610e3800817a3109314b1e6f88c"} {"nl": {"description": "Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a ta minutes, and a bus from the city B departs every b minutes and arrives to the city A in a tb minutes.The driver Simion wants to make his job diverse, so he counts the buses going towards him. Simion doesn't count the buses he meet at the start and finish.You know the time when Simion departed from the city A to the city B. Calculate the number of buses Simion will meet to be sure in his counting.", "input_spec": "The first line contains two integers a,\u2009ta (1\u2009\u2264\u2009a,\u2009ta\u2009\u2264\u2009120) \u2014 the frequency of the buses from the city A to the city B and the travel time. Both values are given in minutes. The second line contains two integers b,\u2009tb (1\u2009\u2264\u2009b,\u2009tb\u2009\u2264\u2009120) \u2014 the frequency of the buses from the city B to the city A and the travel time. Both values are given in minutes. The last line contains the departure time of Simion from the city A in the format hh:mm. It is guaranteed that there are a bus from the city A at that time. Note that the hours and the minutes are given with exactly two digits.", "output_spec": "Print the only integer z \u2014 the number of buses Simion will meet on the way. Note that you should not count the encounters in cities A and B.", "sample_inputs": ["10 30\n10 35\n05:20", "60 120\n24 100\n13:00"], "sample_outputs": ["5", "9"], "notes": "NoteIn the first example Simion departs form the city A at 05:20 AM and arrives to the city B at 05:50 AM. He will meet the first 5 buses from the city B that departed in the period [05:00 AM - 05:40 AM]. Also Simion will meet a bus in the city B at 05:50 AM, but he will not count it.Also note that the first encounter will be between 05:26 AM and 05:27 AM (if we suggest that the buses are go with the sustained speed)."}, "positive_code": [{"source_code": " 1439)\n {\n unset($h[$i - 1]);\n break;\n }\n else\n {\n $j += $c;\n $h[$i] = $j;\n $i++;\n }\n}\n$k = array_reverse($h);\n$l = array();\nfor($x = 0; $x < count($k); $x++)\n{\n $l[$x] = $k[$x] + $d;\n}\n$m = 0;\nfor($x = 0; $x < count($k); $x++)\n{\n if(($k[$x] < $g) && ($l[$x] > $f))\n {\n $m++;\n }\n}\nprint $m;\n?>"}, {"source_code": " 1,\n// DURING => 1\n// );\n// $tb_arr = array(\n// FREQ => 1,\n// DURING => 1\n// );\n// $ta_start = 23 * 60 + 59;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n debug(\" check between time $tb_start and $ta_end. Initial count: $count\" );\n\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $count--;\n }\n\n return intval($count);\n}\n\n// get the most recent meetable bus start time\nfunction get_start($start, $t_arr)\n{\n global $ts;\n\n if ($start - $t_arr[DURING] > $ts)\n {\n $start_time = $start - $t_arr[DURING];\n\n if ( (($start_time - $ts) % $t_arr[FREQ]) == 0)\n {\n return $start_time;\n }\n else\n {\n return $ts + ceil(($start_time - $ts) / $t_arr[FREQ]) * $t_arr[FREQ];\n }\n }\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n debug(\"meet in station at time: $t, freq: $freq\");\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 1,\n// DURING => 1\n// );\n// $tb_arr = array(\n// FREQ => 1,\n// DURING => 1\n// );\n// $ta_start = 23 * 60 + 59;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n debug(\" check between time $tb_start and $ta_end. Initial count: $count\" );\n\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $count--;\n }\n\n return intval($count);\n}\n\n// get the most recent meetable bus start time\nfunction get_start($start, $t_arr)\n{\n global $ts;\n\n if ($start - $t_arr[DURING] > $ts)\n {\n $start_time = $start - $t_arr[DURING];\n\n if ( (($start_time - $ts) % $t_arr[FREQ]) == 0)\n {\n return $start_time;\n }\n else\n {\n return $ts + ceil(($start_time - $ts) / $t_arr[FREQ]) * $t_arr[FREQ];\n }\n }\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during <= $te)\n return $start + $during;\n else\n return $te + 1;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n debug(\"meet in station at time: $t, freq: $freq\");\n return true;\n }\n else\n return false;\n}"}], "negative_code": [{"source_code": " $f) && ($j[$x] < $g))\n {\n $p++;\n }\n}\nprint $p;\n?>"}, {"source_code": " $f) && ($j[$x] < $g))\n {\n $p++;\n }\n}\nprint $p;\n?>"}, {"source_code": " 60,\n 'during' => 120\n );\n$tb_arr = array(\n 'freq' => 24,\n 'during' => 100\n );\n$ta_start = 13 * 60 + 0;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr['during']);\n\n $ta_end = get_end($ta_start, $ta_arr['during']);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr['freq']);\n if ( (($ta_end - $tb_start) % $tb_arr['freq']) == 0)\n $count++;\n\n echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n if (is_station($ta_start-$tb_arr['during'], $tb_arr['freq']))\n $count--;\n\n if (is_station($ta_start+$ta_arr['during'], $tb_arr['freq']))\n $count--;\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 30,\n// DURING => 60\n// );\n// $tb_arr = array(\n// FREQ => 60,\n// DURING => 60\n// );\n// $ta_start = 22 * 60 + 30;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr[DURING]);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = intval(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n // echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n $b_station = false;\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n // meet at arrived station\n if (is_station($ta_start+$ta_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n if ( (($ta_end - $tb_start) % $tb_arr[FREQ]) == 0 && $b_station == true)\n {\n // echo 'add 1' . PHP_EOL;\n $count++;\n }\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n // echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 30,\n// DURING => 60\n// );\n// $tb_arr = array(\n// FREQ => 60,\n// DURING => 60\n// );\n// $ta_start = 22 * 60 + 30;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr[DURING]);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n // echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n $b_station = false;\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n // meet at arrived station\n if (is_station($ta_start+$ta_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n if ( (($ta_end - $tb_start) % $tb_arr[FREQ]) == 0 && $b_station == true)\n {\n // echo 'add 1' . PHP_EOL;\n $count++;\n }\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n // echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 30,\n// DURING => 60\n// );\n// $tb_arr = array(\n// FREQ => 60,\n// DURING => 60\n// );\n// $ta_start = 22 * 60 + 30;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n debug(\" check between time $tb_start and $ta_end. Initial count: $count\" );\n\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $count--;\n }\n\n return intval($count);\n}\n\n// get the most recent meetable bus start time\nfunction get_start($start, $t_arr)\n{\n global $ts;\n\n if ($start - $t_arr[DURING] > $ts)\n {\n $start_time = $start - $t_arr[DURING];\n\n if ( (($start_time - $ts) % $t_arr[FREQ]) == 0)\n {\n return $start_time;\n }\n else\n {\n return $ts + ceil(($start_time - $ts) / $t_arr[FREQ]) * $t_arr[FREQ];\n }\n }\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n debug(\"meet in station at time: $t, freq: $freq\");\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 30,\n// DURING => 60\n// );\n// $tb_arr = array(\n// FREQ => 60,\n// DURING => 60\n// );\n// $ta_start = 22 * 60 + 30;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n debug(\" check between time $tb_start and $ta_end. Initial count: $count\" );\n\n $b_station = false;\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n // // meet at arrived station\n // if (is_station($ta_start+$ta_arr[DURING], $tb_arr[FREQ]))\n // {\n // $b_station = true;\n // $count--;\n // }\n\n return $count;\n}\n\n// get the most recent meetable bus start time\nfunction get_start($start, $t_arr)\n{\n global $ts;\n\n if ($start - $t_arr[DURING] > $ts)\n {\n $start_time = $start - $t_arr[DURING];\n\n if ( (($start_time - $ts) % $t_arr[FREQ]) == 0)\n {\n return $start_time;\n }\n else\n {\n return $ts + ceil(($start_time - $ts) / $t_arr[FREQ]) * $t_arr[FREQ];\n }\n }\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n debug(\"meet in station at time: $t, freq: $freq\");\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 60,\n 'during' => 120\n );\n$tb_arr = array(\n 'freq' => 24,\n 'during' => 100\n );\n$ta_start = 13 * 60 + 0;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr['during']);\n\n $ta_end = get_end($ta_start, $ta_arr['during']);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr['freq']);\n if ( (($ta_end - $tb_start) % $tb_arr['freq']) == 0)\n $count++;\n\n // echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n if (is_station($ta_start-$tb_arr['during'], $tb_arr['freq']))\n $count--;\n\n if (is_station($ta_start+$ta_arr['during'], $tb_arr['freq']))\n $count--;\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n // echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 60,\n// DURING => 120\n// );\n// $tb_arr = array(\n// FREQ => 24,\n// DURING => 100\n// );\n// $ta_start = 13 * 60 + 0;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr[DURING]);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = ceil(($ta_end - $tb_start) / $tb_arr[FREQ]);\n if ( (($ta_end - $tb_start) % $tb_arr[FREQ]) == 0)\n $count++;\n\n // echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n $count--;\n\n if (is_station($ta_start+$ta_arr[DURING], $tb_arr[FREQ]))\n $count--;\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n // echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}, {"source_code": " 30,\n// DURING => 60\n// );\n// $tb_arr = array(\n// FREQ => 60,\n// DURING => 60\n// );\n// $ta_start = 22 * 60 + 30;\n\necho get_count($ta_arr, $tb_arr, $ta_start) . PHP_EOL;\n\nfunction get_count($ta_arr, $tb_arr, $ta_start)\n{\n $tb_start = get_start($ta_start, $tb_arr[DURING]);\n\n $ta_end = get_end($ta_start, $ta_arr[DURING]);\n\n $count = intval(($ta_end - $tb_start) / $tb_arr[FREQ]);\n\n // echo \" check between time $tb_start and $ta_end. Initial count: $count\" . PHP_EOL;\n\n $b_station = false;\n // meet at start staion\n if (is_station($ta_start-$tb_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n // meet at arrived station\n if (is_station($ta_start+$ta_arr[DURING], $tb_arr[FREQ]))\n {\n $b_station = true;\n $count--;\n }\n\n if ( (($ta_end - $tb_start) % $tb_arr[FREQ]) == 0)\n {\n // echo 'add 1' . PHP_EOL;\n $count++;\n }\n\n return $count;\n}\n\nfunction get_start($start, $during)\n{\n global $ts;\n\n if ($start - $during > $ts)\n return $start - $during;\n else\n return $ts;\n}\n\nfunction get_end($start, $during)\n{\n global $te;\n\n if ($start + $during < $te)\n return $start + $during;\n else\n return $te;\n}\n\nfunction is_station($t, $freq)\n{\n global $ts, $te;\n\n if ($t<$ts || $t > $te)\n return false;\n\n if ((($t - $ts) % $freq) == 0)\n {\n // echo \"meet one at station. time: $t, freq: $freq\" . PHP_EOL;\n return true;\n }\n else\n return false;\n}"}], "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7"} {"nl": {"description": "Paul is at the orchestra. The string section is arranged in an r\u2009\u00d7\u2009c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count the number of possible pictures that Paul can take.Two pictures are considered to be different if the coordinates of corresponding rectangles are different.", "input_spec": "The first line of input contains four space-separated integers r, c, n, k (1\u2009\u2264\u2009r,\u2009c,\u2009n\u2009\u2264\u20093000, 1\u2009\u2264\u2009k\u2009\u2264\u2009min(n,\u200910))\u00a0\u2014 the number of rows and columns of the string section, the total number of violas, and the minimum number of violas Paul would like in his photograph, respectively. The next n lines each contain two integers xi and yi (1\u2009\u2264\u2009xi\u2009\u2264\u2009r, 1\u2009\u2264\u2009yi\u2009\u2264\u2009c): the position of the i-th viola. It is guaranteed that no location appears more than once in the input.", "output_spec": "Print a single integer\u00a0\u2014 the number of photographs Paul can take which include at least k violas. ", "sample_inputs": ["2 2 1 1\n1 2", "3 2 3 3\n1 1\n3 1\n2 2", "3 2 3 2\n1 1\n3 1\n2 2"], "sample_outputs": ["4", "1", "4"], "notes": "NoteWe will use '*' to denote violinists and '#' to denote violists.In the first sample, the orchestra looks as follows: *#** Paul can take a photograph of just the viola, the 1\u2009\u00d7\u20092 column containing the viola, the 2\u2009\u00d7\u20091 row containing the viola, or the entire string section, for 4 pictures total.In the second sample, the orchestra looks as follows: #**##* Paul must take a photograph of the entire section.In the third sample, the orchestra looks the same as in the second sample."}, "positive_code": [{"source_code": "= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 1; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 2; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 3; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 4; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 5; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 6; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 7; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 8; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $p9 = $e[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 9; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $p9 = $e[$n + 8];\n $p10 = $e[$n + 9];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 1; $m <= 10; $m++)\n{\n for($n = 0; $n < $b; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $r = array_sum(array_slice($p, $o, $m));\n if($r >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 1; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 2; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 3; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 4; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 5; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 6; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 7; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 8; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 7];\n $p9 = $i[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 9; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 7];\n $p9 = $i[$n + 8];\n $p10 = $i[$n + 9];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 1; $m <= 1; $m++)\n{\n for($n = 0; $n < $a; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $r = array_sum(array_slice($p, $o, $m));\n if($r >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 2; $m++)\n{\n for($n = 0; $n < $a - 1; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 3; $m++)\n{\n for($n = 0; $n < $a - 2; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 4; $m++)\n{\n for($n = 0; $n < $a - 3; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 5; $m++)\n{\n for($n = 0; $n < $a - 4; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 6; $m++)\n{\n for($n = 0; $n < $a - 5; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 7; $m++)\n{\n for($n = 0; $n < $a - 6; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 8; $m++)\n{\n for($n = 0; $n < $a - 7; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 9; $m++)\n{\n for($n = 0; $n < $a - 8; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $p9 = $e[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 9; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 7];\n $p9 = $e[$n + 8];\n $p10 = $e[$n + 9];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nprint $l;\n?>"}, {"source_code": "= $k) $photos++;\n\t\t\t}\n\t\t}\t\t\n\t}\n}\n\nprint $photos;\n?>"}], "negative_code": [{"source_code": "= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 1; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 2; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 3; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 4; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 5; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 6; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 7; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 8; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $p9 = $e[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 9; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $p9 = $e[$n + 7];\n $p10 = $e[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 1; $m <= 10; $m++)\n{\n for($n = 0; $n < $b; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $r = array_sum(array_slice($p, $o, $m));\n if($r >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 1; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 2; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 3; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 4; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 5; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 6; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 7; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 8; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 6];\n $p9 = $i[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $b - 9; $n++)\n {\n for($o = 0; $o <= $a - $m; $o++)\n {\n $p = $i[$n];\n $p2 = $i[$n + 1];\n $p3 = $i[$n + 2];\n $p4 = $i[$n + 3];\n $p5 = $i[$n + 4];\n $p6 = $i[$n + 5];\n $p7 = $i[$n + 6];\n $p8 = $i[$n + 6];\n $p9 = $i[$n + 7];\n $p10 = $i[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l += 1;\n }\n }\n }\n}\nfor($m = 1; $m <= 1; $m++)\n{\n for($n = 0; $n < $a; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $r = array_sum(array_slice($p, $o, $m));\n if($r >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 2; $m <= 2; $m++)\n{\n for($n = 0; $n < $a - 1; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n if($r + $r2 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 3; $m <= 3; $m++)\n{\n for($n = 0; $n < $a - 2; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n if($r + $r2 + $r3 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 4; $m <= 4; $m++)\n{\n for($n = 0; $n < $a - 3; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n if($r + $r2 + $r3 + $r4 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 5; $m <= 5; $m++)\n{\n for($n = 0; $n < $a - 4; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 6; $m <= 6; $m++)\n{\n for($n = 0; $n < $a - 5; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 7; $m <= 7; $m++)\n{\n for($n = 0; $n < $a - 6; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 8; $m <= 8; $m++)\n{\n for($n = 0; $n < $a - 7; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 9; $m <= 9; $m++)\n{\n for($n = 0; $n < $a - 8; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $p9 = $e[$n + 7];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nfor($m = 10; $m <= 10; $m++)\n{\n for($n = 0; $n < $a - 9; $n++)\n {\n for($o = 0; $o <= $b - $m; $o++)\n {\n $p = $e[$n];\n $p2 = $e[$n + 1];\n $p3 = $e[$n + 2];\n $p4 = $e[$n + 3];\n $p5 = $e[$n + 4];\n $p6 = $e[$n + 5];\n $p7 = $e[$n + 6];\n $p8 = $e[$n + 6];\n $p9 = $e[$n + 7];\n $p10 = $e[$n + 8];\n $r = array_sum(array_slice($p, $o, $m));\n $r2 = array_sum(array_slice($p2, $o, $m));\n $r3 = array_sum(array_slice($p3, $o, $m));\n $r4 = array_sum(array_slice($p4, $o, $m));\n $r5 = array_sum(array_slice($p5, $o, $m));\n $r6 = array_sum(array_slice($p6, $o, $m));\n $r7 = array_sum(array_slice($p7, $o, $m));\n $r8 = array_sum(array_slice($p8, $o, $m));\n $r9 = array_sum(array_slice($p9, $o, $m));\n $r10 = array_sum(array_slice($p10, $o, $m));\n if($r + $r2 + $r3 + $r4 + $r5 + $r6 + $r7 + $r8 + $r9 + $r10 >= $d)\n {\n $l -= 1;\n }\n }\n }\n}\nprint $l;\n?>"}], "src_uid": "9c766881f6415e2f53fb43b61f8f40b4"} {"nl": {"description": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant \"n\"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words \"harakiri\", \"yupie\", \"man\", and \"nbo\" are Berlanese while the words \"horse\", \"king\", \"my\", and \"nz\" are not.Help Vitya find out if a word $$$s$$$ is Berlanese.", "input_spec": "The first line of the input contains the string $$$s$$$ consisting of $$$|s|$$$ ($$$1\\leq |s|\\leq 100$$$) lowercase Latin letters.", "output_spec": "Print \"YES\" (without quotes) if there is a vowel after every consonant except \"n\", otherwise print \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["sumimasen", "ninja", "codeforces"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteIn the first and second samples, a vowel goes after each consonant except \"n\", so the word is Berlanese.In the third sample, the consonant \"c\" goes after the consonant \"r\", and the consonant \"s\" stands on the end, so the word is not Berlanese."}, "positive_code": [{"source_code": " 1, b => 0, c => 0, d => 0, e => 1, f => 0, g => 0, h => 0, i => 1, j => 0, k => 0, l => 0, m => 0, n => 0, o => 1, p => 0, q => 0, r => 0, s => 0, t => 0, u => 1, v => 0, w => 0, x => 0, y => 0, z => 0);\n$c = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n if($a[$x] == \"n\")\n {\n continue;\n }\n elseif(($b[$a[$x]] == 0) && ($b[$a[$x + 1]] != 1))\n {\n $c = 1;\n break;\n }\n elseif($b[$a[$x]] == 1)\n {\n continue;\n }\n}\nif($c == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "= sizeof($input)){\n $ok = false;\n break;\n }else if(!isVowel($input[$i+1])){\n $ok = false;\n break;\n } \n } \n}\n\necho $ok ? 'YES' : 'NO';\n\nfunction isVowel($character){\n return $character == 'a' \n || $character == 'i' \n || $character == 'u' \n || $character == 'e' \n || $character == 'o';\n}\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": " 0){\n\tfwrite(STDOUT, 1);\n}else{\n\tif($a == 0 && $c == 0 && $d == 0){\n\t\tfwrite(STDOUT, 1);\n\t}else{\n\t\tfwrite(STDOUT, 0);\n\t}\n}\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "b99578086043537297d374dc01eeb6f8"} {"nl": {"description": "Vasya likes to solve equations. Today he wants to solve $$$(x~\\mathrm{div}~k) \\cdot (x \\bmod k) = n$$$, where $$$\\mathrm{div}$$$ and $$$\\mathrm{mod}$$$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $$$k$$$ and $$$n$$$ are positive integer parameters, and $$$x$$$ is a positive integer unknown. If there are several solutions, Vasya wants to find the smallest possible $$$x$$$. Can you help him?", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 10^6$$$, $$$2 \\leq k \\leq 1000$$$).", "output_spec": "Print a single integer $$$x$$$\u00a0\u2014 the smallest positive integer solution to $$$(x~\\mathrm{div}~k) \\cdot (x \\bmod k) = n$$$. It is guaranteed that this equation has at least one positive integer solution.", "sample_inputs": ["6 3", "1 2", "4 6"], "sample_outputs": ["11", "3", "10"], "notes": "NoteThe result of integer division $$$a~\\mathrm{div}~b$$$ is equal to the largest integer $$$c$$$ such that $$$b \\cdot c \\leq a$$$. $$$a$$$ modulo $$$b$$$ (shortened $$$a \\bmod b$$$) is the only integer $$$c$$$ such that $$$0 \\leq c < b$$$, and $$$a - c$$$ is divisible by $$$b$$$.In the first sample, $$$11~\\mathrm{div}~3 = 3$$$ and $$$11 \\bmod 3 = 2$$$. Since $$$3 \\cdot 2 = 6$$$, then $$$x = 11$$$ is a solution to $$$(x~\\mathrm{div}~3) \\cdot (x \\bmod 3) = 6$$$. One can see that $$$19$$$ is the only other positive integer solution, hence $$$11$$$ is the smallest one."}, "positive_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$xs = [];\nforeach(PrimeUtils::divisors($n) as $divisor=>$v) {\n\t$l = $divisor;\n\t$m = intval($n/$l);\n\t//echo \"$divisor, $l, $m, $k\\n\";\n\t\n\tif ($m<$k) {\n\t\t$xs[] = $k*$l + $m;\n\t}\n}\n\nif (empty($xs)) {\n\techo $n*$k+1;\n} else {\n\techo min($xs);\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$xs = [];\nforeach(PrimeUtils::divisors($n) as $divisor=>$v) {\n\t$l = $divisor;\n\t$m = intval($n/$l);\n\t//echo \"$divisor, $l, $m, $k\\n\";\n\t\n\tif ($m<$k) {\n\t\t$xs[] = $k*$l + $m;\n\t}\n}\n//var_dump($xs);\necho min($xs);\n"}], "src_uid": "ed0ebc1e484fcaea875355b5b7944c57"} {"nl": {"description": "Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He writes down the following sequence of numbers: firstly all odd integers from 1 to n (in ascending order), then all even integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k.", "input_spec": "The only line of input contains integers n and k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u20091012). 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.", "output_spec": "Print the number that will stand at the position number k after Volodya's manipulations.", "sample_inputs": ["10 3", "7 7"], "sample_outputs": ["5", "6"], "notes": "NoteIn the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5."}, "positive_code": [{"source_code": ""}, {"source_code": " 0){\n \n $half = ceil($n/2);\n if($k<=$half){\n $num = 2*$k-1;\n }else{\n $num = 2*($k-$half);\n }\n echo $num.\"\\n\";\n }\n $n = $k = null;\n }\n ?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $part)\n{\n echo 2 * ($k-$part);\n}\n else {\n echo 2*($k-1)+1;\n}"}, {"source_code": "\n"}, {"source_code": " $oddnums) {\n //if so, it's even. ith even number is 2i.\n $i = $k - $oddnums;\n echo 2 * $i;\n} else {\n //it's odd. the ith odd number is 2(i-1) + 1.\n echo 2 * ($k - 1) + 1;\n}\n?>"}, {"source_code": " $c)\n{\n printf(\"%.0f\", ($b - $c) * 2);\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $r){\n printf(\"%.0f\" ,$r * 2 - 1);\n }\n else\n printf(\"%.0f\", ((floor(($n + 1) / 2)) - $r) * -2);\n \n "}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0){\n $half = ceil($n/2);\n if($k<=$half){\n $num = 2*$k-1;\n }else{\n $num = 2*($k-$half);\n }\n echo $num.\"\\n\";\n }\n $n = $k = null;\n }\n ?>"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0) {\n $k = bcsub($k, $countNech, 0); \n $out = bcmul($k, '2', 0);\n} else {\n $out = bcmul($k, '2', 0);\n $out = bcsub($out, '1', 0); \n}\n\necho $out;\n\n?>"}, {"source_code": " $part)\n{\n echo 2 * ($part-$k);\n}\n else {\n echo 2*($k-1)+1;\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= $r)){\n for ($i = 0; $i < $r - 1; $i++){\n $k = $k + 2;\n echo $k;\n }\n }\n if (($n % 2 == 0) && ($n / 2 < $r)){\n for ($i = 0; $i < ($r - $n / 2 ) ; $i++){\n $k = $k + 1;\n echo $k;\n }\n }\n if (($n % 2 != 0) && ( round($n / 2) >= $r)){\n for ($i = 0; $i < $r - 1; $i++){\n $k = $k + 2; \n echo ($k);\n }\n }if (($n % 2 !== 0) && ( round($n / 2) < $r)){\n for ($i = 0; $i < ($r - round($n / 2)); $i++){\n $k = $k + 1; \n echo ($k + 2);\n }\n }\n "}, {"source_code": "= $r){\n echo ( $r * 2 - 1);\n }\n else\n echo (( intval( ($n + 1 ) / 2) - $r) * -2);\n \n "}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0; $i--) {\n array_unshift($even, $odd[$i]);\n}\nprint($even[$k-1]);\n"}, {"source_code": "= 0; $i--) {\n array_unshift($even, $odd[$i]);\n}\nprint($even[$k-1]);"}, {"source_code": " 0)\n{\n $j = current($i);\n print $j;\n}\nelse\n{\n print \"-1\";\n}\n?>"}, {"source_code": " 0)\n {\n reset($ee);\n echo current($ee);\n } else {\n echo \"-1\";\n }\n \n echo PHP_EOL;"}, {"source_code": "=0) break;\n $t2[$k] = $d + $k*$c;\n if(in_array($t2[$k], $t1)){\n $ok = $t2[$k];\n }\n }\n return $ok;\n}\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nlist($c, $d) = explode(\" \", trim(fgets(STDIN)));\necho ab($a,$b,$c,$d);\n?>"}, {"source_code": " $d) {\n $d += $c;\n }\n else {\n $b += $a;\n }\n $i++;\n}\necho -1;"}], "negative_code": [], "src_uid": "158cb12d45f4ee3368b94b2b622693e7"} {"nl": {"description": "You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied: the i-th letter occurs in the string no more than ai times; the number of occurrences of each letter in the string must be distinct for all the letters that occurred in the string at least once. ", "input_spec": "The first line of the input contains a single integer n (2\u2009\u2009\u2264\u2009\u2009n\u2009\u2009\u2264\u2009\u200926)\u00a0\u2014 the number of letters in the alphabet. The next line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 i-th of these integers gives the limitation on the number of occurrences of the i-th character in the string.", "output_spec": "Print a single integer \u2014 the maximum length of the string that meets all the requirements.", "sample_inputs": ["3\n2 5 5", "3\n1 1 2"], "sample_outputs": ["11", "3"], "notes": "NoteFor convenience let's consider an alphabet consisting of three letters: \"a\", \"b\", \"c\". In the first sample, some of the optimal strings are: \"cccaabbccbb\", \"aabcbcbcbcb\". In the second sample some of the optimal strings are: \"acc\", \"cbc\"."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"} {"nl": {"description": "During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow crystals, green\u00a0\u2014 one yellow and one blue, and for a blue ball, three blue crystals are enough.Right now there are A yellow and B blue crystals in Grisha's disposal. Find out how many additional crystals he should acquire in order to produce the required number of balls.", "input_spec": "The first line features two integers A and B (0\u2009\u2264\u2009A,\u2009B\u2009\u2264\u2009109), denoting the number of yellow and blue crystals respectively at Grisha's disposal. The next line contains three integers x, y and z (0\u2009\u2264\u2009x,\u2009y,\u2009z\u2009\u2264\u2009109)\u00a0\u2014 the respective amounts of yellow, green and blue balls to be obtained.", "output_spec": "Print a single integer\u00a0\u2014 the minimum number of crystals that Grisha should acquire in addition.", "sample_inputs": ["4 3\n2 1 1", "3 9\n1 1 3", "12345678 87654321\n43043751 1000000000 53798715"], "sample_outputs": ["2", "1", "2147483648"], "notes": "NoteIn the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue."}, "positive_code": [{"source_code": ""}, {"source_code": "\n"}], "negative_code": [], "src_uid": "35202a4601a03d25e18dda1539c5beba"} {"nl": {"description": "Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.But unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of apples. The second line contains n integers w1,\u2009w2,\u2009...,\u2009wn (wi\u2009=\u2009100 or wi\u2009=\u2009200), where wi is the weight of the i-th apple.", "output_spec": "In a single line print \"YES\" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print \"NO\" (without the quotes).", "sample_inputs": ["3\n100 200 100", "4\n100 100 100 200"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa."}, "positive_code": [{"source_code": " $e)\n {\n $f = $d - $e;\n if(($f == 200) && ($b[0] == 100))\n {\n $c = 1;\n }\n break;\n }\n}\nif($c == 1)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "9679acef82356004e47b1118f8fc836a"} {"nl": {"description": "Vasya studies music. He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. We will consider the C note in the row's beginning and the C note after the H similar and we will identify them with each other. The distance between the notes along the musical scale is measured in tones: between two consecutive notes there's exactly one semitone, that is, 0.5 tone. The distance is taken from the lowest tone to the uppest one, that is, the distance between C and E is 4 semitones and between E and C is 8 semitonesVasya also knows what a chord is. A chord is an unordered set of no less than three notes. However, for now Vasya only works with triads, that is with the chords that consist of exactly three notes. He can already distinguish between two types of triads \u2014 major and minor.Let's define a major triad. Let the triad consist of notes X, Y and Z. If we can order the notes so as the distance along the musical scale between X and Y equals 4 semitones and the distance between Y and Z is 3 semitones, then the triad is major. The distance between X and Z, accordingly, equals 7 semitones.A minor triad is different in that the distance between X and Y should be 3 semitones and between Y and Z \u2014 4 semitones.For example, the triad \"C E G\" is major: between C and E are 4 semitones, and between E and G are 3 semitones. And the triplet \"C# B F\" is minor, because if we order the notes as \"B C# F\", than between B and C# will be 3 semitones, and between C# and F \u2014 4 semitones.Help Vasya classify the triad the teacher has given to him.", "input_spec": "The only line contains 3 space-separated notes in the above-given notation.", "output_spec": "Print \"major\" if the chord is major, \"minor\" if it is minor, and \"strange\" if the teacher gave Vasya some weird chord which is neither major nor minor. Vasya promises you that the answer will always be unambiguous. That is, there are no chords that are both major and minor simultaneously.", "sample_inputs": ["C E G", "C# B F", "A B H"], "sample_outputs": ["major", "minor", "strange"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "6aa83c2f6e095848bc63aba7d013aa58"} {"nl": {"description": "Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For example, imagine Ciel has three boxes: the first has strength 2, the second has strength 1 and the third has strength 1. She cannot put the second and the third box simultaneously directly on the top of the first one. But she can put the second box directly on the top of the first one, and then the third box directly on the top of the second one. We will call such a construction of boxes a pile.Fox Ciel wants to construct piles from all the boxes. Each pile will contain some boxes from top to bottom, and there cannot be more than xi boxes on the top of i-th box. What is the minimal number of piles she needs to construct?", "input_spec": "The first line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). The next line contains n integers x1,\u2009x2,\u2009...,\u2009xn (0\u2009\u2264\u2009xi\u2009\u2264\u2009100).", "output_spec": "Output a single integer \u2014 the minimal possible number of piles.", "sample_inputs": ["3\n0 0 10", "5\n0 1 2 3 4", "4\n0 0 0 0", "9\n0 1 0 2 0 1 1 2 10"], "sample_outputs": ["2", "1", "4", "3"], "notes": "NoteIn example 1, one optimal way is to build 2 piles: the first pile contains boxes 1 and 3 (from top to bottom), the second pile contains only box 2.In example 2, we can build only 1 pile that contains boxes 1, 2, 3, 4, 5 (from top to bottom)."}, "positive_code": [{"source_code": "= count($c))\n {\n array_push($c, $b[$y]);\n unset($b[$y]);\n }\n elseif($b[$y] < count($c))\n {\n continue;\n }\n }\n if(count($b) == 0)\n {\n break;\n }\n}\nprint $x;\n?>"}, {"source_code": " 0) && ($y != 0))\n {\n unset($b[$c]);\n $c = $y;\n $e--;\n $e = $b[$c];\n }\n elseif(($b[$y] == $b[$c]) && ($e > 0) && ($y != 0))\n {\n unset($b[$c]);\n $c = $y;\n $e--;\n }\n }\n unset($b[$c]);\n rsort($b);\n if(count($b) > 0)\n {\n $d++;\n }\n else\n {\n $d++;\n break;\n }\n}\nif($f > $d)\n{\n print $d + $f - $d;\n}\nelse\n{\n print $d;\n}\n?>"}, {"source_code": " 0)\n {\n $d++;\n }\n else\n {\n $d++;\n break;\n }\n}\nprint $d;\n?>"}], "src_uid": "7c710ae68f27f140e7e03564492f7214"} {"nl": {"description": "Natasha is planning an expedition to Mars for $$$n$$$ people. One of the important tasks is to provide food for each participant.The warehouse has $$$m$$$ daily food packages. Each package has some food type $$$a_i$$$.Each participant must eat exactly one food package each day. Due to extreme loads, each participant must eat the same food type throughout the expedition. Different participants may eat different (or the same) types of food.Formally, for each participant $$$j$$$ Natasha should select his food type $$$b_j$$$ and each day $$$j$$$-th participant will eat one food package of type $$$b_j$$$. The values $$$b_j$$$ for different participants may be different.What is the maximum possible number of days the expedition can last, following the requirements above?", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 100$$$, $$$1 \\le m \\le 100$$$)\u00a0\u2014 the number of the expedition participants and the number of the daily food packages available. The second line contains sequence of integers $$$a_1, a_2, \\dots, a_m$$$ ($$$1 \\le a_i \\le 100$$$), where $$$a_i$$$ is the type of $$$i$$$-th food package.", "output_spec": "Print the single integer\u00a0\u2014 the number of days the expedition can last. If it is not possible to plan the expedition for even one day, print 0.", "sample_inputs": ["4 10\n1 5 2 1 1 1 2 5 7 2", "100 1\n1", "2 5\n5 4 3 2 1", "3 9\n42 42 42 42 42 42 42 42 42"], "sample_outputs": ["2", "0", "1", "3"], "notes": "NoteIn the first example, Natasha can assign type $$$1$$$ food to the first participant, the same type $$$1$$$ to the second, type $$$5$$$ to the third and type $$$2$$$ to the fourth. In this case, the expedition can last for $$$2$$$ days, since each participant can get two food packages of his food type (there will be used $$$4$$$ packages of type $$$1$$$, two packages of type $$$2$$$ and two packages of type $$$5$$$).In the second example, there are $$$100$$$ participants and only $$$1$$$ food package. In this case, the expedition can't last even $$$1$$$ day."}, "positive_code": [{"source_code": "= 1; $x--)\n{\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= $a)\n {\n $f = max($f, $x);\n break;\n }\n }\n}\nprint $f;\n?>"}], "negative_code": [{"source_code": "= 1; $x--)\n{\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= $x)\n {\n $f = max($f, $g);\n break;\n }\n }\n}\nprint $f;\n?>"}, {"source_code": "= 1; $x--)\n{\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= $x)\n {\n $f = max($f, $x);\n break;\n }\n }\n}\nprint $f;\n?>"}, {"source_code": "= 1; $x--)\n{\n $f = 0;\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= $x)\n {\n $f = 1;\n $h = max($h, $g);\n }\n }\n}\nif($f == 0)\n{\n print \"0\";\n}\nelse\n{\n print $h;\n}\n?>"}, {"source_code": "= 1; $x--)\n{\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= 1)\n {\n $f = max($f, $x);\n break;\n }\n }\n}\nprint $f;\n?>"}, {"source_code": "= 1; $x--)\n{\n $f = 0;\n $g = 0;\n for($y = 0; $y < count($e); $y++)\n {\n $h = floor($e[$y] / $x);\n $g += $h;\n if($g >= $x)\n {\n $f = 1;\n break;\n }\n }\n if($f == 1)\n {\n break;\n }\n}\nif($f == 0)\n{\n print \"0\";\n}\nelse\n{\n print $x;\n}\n?>"}], "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe"} {"nl": {"description": "Polycarpus has got n candies and m friends (n\u2009\u2265\u2009m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible.For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one.", "input_spec": "The single line of the input contains a pair of space-separated positive integers n, m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100;n\u2009\u2265\u2009m) \u2014 the number of candies and the number of Polycarpus's friends.", "output_spec": "Print the required sequence a1,\u2009a2,\u2009...,\u2009am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value.", "sample_inputs": ["12 3", "15 4", "18 7"], "sample_outputs": ["4 4 4", "3 4 4 4", "2 2 2 3 3 3 3"], "notes": "NotePrint ai in any order, separate the numbers by spaces."}, "positive_code": [{"source_code": "= 1; $y--)\n {\n $g -= $x;\n if(((($f * $d) + ($g * $e)) == $a) && (($f + $g) == $b))\n {\n $h = 1;\n break;\n }\n }\n if($h == 1)\n {\n break;\n }\n $g = $b;\n }\n for($x = 1; $x <= $f; $x++)\n {\n print $d . \" \";\n }\n for($x = 1; $x < $g; $x++)\n {\n print $e . \" \";\n }\n print $e;\n}\n?>"}, {"source_code": "#!/usr/bin/php\n= 1; $y--)\n {\n $g -= $x;\n if((($f * $d) + ($g * $e)) == $a)\n {\n $h = 1;\n break;\n }\n }\n if($h == 1)\n {\n break;\n }\n $g = $b - $f;\n }\n for($x = 1; $x <= $f; $x++)\n {\n print $d . \" \";\n }\n for($x = 1; $x < $g; $x++)\n {\n print $e . \" \";\n }\n print $e;\n}\n?>"}, {"source_code": "= 1; $y--)\n {\n $g -= $x;\n if(((($f * $d) + ($g * $e)) == $a) && (($f + $g) == $b))\n {\n $h = 1;\n break;\n }\n }\n if($h == 1)\n {\n break;\n }\n $g = $b - $f;\n }\n for($x = 1; $x <= $f; $x++)\n {\n print $d . \" \";\n }\n for($x = 1; $x < $g; $x++)\n {\n print $e . \" \";\n }\n print $e;\n}\n?>"}, {"source_code": ""}, {"source_code": "#!/usr/bin/php\n\n\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\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\tlist($price, $r) = readStringExplodeNum($stream, ' ', true);\n\tfor ($i = 1; $i <= 10; $i++) {\n\t\t$amount = $i * $price;\n\t\t\n\t\tif ($amount % 10 == $r || $amount % 10 == 0) {\n\t\t\techo $i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": "1) return true;\n\treturn false;\n}\nfunction calculate_min($k, $n){\n\t$allow = true;\n\t$c = 1;\n\t$num = $k-$n;\n\tif(dividable($num)) return $c;\n\tfor($i=0;$i<=10; $i++){\n\t\t$c++;\n\t\tif(dividable(($c-1)*$k - $n)) return $c-1;\n\t\tif(dividable(($c-1)*$k)) return $c-1;\n\t}\n\treturn \"undefined\";\n}\n$read = read();\n\nlist($k, $n) = explode(\" \", $read);\nput(calculate_min($k, $n));\n?>"}, {"source_code": "1) return true;\n\treturn false;\n}\nfunction calculate_min($k, $n){\n\t$allow = true;\n\t$c = 1;\n\t$num = $k-$n;\n\tif(dividable($num)) return $c;\n\tfor($i=0;$i<=10; $i++){\n\t\t$c++;\n\t\tif(dividable(($c-1)*$k)) return $c-1;\n\t\tif(dividable(($c-1)*$k - $n)) return $c-1;\n\t}\n\treturn \"undefined\";\n}\n$read = read();\n\nlist($k, $n) = explode(\" \", $read);\nput(calculate_min($k, $n));\n?>"}, {"source_code": "1) return true;\n\treturn false;\n}\nfunction calculate_min($k, $n){\n\t$allow = true;\n\t$c = 1;\n\t$num = $k-$n;\n\tif(dividable($num)) return $c;\n\tfor($i=0;$i<=10; $i++){\n\t\t$c++;\n\t\tif(dividable(($c-1)*$k - $n)) return $c-1;\n\t\tif(dividable(($c-1)*$k)) return $c-1;\n\t}\n\treturn \"undefined\";\n}\n$read = read();\n\nlist($k, $n) = explode(\" \", $read);\nput(calculate_min($k, $n));\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3"} {"nl": {"description": "There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i\u2009-\u2009j|.Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that there is at most one criminal in each city.Limak is going to use a BCD (Bear Criminal Detector). The BCD will tell Limak how many criminals there are for every distance from a city a. After that, Limak can catch a criminal in each city for which he is sure that there must be a criminal.You know in which cities criminals are. Count the number of criminals Limak will catch, after he uses the BCD.", "input_spec": "The first line of the input contains two integers n and a (1\u2009\u2264\u2009a\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of cities and the index of city where Limak lives. The second line contains n integers t1,\u2009t2,\u2009...,\u2009tn (0\u2009\u2264\u2009ti\u2009\u2264\u20091). There are ti criminals in the i-th city.", "output_spec": "Print the number of criminals Limak will catch.", "sample_inputs": ["6 3\n1 1 1 0 1 0", "5 2\n0 0 0 1 0"], "sample_outputs": ["3", "1"], "notes": "NoteIn the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red. Using the BCD gives Limak the following information: There is one criminal at distance 0 from the third city\u00a0\u2014 Limak is sure that this criminal is exactly in the third city. There is one criminal at distance 1 from the third city\u00a0\u2014 Limak doesn't know if a criminal is in the second or fourth city. There are two criminals at distance 2 from the third city\u00a0\u2014 Limak is sure that there is one criminal in the first city and one in the fifth city. There are zero criminals for every greater distance. So, Limak will catch criminals in cities 1, 3 and 5, that is 3 criminals in total.In the second sample (drawing below), the BCD gives Limak the information that there is one criminal at distance 2 from Limak's city. There is only one city at distance 2 so Limak is sure where a criminal is. "}, "positive_code": [{"source_code": "= 1; $x--)\n{\n if($x == $b)\n {\n break;\n }\n else\n {\n $e++;\n }\n}\nif($d < $e)\n{\n $f = $e - $d;\n $b += $f;\n for($x = 1; $x <= $f; $x++)\n {\n array_unshift($c, 2);\n }\n}\nelseif($d > $e)\n{\n $f = $d - $e;\n for($x = 1; $x <= $f; $x++)\n {\n array_push($c, 2);\n }\n}\n$g = 0;\n$h = $b - 2;\n$i = $b;\nfor($x = $b - 1; $x >= 0; $x--)\n{\n if($x == ($b - 1))\n {\n if($c[$x] == 1)\n {\n $g++;\n }\n }\n else\n {\n if(($c[$h] == 1) && ($c[$i] == 1))\n {\n $g += 2;\n }\n elseif(($c[$h] == 1) && ($c[$i] == 2))\n {\n $g++;\n }\n elseif(($c[$h] == 2) && ($c[$i] == 1))\n {\n $g++;\n }\n $h--;\n $i++;\n }\n}\nprint $g;\n?>"}, {"source_code": "($cities_cnt/2)){\nfor ($i=0;$i<($limak_city);$i++){\n\t\n\t$r = abs($limak_city-$i);\n\t//echo $r;\n\tif(($cities_cnt-($limak_city+$r)<=0)||(($limak_city-$r)<0)){\n\t // echo \"!\".$crims[$limak_city-$r].\"!\\n\";\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t // echo \"+\".($limak_city+$r);\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n\t//echo $catched.\" \";\n}\n}else{\n\tfor ($i=$cities_cnt;$i>($limak_city);$i--){\n\n\t$r = abs($limak_city-$i);\n//\techo $r;\n\tif(($cities_cnt-($limak_city+$r)<=0)||(($limak_city-$r)<0)){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t\t\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n//\techo $catched.\" \";\n}\n\t\n}\nif($crims[$limak_city]>0){\n\t$catched+=1;\n}\necho $catched;\n\n"}, {"source_code": "= 0 && $id2 < $n)\n {\n if($t[$id] == $t[$id2] && $t[$id] != '0')\n {\n $ans ++;\n if($id != $id2)\n $ans ++;\n }\n $id --;\n $id2 ++;\n }\n while($id >= 0) \n {\n $ans += $t[$id] == '1';\n $id --;\n }\n while($id2 < $n) \n {\n $ans += $t[$id2] == '1';\n $id2 ++;\n }\n echo $ans;\n?>\n"}], "negative_code": [{"source_code": "($cities_cnt/2)){\nfor ($i=0;$i<($limak_city);$i++){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n}else{\n\tfor ($i=$cities_cnt;$i>($limak_city);$i--){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n\t\n}\nif($crims[$limak_city]>0){\n\t$catched+=1;\n}\necho $catched;\n\n"}, {"source_code": "($cities_cnt/2)){\nfor ($i=0;$i<($limak_city);$i++){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}elseif($cities_cnt-($r+$r)>=0){\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n}else{\n\tfor ($i=$cities_cnt;$i>($limak_city);$i--){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n\t\n}\nif($crims[$limak_city]>0){\n\t$catched+=1;\n}\necho $catched;\n\n"}, {"source_code": "($cities_cnt/2)){\nfor ($i=0;$i<($limak_city);$i++){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}elseif($cities_cnt-($r+$r)>=0){\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n}else{\n\tfor ($i=$cities_cnt;$i>($limak_city);$i--){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<0)||($cities_cnt>($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n\t\n}\nif($crims[$limak_city]>0){\n\t$catched+=1;\n}\necho $catched;\n\n"}, {"source_code": "($cities_cnt/2)){\nfor ($i=0;$i<($limak_city);$i++){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<=0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n}else{\n\tfor ($i=$cities_cnt;$i>($limak_city);$i--){\n\t\n\t$r = abs($limak_city-$i);\n\tif(($cities_cnt-($limak_city+$r)<=0)||($cities_cnt>=($limak_city+$r))){\n\t\tif(((int)$crims[$limak_city+$r])>0||((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=1;\n\t\t}\n\t}else{\n\t\tif(((int)$crims[$limak_city+$r])>0&&((int)$crims[$limak_city-$r])>0){\n\t\t\t$catched+=2;\n\t\t}\n\t\t\n\t\t\n\t}\n}\n\t\n}\nif($crims[$limak_city]>0){\n\t$catched+=1;\n}\necho $catched;\n\n"}], "src_uid": "4840d571d4ce6e1096bb678b6c100ae5"} {"nl": {"description": "Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.To obfuscate the code, Kostya first looks at the first variable name used in his program and replaces all its occurrences with a single symbol a, then he looks at the second variable name that has not been replaced yet, and replaces all its occurrences with b, and so on. Kostya is well-mannered, so he doesn't use any one-letter names before obfuscation. Moreover, there are at most 26 unique identifiers in his programs.You are given a list of identifiers of some program with removed spaces and line breaks. Check if this program can be a result of Kostya's obfuscation.", "input_spec": "In the only line of input there is a string S of lowercase English letters (1\u2009\u2264\u2009|S|\u2009\u2264\u2009500)\u00a0\u2014 the identifiers of a program with removed whitespace characters.", "output_spec": "If this program can be a result of Kostya's obfuscation, print \"YES\" (without quotes), otherwise print \"NO\".", "sample_inputs": ["abacaba", "jinotega"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample case, one possible list of identifiers would be \"number string number character number string number\". Here how Kostya would obfuscate the program: replace all occurences of number with a, the result would be \"a string a character a string a\", replace all occurences of string with b, the result would be \"a b a character a b a\", replace all occurences of character with c, the result would be \"a b a c a b a\", all identifiers have been replaced, thus the obfuscation is finished."}, "positive_code": [{"source_code": ""}, {"source_code": "#!/usr/bin/php\n 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$s = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n$now = -1;\n$yes = true;\nfor($i = ord(\"a\"); $i <= ord(\"z\"); $i++) {\n $ret = strpos($s, chr($i));\n $lat = $now;\n if($ret === false) {\n $now = 100000;\n }\n else {\n $now = $ret;\n }\n if($now < $lat) {\n $yes = false;\n }\n}\nif($yes) {\n echo \"YES\";\n}\nelse{\n echo \"NO\";\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\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$s = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n$now = -1;\n$yes = true;\nfor($i = ord(\"a\"); $i <= ord(\"z\"); $i++) {\n $ret = strpos($s, chr($i));\n $lat = $now;\n if($ret === false) {\n $now = 100000;\n }\n else {\n $now = $ret;\n }\n if($now < $lat) {\n $yes = false;\n }\n}\nif($yes) {\n echo \"YES\";\n}\nelse{\n echo \"NO\";\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\n?>"}, {"source_code": ""}, {"source_code": "=0; $i--)\n {\n $flag = false;\n if($arr[$i]!='a')\n {\n for($j=$i-1; $j>=0; $j--)\n {\n $buffer = $arr[$j];\n ++$buffer;\n \n if( $arr[$i] == $buffer)\n {\n $flag = true;\n break;\n }\n }\n if(!$flag)\n {\n $ans = 'no';\n break;\n }\n }\n }\n \n echo ($ans == 'no') ? \"NO\\n\" : \"YES\\n\";\n?>\n"}], "negative_code": [{"source_code": " $d[$x + 1])\n {\n $e = 1;\n break;\n }\n}\nif($e == 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "#!/usr/bin/php\n"}], "src_uid": "c4551f66a781b174f95865fa254ca972"} {"nl": {"description": "Let's write all the positive integer numbers one after another from $$$1$$$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...Your task is to print the $$$k$$$-th digit of this sequence.", "input_spec": "The first and only line contains integer $$$k$$$ ($$$1 \\le k \\le 10000$$$) \u2014 the position to process ($$$1$$$-based index).", "output_spec": "Print the $$$k$$$-th digit of the resulting infinite sequence.", "sample_inputs": ["7", "21"], "sample_outputs": ["7", "5"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " $k) {\n break;\n }\n $powers = [$i+2, $powCount, $digitCount];\n }\n\n [$size, $powCount, $digitCount] = $powers;\n $shift = floor(($k - $digitCount) / $size);\n $shift_x = ceil(($k - $digitCount) / $size);\n $key = sprintf('%.0f', $k - $digitCount - ($shift * $size + 1));\n echo (sprintf('%.0f', $powCount + $shift_x))[$key];\n}\n"}], "negative_code": [{"source_code": " $k) {\n break;\n }\n $powers = [$i+2, $powCount, $digitCount];\n }\n\n [$size, $powCount, $digitCount] = $powers;\n $shift = (int)floor(($k - $digitCount) / $size);\n $shift_x = (int)ceil(($k - $digitCount) / $size);\n echo (sprintf('%.0f', $powCount + $shift_x))[$k - $digitCount - ($shift * $size + 1)];\n}\n"}, {"source_code": " $k) {\n break;\n }\n $powers = [$i+2, $powCount, $digitCount];\n }\n\n [$size, $powCount, $digitCount] = $powers;\n $shift = (int)floor(($k - $digitCount) / $size);\n $shift_x = (int)ceil(($k - $digitCount) / $size);\n echo ((string)($powCount + $shift_x))[$k - $digitCount - ($shift * $size + 1)];\n}\n"}, {"source_code": " $k) {\n break;\n }\n $powers = [$i+2, $powCount, $digitCount];\n}\n\n[$size, $powCount, $digitCount] = $powers;\n$shift = (int)floor(($k - $digitCount) / $size);\n$shift_x = (int)ceil(($k - $digitCount) / $size);\necho ((string)($powCount + $shift_x))[$k - $digitCount - ($shift * $size + 1)];\n"}], "src_uid": "1503d761dd4e129fb7c423da390544ff"} {"nl": {"description": "Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.Yakko thrown a die and got Y points, Wakko \u2014 W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.", "input_spec": "The only line of the input file contains two natural numbers Y and W \u2014 the results of Yakko's and Wakko's die rolls.", "output_spec": "Output the required probability in the form of irreducible fraction in format \u00abA/B\u00bb, where A \u2014 the numerator, and B \u2014 the denominator. If the required probability equals to zero, output \u00ab0/1\u00bb. If the required probability equals to 1, output \u00ab1/1\u00bb. ", "sample_inputs": ["4 2"], "sample_outputs": ["1/2"], "notes": "NoteDot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $b)return $a;\n else return $b;\n}\t\n\nfunction gcd($a,$b) {\n\tif ($b == 0)\n\t\treturn $a;\n\treturn gcd($b, $a % $b);\n}\n$r=6-fmax($y,$w)+1;\n$g=gcd($r,6);\n$a1=$r/$g;\n$a2=6/$g;\necho(${a1}.\"/\".${a2});\n?>"}, {"source_code": "\n\n\n"}, {"source_code": "1) {$j=7-$j; \nif(($j%2)==0) { print (($j/2).\"/\".\"3\");};\nif(($j%3)==0) { print (($j/3).\"/\".\"2\");};}\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\nfunction nod($a, $b) {\n\twhile ($a <> 0 && $b <> 0) {\n\t\tif ($a > $b)\n\t\t\t$a = $a % $b;\n\t\telse\n\t\t\t$b = $b % $a;\n\t\t$nod = $a + $b;\n\t}\n\treturn $nod;\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\tlist($n1, $n2) = readStringExplodeNum($f, ' ', true);\n\n\t$goodCnt = 6 - max($n1, $n2) + 1;\n\t$nod = nod($goodCnt, 6);\n\t$base = 6;\n\t$goodCnt/=$nod;\n\t$base/=$nod;\n\n\techo \"{$goodCnt}/{$base}\";\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"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 '';\n}\n\n$stdin = @fopen('data.txt', 'r');\nif (!$stdin) {\n $stdin = fopen('php://stdin', 'r');\n}\n\nfunction g() {\n global $stdin;\n return trim(fgets($stdin));\n}\n\n/****************************************************** Solving block *****************************************************/\nlist($a, $b) = explode(' ', g());\n$max = $a > $b ? $a : $b;\n$max--;\n$points = 6 - $max;\n\nswitch($points) {\n case 0: echo '0/1'; break;\n case 1: echo '1/6'; break;\n case 2: echo '1/3'; break;\n case 3: echo '1/2'; break;\n case 4: echo '2/3'; break;\n case 5: echo '5/6'; break;\n case 6: echo '1/1'; break;\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n\n"}, {"source_code": "\n\n\n"}, {"source_code": "\n\n\n"}, {"source_code": " $w) $m = $y; else $m = $w;\nswitch($m){\n case 1: print '1/1'; break;\n case 2: print '5/6'; break;\n case 3: print '2/3'; break;\n case 4: print '1/2'; break;\n case 5: print '1/3'; break;\n case 6: print '1/6'; break;\n}\n?>"}, {"source_code": ""}, {"source_code": "$b)?($c=$a):($c=$b);\nif($c==6) {print (\"1/\".$c); }\nelseif($c==1) {print ($c.\"/1\"); };\n$s=6-($c-1);\nif (($s%2==0)and($s!=6)and($s!=1)) { print(($s/2).\"/\".(6/2));}\nelseif(($s%3==0)and($s!=6)and($s!=1)) {print (($s/3).\"/\".(6/3));}\nelseif(($s!=6)and($s!=1)) {print(($s).\"/6\");}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\ufeff\n"}, {"source_code": "\ufeff\n"}, {"source_code": "\ufeff\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n\n"}], "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414"} {"nl": {"description": "Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.You are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. Please note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of pieces in the chocolate bar. The second line contains n integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u20091), where 0 represents a piece without the nut and 1 stands for a piece with the nut.", "output_spec": "Print the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.", "sample_inputs": ["3\n0 1 0", "5\n1 0 1 0 1"], "sample_outputs": ["1", "4"], "notes": "NoteIn the first sample there is exactly one nut, so the number of ways equals 1\u00a0\u2014 Bob shouldn't make any breaks.In the second sample you can break the bar in four ways:10|10|11|010|110|1|011|01|01"}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 0) {\n $tempVars ++;\n if ($vars > 0) {\n $vars = $vars * $tempVars;\n } else {\n $vars = $tempVars;\n }\n $tempVars = 0;\n } else {\n \n }\n }\n \n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo number_format($vars, 0, '', '');\n}\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0) {\n $vars ++;\n }\n $tempVars = 0;\n $countMode = false;\n if ($nuts[$i+1] == '0') {\n $countMode = true;\n }\n }\n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo $vars;\n}\n\n?>"}, {"source_code": " 0) {\n $tempVars ++;\n if ($vars > 0) {\n $vars = $vars * $tempVars;\n } else {\n $vars = $tempVars;\n }\n $tempVars = 0;\n } else {\n \n }\n }\n \n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo number_format($vars, 0, '', '');\n}\n\n?>"}, {"source_code": " 0) {\n $tempVars ++;\n if ($vars > 0) {\n $vars = $vars * $tempVars;\n } else {\n $vars = $tempVars;\n }\n $tempVars = 0;\n } else {\n \n }\n }\n \n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo $vars;\n}\n\n?>"}, {"source_code": " 0) {\n $vars ++;\n }\n $tempVars = 0;\n $countMode = false;\n if ($nuts[$i+1] == '0') {\n $countMode = true;\n }\n }\n}\n\necho $vars;\n\n?>"}, {"source_code": ""}, {"source_code": " 0) {\n $vars = $vars + $tempVars;\n $vars ++;\n $countMode = false;\n }\n $tempVars = 0;\n \n if ($nuts[$i+1] == '0') {\n $countMode = true;\n }\n }\n /*\n if ($i == ($length - 1)) {\n if ($tempVars > 0) {\n $vars ++;\n }\n }\n */\n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo $vars;\n}\n\n?>"}, {"source_code": " 0) {\n $tempVars ++;\n if ($vars > 0) {\n $vars = $vars * $tempVars;\n } else {\n $vars = $tempVars;\n }\n $tempVars = 0;\n } else {\n \n }\n }\n \n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo number_format($vars, 0, '', '');\n}\n\n?>"}, {"source_code": " 0)) {\n $vars++;\n }\n $tempVars = 0;\n }\n}\n\necho $vars;\n\n?>"}, {"source_code": " 0) {\n $vars ++;\n }\n $tempVars = 0;\n $countMode = false;\n if ($nuts[$i+1] == '0') {\n $countMode = true;\n }\n }\n}\nif ($vars == 0) {\n echo '1';\n} else {\n echo $vars;\n}\n\n?>"}], "src_uid": "58242665476f1c4fa723848ff0ecda98"} {"nl": {"description": "String can be called correct if it consists of characters \"0\" and \"1\" and there are no redundant leading zeroes. Here are some examples: \"0\", \"10\", \"1001\".You are given a correct string s.You can perform two different operations on this string: swap any pair of adjacent characters (for example, \"101\" \"110\"); replace \"11\" with \"1\" (for example, \"110\" \"10\"). Let val(s) be such a number that s is its binary representation.Correct string a is less than some other correct string b iff val(a)\u2009<\u2009val(b).Your task is to find the minimum correct string that you can obtain from the given one using the operations described above. You can use these operations any number of times in any order (or even use no operations at all).", "input_spec": "The first line contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the length of string s. The second line contains the string s consisting of characters \"0\" and \"1\". It is guaranteed that the string s is correct.", "output_spec": "Print one string \u2014 the minimum correct string that you can obtain from the given one.", "sample_inputs": ["4\n1001", "1\n1"], "sample_outputs": ["100", "1"], "notes": "NoteIn the first example you can obtain the answer by the following sequence of operations: \"1001\" \"1010\" \"1100\" \"100\".In the second example you can't obtain smaller answer no matter what operations you use."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "ac244791f8b648d672ed3de32ce0074d"} {"nl": {"description": "The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third\u00a0\u2014 with the fourth, the fifth\u00a0\u2014 with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.", "input_spec": "The only line contains three integers n, a and b (2\u2009\u2264\u2009n\u2009\u2264\u2009256, 1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009n)\u00a0\u2014 the total number of teams, and the ids of the teams that Arkady is interested in. It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.", "output_spec": "In the only line print \"Final!\" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integer\u00a0\u2014 the number of the round in which teams a and b can meet. The round are enumerated from 1.", "sample_inputs": ["4 1 2", "8 2 6", "8 7 5"], "sample_outputs": ["1", "Final!", "2"], "notes": "NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round."}, "positive_code": [{"source_code": " $d)) || (($c <= $d) && ($b > $d)))\n{\n print \"Final!\";\n}\nelse\n{\n $e = range(1, $a);\n $g = 1;\n $h = 0;\n while(TRUE)\n {\n $f = array();\n for($x = 0; $x < count($e) - 1; $x++)\n {\n if((($e[$x] == $b) && ($e[$x + 1] == $c)) || (($e[$x] == $c) && ($e[$x + 1] == $b)))\n {\n $h = 1;\n break;\n }\n elseif((($e[$x] == $b) && ($e[$x + 1] != $c)) || (($e[$x] != $c) && ($e[$x + 1] == $b)))\n {\n $f[count($f)] = $b;\n }\n elseif((($e[$x] != $b) && ($e[$x + 1] == $c)) || (($e[$x] == $c) && ($e[$x + 1] != $b)))\n {\n $f[count($f)] = $c;\n }\n elseif((($e[$x] != $b) && ($e[$x + 1] != $c)) || (($e[$x] != $c) && ($e[$x + 1] != $b)))\n {\n $f[count($f)] = $e[$x];\n }\n $x++;\n }\n if($h == 0)\n {\n $e = $f;\n $g++;\n }\n else\n {\n break;\n }\n }\n print $g;\n}\n?>"}], "negative_code": [{"source_code": " $d))\n{\n print \"Final!\";\n}\nelse\n{\n $e = range(1, $a);\n $g = 1;\n $h = 0;\n while(TRUE)\n {\n $f = array();\n for($x = 0; $x < count($e) - 1; $x++)\n {\n if((($e[$x] == $b) && ($e[$x + 1] == $c)) || (($e[$x] == $c) && ($e[$x + 1] == $b)))\n {\n $h = 1;\n break;\n }\n elseif((($e[$x] == $b) && ($e[$x + 1] != $c)) || (($e[$x] != $c) && ($e[$x + 1] == $b)))\n {\n $f[count($f)] = $b;\n }\n elseif((($e[$x] != $b) && ($e[$x + 1] == $c)) || (($e[$x] == $c) && ($e[$x + 1] != $b)))\n {\n $f[count($f)] = $c;\n }\n elseif((($e[$x] != $b) && ($e[$x + 1] != $c)) || (($e[$x] != $c) && ($e[$x + 1] != $b)))\n {\n $f[count($f)] = $e[$x];\n }\n $x++;\n }\n if($h == 0)\n {\n $e = $f;\n $g++;\n }\n else\n {\n break;\n }\n }\n print $g;\n}\n?>"}], "src_uid": "a753bfa7bde157e108f34a28240f441f"} {"nl": {"description": "Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the desks in a lane are numbered from 1 to m starting from the blackboard. Note that the lanes go perpendicularly to the blackboard, not along it (see picture).The organizers numbered all the working places from 1 to 2nm. The places are numbered by lanes (i.\u00a0e. all the places of the first lane go first, then all the places of the second lane, and so on), in a lane the places are numbered starting from the nearest to the blackboard (i.\u00a0e. from the first desk in the lane), at each desk, the place on the left is numbered before the place on the right. The picture illustrates the first and the second samples. Santa Clause knows that his place has number k. Help him to determine at which lane at which desk he should sit, and whether his place is on the left or on the right!", "input_spec": "The only line contains three integers n, m and k (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u200910\u2009000, 1\u2009\u2264\u2009k\u2009\u2264\u20092nm)\u00a0\u2014 the number of lanes, the number of desks in each lane and the number of Santa Claus' place.", "output_spec": "Print two integers: the number of lane r, the number of desk d, and a character s, which stands for the side of the desk Santa Claus. The character s should be \"L\", if Santa Clause should sit on the left, and \"R\" if his place is on the right.", "sample_inputs": ["4 3 9", "4 3 24", "2 4 4"], "sample_outputs": ["2 2 L", "4 3 R", "1 2 R"], "notes": "NoteThe first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his place is in the first lane at the second desk on the right."}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb"} {"nl": {"description": "Unary is a minimalistic Brainfuck dialect in which programs are written using only one token. Brainfuck programs use 8 commands: \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" and \",\" (their meaning is not important for the purposes of this problem). Unary programs are created from Brainfuck programs using the following algorithm. First, replace each command with a corresponding binary code, using the following conversion table: \">\" \u2009\u2192\u2009 1000, \"<\" \u2009\u2192\u2009 1001, \"+\" \u2009\u2192\u2009 1010, \"-\" \u2009\u2192\u2009 1011, \".\" \u2009\u2192\u2009 1100, \",\" \u2009\u2192\u2009 1101, \"[\" \u2009\u2192\u2009 1110, \"]\" \u2009\u2192\u2009 1111. Next, concatenate the resulting binary codes into one binary number in the same order as in the program. Finally, write this number using unary numeral system \u2014 this is the Unary program equivalent to the original Brainfuck one.You are given a Brainfuck program. Your task is to calculate the size of the equivalent Unary program, and print it modulo 1000003 (106\u2009+\u20093).", "input_spec": "The input will consist of a single line p which gives a Brainfuck program. String p will contain between 1 and 100 characters, inclusive. Each character of p will be \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" or \",\".", "output_spec": "Output the size of the equivalent Unary program modulo 1000003 (106\u2009+\u20093).", "sample_inputs": [",.", "++++[>,.<-]"], "sample_outputs": ["220", "61425"], "notes": "NoteTo write a number n in unary numeral system, one simply has to write 1 n times. For example, 5 written in unary system will be 11111.In the first example replacing Brainfuck commands with binary code will give us 1101 1100. After we concatenate the codes, we'll get 11011100 in binary system, or 220 in decimal. That's exactly the number of tokens in the equivalent Unary program."}, "positive_code": [{"source_code": "\", \"<\", \"+\", \"-\", \".\", \",\", \"[\", \"]\");\narray_unshift($b, \" \");\nunset($b[0]);\n$c = array(\"1000\", \"1001\", \"1010\", \"1011\", \"1100\", \"1101\", \"1110\", \"1111\");\narray_unshift($c, \" \");\nunset($c[0]);\n$d = \"\";\n$f = \"\";\nfor($x = 0; $x < count($a); $x++)\n{\n $e = array_search($a[$x], $b);\n $d .= $c[$e];\n}\n$e = str_split($d);\n$g = count($e) - 1;\nfor($x = 0; $x < count($e); $x++)\n{\n if($e[$x] == \"1\")\n {\n $f = bcadd(bcpow(2, $g), $f);\n }\n $g--;\n}\nprint bcmod($f, \"1000003\");\n?>"}, {"source_code": "'=>'1000',\n '<'=>'1001',\n '+'=>'1010',\n '-'=>'1011',\n '.'=>'1100',\n ','=>'1101',\n '['=>'1110',\n ']'=>'1111'\n);\n$key = array_keys($s);\n$val = array_values($s);\n$res = str_replace($key, $val, $in);\necho( bcmod(BCBin2Dec($res), (bcadd(bcpow(10,6),3))));\n"}, {"source_code": "\"]=\"1000\";\n$a[\"<\"]=\"1001\";\n$a[\"+\"]=\"1010\";\n$a[\"-\"]=\"1011\";\n$a[\".\"]=\"1100\";\n$a[\",\"]=\"1101\";\n$a[\"[\"]=\"1110\";\n$a[\"]\"]=\"1111\";\n$s=\"\";\n$k=\"0\";\nfor ($i=0;$i"}, {"source_code": "':\n\t\t\t\treturn \"8\";\n\t\t\tcase '<':\n\t\t\t\treturn \"9\";\n\t\t\tcase '+':\n\t\t\t\treturn \"10\";\n\t\t\tcase '-':\n\t\t\t\treturn \"11\";\n\t\t\tcase '.':\n\t\t\t\treturn \"12\";\n\t\t\tcase ',':\n\t\t\t\treturn \"13\";\n\t\t\tcase '[':\n\t\t\t\treturn \"14\";\n\t\t\tcase ']':\n\t\t\t\treturn \"15\";\n\t\t}\n\t}\n\tfunction check($c)\n\t{\n\t\treturn $c == '>' || $c == '<' || $c == '+' || $c == '-' || $c == '.' || $c == ',' || $c == '[' || $c == ']';\n\t}\n\t$stdin = fopen(\"php://stdin\", \"r\");\n\t$str = fgets($stdin);\n\t$len = strlen($str);\n\t$num = \"0\";\n\tfor($i = 0; $i < $len; $i++)\n\t{\n\t\tif(check($str[$i]))\n\t\t{\n\t\t\t$num = bcmul($num, \"16\");\n\t\t\t$num = bcadd($num, gao($str[$i]));\n\t\t}\n\t}\n\techo (bcmod($num, \"1000003\")).\"\\n\";\n?>\n"}], "negative_code": [{"source_code": "\", \"<\", \"+\", \"-\", \".\", \",\", \"[\", \"]\");\narray_unshift($b, \" \");\nunset($b[0]);\n$c = array(\"1000\", \"1001\", \"1010\", \"1011\", \"1100\", \"1101\", \"1110\", \"1111\");\narray_unshift($c, \" \");\nunset($c[0]);\n$d = \"\";\n$f = \"\";\nfor($x = 0; $x < count($a); $x++)\n{\n $e = array_search($a[$x], $b);\n $d .= $c[$e];\n}\n$e = str_split($d);\n$g = count($e) - 1;\nfor($x = 0; $x < count($e); $x++)\n{\n if($e[$x] == \"1\")\n {\n $f += pow(2, $g);\n }\n $g--;\n}\nprint bcmod($f, \"1000003\");\n?>"}, {"source_code": "'=>'1000',\n '<'=>'1001',\n '+'=>'1010',\n '-'=>'1011',\n '.'=>'1100',\n ','=>'1101',\n '['=>'1110',\n ']'=>'1111'\n);\n$key = array_keys($s);\n$val = array_values($s);\n$res = str_replace($key, $val, $in);\necho( bcmod(bindec($res), (bcadd(bcpow(10,6),3))));"}, {"source_code": "':\n\t\t\t\treturn \"8\";\n\t\t\tcase '<':\n\t\t\t\treturn \"9\";\n\t\t\tcase '+':\n\t\t\t\treturn \"10\";\n\t\t\tcase '-':\n\t\t\t\treturn \"11\";\n\t\t\tcase '.':\n\t\t\t\treturn \"12\";\n\t\t\tcase ',':\n\t\t\t\treturn \"13\";\n\t\t\tcase '[':\n\t\t\t\treturn \"14\";\n\t\t\tcase ']':\n\t\t\t\treturn \"15\";\n\t\t}\n\t}\n\t$stdin = fopen(\"php://stdin\", \"r\");\n\t$str = fgets($stdin);\n\t$len = strlen($str);\n\t$num = \"0\";\n\tfor($i = 0; $i < $len-1; $i++)\n\t{\n\t\t$num = bcmul($num, \"16\");\n\t\t$num = bcadd($num, gao($str[$i]));\n\t}\n\techo (bcmod($num, \"1000003\")).\"\\n\";\n?>\n"}], "src_uid": "04fc8dfb856056f35d296402ad1b2da1"} {"nl": {"description": "Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins?", "input_spec": "The single line contains two integers a and b (1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u20096)\u00a0\u2014 the numbers written on the paper by the first and second player, correspondingly.", "output_spec": "Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly.", "sample_inputs": ["2 5", "2 4"], "sample_outputs": ["3 0 3", "2 1 3"], "notes": "NoteThe dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct.You can assume that number a is closer to number x than number b, if |a\u2009-\u2009x|\u2009<\u2009|b\u2009-\u2009x|."}, "positive_code": [{"source_code": " $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\n$f = abs(5 - $a);\n$g = abs(5 - $b);\nif($f > $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\n$f = abs(4 - $a);\n$g = abs(4 - $b);\nif($f > $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\n$f = abs(3 - $a);\n$g = abs(3 - $b);\nif($f > $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\n$f = abs(2 - $a);\n$g = abs(2 - $b);\nif($f > $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\n$f = abs(1 - $a);\n$g = abs(1 - $b);\nif($f > $g)\n{\n $c++;\n}\nelseif($f < $g)\n{\n $d++;\n}\nelse\n{\n $e++;\n}\nprint $d . \" \" . $e . \" \" . $c;\n?>"}, {"source_code": " abs ($B - $i)) {\n $Z = $Z + 1;\n }\n}\nprintf (\"%d %d %d\\n\", $X, $Y, $Z);\n?>"}, {"source_code": " abs( $b - $i ) ) {\n $z = $z + 1;\n }\n }\n printf ( \"%d %d %d\\n\", $x, $y, $z );\n?>"}, {"source_code": " abs($a_b[1] - $i )){\n $b_win++;\n \n }\n else{\n $draw++;\n }\n \n \n \n }\n \n print $a_win . \" \" . $draw . \" \" .$b_win ;\n\n?>"}, {"source_code": " abs($b - $j)) {\n\t\t$result[2]++;\n\t}\n\telseif (abs($a - $j) == abs($b - $j)) {\n\t\t$result[1]++;\n\t}\n\n}\n\nprint implode(' ', $result);\n"}, {"source_code": " $diffb) {\n $wins ++;\n } else {\n $draw ++;\n }\n}\n\nprint $winf . ' ' . $draw . ' ' . $wins;\n\nfunction getline() {\n return trim(fgets(STDIN));\n}\n"}, {"source_code": " abs($b - $i)) {\n $bwins++;\n } else {\n $tie++;\n }\n}\n\necho $awins.\" \".$tie.\" \".$bwins;\n?>"}], "negative_code": [{"source_code": " abs($b - $x)) {\n $bwins++;\n } else {\n $tie++;\n }\n}\n\necho $awins.\" \".$tie.\" \".$bwins;\n?>"}], "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8"} {"nl": {"description": "Any resemblance to any real championship and sport is accidental.The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship: the team that kicked most balls in the enemy's goal area wins the game; the victory gives 3 point to the team, the draw gives 1 point and the defeat gives 0 points; a group consists of four teams, the teams are ranked by the results of six games: each team plays exactly once with each other team; the teams that get places 1 and 2 in the group stage results, go to the next stage of the championship. In the group stage the team's place is defined by the total number of scored points: the more points, the higher the place is. If two or more teams have the same number of points, then the following criteria are used (the criteria are listed in the order of falling priority, starting from the most important one): the difference between the total number of scored goals and the total number of missed goals in the championship: the team with a higher value gets a higher place; the total number of scored goals in the championship: the team with a higher value gets a higher place; the lexicographical order of the name of the teams' countries: the country with the lexicographically smaller name gets a higher place. The Berland team plays in the group where the results of 5 out of 6 games are already known. To be exact, there is the last game left. There the Berand national team plays with some other team. The coach asks you to find such score X:Y (where X is the number of goals Berland scored and Y is the number of goals the opponent scored in the game), that fulfills the following conditions: X > Y, that is, Berland is going to win this game; after the game Berland gets the 1st or the 2nd place in the group; if there are multiple variants, you should choose such score X:Y, where value X\u2009-\u2009Y is minimum; if it is still impossible to come up with one score, you should choose the score where value Y (the number of goals Berland misses) is minimum. ", "input_spec": "The input has five lines. Each line describes a game as \"team1 team2 goals1:goals2\" (without the quotes), what means that team team1 played a game with team team2, besides, team1 scored goals1 goals and team2 scored goals2 goals. The names of teams team1 and team2 are non-empty strings, consisting of uppercase English letters, with length of no more than 20 characters; goals1,\u2009goals2 are integers from 0 to 9. The Berland team is called \"BERLAND\". It is guaranteed that the Berland team and one more team played exactly 2 games and the the other teams played exactly 3 games.", "output_spec": "Print the required score in the last game as X:Y, where X is the number of goals Berland scored and Y is the number of goals the opponent scored. If the Berland team does not get the first or the second place in the group, whatever this game's score is, then print on a single line \"IMPOSSIBLE\" (without the quotes). Note, that the result score can be very huge, 10:0 for example.", "sample_inputs": ["AERLAND DERLAND 2:1\nDERLAND CERLAND 0:3\nCERLAND AERLAND 0:1\nAERLAND BERLAND 2:0\nDERLAND BERLAND 4:0", "AERLAND DERLAND 2:2\nDERLAND CERLAND 2:3\nCERLAND AERLAND 1:3\nAERLAND BERLAND 2:1\nDERLAND BERLAND 4:1"], "sample_outputs": ["6:0", "IMPOSSIBLE"], "notes": "NoteIn the first sample \"BERLAND\" plays the last game with team \"CERLAND\". If Berland wins with score 6:0, the results' table looks like that in the end: AERLAND (points: 9, the difference between scored and missed goals: 4, scored goals: 5) BERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 6) DERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 5) CERLAND (points: 3, the difference between scored and missed goals: -4, scored goals: 3) In the second sample teams \"AERLAND\" and \"DERLAND\" have already won 7 and 4 points, respectively. The Berland team wins only 3 points, which is not enough to advance to the next championship stage."}, "positive_code": [{"source_code": " $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $h[$x] += 3;\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nelseif($d == $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $h[$x] += 1;\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 1;\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nelseif($d < $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 3;\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nif($d2 > $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $h[$x] += 3;\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nelseif($d2 == $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $h[$x] += 1;\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $h[$x] += 1;\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nelseif($d2 < $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $h[$x] += 3;\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nif($d3 > $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $h[$x] += 3;\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b3)\n {\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nelseif($d3 == $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $h[$x] += 1;\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 1;\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nelseif($d3 < $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b3)\n {\n $h[$x] += 3;\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nif($d4 > $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $h[$x] += 3;\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nelseif($d4 == $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $h[$x] += 1;\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $h[$x] += 1;\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nelseif($d4 < $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $h[$x] += 3;\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nif($d5 > $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $h[$x] += 3;\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nelseif($d5 == $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $h[$x] += 1;\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $h[$x] += 1;\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nelseif($d5 < $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $h[$x] += 3;\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nfor($x = 0; $x < 4; $x++)\n{\n if($g[$x] == \"BERLAND\")\n {\n break;\n }\n}\n$k = $h[$x] + 3;\n$l = $h;\nrsort($l);\nif($l[1] > $k)\n{\n print \"IMPOSSIBLE\";\n}\nelse\n{ \n $m = array();\n $n = array();\n $o = array();\n $h[$ber] += 3;\n for($w = 0; $w <= 50; $w++)\n {\n for($x = 0; $x < $w; $x++)\n {\n $g2 = $g;\n $h2 = $h;\n $i2 = $i;\n $j2 = $j;\n $i2[$ber] = $i[$ber] + $w;\n $i2[$reb] = $i[$reb] + $x;\n $j2[$ber] = $j[$ber] + $x;\n $j2[$reb] = $j[$reb] + $w;\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if(($i2[$y] > $i2[$z]) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if((($i2[$y] - $j2[$y]) > ($i2[$z] - $j2[$z])) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if(($h2[$y] > $h2[$z]) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n if(($g2[0] == \"BERLAND\") || ($g2[1] == \"BERLAND\"))\n {\n array_push($m, $w);\n array_push($n, $x);\n array_push($o, $w - $x);\n }\n }\n }\n $s = min($o);\n $t = array();\n $v = array();\n for($x = 0; $x < count($o); $x++)\n {\n if($o[$x] == $s)\n {\n $t[$x] = $n[$x];\n $v[$x] = 1;\n }\n }\n $u = min($t);\n for($x = 0; $x < count($o); $x++)\n {\n if(($n[$x] == $u) && ($v[$x] == TRUE))\n {\n break;\n }\n }\n print $m[$x] . \":\" . $n[$x];\n}\n?>"}], "negative_code": [{"source_code": " $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $h[$x] += 3;\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nelseif($d == $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $h[$x] += 1;\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 1;\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nelseif($d < $e)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a)\n {\n $i[$x] += $d;\n $j[$x] += $e;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 3;\n $i[$x] += $e;\n $j[$x] += $d;\n }\n }\n}\nif($d2 > $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $h[$x] += 3;\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nelseif($d2 == $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $h[$x] += 1;\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $h[$x] += 1;\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nelseif($d2 < $e2)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a2)\n {\n $i[$x] += $d2;\n $j[$x] += $e2;\n }\n if($g[$x] == $b2)\n {\n $h[$x] += 3;\n $i[$x] += $e2;\n $j[$x] += $d2;\n }\n }\n}\nif($d3 > $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $h[$x] += 3;\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b3)\n {\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nelseif($d3 == $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $h[$x] += 1;\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b)\n {\n $h[$x] += 1;\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nelseif($d3 < $e3)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a3)\n {\n $i[$x] += $d3;\n $j[$x] += $e3;\n }\n if($g[$x] == $b3)\n {\n $h[$x] += 3;\n $i[$x] += $e3;\n $j[$x] += $d3;\n }\n }\n}\nif($d4 > $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $h[$x] += 3;\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nelseif($d4 == $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $h[$x] += 1;\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $h[$x] += 1;\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nelseif($d4 < $e4)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a4)\n {\n $i[$x] += $d4;\n $j[$x] += $e4;\n }\n if($g[$x] == $b4)\n {\n $h[$x] += 3;\n $i[$x] += $e4;\n $j[$x] += $d4;\n }\n }\n}\nif($d5 > $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $h[$x] += 3;\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nelseif($d5 == $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $h[$x] += 1;\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $h[$x] += 1;\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nelseif($d5 < $e5)\n{\n for($x = 0; $x < 4; $x++)\n {\n if($g[$x] == $a5)\n {\n $i[$x] += $d5;\n $j[$x] += $e5;\n }\n if($g[$x] == $b5)\n {\n $h[$x] += 3;\n $i[$x] += $e5;\n $j[$x] += $d5;\n }\n }\n}\nfor($x = 0; $x < 4; $x++)\n{\n if($g[$x] == \"BERLAND\")\n {\n break;\n }\n}\n$k = $h[$x] + 3;\n$l = $h;\nrsort($l);\nif($l[1] > $k)\n{\n print \"IMPOSSIBLE\";\n}\nelse\n{ \n $m = array();\n $n = array();\n $o = array();\n $h[$ber] += 3;\n for($w = 0; $w <= 50; $w++)\n {\n for($x = 0; $x < $w; $x++)\n {\n $g2 = $g;\n $h2 = $h;\n $i2 = $i;\n $j2 = $j;\n $i2[$ber] = $i[$ber] + $w;\n $i2[$reb] = $i[$reb] + $x;\n $j2[$ber] = $j[$ber] + $x;\n $j2[$reb] = $j[$reb] + $w;\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if(($i2[$y] > $i2[$z]) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if((($i2[$y] - $j2[$y]) > ($i2[$z] - $j2[$z])) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n for($y = 0; $y < 4; $y++)\n {\n for($z = 0; $z < 4; $z++)\n {\n if(($h2[$y] > $h2[$z]) && ($y > $z))\n {\n $p = $g2[$y];\n $r = $g2[$z];\n array_splice($g2, $y, 1);\n array_splice($g2, $z, 1, array($p, $r));\n $p = $h2[$y];\n $r = $h2[$z];\n array_splice($h2, $y, 1);\n array_splice($h2, $z, 1, array($p, $r));\n $p = $i2[$y];\n $r = $i2[$z];\n array_splice($i2, $y, 1);\n array_splice($i2, $z, 1, array($p, $r));\n $p = $j2[$y];\n $r = $j2[$z];\n array_splice($j2, $y, 1);\n array_splice($j2, $z, 1, array($p, $r));\n }\n }\n }\n if(($g2[0] == \"BERLAND\") || ($g2[1] == \"BERLAND\"))\n {\n array_push($m, $w);\n array_push($n, $x);\n array_push($o, $w - $x);\n }\n }\n }\n $s = min($o);\n $t = array();\n $v = array();\n for($x = 0; $x < count($o); $x++)\n {\n if($o[$x] == $s)\n {\n $t[$x] = $n[$x];\n $v[$x] = 1;\n }\n }\n $u = min($t);\n for($x = 0; $x < count($o); $x++)\n {\n if(($n[$x] == $u) && ($v[$x] == TRUE))\n {\n break;\n }\n }\n print $m[$x] . \":\" . $n[$x];\n}\n?>"}], "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1"} {"nl": {"description": "InputThe input contains a single integer $$$a$$$ ($$$0 \\le a \\le 63$$$).OutputOutput a single number.ExamplesInput\n2\nOutput\n2\nInput\n5\nOutput\n24\nInput\n35\nOutput\n50\n", "input_spec": "The input contains a single integer $$$a$$$ ($$$0 \\le a \\le 63$$$).", "output_spec": "Output a single number.", "sample_inputs": ["2", "5", "35"], "sample_outputs": ["2", "24", "50"], "notes": null}, "positive_code": [{"source_code": "=32){\n $ans+=32;\n $x-=32;\n }\n if($x>=16){\n $ans+=1;\n $x-=16;\n }\n if($x>=8){\n $ans+=4;\n $x-=8;\n }\n if($x>=4){\n $ans+=8;\n $x-=4;\n }\n if($x>=2){\n $ans+=2;\n $x-=2;\n }\n if($x>=1){\n $ans+=16;\n $x-=1;\n }\n print $ans;\n \n}\nfunction main(){\n $t=1;\n //$t=readLine();\n for($i=0;$i<$t;$i++){\n solve($i);\n }\n}\nmain();\n?>"}], "negative_code": [{"source_code": "=32){\n $ans+=32;\n $x-=32;\n }\n if($x>=16){\n $ans+=1;\n $x-=16;\n }\n if($x>=8){\n $ans+=4;\n $x-=8;\n }\n if($x>=4){\n $ans+=8;\n $x-=4;\n }\n if($x>=2){\n $ans+=2;\n $x-=2;\n }\n if($x>=1){\n $ans+=16;\n $x-=1;\n }\n print $ans;\n \n}\nfunction main(){\n $t=1;\n //$t=readLine();\n for($i=0;$i<$t;$i++){\n solve();\n }\n}\nmain();\n?>"}], "src_uid": "db5e54f466e1f3d69a51ea0b346e667c"} {"nl": {"description": "Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.A poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the most formidable professor of all times, a three times Soviet Union Hero, a Noble Prize laureate in student expulsion, venerable Petr Palych.The poor student couldn't answer a single question. Thus, instead of a large spacious office he is going to apply for a job to thorium mines. But wait a minute! Petr Palych decided to give the student the last chance! Yes, that is possible only in dreams. So the professor began: \"Once a Venusian girl and a Marsian boy met on the Earth and decided to take a walk holding hands. But the problem is the girl has al fingers on her left hand and ar fingers on the right one. The boy correspondingly has bl and br fingers. They can only feel comfortable when holding hands, when no pair of the girl's fingers will touch each other. That is, they are comfortable when between any two girl's fingers there is a boy's finger. And in addition, no three fingers of the boy should touch each other. Determine if they can hold hands so that the both were comfortable.\"The boy any the girl don't care who goes to the left and who goes to the right. The difference is only that if the boy goes to the left of the girl, he will take her left hand with his right one, and if he goes to the right of the girl, then it is vice versa.", "input_spec": "The first line contains two positive integers not exceeding 100. They are the number of fingers on the Venusian girl's left and right hand correspondingly. The second line contains two integers not exceeding 100. They are the number of fingers on the Marsian boy's left and right hands correspondingly.", "output_spec": "Print YES or NO, that is, the answer to Petr Palych's question.", "sample_inputs": ["5 1\n10 5", "4 5\n3 3", "1 2\n11 6"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteThe boy and the girl don't really care who goes to the left."}, "positive_code": [{"source_code": "= $e - 2) && ($d <= $f))\n {\n print \"YES\";\n }\n else\n {\n $g = $b;\n $g++;\n $h = $g * 2;\n if(($c >= $g - 2) && ($c <= $h))\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n}\n?>"}, {"source_code": "= (ceil($m_boy_finger/2)-1) && $v_girl_finger <= ($m_boy_finger + 1) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": "=$g[0]-1) || ($b[0]<=$p2 && $b[0]>=$g[1]-1)) echo \"YES\";\nelse echo \"NO\"; \n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 1)\n{\n if($d <= $f)\n {\n print \"YES\";\n }\n else\n {\n if($b > 1)\n {\n if($c <= $h)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n }\n}\nelse\n{\n if($b > 1)\n {\n if($c <= $h)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " $m_boy_finger - 2 && $v_girl_finger <= $m_boy_finger + 1) \n\t && ($m_boy_finger < $v_girl_finger + 1 && $m_boy_finger >= $v_girl_finger - 1 ) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": " $m_boy_finger - 2 && $v_girl_finger <= $m_boy_finger + 1) \n\t && ($m_boy_finger < $v_girl_finger + 1 && $m_boy_finger >= $v_girl_finger - 1 ) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": "= $m_boy_finger - 2 && $v_girl_finger <= $m_boy_finger + 1) \n\t && ($m_boy_finger <= $v_girl_finger + 1 && $m_boy_finger >= $v_girl_finger - 1 ) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": " $m_boy_finger - 2 && $v_girl_finger <= $m_boy_finger + 1) \n\t && ($m_boy_finger < $v_girl_finger + 1 && $m_boy_finger >= $v_girl_finger - 1 ) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": "= (ceil($m_boy_finger/2)-1) && $v_girl_finger <= ($m_boy_finger + 2) ) {\n\t\techo \"YES\";\n\t\texit(0);\n\t}\n}\n\necho \"NO\";\nexit(0);\n"}, {"source_code": "$p1 || $b[1]<$g[0]-1 || $b[0]>$p2 && $b[0]<$g[1]-1) echo \"NO\";\nelse echo \"YES\"; \n?>"}, {"source_code": "$p1 || $b[1]<$g[0]-1 || $b[0]>$p2 || $b[0]<$g[1]-1) echo \"NO\";\nelse echo \"YES\"; \n?>"}, {"source_code": "=$g[0]-1) || ($b[0]<$p2 && $b[0]>=$g[1]-1)) echo \"YES\";\nelse echo \"NO\"; \n?>"}, {"source_code": "$g[0]-1) || ($b[0]<$p2 && $b[0]>$g[1]-1)) echo \"YES\";\nelse echo \"NO\"; \n?>"}, {"source_code": ""}], "src_uid": "36b7478e162be6e985613b2dad0974dd"} {"nl": {"description": "Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty.", "input_spec": "The first line contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009360) \u00a0\u2014 the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009360) \u00a0\u2014 the angles of the sectors into which the pizza was cut. The sum of all ai is 360.", "output_spec": "Print one integer \u00a0\u2014 the minimal difference between angles of sectors that will go to Vasya and Petya.", "sample_inputs": ["4\n90 90 90 90", "3\n100 100 160", "1\n360", "4\n170 30 150 10"], "sample_outputs": ["0", "40", "360", "0"], "notes": "NoteIn first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90\u2009+\u200990)\u2009-\u2009(90\u2009+\u200990)|\u2009=\u20090.In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360\u2009-\u20090|\u2009=\u2009360.In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170\u2009+\u200910)\u2009-\u2009(30\u2009+\u2009150)|\u2009=\u20090.Picture explaning fourth sample:Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector."}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}], "src_uid": "1b6a6aff81911865356ec7cbf6883e82"} {"nl": {"description": "Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1\u2009\u00d7\u2009b1 rectangle, the paintings have shape of a a2\u2009\u00d7\u2009b2 and a3\u2009\u00d7\u2009b3 rectangles.Since the paintings are painted in the style of abstract art, it does not matter exactly how they will be rotated, but still, one side of both the board, and each of the paintings must be parallel to the floor. The paintings can touch each other and the edges of the board, but can not overlap or go beyond the edge of the board. Gerald asks whether it is possible to place the paintings on the board, or is the board he bought not large enough?", "input_spec": "The first line contains two space-separated numbers a1 and b1 \u2014 the sides of the board. Next two lines contain numbers a2,\u2009b2,\u2009a3 and b3 \u2014 the sides of the paintings. All numbers ai,\u2009bi in the input are integers and fit into the range from 1 to 1000.", "output_spec": "If the paintings can be placed on the wall, print \"YES\" (without the quotes), and if they cannot, print \"NO\" (without the quotes).", "sample_inputs": ["3 2\n1 3\n2 1", "5 5\n3 3\n3 3", "4 2\n2 3\n1 2"], "sample_outputs": ["YES", "NO", "YES"], "notes": "NoteThat's how we can place the pictures in the first test:And that's how we can do it in the third one."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "2ff30d9c4288390fd7b5b37715638ad9"} {"nl": {"description": "The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (https://en.wikipedia.org/wiki/Leap_year).", "input_spec": "The only line contains integer y (1000\u2009\u2264\u2009y\u2009<\u2009100'000) \u2014 the year of the calendar.", "output_spec": "Print the only integer y' \u2014 the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.", "sample_inputs": ["2016", "2000", "50501"], "sample_outputs": ["2044", "2028", "50507"], "notes": "NoteToday is Monday, the 13th of June, 2016."}, "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": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2"} {"nl": {"description": "There are five people playing a game called \"Generosity\". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.", "input_spec": "The input consists of a single line containing five integers c1,\u2009c2,\u2009c3,\u2009c4 and c5 \u2014 the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0\u2009\u2264\u2009c1,\u2009c2,\u2009c3,\u2009c4,\u2009c5\u2009\u2264\u2009100).", "output_spec": "Print the only line containing a single positive integer b \u2014 the number of coins in the initial bet of each player. If there is no such value of b, then print the only value \"-1\" (quotes for clarity).", "sample_inputs": ["2 5 4 0 4", "4 5 9 2 1"], "sample_outputs": ["3", "-1"], "notes": "NoteIn the first sample the following sequence of operations is possible: One coin is passed from the fourth player to the second player; One coin is passed from the fourth player to the fifth player; One coin is passed from the first player to the third player; One coin is passed from the fourth player to the second player. "}, "positive_code": [{"source_code": ""}, {"source_code": "0){\necho $initial;\n}else {\necho \"-1\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 0 && $s % 5 == 0)\n {\n fprintf(STDOUT, \"%d\\n\", $s / 5);\n }\n else {\n fprintf(STDOUT, \"-1\\n\");\n }\n?>"}, {"source_code": "0){\n\t\techo $sum/5;\n\t}\n\telse{\n\t\techo \"-1\";\n\t}\n?>"}, {"source_code": ""}, {"source_code": " $value) {\n $sum += (int) $value;\n}\n\nif ((($sum % 5) !== 0) or ($sum == 0)) {\n echo -1;\n} else {\n echo $sum / 5;\n}\n\n?>"}, {"source_code": " 0){\n echo $sum / 5;\n}else{\n echo -1;\n}"}, {"source_code": " 0 && !($sum % 5) ? $sum / 5 : '-1';\n"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0){\n\t\techo \"$sum/5\";\n\t}\n\telse{\n\t\techo \"-1\";\n\t}\n?>"}, {"source_code": ""}, {"source_code": " $value) {\n $sum += (int) $value;\n}\n\nif (($sum % 5) == 0) {\n echo $sum / 5;\n} else {\n echo -1;\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "d6c876a84c7b92141710be5d76536eab"} {"nl": {"description": "Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible.Note that the game consisted of several complete sets.", "input_spec": "The first line contains three space-separated integers k, a and b (1\u2009\u2264\u2009k\u2009\u2264\u2009109, 0\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009109, a\u2009+\u2009b\u2009>\u20090).", "output_spec": "If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.", "sample_inputs": ["11 11 5", "11 2 3"], "sample_outputs": ["1", "-1"], "notes": "NoteNote that the rules of the game in this problem differ from the real table tennis game, for example, the rule of \"balance\" (the winning player has to be at least two points ahead to win a set) has no power within the present problem."}, "positive_code": [{"source_code": " 0)) || (($d == 0) && ($g > 0)))\n{\n print \"-1\";\n}\nelseif(($h >= $g) || ($i >= $f))\n{\n print $d + $e;\n}\nelse\n{\n print \"-1\";\n}\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$k = $dxs->G();\n$a = $dxs->G();\n$b = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\nif ($a < $k and $b < $k) {\n if($a + $b == 0){\n echo 0;\n }\n else{\n echo -1;\n }\n}\nelse if($a < $k and $b % $k != 0){\n echo -1;\n}\nelse if($b < $k and $a % $k != 0){\n echo -1;\n}\nelse{\n echo intdiv($a , $k) + intdiv($b , $k);\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\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$k = $dxs->G();\n$a = $dxs->G();\n$b = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\nif ($a < $k and $b < $k) {\n if($a + $b == 0){\n echo 0;\n }\n else{\n echo -1;\n }\n}\nelse if($a < $k and $b % $k != 0){\n echo -1;\n}\nelse if($b < $k and $a % $k != 0){\n echo -1;\n}\nelse{\n echo intdiv($a , $k) + intdiv($b , $k);\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\n?>"}, {"source_code": "=$k) {\n\n\tif($min >= $k) {\n\n\t\techo $sum;\n\t\tdie();\n\n\n\t}\n\n}\n\nelse if(($resto1==0) && ($max>=$k)) { \n\techo $sum; die(); }\n\n\t// var_dump($resto1==0,$max>=$k);\n\n\necho \"-1\";\n\n?>"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= $g) || ($i >= $f))\n{\n print $d + $e;\n}\nelse\n{\n print \"-1\";\n}\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$k = $dxs->G();\n$a = $dxs->G();\n$b = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\nif ($a < $k and $b < $k) {\n echo -1;\n}\nelse if($a < $k and $b % $k != 0){\n echo -1;\n}\nelse if($b < $k and $a % $k != 0){\n echo -1;\n}\nelse{\n echo intdiv($a , $k) + intdiv($b / $k);\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\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$k = $dxs->G();\n$a = $dxs->G();\n$b = $dxs->G();\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\nif ($a < $k and $b < $k) {\n if($a + $b == 0){\n echo 0;\n }\n else{\n echo -1;\n }\n}\nelse if($a < $k and $b % $k != 0){\n echo -1;\n}\nelse if($b < $k and $a % $k != 0){\n echo -1;\n}\nelse{\n echo intdiv($a , $k) + intdiv($b / $k);\n}\n/////////////////////////////////////////////////////////////////////////////////////////////////\n?>"}], "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2"} {"nl": {"description": "Arkady and his friends love playing checkers on an $$$n \\times n$$$ field. The rows and the columns of the field are enumerated from $$$1$$$ to $$$n$$$.The friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wants to give to his friends one set of candies per each cell of the field: the set of candies for cell $$$(i, j)$$$ will have exactly $$$(i^2 + j^2)$$$ candies of unique type.There are $$$m$$$ friends who deserve the present. How many of these $$$n \\times n$$$ sets of candies can be split equally into $$$m$$$ parts without cutting a candy into pieces? Note that each set has to be split independently since the types of candies in different sets are different.", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le 10^9$$$, $$$1 \\le m \\le 1000$$$)\u00a0\u2014 the size of the field and the number of parts to split the sets into.", "output_spec": "Print a single integer\u00a0\u2014 the number of sets that can be split equally.", "sample_inputs": ["3 3", "6 5", "1000000000 1"], "sample_outputs": ["1", "13", "1000000000000000000"], "notes": "NoteIn the first example, only the set for cell $$$(3, 3)$$$ can be split equally ($$$3^2 + 3^2 = 18$$$, which is divisible by $$$m=3$$$).In the second example, the sets for the following cells can be divided equally: $$$(1, 2)$$$ and $$$(2, 1)$$$, since $$$1^2 + 2^2 = 5$$$, which is divisible by $$$5$$$; $$$(1, 3)$$$ and $$$(3, 1)$$$; $$$(2, 4)$$$ and $$$(4, 2)$$$; $$$(2, 6)$$$ and $$$(6, 2)$$$; $$$(3, 4)$$$ and $$$(4, 3)$$$; $$$(3, 6)$$$ and $$$(6, 3)$$$; $$$(5, 5)$$$. In the third example, sets in all cells can be divided equally, since $$$m = 1$$$."}, "positive_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 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\nlist($n, $m) = $ir->readArrayOfInt(2);\n$fullTimes = intval($n/$m);\n$mod = $n%$m;\n\n$a = array_fill(1,$m, []);\n\nfor ($i=1; $i<=$m; $i++) {\n\tfor ($j=$i; $j<=$m; $j++) {\n\t\t$a[$i][$j] = ( $i*$i + $j*$j )%$m;\n\t\t$a[$j][$i] = $a[$i][$j];\n\t}\n}\n\n$fullCnt = 0;\nfor ($i=1; $i<=$m; $i++) {\n\tfor ($j=1; $j<=$m; $j++) {\n\t\tif ($a[$i][$j] == 0) {\n\t\t\t$fullCnt++;\n\t\t}\n\t}\n}\n\n$halfCnt = 0;\nfor ($i=1; $i<=$m; $i++) {\n\tfor ($j=1; $j<=$mod; $j++) {\n\t\tif ($a[$i][$j] == 0) {\n\t\t\t$halfCnt++;\n\t\t}\n\t}\n}\n\n$quarterCnt = 0;\nfor ($i=1; $i<=$mod; $i++) {\n\tfor ($j=1; $j<=$mod; $j++) {\n\t\tif ($a[$i][$j] == 0) {\n\t\t\t$quarterCnt++;\n\t\t}\n\t}\n}\n\n$totalCnt = bcadd(bcadd(bcmul($fullCnt, bcmul($fullTimes,$fullTimes)), bcmul(bcmul(2,$halfCnt),$fullTimes)), $quarterCnt);\n\necho $totalCnt;\n"}], "negative_code": [], "src_uid": "2ec9e7cddc634d7830575e14363a4657"} {"nl": {"description": "So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks in the same row are numbered from left to right). Let us describe the hopscotch with numbers that denote the number of squares in the row, staring from the lowest one: 1-1-2-1-2-1-2-(1-2)..., where then the period is repeated (1-2). The coordinate system is defined as shown in the figure. Side of all the squares are equal and have length a.Maria is a very smart and clever girl, and she is concerned with quite serious issues: if she throws a stone into a point with coordinates (x,\u2009y), then will she hit some square? If the answer is positive, you are also required to determine the number of the square.It is believed that the stone has fallen into the square if it is located strictly inside it. In other words a stone that has fallen on the square border is not considered a to hit a square.", "input_spec": "The only input line contains three integers: a, x, y, where a (1\u2009\u2264\u2009a\u2009\u2264\u2009100) is the side of the square, x and y (\u2009-\u2009106\u2009\u2264\u2009x\u2009\u2264\u2009106,\u20090\u2009\u2264\u2009y\u2009\u2264\u2009106) are coordinates of the stone.", "output_spec": "Print the number of the square, inside which the stone fell. If the stone is on a border of some stone or outside the court, print \"-1\" without the quotes.", "sample_inputs": ["1 0 0", "3 1 1", "3 0 10", "3 0 7", "3 4 0"], "sample_outputs": ["-1", "1", "5", "-1", "-1"], "notes": null}, "positive_code": [{"source_code": "= $e))\n {\n print \"-1\";\n }\n else\n {\n print \"1\";\n }\n}\nelseif($c > $a)\n{\n $e = floor($c / $a);\n $f = $e % 2;\n $g = ceil($e / 2);\n $h = $e + $g;\n $i = $a / 2;\n $j = ($e / 2) * 3;\n if($f == 0)\n {\n if(($b <= (0 - $a)) || ($b >= $a) || ($b == 0))\n {\n print \"-1\";\n }\n else\n {\n \n if(($b > (0 - $a)) && ($b < 0))\n {\n print $j;\n }\n elseif(($b > 0) && ($b < $a))\n {\n print $j + 1;\n }\n }\n }\n else\n {\n if(($b <= (0 - $i)) || ($b >= $i))\n {\n print \"-1\";\n }\n else\n {\n print $h;\n }\n }\n}\n?>"}], "negative_code": [{"source_code": " $e))\n {\n print \"-1\";\n }\n else\n {\n print \"1\";\n }\n}\nelseif($c > $a)\n{\n $e = floor($c / $a);\n $f = $e % 2;\n $g = ceil($e / 2);\n $h = $e + $g;\n $i = $c / $a;\n $j = ($e / 2) * 3;\n if($f == 0)\n {\n if(($b < (0 - $a)) || ($b > $a) || ($b == 0))\n {\n print \"-1\";\n }\n else\n {\n \n if(($b > (0 - $a)) && ($b < 0))\n {\n print $j;\n }\n elseif(($b > 0) && ($b < $a))\n {\n print $j + 1;\n }\n }\n }\n else\n {\n if(($b < (0 - $i)) && ($b > $i))\n {\n print \"-1\";\n }\n else\n {\n print $h;\n }\n }\n}\n?>"}, {"source_code": " $e))\n {\n print \"-1\";\n }\n else\n {\n print \"1\";\n }\n}\nelseif($c > $a)\n{\n $e = floor($c / $a);\n $f = $e % 2;\n $g = ceil($e / 2);\n $h = $e + $g;\n $i = $a / 2;\n $j = ($e / 2) * 3;\n if($f == 0)\n {\n if(($b <= (0 - $a)) || ($b >= $a) || ($b == 0))\n {\n print \"-1\";\n }\n else\n {\n \n if(($b > (0 - $a)) && ($b < 0))\n {\n print $j;\n }\n elseif(($b > 0) && ($b < $a))\n {\n print $j + 1;\n }\n }\n }\n else\n {\n if(($b <= (0 - $i)) || ($b >= $i))\n {\n print \"-1\";\n }\n else\n {\n print $h;\n }\n }\n}\n?>"}, {"source_code": " $e))\n {\n print \"-1\";\n }\n else\n {\n print \"1\";\n }\n}\nelseif($c > $a)\n{\n $e = floor($c / $a);\n $f = $e % 2;\n $g = ceil($e / 2);\n $h = $e + $g;\n if($f == 0)\n {\n if(($b < (0 - $e)) || ($b > $e) || ($b == 0))\n {\n print \"-1\";\n }\n else\n {\n if(($b > (0 - $a)) && ($b < 0))\n {\n print $h + 1;\n }\n else\n {\n print $h + 2;\n }\n }\n }\n else\n {\n if(($b < (0 - $e)) || ($b > $e))\n {\n print \"-1\";\n }\n else\n {\n print $h;\n }\n }\n}\n?>"}], "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02"} {"nl": {"description": "The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a\u2009>\u20091). Note that the Beaver must use all the pebbles he has, i. e. n\u2009=\u2009a\u00b7b. 10 pebbles are arranged in two rows, each row has 5 pebbles Once the Smart Beaver has arranged the pebbles, he takes back any of the resulting rows (that is, b pebbles) and discards all other pebbles. Then he arranges all his pebbles again (possibly choosing other values of a and b) and takes back one row, and so on. The game continues until at some point the Beaver ends up with exactly one pebble. The game process can be represented as a finite sequence of integers c1,\u2009...,\u2009ck, where: c1\u2009=\u2009n ci\u2009+\u20091 is the number of pebbles that the Beaver ends up with after the i-th move, that is, the number of pebbles in a row after some arrangement of ci pebbles (1\u2009\u2264\u2009i\u2009<\u2009k). Note that ci\u2009>\u2009ci\u2009+\u20091. ck\u2009=\u20091 The result of the game is the sum of numbers ci. You are given n. Find the maximum possible result of the game.", "input_spec": "The single line of the input contains a single integer n \u2014 the initial number of pebbles the Smart Beaver has. The input limitations for getting 30 points are: 2\u2009\u2264\u2009n\u2009\u2264\u200950 The input limitations for getting 100 points are: 2\u2009\u2264\u2009n\u2009\u2264\u2009109 ", "output_spec": "Print a single number \u2014 the maximum possible result of the game.", "sample_inputs": ["10", "8"], "sample_outputs": ["16", "15"], "notes": "NoteConsider the first example (c1\u2009=\u200910). The possible options for the game development are: Arrange the pebbles in 10 rows, one pebble per row. Then c2\u2009=\u20091, and the game ends after the first move with the result of 11. Arrange the pebbles in 5 rows, two pebbles per row. Then c2\u2009=\u20092, and the game continues. During the second move we have two pebbles which can be arranged in a unique way (remember that you are not allowed to put all the pebbles in the same row!) \u2014 2 rows, one pebble per row. c3\u2009=\u20091, and the game ends with the result of 13. Finally, arrange the pebbles in two rows, five pebbles per row. The same logic leads us to c2\u2009=\u20095,\u2009c3\u2009=\u20091, and the game ends with the result of 16 \u2014 the maximum possible result. "}, "positive_code": [{"source_code": ""}, {"source_code": "'; print_r($var); echo '';}\n function read_str(){return trim(fgets($GLOBALS['file']));}\n function read_array(){return explode(' ', read_str());}\n /***************************************************************/\n \n $n = read_str();\n \n function find_max($n)\n {\n $max = $n/2;\n $a=1;\n do\n {\n $a++;\n $b = $n/$a; \n if(is_int($b)) break;\n } while ($a<$max);\n if($a>$max) return 1; \n else return max($a,$b);\n }\n \n function calc($n)\n {\n $count = $n;\n do\n { \n $n = find_max($n);\n $count += $n;\n } while($n != 1);\n \n return $count;\n }\n \n echo calc($n);\n?>"}, {"source_code": "'; print_r($var); echo '';}\n function read_str(){return trim(fgets($GLOBALS['file']));}\n function read_array(){return explode(' ', read_str());}\n /***************************************************************/\n \n $n = read_str();\n\n \n/**\n * Checks if $num is a Prime Number\n * @param int $num\n * @return boolean\n */\nfunction isPrime($num) {\n //1 is not prime. See: http://en.wikipedia.org/wiki/Prime_number#Primality_of_one\n if($num == 1)\n return false;\n\n //2 is prime (the only even number that is prime)\n if($num == 2)\n return true;\n\n /**\n * if the number is divisible by two, then it's not prime and it's no longer\n * needed to check other even numbers\n */\n if($num % 2 == 0) {\n return false;\n }\n\n /**\n * Checks the odd numbers. If any of them is a factor, then it returns false.\n * The sqrt can be an aproximation, hence just for the sake of\n * security, one rounds it to the next highest integer value.\n */\n for($i = 3; $i <= ceil(sqrt($num)); $i = $i + 2) {\n if($num % $i == 0)\n return false;\n }\n\n return true;\n}\n\n\n \n function find_max($n)\n {\n if(isPrime($n)) return 1;\n $max = $n/2;\n $a=1;\n do\n {\n $a++;\n $b = $n/$a; \n\n if(is_int($b)) break;\n } while ($a<$max);\n if($a>$max) return 1; \n else return max($a,$b);\n }\n \n function calc($n)\n { \n $count = $n;\n do\n { \n $n = find_max($n);\n \n $count += $n;\n } while($n != 1);\n \n return $count;\n }\n \n echo calc($n);\n?>"}], "negative_code": [], "src_uid": "821c0e3b5fad197a47878bba5e520b6e"} {"nl": {"description": "There are $$$n$$$ students in a school class, the rating of the $$$i$$$-th student on Codehorses is $$$a_i$$$. You have to form a team consisting of $$$k$$$ students ($$$1 \\le k \\le n$$$) such that the ratings of all team members are distinct.If it is impossible to form a suitable team, print \"NO\" (without quotes). Otherwise print \"YES\", and then print $$$k$$$ distinct numbers which should be the indices of students in the team you form. If there are multiple answers, print any of them.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le k \\le n \\le 100$$$) \u2014 the number of students and the size of the team you have to form. The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 100$$$), where $$$a_i$$$ is the rating of $$$i$$$-th student.", "output_spec": "If it is impossible to form a suitable team, print \"NO\" (without quotes). Otherwise print \"YES\", and then print $$$k$$$ distinct integers from $$$1$$$ to $$$n$$$ which should be the indices of students in the team you form. All the ratings of the students in the team should be distinct. You may print the indices in any order. If there are multiple answers, print any of them. Assume that the students are numbered from $$$1$$$ to $$$n$$$.", "sample_inputs": ["5 3\n15 13 15 15 12", "5 4\n15 13 15 15 12", "4 4\n20 10 40 30"], "sample_outputs": ["YES\n1 2 5", "NO", "YES\n1 2 3 4"], "notes": "NoteAll possible answers for the first example: {1 2 5} {2 3 5} {2 4 5} Note that the order does not matter."}, "positive_code": [{"source_code": ""}, {"source_code": "=$k):\n\n foreach ($uniq as $value) {\n $j++;\n for ($i=0;$i<=count($a);$i++){\n if ($a[$i] == $value):\n $l++;\n $out[]=$i+1;\n break;\n endif;\n }\n if ($l==$k) break;\n }\n\n if ($debug):\n print (\"j:\".$j.\"\\r\\n\");\n print (\"l:\".$l.\"\\r\\n\");\n endif;\n print (\"YES\\r\\n\");\n\n print (implode(\" \",$out).\"\\r\\n\");\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "=$k)\n {\n\techo \"YES\\n\";\n\tfor ($i=0; $i "}, {"source_code": ""}, {"source_code": "=$k):\n foreach ($uniq as $value) {\n for ($i=0;$i<=$k+1;$i++){\n if ($a[$i] == $value):\n $out[]=$i+1;\n $i=0;\n break;\n endif;\n }\n }\n\n\n print (\"YES\\r\\n\");\n print (implode(\" \",$out));\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "=$k):\n\n foreach ($uniq as $value) {\n $j++;\n for ($i=0;$i<=$n;$i++){\n $l++;\n if ($a[$i] == $value):\n $out[]=$i+1;\n break;\n endif;\n }\n }\n\n if ($debug):\n print (\"j:\".$j.\"\\r\\n\");\n print (\"l:\".$l.\"\\r\\n\");\n endif;\n print (\"YES\\r\\n\");\n print (implode(\" \",$out).\"\\r\\n\");\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "=$k):\n foreach ($uniq as $value) {\n for ($i=0;$i<=$k;$i++){\n if ($a[$i] == $value):\n $out[]=$i;\n break;\n endif;\n }\n }\n\n\n print (\"YES\\r\\n\");\n print (implode(\" \",$out));\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "=$k):\n foreach ($uniq as $value) {\n for ($i=0;$i<=$k+1;$i++){\n if ($a[$i] == $value):\n $out[]=$i+1;\n break;\n endif;\n }\n }\n\n\n print (\"YES\\r\\n\");\n print (implode(\" \",$out));\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "$debug=0;\n$b=readline (\"n k:\");\n$a=readline (\"ratings:\");\n$arr1=explode(\" \",$b);\n$a=explode(\" \",$a);\n$n=($arr1[0]);\n$k=($arr1[1]);\n($debug) ? print ($n . \"\\r\\n\"): \"\";\n($debug) ? print ($k . \"\\r\\n\"): \"\";\n($debug) ? print_r ($a): \"\" ;\n$uniq=array_unique($a);\n$out=[];\n\nif (count($uniq)>=$k):\n foreach ($uniq as $value) {\n for ($i=0;$i<=$k;$i++){\n if ($a[$i] == $value):\n $out[]=$i;\n break;\n endif;\n }\n }\n\n\n print (\"YES\\r\\n\");\n print (implode(\" \",$out));\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": "=$k):\n foreach ($uniq as $value) {\n for ($i=0;$i<=$k;$i++){\n if ($a[$i] == $value):\n $out[]=$i+1;\n break;\n endif;\n }\n }\n\n\n print (\"YES\\r\\n\");\n print (implode(\" \",$out));\nelse:\n print(\"NO\");\nendif;\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}], "negative_code": [{"source_code": "\n"}], "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863"} {"nl": {"description": "Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium. The scales is in equilibrium if the total sum of weights on the left pan is equal to the total sum of weights on the right pan.", "input_spec": "The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol \"|\" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially on the left pan of the scale. All weights that are recorded in the sequence after the delimiter are initially on the right pan of the scale. The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet. It is guaranteed that all the English letters in the input data are different. It is guaranteed that the input does not contain any extra characters.", "output_spec": "If you cannot put all the weights on the scales so that the scales were in equilibrium, print string \"Impossible\". Otherwise, print the description of the resulting scales, copy the format of the input. If there are multiple answers, print any of them.", "sample_inputs": ["AC|T\nL", "|ABC\nXYZ", "W|T\nF", "ABC|\nD"], "sample_outputs": ["AC|TL", "XYZ|ABC", "Impossible", "Impossible"], "notes": null}, "positive_code": [{"source_code": "= 0) && (((count($g) - $h) % 2) == 0))\n{\n $i = ($d + $f + count($g)) / 2;\n $j = $i - $d;\n $k = $i - $f;\n $l = implode(\"\", array_splice($c, 0, $d));\n $m = implode(\"\", array_splice($c, $o));\n for($x = 0; $x < $j; $x++)\n {\n $l .= $g[$x];\n }\n for($y = $x; $y < $k + $j; $y++)\n {\n $m .= $g[$y];\n }\n print $l . $m;\n}\nelse\n{\n print \"Impossible\";\n}\n?>"}, {"source_code": "$len2){\n\t\t\t$str2=$str2.$in2[0];\n\t\t\t$in2=substr($in2, 1);\n\t\t}else{\n\t\t\t$str1=$str1.$in2[0];\n\t\t\t$str2=$str2.$in2[1];\n\t\t\t$in2=substr($in2, 2);\n\t\t}\n\n\t}\n\techo $str1.\"|\".$str2;\n}\n\n?>"}], "negative_code": [{"source_code": "= 0) && (((count($g) - $h) % 2) == 0))\n{\n $i = ($d + $f + count($g)) / 2;\n $j = $i - $d;\n $k = $i - $f;\n $l = implode(\"\", array_splice($c, 0, $d));\n $m = implode(\"\", array_splice($c, $o));\n for($x = 0; $x < $j; $x++)\n {\n $l .= $g[$x];\n }\n for($y = $x; $y < $k; $y++)\n {\n $m .= $g[$y];\n }\n print $l . $m;\n}\nelse\n{\n print \"Impossible\";\n}\n?>"}], "src_uid": "917f173b8523ddd38925238e5d2089b9"} {"nl": {"description": "You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.", "input_spec": "The single line of the input contains a pair of integers m, s (1\u2009\u2264\u2009m\u2009\u2264\u2009100,\u20090\u2009\u2264\u2009s\u2009\u2264\u2009900) \u2014 the length and the sum of the digits of the required numbers.", "output_spec": "In the output print the pair of the required non-negative integer numbers \u2014 first the minimum possible number, then \u2014 the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers \"-1 -1\" (without the quotes).", "sample_inputs": ["2 15", "3 0"], "sample_outputs": ["69 96", "-1 -1"], "notes": null}, "positive_code": [{"source_code": "= 0; $x--)\n{\n for($y = 0; $y <= 9; $y++)\n {\n $c[$x] = $y;\n $d = array_sum($c);\n if($d == $b)\n {\n $i = 1;\n break;\n }\n }\n if($d == $b)\n {\n break;\n }\n}\n$e = implode($c);\n$f = array_fill(0, $a, 9);\n$j = 0;\nfor($x = count($f) - 1; $x >= 0; $x--)\n{\n for($y = 9; $y >= 0; $y--)\n {\n $f[$x] = $y;\n $g = array_sum($f);\n if($g == $b)\n {\n $j = 1;\n break;\n }\n }\n if($g == $b)\n {\n break;\n }\n}\nif(($i == 0) || ($j == 0))\n{\n print \"-1 -1\";\n}\nelse\n{\n $h = implode($f);\n print $e . \" \" . $h;\n}\n?>"}, {"source_code": "$m*9 || $s<1) {echo \"-1 -1\"; exit;}\n$j=$s;\nfor ($i=1; $i<=$m; $i++){\n\t$a[0]++;\n\tif ($i==$m) $a[$i]=$j;\n\telse{\n\t\tif ($j>9){\n\t\t\t$a[$i]=9;\n\t\t\t$j-=9;\n\t\t}\n\t\telse{\n\t\t\t$a[$i]=$j-1;\n\t\t\t$j=1;\n\t\t}\n\t}\n}\nfor ($i=$a[0]; $i>0; $i--) echo $a[$i];\necho \" \";\n$j=$s;\nfor ($i=1; $i<=$m; $i++){\n\t$b[0]++;\n\tif ($j>9){\n\t\t$b[$i]=9;\n\t\t$j-=9;\n\t}\n\telse{\n\t\t$b[$i]=$j;\n\t\t$j=0;\n\t}\n}\nfor ($i=1; $i<=$b[0]; $i++) echo $b[$i];\n?>"}, {"source_code": "=9) { \n $mino[$q]+=9;\n $a-=9;\n $q--;\n}\n$mino[$q]+=$a;\n$x=join('',$mino);\necho $x;\necho \"\\n\";\n$s=$jame;\n$q2=$num-1;\n$i=0;\n$maxo=str_split(str_repeat('0',$num));\nwhile ($s >=9 and $i <$num) {\n $maxo[$i]+=9;\n $s-=9;\n $i++;\n}\nif($s !=0){\n @$maxo[$i]+=$s;\n}\n$y=join('',$maxo);\necho $y;"}], "negative_code": [{"source_code": ""}, {"source_code": "=9) { \n $mino[$q]+=9;\n $a-=9;\n $q--;\n}\n$mino[$q]+=$a;\n$x=join('',$mino);\necho $x;\necho \"\\n\";\n$s=$jame;\n$q2=$num-1;\n$i=0;\n$maxo=str_split(str_repeat('0',$num));\nwhile ($s >=9 and $i <$num) {\n $maxo[$i]+=9;\n $s-=9;\n $i++;\n}\nif($s !=0){\n @$maxo[$i]+=$s;\n}\n$y=join('',$maxo);\necho $y;"}, {"source_code": "=9) { \n $mino[$q]+=9;\n $a-=9;\n $q--;\n}\n$mino[$q]+=$a;\necho join('',$mino);\necho \"\\n\";\n$s=$jame;\n$q2=$num-1;\n$i=0;\n$maxo=str_split(str_repeat('0',$num));\nwhile ($s >=9 and $i <$num) {\n $maxo[$i]=9;\n $s-=9;\n $i++;\n}\n@$maxo[$i]+=$s;\necho join('',$maxo);"}, {"source_code": "=9) { \n $mino[$q]+=9;\n $a-=9;\n $q--;\n}\n$mino[$q]+=$a;\n$x=join('',$mino);\necho $x;\necho \"\\n\";\n$s=$jame;\n$q2=$num-1;\n$i=0;\n$maxo=str_split(str_repeat('0',$num));\nwhile ($s >=9 and $i <$num) {\n $maxo[$i]+=9;\n $s-=9;\n $i++;\n}\nif($s !=0){\n @$maxo[$i]+=$s;\n}\n$y=join('',$maxo);\necho $y;"}], "src_uid": "75d062cece5a2402920d6706c655cad7"} {"nl": {"description": "Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.One day in 230 AD Shapur was trying to find out if any one can possibly do calculations faster than him. As a result he made a very great contest and asked every one to come and take part.In his contest he gave the contestants many different pairs of numbers. Each number is made from digits 0 or 1. The contestants should write a new number corresponding to the given pair of numbers. The rule is simple: The i-th digit of the answer is 1 if and only if the i-th digit of the two given numbers differ. In the other case the i-th digit of the answer is 0.Shapur made many numbers and first tried his own speed. He saw that he can perform these operations on numbers of length \u221e (length of a number is number of digits in it) in a glance! He always gives correct answers so he expects the contestants to give correct answers, too. He is a good fellow so he won't give anyone very big numbers and he always gives one person numbers of same length.Now you are going to take part in Shapur's contest. See if you are faster and more accurate.", "input_spec": "There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100.", "output_spec": "Write one line \u2014 the corresponding answer. Do not omit the leading 0s.", "sample_inputs": ["1010100\n0100101", "000\n111", "1110\n1010", "01110\n01100"], "sample_outputs": ["1110001", "111", "0100", "00010"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 1) {\n break;\n }\n}\n\nfor($i = 0; $i 1) {\n break;\n }\n}\n\nfor($i = 0; $i 1) {\n break;\n }\n}\n\nfor($i = 0; $i 1) {\n break;\n }\n}\n\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "';print_r($var);echo '';} \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 $line1 = read_line();\n $line2 = read_line();\n $len = strlen($line1);\n \n for ($i=0; $i<$len; $i++)\n {\n $char1 = $line1[$i];\n $char2 = $line2[$i];\n \n if($char1 == $char2) echo '0';\n else echo '1';\n }\n?>"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " 1) {\n break;\n }\n}\n\nfor($i = 0; $i"}, {"source_code": "$f=fopen(STDIN,\"r\");\n$a=fgets($f);\n$b=fgets($f);\n\nfunction xors($a,$b){\n $r='';\n for ($i=0,$n=strlen($a);$i<$a;$i++){\n //for ($j=$i;$j<$n;$j++){\n if($a[$i]==$b[$i]) $r.='0'; \n else $r.='1'; \n // break;\n //}\n }\n return (int)$r;\n}\necho xors($a,$b);"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "function xors($a,$b){\n\t$r='';\n\tfor ($i=0,$n=strlen($a);$i<$a;$i++){\n\t\tfor ($j=$i,$m=strlen($a);$j<$m;$j++){\n\t\t\tif($a[$i]==$b[$j]) $r.='0'; \n\t\t\telse $r.='1'; \n\t\t\tbreak;\n\t\t}\n\t}\n\treturn $r;\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"nl": {"description": "Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.", "input_spec": "The first line contains two integers n and k (2\u2009\u2264\u2009n\u2009\u2264\u2009100000, 1\u2009\u2264\u2009k\u2009\u2264\u200920).", "output_spec": "If it's impossible to find the representation of n as a product of k numbers, print -1. Otherwise, print k integers in any order. Their product must be equal to n. If there are multiple answers, print any of them.", "sample_inputs": ["100000 2", "100000 20", "1024 5"], "sample_outputs": ["2 50000", "-1", "2 64 2 2 2"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79"} {"nl": {"description": "Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x\u2009\u2260\u2009y) meet in a violent fight, then the pixel that survives the fight immediately changes its color to z (z\u2009\u2260\u2009x;\u00a0z\u2009\u2260\u2009y). Pixels of the same color are friends, so they don't fight.The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous. ", "input_spec": "The first line contains three space-separated integers a, b and c (0\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u2009231;\u00a0a\u2009+\u2009b\u2009+\u2009c\u2009>\u20090) \u2014 the number of red, green and blue pixels, correspondingly.", "output_spec": "Print a single number \u2014 the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.", "sample_inputs": ["1 1 1", "3 1 0"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels.In the second sample the following sequence of fights is possible: red and blue, green and red, red and blue. As a result, after all fights there is one green pixel left."}, "positive_code": [{"source_code": ""}, {"source_code": "= ($f2 + $e2))\n {\n $e = ($m1[0] + $m1[1]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[0] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[2] < $f)\n {\n $g = $f - $m1[2];\n $d = $m1[2] + (($m1[0] - $m1[2]) - ($m1[1] + $m1[2])) + $m1[1] + $m1[2];\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n elseif(($f1 + $e1) < ($f2 + $e2))\n {\n $e = ($m1[1] + $m1[2]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[1] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[0] < $f)\n {\n $g = $f - $m1[0];\n $d = $m1[0] + (($m1[1] - $m1[0]) - ($m1[2] + $m1[0])) + $m1[2] + $m1[0];\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n }\n}\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": "= ($f2 + $e2))\n {\n $e = ($m1[0] + $m1[1]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[0] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[2] < $f)\n {\n $g = $f - $m1[2];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n elseif(($f1 + $e1) < ($f2 + $e2))\n {\n $e = ($m1[1] + $m1[2]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[1] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[0] < $f)\n {\n $g = $f - $m1[0];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n }\n}\n?>"}, {"source_code": "= ($f2 + $e2))\n {\n $e = ($m1[0] + $m1[1]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[0] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[2] < $f)\n {\n $g = $f - $m1[2];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n elseif(($f1 + $e1) < ($f2 + $e2))\n {\n $e = ($m1[1] + $m1[2]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[1] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[0] < $f)\n {\n $g = $f - $m1[0];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": "= ($f2 + $e2))\n {\n $e = ($m1[0] + $m1[1]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[0] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[2] < $f)\n {\n $g = $f - $m1[2];\n $h = $g + ($f - $g) * 2 + $e;\n print $h; \n }\n else\n {\n $h = $f + $e;\n print $h;\n }\n }\n elseif(($f1 + $e1) < ($f2 + $e2))\n {\n $e = ($m1[1] + $m1[2]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[1] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[0] < $f)\n {\n $g = $f - $m1[0];\n $h = $g + ($f - $g) * 2 + $e;\n print $h; \n }\n else\n {\n $h = $f + $e;\n print $h;\n }\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " ($f2 + $e2))\n {\n $e = ($m1[0] + $m1[1]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[0] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[2] < $f)\n {\n $g = $f - $m1[2];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n elseif(($f1 + $e1) <= ($f2 + $e2))\n {\n $e = ($m1[1] + $m1[2]) / 2; // \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0440\u0435\u0447\u0438\n $f = $m1[1] - $e; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432 \u0434\u043e \u0447\u0438\u0441\u0435\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0438\n if($m1[0] < $f)\n {\n $g = $f - $m1[0];\n $d = $g + ($f - $g) * 2 + $e;\n print $d; \n }\n else\n {\n $d = $f + $e;\n print $d;\n }\n }\n }\n}\n?>"}, {"source_code": "1)) {$rez=$rez.\"a\";};\n if ((($b%2)==0)and($b>1)) {$rez=$rez.\"b\";};\n if ((($c%2)==0)and($c>1)) {$rez=$rez.\"c\";};\n return $rez; }\n\nfunction kolvonc(&$a,&$b,&$c)\n { if ((($a%2)!=0)and($a>1)) {$res=$res.\"a\";};\n if ((($b%2)!=0)and($b>1)) {$res=$res.\"b\";};\n if ((($c%2)!=0)and($c>1)) {$res=$res.\"c\";};\n return $res; }\n\nfunction vvod(&$a,&$b,&$c,&$u)\n {if ($u==\"ab\") {$res=(max($a,$b));};\n if ($u==\"bc\") {$res=(max($b,$c));};\n if ($u==\"ac\") {$res=(max($a,$c));};\n if ($u==\"abc\") {$res=(($a+$b+$c)-(min($a,$b,$c)+max($a,$b,$c)));};\n return $res; }\n\nfunction vvodd(&$a,&$b,&$c,&$u)\n {if (($u==\"ab\")and($c<2)) {$res=(min($a,$b));} else{$res=(max($a,$b));};\n if (($u==\"bc\")and($a<2)) {$res=(min($b,$c));} else{$res=(max($b,$c));};\n if (($u==\"ac\")and($b<2)) {$res=(min($a,$c));} else{$res=(max($a,$c));};\n if ($u==\"abc\") {$res=(($a+$b+$c)-(min($a,$b,$c)+max($a,$b,$c)));};\n return $res; }\n\n$m=kolvo($a,$b,$c);\n$n=kolvonc($a,$b,$c);\nif ((strlen($m))>(strlen($n))) {print (vvod($a,$b,$c,$m));} else {print (vvodd($a,$b,$c,$n));} ;\n?>"}], "src_uid": "b8008caf788336775cb8ebb76478b04c"} {"nl": {"description": "You are given three positive integers x,\u2009y,\u2009n. Your task is to find the nearest fraction to fraction whose denominator is no more than n. Formally, you should find such pair of integers a,\u2009b (1\u2009\u2264\u2009b\u2009\u2264\u2009n;\u00a00\u2009\u2264\u2009a) that the value is as minimal as possible.If there are multiple \"nearest\" fractions, choose the one with the minimum denominator. If there are multiple \"nearest\" fractions with the minimum denominator, choose the one with the minimum numerator.", "input_spec": "A single line contains three integers x,\u2009y,\u2009n (1\u2009\u2264\u2009x,\u2009y,\u2009n\u2009\u2264\u2009105).", "output_spec": "Print the required fraction in the format \"a/b\" (without quotes).", "sample_inputs": ["3 7 6", "7 2 4"], "sample_outputs": ["2/5", "7/2"], "notes": null}, "positive_code": [{"source_code": " $b)\n {\n $a -= $b;\n }\n else\n {\n $b -= $a;\n }\n }\n $d /= $a;\n $e /= $a;\n print $d . \"/\" . $e;\n}\nelse\n{\n $d = $a / $b;\n $e = ceil($d * $c);\n $f = $e / $c;\n $g = abs($d - $f);\n $h = $e;\n $h--;\n $i = $c;\n $j = $e;\n $k = $c;\n while(TRUE)\n {\n if(($h == -1) || ($i == -1))\n {\n break;\n }\n else\n {\n $l = $h / $i;\n $m = abs($d - $l);\n if($m <= $g)\n {\n $g = $m;\n $j = $h;\n $k = $i;\n }\n if($l >= $d)\n {\n $h--;\n }\n else\n {\n $i--;\n }\n }\n }\n print $j . \"/\" . $k;\n}\n?>"}], "negative_code": [{"source_code": "= $d)\n {\n $h--;\n }\n else\n {\n $i--;\n }\n }\n }\n print $j . \"/\" . $k;\n}\n?>"}, {"source_code": " 1)\n{\n for($x = 0; $x < $k; $x++)\n {\n array_push($n, $m[$h[$x]]);\n }\n sort($n);\n $o = $n[0];\n for($x = 0; $x < $k; $x++)\n {\n if($m[$h[$x]] == $o)\n {\n array_push($p, $l[$h[$x]]);\n }\n }\n sort($p);\n $r = $p[0];\n print $r . \"/\" . $o;\n}\nelse\n{\n $i = $g[$h[0]];\n print $i;\n}\n?>"}, {"source_code": " 1)\n{\n for($x = 0; $x < $k; $x++)\n {\n array_push($n, $m[$h[$x]]);\n }\n sort($n);\n $o = $n[0];\n for($x = 0; $x < $k; $x++)\n {\n if($m[$h[$x]] == $o)\n {\n array_push($p, $l[$h[$x]]);\n }\n }\n sort($p);\n $r = $p[0];\n print $r . \"/\" . $o;\n}\nelse\n{\n $i = $g[$h[0]];\n print $i;\n}\n?>"}, {"source_code": " $b)\n {\n $a -= $b;\n }\n else\n {\n $b -= $a;\n }\n }\n $d /= $a;\n $e /= $a;\n print $d . \"/\" . $e;\n}\nelse\n{\n $d = $a / $b;\n $e = ceil($d * $c);\n $f = $e / $c;\n $g = abs($d - $f);\n $h = $e;\n $h--;\n $i = $c;\n $j = $e;\n $k = $c;\n while(TRUE)\n {\n if(($h == -1) || ($i == -1))\n {\n break;\n }\n else\n {\n $l = $h / $i;\n $m = abs($d - $l);\n if($m <= $g)\n {\n $g = $m;\n $j = $h;\n $k = $i;\n }\n if($l >= $d)\n {\n $h--;\n }\n else\n {\n $i--;\n }\n }\n }\n print $j . \"/\" . $k;\n}\n?>"}], "src_uid": "827bc6f120aff6a6f04271bc84e863ee"} {"nl": {"description": "In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8\u2009\u00d7\u20098): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone \u2014 neither any other statues, nor Anna, nor Maria.Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is \u2014 to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.", "input_spec": "You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one \u2014 for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is \".\". If a cell has Maria, then it is represented by character \"M\". If a cell has Anna, it is represented by the character \"A\". If a cell has a statue, then the cell is represented by character \"S\". It is guaranteed that the last character of the first row is always \"A\", the first character of the last line is always \"M\". The remaining characters are \".\" or \"S\".", "output_spec": "If Maria wins, print string \"WIN\". If the statues win, print string \"LOSE\".", "sample_inputs": [".......A\n........\n........\n........\n........\n........\n........\nM.......", ".......A\n........\n........\n........\n........\n........\nSS......\nM.......", ".......A\n........\n........\n........\n........\n.S......\nS.......\nMS......"], "sample_outputs": ["WIN", "LOSE", "LOSE"], "notes": null}, "positive_code": [{"source_code": "= 0 && $board[$y - $turn][$x] == 'S') continue;\n if ($y - ($turn + 1) >= 0 && $board[$y - ($turn + 1)][$x] == 'S') continue;\n for ($vy = -1; $vy <= 1; $vy++)\n {\n for ($vx = -1; $vx <= 1; $vx++)\n {\n $ny = $y + $vy;\n $nx = $x + $vx;\n if (ok($ny, $nx) && $now[$ny][$nx])\n {\n $next[$y][$x] = true;\n if ($board[$y][$x] == 'A') return true;\n }\n }\n }\n }\n }\n $now = $next;\n }\n return false;\n}\n\nfunction ok($y, $x)\n{\n return $x >= 0 && $y >= 0 && $x < 8 && $y < 8;\n}\n\ncalc();\n?>\n"}, {"source_code": "= 0 && $board[$y - $turn][$x] == 'S') return false;\n if ($turn >= 8) return true;\n for ($vy = -1; $vy <= 1; $vy++)\n {\n for ($vx = -1; $vx <= 1; $vx++)\n {\n $ny = $y + $vy;\n $nx = $x + $vx;\n if ($ny < 0 || $ny >= 8 || $nx < 0 || $ny >= 8) continue;\n if ($ny - $turn >= 0 && $board[$ny - $turn][$nx] == 'S') continue;\n if (dfs($ny, $nx, $turn + 1)) return true;\n\n }\n }\n return false;\n}\n\ncalc();\n?>\n"}, {"source_code": "=0;$y--) {\n if(in_array($area[$round][$y][$x], array('M'))) {\n for($i=-1;$i<2;$i++) {\n for($n=-1;$n<2;$n++) {\n if(($n==0&&$i==0)||($y+$n)<0||($x+$i)<0||($x+$i)>7||($y+$n)>7){\n continue;\n }\n if(in_array($area[$round][$y+$n][$x+$i], array('A'))){\n die('WIN');\n }\n if(in_array($area[$round][$y+$n][$x+$i], array('.'))){\n $area[$round+1][$y+$n][$x+$i] = 'M';\n }\n }\n }\n }\n }\n }\n $round++;\n for($x=0;$x<8;$x++) {\n for($y=7;$y>=0;$y--) {\n if(in_array($area[$round][$y][$x], array('S'))) {\n $area[$round][$y][$x] = '.';\n if(($y+1)>7) {\n continue;\n }\n $area[$round][$y+1][$x] = 'S';\n }\n }\n }\n\n $mcount = 0;\n for($x=0;$x<8;$x++) {\n for($y=7;$y>=0;$y--) {\n if(in_array($area[$round][$y][$x], array('M'))) {\n $mcount++;\n }\n }\n }\n\n /*echo(\"\\n\".'Round: '.$round.\"\\n\");\n for( $i=0; $i<8; $i++) {\n echo($area[$round-1][$i].' '.$area[$round][$i].\"\\n\");\n }\n echo('M:'.$mcount.\"\\n\");*/\n if($mcount==0) {\n die(\"LOSE\");\n }\n}"}], "negative_code": [{"source_code": "= 0 && $board[$y - $turn][$x] == 'S') return false;\n if ($turn >= 8) return true;\n for ($vy = -1; $vy <= 1; $vy++)\n {\n for ($vx = -1; $vx <= 1; $vx++)\n {\n $ny = $y + $vy;\n $nx = $x + $vx;\n if ($ny < 0 || $ny >= 8 || $nx < 0 || $ny >= 8) continue;\n if ($ny - $turn >= 0 && $board[$ny - $turn][$nx] == 'S') continue;\n if (dfs($ny, $nx, $turn + 1)) return true;\n\n }\n }\n return false;\n}\n\ncalc();\n?>\n"}, {"source_code": "= 0 && $board[$y - $turn][$x] == 'S') return false;\n if ($turn >= 8) return true;\n for ($vy = -1; $vy <= 1; $vy++)\n {\n for ($vx = -1; $vx <= 1; $vx++)\n {\n $ny = $y + $vy;\n $nx = $x + $vx;\n if ($ny < 0 || $ny >= 8 || $nx < 0 || $ny >= 8) continue;\n if ($ny - $turn >= 0 && $board[$ny - $turn][$nx] == 'S') continue;\n if (dfs($ny, $nx, $turn + 1)) return true;\n\n }\n }\n return false;\n}\n\ncalc();\n?>\n"}, {"source_code": "=0;$y--) {\n if(in_array($area[$y][$x], array('S'))) {\n $area[$y][$x] = '.';\n if($y+1 <= 7) {\n if(in_array($area[$y+1][$x], array('M'))) {\n die('LOSE');\n }\n $area[$y+1][$x] = 'S';\n }\n }\n }\n }\n}\n\nfunction is_free_point($x,$y, $area) {\n if(valid_point($x, $y)) {\n if(in_array($area[$y][$x], array('.','A','M'))) {\n return TRUE;\n }\n }\n return FALSE;\n}\n\nfunction is_danger_point($x,$y,$area) {\n if( valid_point($x,($y-1) ) === FALSE || is_free_point($x, ($y-1) , $area) ) {\n return FALSE;\n }\n return TRUE;\n}\n\nfunction valid_point($x,$y) {\n if($x > 7 || $y > 7 || $x < 0 || $y < 0) {\n return FALSE;\n }\n return TRUE;\n}"}, {"source_code": "=0;$y--) {\n if(in_array($area[$y][$x], array('S'))) {\n $area[$y][$x] = '.';\n if($y+1 <= 7) {\n if(in_array($area[$y+1][$x], array('M'))) {\n die('LOSE');\n }\n $area[$y+1][$x] = 'S';\n }\n }\n }\n }\n}\n\nfunction is_free_point($x,$y, $area) {\n if(valid_point($x, $y)) {\n if(in_array($area[$y][$x], array('.','A','M'))) {\n return TRUE;\n }\n }\n return FALSE;\n}\n\nfunction is_danger_point($x,$y,$area) {\n if( valid_point($x,($y-1) ) === FALSE || is_free_point($x, ($y-1) , $area) ) {\n return FALSE;\n }\n return TRUE;\n}\n\nfunction valid_point($x,$y) {\n if($x > 7 || $y > 7 || $x < 0 || $y < 0) {\n return FALSE;\n }\n return TRUE;\n}"}], "src_uid": "f47e4ab041288ba9567c19930eb9a090"} {"nl": {"description": "For a positive integer n let's define a function f:f(n)\u2009=\u2009\u2009-\u20091\u2009+\u20092\u2009-\u20093\u2009+\u2009..\u2009+\u2009(\u2009-\u20091)nn Your task is to calculate f(n) for a given integer n.", "input_spec": "The single line contains the positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091015).", "output_spec": "Print f(n) in a single line.", "sample_inputs": ["4", "5"], "sample_outputs": ["2", "-3"], "notes": "Notef(4)\u2009=\u2009\u2009-\u20091\u2009+\u20092\u2009-\u20093\u2009+\u20094\u2009=\u20092f(5)\u2009=\u2009\u2009-\u20091\u2009+\u20092\u2009-\u20093\u2009+\u20094\u2009-\u20095\u2009=\u2009\u2009-\u20093"}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0 ; $i--) { \n $char = $input_line[$i];\n if ($char === '9') {\n $input_line[$i] = '0';\n } else {\n $k = (int) $char;\n $k ++;\n $input_line[$i] = (string) $k;\n break;\n }\n }\n if ($i < 0) {\n echo '-' . bcdiv('1'.$input_line, '2');\n } else {\n echo '-' . bcdiv($input_line, '2');\n }\n}\n\n?>"}, {"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": " 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\nfunction mint($a, $b){if($a<$b){return $a;}else{return $b;}}\nfunction maxt($a, $b){if($a>$b){return $a;}else{return $b;}}\n\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n\n$a=$dxs-> G(); \n$b=$dxs-> G(); \n$jo=$dxs-> G();\n\n$res1 = $a+$a+$b+$b;\n$res2 = $a+$jo+$b;\n$res3 = $a+$jo+$jo+$a;\n$res4 = $b+$jo+$jo+$b;\n\n$res = mint($res1, mint($res2, mint($res3, $res4)));\n\necho $res+\"\\n\";\n\n////////////////////////////////// PRINT OUTPUT ////////////////////////////////////////////////\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\n\n// $x = $dxs-> G(); equivalent to cin>>x; [G() like Get] and for read a complete line//\n// $line = $dxs->GL(); // GL() like GetLine then i can emulate cin>> of C++ //\n// :P for see this template in action see my submissions ;) oh! i was forget that the constructor //\n// $dxs = newSdtIn(true) is 'true' //\n// if you are testing localy then read of input.txt, for submit the code change this to 'false'..//\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_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*/ $dxs = new stdIn(false);\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////// DECLARE FUNCTIONS ///////////////////////////////////////\n\nfunction mint($a, $b){if($a<$b){return $a;}else{return $b;}}\nfunction maxt($a, $b){if($a>$b){return $a;}else{return $b;}}\n\n/////////////////////////////////// MAIN CODE /////////////////////////////////////////////////\n\n$a=$dxs-> G(); \n$b=$dxs-> G(); \n$jo=$dxs-> G();\n\n$res1 = $a+$a+$b+$b;\n$res2 = $a+$jo+$b;\n$res3 = $a+$jo+$a;\n$res4 = $b+$jo+$b;\n\n$res = mint($res1, mint($res2, mint($res3, $res4)));\n\necho $res+\"\\n\";\n\n////////////////////////////////// PRINT OUTPUT ////////////////////////////////////////////////\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\n\n// $x = $dxs-> G(); equivalent to cin>>x; [G() like Get] and for read a complete line//\n// $line = $dxs->GL(); // GL() like GetLine then i can emulate cin>> of C++ //\n// :P for see this template in action see my submissions ;) oh! i was forget that the constructor //\n// $dxs = newSdtIn(true) is 'true' //\n// if you are testing localy then read of input.txt, for submit the code change this to 'false'..//\n?>"}, {"source_code": "=$d2)\n{\n\t$min=$d2;\n\t$store=$d1;\n}\nelse\n{\n\t$min=$d1;\n\t$store=$d2;\n}\nif($d1+$d2>=$d3)\n$min1=$d3;\nelse\n$min1=$d1+$d2;\necho $min+$store+$min1;"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "26cd7954a21866dbb2824d725473673e"} {"nl": {"description": "Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $$$f(599) = 6$$$: $$$599 + 1 = 600 \\rightarrow 60 \\rightarrow 6$$$; $$$f(7) = 8$$$: $$$7 + 1 = 8$$$; $$$f(9) = 1$$$: $$$9 + 1 = 10 \\rightarrow 1$$$; $$$f(10099) = 101$$$: $$$10099 + 1 = 10100 \\rightarrow 1010 \\rightarrow 101$$$. We say that some number $$$y$$$ is reachable from $$$x$$$ if we can apply function $$$f$$$ to $$$x$$$ some (possibly zero) times so that we get $$$y$$$ as a result. For example, $$$102$$$ is reachable from $$$10098$$$ because $$$f(f(f(10098))) = f(f(10099)) = f(101) = 102$$$; and any number is reachable from itself.You are given a number $$$n$$$; your task is to count how many different numbers are reachable from $$$n$$$.", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$).", "output_spec": "Print one integer: the number of different numbers that are reachable from $$$n$$$.", "sample_inputs": ["1098", "10"], "sample_outputs": ["20", "19"], "notes": "NoteThe numbers that are reachable from $$$1098$$$ are:$$$1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099$$$."}, "positive_code": [{"source_code": " 1);\nwhile(TRUE)\n{\n $a = intval($a);\n $a += 1;\n while(TRUE)\n {\n $a = strval($a);\n if($a[strlen($a) - 1] == 0)\n {\n $a = substr($a, 0, -1);\n }\n else\n {\n break;\n }\n }\n if($c[$a] == 1)\n {\n break;\n }\n else\n {\n $b++;\n $c[$a] = 1;\n }\n}\nprint $b;\n?>"}, {"source_code": " $sV){\n if($sK != 0){\n $iCount += 9 - $sV;\n }\n }\n}\n\necho $iCount;\n\n"}, {"source_code": " $v) {\n if ($k != 0) {\n $i += 9 - $v;\n }\n }\n echo $i;\n?>"}], "negative_code": [{"source_code": " 1) { $n = f($n); $c++; }\n\necho $c;"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "055fbbde4b9ffd4473e6e716da6da899"} {"nl": {"description": "Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1\u2009234\u2009567 game-coins each), cars (for 123\u2009456 game-coins each) and computers (for 1\u2009234 game-coins each).Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a\u2009\u00d7\u20091\u2009234\u2009567\u2009+\u2009b\u2009\u00d7\u2009123\u2009456\u2009+\u2009c\u2009\u00d7\u20091\u2009234\u2009=\u2009n?Please help Kolya answer this question.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009109)\u00a0\u2014 Kolya's initial game-coin score.", "output_spec": "Print \"YES\" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print \"NO\" (without quotes).", "sample_inputs": ["1359257", "17851817"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1\u2009234\u2009567\u2009+\u2009123\u2009456\u2009+\u20091234\u2009=\u20091\u2009359\u2009257 game-coins in total."}, "positive_code": [{"source_code": ""}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $n += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n {\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 123456)\n {\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 1234)\n {\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 1234567)\n {\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 123456)\n {\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 1234)\n {\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n {\n $a -= 1234567;\n $b = $a % 123456;\n $c = $b % 1234;\n if($c == 0)\n {\n $e = 1;\n break;\n }\n }\n elseif($a > 123456)\n {\n $a -= 123456;\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n elseif($a > 1234)\n {\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n }\n $a = $f;\n for($x = 1; $x <= 1000; $x++)\n {\n if($a > 123456)\n {\n $a -= 123456;\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n elseif($a > 1234)\n {\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n }\n if($e == 1)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": ""}, {"source_code": " 1234567)\n {\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 123456)\n {\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 1234)\n {\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 1234567)\n {\n $a -= 1234567;\n $b = $a % 123456;\n $c = $b % 1234;\n if($c == 0)\n {\n $e = 1;\n break;\n }\n }\n elseif($a > 123456)\n {\n $a -= 123456;\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n elseif($a > 1234)\n {\n $b = $a % 1234;\n if($b == 0)\n {\n $e = 1;\n break;\n }\n }\n }\n if($e == 1)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 1234567)\n {\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 123456)\n {\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 1234)\n {\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": " 1234567)\n{\n $i = floor(bcdiv($a , 1234567));\n $j = bcmod($a, 1234567);\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor(bcdiv($j, 123456));\n $m = bcmod($j, 123456);\n for($y = 1; $y <= $l; $y++)\n {\n $n = bcmod($m, 1234);\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m = bcadd($m, 123456);\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j = bcadd($j, 1234567);\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n if($m < 123456)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n }\n else\n {\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n{\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n if($j < 123456)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n }\n }\n else\n {\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n if($m < 123456)\n {\n $k = 1;\n break;\n }\n else\n {\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 123456)\n{\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n}\nelseif($a > 1234)\n{\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " 1234567)\n {\n $i = floor($a / 1234567);\n $j = $a % 1234567;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = floor($j / 123456);\n $m = $j % 123456;\n for($y = 1; $y <= $l; $y++)\n {\n $n = $m % 1234;\n if($n == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $m += 123456;\n }\n }\n if($k == 1)\n {\n break;\n }\n else\n {\n $j += 1234567;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 123456)\n {\n $i = floor($a / 123456);\n $j = $a % 123456;\n $k = 0;\n for($x = 1; $x <= $i; $x++)\n {\n $l = $j % 1234;\n if($l == 0)\n {\n $k = 1;\n break;\n }\n else\n {\n $j += 123456;\n }\n }\n if($k == 0)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n elseif($a > 1234)\n {\n $i = $a % 1234;\n if($i == 0)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n }\n else\n {\n print \"NO\";\n }\n}\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "6bcb324c072f796f4d50bafea5f624b2"} {"nl": {"description": "Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments, check if he can choose exactly 3 of them to form a non-degenerate triangle.Mahmoud should use exactly 3 line segments, he can't concatenate two line segments or change any length. A non-degenerate triangle is a triangle with positive area.", "input_spec": "The first line contains single integer n (3\u2009\u2264\u2009n\u2009\u2264\u2009105)\u00a0\u2014 the number of line segments Mahmoud has. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the lengths of line segments Mahmoud has.", "output_spec": "In the only line print \"YES\" if he can choose exactly three line segments and form a non-degenerate triangle with them, and \"NO\" otherwise.", "sample_inputs": ["5\n1 5 3 2 4", "3\n4 1 2"], "sample_outputs": ["YES", "NO"], "notes": "NoteFor the first example, he can use line segments with lengths 2, 4 and 5 to form a non-degenerate triangle."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "$max)) {\t\n\t\techo \"YES\";\n\t\tdie();\t}\n\n}\n\n$i++;\n\n}\n\necho \"NO\";\n\n\n\n?>"}, {"source_code": "$arr[$i+2] &&\n $arr[$i+2] + $arr[$i+1]>$arr[$i] &&\n $arr[$i] + $arr[$i+2]>$arr[$i+1])\n {\n $flag = true;\n break;\n }\n }\n echo ($flag ? \"YES\" : \"NO\") . PHP_EOL;\n?>"}], "negative_code": [{"source_code": "$max)) {\t\n\t\techo \"YES\";\n\t\tbreak 2;\n\t}\n\n}\n\n$i++;\n\n}\n\n\n\n\n?>"}, {"source_code": "=$max) {\t\n\t\techo \"YES\";\n\t\tbreak 2;\n\t}\n\n}\n\n$i++;\n\n}\n\n\n\n\n?>"}, {"source_code": "$max)) {\t\n\t\techo \"YES\";\n\t\tbreak 2;\n\t}\n\n}\n\n$i++;\n\n}\n\n\n\n\n?>"}, {"source_code": "$arr[$i+2] &&\n $arr[$i+2] + $arr[$i+1]>$arr[$i] &&\n $arr[$i] + $arr[$i+2]>$arr[$i+1])\n {\n $flag = true;\n break;\n }\n }\n echo ($flag ? \"YES\" : \"NO\") . PHP_EOL;\n?>\n"}], "src_uid": "897bd80b79df7b1143b652655b9a6790"} {"nl": {"description": "Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him tj minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.By solving subtask of arbitrary problem he earns one point. Thus, the number of points for task is equal to the number of solved subtasks in it. Moreover, if Polycarp completely solves the task (solves all k of its subtasks), he recieves one extra point. Thus, total number of points he recieves for the complete solution of the task is k\u2009+\u20091.Polycarp has M minutes of time. What is the maximum number of points he can earn?", "input_spec": "The first line contains three integer numbers n, k and M (1\u2009\u2264\u2009n\u2009\u2264\u200945, 1\u2009\u2264\u2009k\u2009\u2264\u200945, 0\u2009\u2264\u2009M\u2009\u2264\u20092\u00b7109). The second line contains k integer numbers, values tj (1\u2009\u2264\u2009tj\u2009\u2264\u20091000000), where tj is the time in minutes required to solve j-th subtask of any task.", "output_spec": "Print the maximum amount of points Polycarp can earn in M minutes.", "sample_inputs": ["3 4 11\n1 2 3 4", "5 5 10\n1 2 4 8 16"], "sample_outputs": ["6", "7"], "notes": "NoteIn the first example Polycarp can complete the first task and spend 1\u2009+\u20092\u2009+\u20093\u2009+\u20094\u2009=\u200910 minutes. He also has the time to solve one subtask of the second task in one minute.In the second example Polycarp can solve the first subtask of all five tasks and spend 5\u00b71\u2009=\u20095 minutes. Also he can solve the second subtasks of two tasks and spend 2\u00b72\u2009=\u20094 minutes. Thus, he earns 5\u2009+\u20092\u2009=\u20097 points in total."}, "positive_code": [{"source_code": " 0)\n {\n $f += $a;\n }\n}\nif(($x == $b - 1) && ($i == 0))\n{\n $f += $a;\n}\nelseif(($x == $b - 1) && ($i == 1))\n{\n $f += $h;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\nfor($x = 0; $x < $a; $x++)\n{\n $c2 = $c;\n $k = 0;\n for($y = 0; $y <= $x; $y++)\n {\n $c2 -= $j;\n if($c2 < 0)\n {\n $c2 += $j;\n break;\n }\n elseif($c2 == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c2 > 0)\n {\n $k += $b + 1;\n }\n }\n if($c2 > 0)\n {\n $i = 0;\n for($z = 0; $z < $b; $z++)\n {\n $g = $d[$z] * ($a - $y);\n $c2 -= $g;\n if($c2 < 0)\n {\n $c2 += $g;\n $h = floor($c2 / $d[$z]);\n $k += $h;\n $i = 1;\n break;\n }\n elseif($c2 == 0)\n {\n $k += ($a - $y);\n break;\n }\n elseif($c2 > 0)\n {\n $k += ($a - $y);\n }\n }\n if(($z == $b - 1) && ($i == 0))\n {\n $k += ($a - $y);\n }\n elseif(($z == $b - 1) && ($i == 1))\n {\n $k += $h;\n }\n }\n $e[count($e)] = $k;\n}\nprint max($e);\n?>"}], "negative_code": [{"source_code": " 0)\n {\n $f += $a;\n }\n}\nif(($x == $b - 1) && ($i == 0))\n{\n $f += $a;\n}\nelseif(($x == $b - 1) && ($i == 1))\n{\n $f += $h;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\n$k = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $c -= $j;\n if($c < 0)\n {\n $c += $j;\n $a -= $x;\n for($y = 0; $y < $b; $y++)\n {\n $g = $d[$y] * $a;\n $c -= $g;\n if($c < 0)\n {\n $c += $g;\n $h = floor($c / $d[$y]);\n $k += $h;\n break;\n }\n elseif($c == 0)\n {\n $k += $a;\n break;\n }\n elseif($c > 0)\n {\n $k += $a;\n }\n }\n break;\n }\n elseif($c == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c > 0)\n {\n $k += $b + 1;\n }\n}\n$e[count($e)] = $k;\nprint max($e);\n?>"}, {"source_code": " 0)\n {\n $f += $a;\n }\n}\n$i = $a * $b;\nif($f == $i)\n{\n $f += $a;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\n$k = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $c -= $j;\n if($c < 0)\n {\n $c += $j;\n $a -= $x;\n for($y = 0; $y < $b; $y++)\n {\n $g = $d[$y] * $a;\n $c -= $g;\n if($c < 0)\n {\n $c += $g;\n $h = floor($c / $d[$y]);\n $k += $h;\n break;\n }\n elseif($c == 0)\n {\n $k += $a;\n break;\n }\n elseif($c > 0)\n {\n $k += $a;\n }\n }\n break;\n }\n elseif($c == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c > 0)\n {\n $k += $b + 1;\n }\n}\n$e[count($e)] = $k;\nprint max($e);\n?>"}, {"source_code": " 0)\n {\n $f += $a;\n }\n}\n$i = $a * $b;\nif($f == $i)\n{\n $f += $a;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\n$k = 0;\nfor($x = 0; $x < $a; $x++)\n{\n $c -= $j;\n if($c < 0)\n {\n $c += $j;\n $a -= $x;\n for($y = 0; $y < $b; $y++)\n {\n $g = $d[$y] * $a;\n $c -= $g;\n if($c < 0)\n {\n $c += $g;\n $h = floor($c / $d[$y]);\n $k += $h;\n break;\n }\n elseif($c == 0)\n {\n $k += $a;\n break;\n }\n elseif($c > 0)\n {\n $k += $a;\n }\n }\n break;\n }\n elseif($c == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c > 0)\n {\n $k += $b + 1;\n }\n}\n$e[count($e)] = $k;\nprint max($e);\n?>"}, {"source_code": " 0)\n {\n $f += $a;\n }\n}\nif(($x == $b - 1) && ($i == 0))\n{\n $f += $a;\n}\nelseif(($x == $b - 1) && ($i == 1))\n{\n $f += $h;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\nfor($x = 0; $x < $a; $x++)\n{\n $c2 = $c;\n $k = 0;\n for($y = 0; $y <= $x; $y++)\n {\n $c2 -= $j;\n if($c2 < 0)\n {\n $c2 += $j;\n for($z = 0; $z < $b; $z++)\n {\n $g = $d[$z] * ($a - $y);\n $c2 -= $g;\n if($c2 < 0)\n {\n $c2 += $g;\n $h = floor($c2 / $d[$z]);\n $k += $h;\n $c2 -= $g;\n break;\n }\n elseif($c2 == 0)\n {\n $k += ($a - $y);\n break;\n }\n elseif($c2 > 0)\n {\n $k += ($a - $y);\n }\n }\n break;\n }\n elseif($c2 == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c2 > 0)\n {\n $k += $b + 1;\n }\n }\n if($c2 > 0)\n {\n $i = 0;\n for($z = 0; $z < $b; $z++)\n {\n $g = $d[$z] * ($a - $y);\n $c2 -= $g;\n if($c2 < 0)\n {\n $c2 += $g;\n $h = floor($c2 / $d[$z]);\n $k += $h;\n break;\n }\n elseif($c2 == 0)\n {\n $k += ($a - $y);\n break;\n }\n elseif($c2 > 0)\n {\n $k += ($a - $y);\n }\n }\n if(($x == $b - 1) && ($i == 0))\n {\n $k += ($a - $y);\n }\n elseif(($x == $b - 1) && ($i == 1))\n {\n $k += $h;\n }\n }\n $e[count($e)] = $k;\n}\nprint max($e);\n?>"}, {"source_code": " 0)\n {\n $f += $a;\n }\n}\nif(($x == $b - 1) && ($i == 0))\n{\n $f += $a;\n}\nelseif(($x == $b - 1) && ($i == 1))\n{\n $f += $h;\n}\n$e[count($e)] = $f;\n$j = array_sum($d);\nfor($x = 0; $x < $a; $x++)\n{\n $c2 = $c;\n $k = 0;\n for($y = 0; $y <= $x; $y++)\n {\n $c2 -= $j;\n if($c2 < 0)\n {\n $c2 += $j;\n for($z = 0; $z < $b; $z++)\n {\n $g = $d[$z] * ($a - $y);\n $c2 -= $g;\n if($c2 < 0)\n {\n $c2 += $g;\n $h = floor($c2 / $d[$z]);\n $k += $h;\n break;\n }\n elseif($c2 == 0)\n {\n $k += ($a - $y);\n break;\n }\n elseif($c2 > 0)\n {\n $k += ($a - $y);\n }\n }\n break;\n }\n elseif($c2 == 0)\n {\n $k += $b + 1;\n break;\n }\n elseif($c2 > 0)\n {\n $k += $b + 1;\n }\n }\n if($c2 > 0)\n {\n $i = 0;\n for($z = 0; $z < $b; $z++)\n {\n $g = $d[$z] * ($a - $y);\n $c2 -= $g;\n if($c2 < 0)\n {\n $c2 += $g;\n $h = floor($c2 / $d[$z]);\n $k += $h;\n break;\n }\n elseif($c2 == 0)\n {\n $k += ($a - $y);\n break;\n }\n elseif($c2 > 0)\n {\n $k += ($a - $y);\n }\n }\n if(($x == $b - 1) && ($i == 0))\n {\n $k += ($a - $y);\n }\n elseif(($x == $b - 1) && ($i == 1))\n {\n $k += $h;\n }\n }\n $e[count($e)] = $k;\n}\nprint max($e);\n?>"}], "src_uid": "d659e92a410c1bc836be64fc1c0db160"} {"nl": {"description": "One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0,\u20090,\u20090), and the opposite one is at point (x1,\u2009y1,\u2009z1). The six faces of the box contain some numbers a1,\u2009a2,\u2009...,\u2009a6, exactly one number right in the center of each face. The numbers are located on the box like that: number a1 is written on the face that lies on the ZOX plane; a2 is written on the face, parallel to the plane from the previous point; a3 is written on the face that lies on the XOY plane; a4 is written on the face, parallel to the plane from the previous point; a5 is written on the face that lies on the YOZ plane; a6 is written on the face, parallel to the plane from the previous point. At the moment Vasya is looking at the box from point (x,\u2009y,\u2009z). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai\u2009=\u20096, then he can't mistake this number for 9 and so on). ", "input_spec": "The fist input line contains three space-separated integers x, y and z (|x|,\u2009|y|,\u2009|z|\u2009\u2264\u2009106) \u2014 the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1\u2009\u2264\u2009x1,\u2009y1,\u2009z1\u2009\u2264\u2009106) \u2014 the coordinates of the box's vertex that is opposite to the vertex at point (0,\u20090,\u20090). The third line contains six space-separated integers a1,\u2009a2,\u2009...,\u2009a6 (1\u2009\u2264\u2009ai\u2009\u2264\u2009106) \u2014 the numbers that are written on the box faces. It is guaranteed that point (x,\u2009y,\u2009z) is located strictly outside the box.", "output_spec": "Print a single integer \u2014 the sum of all numbers on the box faces that Vasya sees.", "sample_inputs": ["2 2 2\n1 1 1\n1 2 3 4 5 6", "0 0 10\n3 2 3\n1 2 3 4 5 6"], "sample_outputs": ["12", "4"], "notes": "NoteThe first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6 (on the right face that is the lightest) and a4 (on the left visible face).In the second sample Vasya can only see number a4."}, "positive_code": [{"source_code": "$x1) $s+=$a6;\n\t if($y>$y1) $s+=$a2;\n\t if($z>$z1) $s+=$a4;\n\t echo $s;\n?>\n\t \t\t\t \t\t\t\t \t \t\t \t\t"}, {"source_code": " $y) $ans += $cur;\n\t$cur = in();\n\tif($vz < 0) $ans += $cur;\n\t$cur = in();\n\tif($vz > $z) $ans += $cur;\n\t$cur = in();\n\tif($vx < 0) $ans += $cur;\n\t$cur = in();\n\tif($vx > $x) $ans += $cur;\n\techo $ans;\n?>\n"}, {"source_code": " $y) $r = $r + $a2;\nif ($z1 < 0) $r = $r + $a3;\nif ($z1 > $z) $r = $r + $a4;\nif ($x1 < 0) $r = $r + $a5;\nif ($x1 > $x) $r = $r + $a6;\n\necho \"$r\\n\";\n?>"}], "negative_code": [], "src_uid": "c7889a8f64c57cf7be4df870f68f749e"} {"nl": {"description": "A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of sand into b grams of lead, the second one allows you to convert c grams of lead into d grams of gold and third one allows you to convert e grams of gold into f grams of sand. When Harry told his friends about these spells, Ron Weasley was amazed. After all, if they succeed in turning sand into lead, lead into gold, and then turning part of the gold into sand again and so on, then it will be possible to start with a small amount of sand and get huge amounts of gold! Even an infinite amount of gold! Hermione Granger, by contrast, was skeptical about that idea. She argues that according to the law of conservation of matter getting an infinite amount of matter, even using magic, is impossible. On the contrary, the amount of matter may even decrease during transformation, being converted to magical energy. Though Hermione's theory seems convincing, Ron won't believe her. As far as Ron is concerned, Hermione made up her law of conservation of matter to stop Harry and Ron wasting their time with this nonsense, and to make them go and do homework instead. That's why Ron has already collected a certain amount of sand for the experiments. A quarrel between the friends seems unavoidable...Help Harry to determine which one of his friends is right, and avoid the quarrel after all. To do this you have to figure out whether it is possible to get the amount of gold greater than any preassigned number from some finite amount of sand.", "input_spec": "The first line contains 6 integers a, b, c, d, e, f (0\u2009\u2264\u2009a,\u2009b,\u2009c,\u2009d,\u2009e,\u2009f\u2009\u2264\u20091000).", "output_spec": "Print \"Ron\", if it is possible to get an infinitely large amount of gold having a certain finite amount of sand (and not having any gold and lead at all), i.e., Ron is right. Otherwise, print \"Hermione\".", "sample_inputs": ["100 200 250 150 200 250", "100 50 50 200 200 100", "100 10 200 20 300 30", "0 0 0 0 0 0", "1 1 0 1 1 1", "1 0 1 2 1 2", "100 1 100 1 0 1"], "sample_outputs": ["Ron", "Hermione", "Hermione", "Hermione", "Ron", "Hermione", "Ron"], "notes": "NoteConsider the first sample. Let's start with the 500 grams of sand. Apply the first spell 5 times and turn the sand into 1000 grams of lead. Then apply the second spell 4 times to get 600 grams of gold. Let\u2019s take 400 grams from the resulting amount of gold turn them back into sand. We get 500 grams of sand and 200 grams of gold. If we apply the same operations to 500 grams of sand again, we can get extra 200 grams of gold every time. Thus, you can get 200, 400, 600 etc. grams of gold, i.e., starting with a finite amount of sand (500 grams), you can get the amount of gold which is greater than any preassigned number.In the forth sample it is impossible to get sand, or lead, or gold, applying the spells.In the fifth sample an infinitely large amount of gold can be obtained by using only the second spell, which allows you to receive 1 gram of gold out of nothing. Note that if such a second spell is available, then the first and the third one do not affect the answer at all.The seventh sample is more interesting. We can also start with a zero amount of sand there. With the aid of the third spell you can get sand out of nothing. We get 10000 grams of sand in this manner. Let's get 100 grams of lead using the first spell 100 times. Then make 1 gram of gold from them. We managed to receive 1 gram of gold, starting with a zero amount of sand! Clearly, in this manner you can get an infinitely large amount of gold."}, "positive_code": [{"source_code": "0||$c<1&&$d>0?\"Ron\\n\":\"Hermione\\n\");\n?>\n\n\n"}], "negative_code": [{"source_code": "0||$c===0&&$d>0?\"Ron\\n\":\"Hermione\\n\");\n?>\n\n\n"}], "src_uid": "44d608de3e1447f89070e707ba550150"} {"nl": {"description": "Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $$$1$$$ to $$$9$$$). In this problem, we use one digit and one lowercase letter, which is the first character of the suit, to represent a suited tile. All possible suited tiles are represented as 1m, 2m, $$$\\ldots$$$, 9m, 1p, 2p, $$$\\ldots$$$, 9p, 1s, 2s, $$$\\ldots$$$, 9s.In order to win the game, she must have at least one mentsu (described below) in her hand, so sometimes she should draw extra suited tiles. After drawing a tile, the number of her tiles increases by one. She can draw any tiles she wants, including those already in her hand.Do you know the minimum number of extra suited tiles she needs to draw so that she can win?Here are some useful definitions in this game: A mentsu, also known as meld, is formed by a koutsu or a shuntsu; A koutsu, also known as triplet, is made of three identical tiles, such as [1m, 1m, 1m], however, [1m, 1p, 1s] or [1m, 4m, 7m] is NOT a koutsu; A shuntsu, also known as sequence, is made of three sequential numbered tiles in the same suit, such as [1m, 2m, 3m] and [5s, 7s, 6s], however, [9m, 1m, 2m] or [1m, 2p, 3s] is NOT a shuntsu. Some examples: [2m, 3p, 2s, 4m, 1s, 2s, 4s] \u2014 it contains no koutsu or shuntsu, so it includes no mentsu; [4s, 3m, 3p, 4s, 5p, 4s, 5p] \u2014 it contains a koutsu, [4s, 4s, 4s], but no shuntsu, so it includes a mentsu; [5p, 5s, 9m, 4p, 1s, 7p, 7m, 6p] \u2014 it contains no koutsu but a shuntsu, [5p, 4p, 6p] or [5p, 7p, 6p], so it includes a mentsu. Note that the order of tiles is unnecessary and you can assume the number of each type of suited tiles she can draw is infinite.", "input_spec": "The only line contains three strings\u00a0\u2014 the tiles in Tokitsukaze's hand. For each string, the first character is a digit ranged from $$$1$$$ to $$$9$$$ and the second character is m, p or s.", "output_spec": "Print a single integer\u00a0\u2014 the minimum number of extra suited tiles she needs to draw.", "sample_inputs": ["1s 2s 3s", "9m 9m 9m", "3p 9m 2p"], "sample_outputs": ["0", "0", "1"], "notes": "NoteIn the first example, Tokitsukaze already has a shuntsu.In the second example, Tokitsukaze already has a koutsu.In the third example, Tokitsukaze can get a shuntsu by drawing one suited tile\u00a0\u2014 1p or 4p. The resulting tiles will be [3p, 9m, 2p, 1p] or [3p, 9m, 2p, 4p]."}, "positive_code": [{"source_code": " $a, 1 => $b, 2 => $c);\n $f = array(\"s\", \"m\", \"p\");\n for($w = 0; $w < 3; $w++)\n {\n for($x = 1; $x <= 7; $x++)\n {\n for($y = $x + 1; $y <= 8; $y++)\n {\n for($z = $y + 1; $z <= 9; $z++)\n {\n if(($z - $y > 1) || ($y - $x) > 1)\n {\n break;\n }\n $g = $x . $f[$w];\n $h = $y . $f[$w];\n $i = $z . $f[$w];\n $j = array($g, $h, $i);\n $k = array_intersect($e, $j);\n $l = 3 - count($k);\n $m = min($m, $l);\n }\n }\n }\n }\n}\nprint min($d, $m);\n?>"}, {"source_code": " 0, 'p' => 0, 's' => 0);\n foreach($n as $k => $v){\n $arr[$v[1]] += 1; \n }\n arsort($arr);\n if(reset($arr) == 1){\n echo 2;\n } else if (reset($arr) == 2) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(abs($a[0] - $a[1]) <= 2) {\n echo 1;\n } else {\n echo 2;\n }\n } else if(reset($arr) == 3) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n $b = array_count_values($a);\n arsort($b);\n if(max($a) - min($a) == 0) {\n echo 0;\n } else if (max($a) - min($a) == 2) {\n if(reset($b) < 2) {\n echo 0;\n }else{\n echo 1;\n }\n } else if (max($a) - min($a) > 2){\n $b = array_count_values($a);\n arsort($b);\n $d = array_keys($b);\n sort($d);\n $m1 = $d[0]+1;\n $m2 = $d[2]-1;\n $m3 = $d[1]+1;\n $m4 = $d[1]-1;\n if(reset($b) < 2) {\n if(in_array($m1, $d) || in_array($m2, $d) || in_array($m3, $d) || in_array($m4, $d) || ($m1 == $m4) || ($m3 == $m2)){\n echo 1;\n } else {\n echo 2;\n }\n } else {\n echo 1;\n }\n } else {\n echo 1;\n }\n }\n\n ?>"}], "negative_code": [{"source_code": " $a, 1 => $b, 2 => $c);\n $f = array(\"s\", \"m\", \"p\");\n $m = 3;\n for($w = 0; $w < 3; $w++)\n {\n for($x = 1; $x <= 7; $x++)\n {\n for($y = $x + 1; $y <= 8; $y++)\n {\n for($z = $y + 1; $z <= 9; $z++)\n {\n $g = $x . $f[$w];\n $h = $y . $f[$w];\n $i = $z . $f[$w];\n $j = array($g, $h, $i);\n $k = array_intersect($e, $j);\n $l = 3 - count($k);\n $m = min($m, $l);\n }\n }\n }\n }\n}\nprint min($d, $m);\n?>"}, {"source_code": " $a, 1 => $b, 2 => $c);\n $f = array(\"s\", \"m\", \"p\");\n for($w = 0; $w < 3; $w++)\n {\n for($x = 1; $x <= 7; $x++)\n {\n for($y = $x + 1; $y <= 8; $y++)\n {\n for($z = $y + 1; $z <= 9; $z++)\n {\n $g = $x . $f[$w];\n $h = $y . $f[$w];\n $i = $z . $f[$w];\n $j = array($g, $h, $i);\n $k = array_intersect($e, $j);\n $l = 3 - count($k);\n $m = min($m, $l);\n }\n }\n }\n }\n}\nprint min($d, $m);\n?>"}, {"source_code": " 0, 'p' => 0, 's' => 0);\n foreach($n as $k => $v){\n $arr[$v[1]] += 1; \n }\n arsort($arr);\n if(reset($arr) == 1){\n echo 2;\n } else if (reset($arr) == 2) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(abs($a[0] - $a[1]) <= 2) {\n echo 1;\n } else {\n echo 2;\n }\n } else if(reset($arr) == 3) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n $b = array_count_values($a);\n arsort($b);\n if(max($a) - min($a) == 0) {\n echo 0;\n } else if (max($a) - min($a) == 2) {\n if(reset($b) < 2) {\n echo 0;\n }else{\n echo 1;\n }\n } else if (max($a) - min($a) > 2){\n $b = array_count_values($a);\n arsort($b);\n $d = array_keys($b);\n sort($d);\n $m1 = $d[0]+1;\n $m2 = $d[2]-1;\n $m3 = $d[1]+1;\n $m4 = $d[1]-1;\n if(reset($b) < 2) {\n if(in_array($m1, $d) || in_array($m2, $d) || in_array($m3, $d) || in_array($m4, $d) || ($m1 == $m4) || ($m3 == $m2)){\n echo 1;\n } else {\n echo 2;\n }\n } else {\n echo 1;\n }\n }\n }\n\n ?>"}, {"source_code": " 0, 'p' => 0, 's' => 0);\n foreach($n as $k => $v){\n $arr[$v[1]] += 1; \n }\n arsort($arr);\n if(reset($arr) == 1){\n echo 2;\n } else if (reset($arr) == 2) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(abs($a[0] - $a[1]) <= 2) {\n echo 1;\n } else {\n echo 2;\n }\n } else if(reset($arr) == 3) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n $b = array_count_values($a);\n arsort($b);\n if(max($a) - min($a) == 0) {\n echo 0;\n } else if (max($a) - min($a) == 2) {\n if(reset($b) < 2) {\n echo 0;\n }else{\n echo 1;\n }\n } else if (max($a) - min($a) > 2){\n $b = array_count_values($a);\n $d = array_keys($b);\n \n $max = max($d)-1;\n $min = min($d)+1;\n if(reset($b) < 2) {\n if(in_array($max, $d) || in_array($min, $d)){\n echo 1;\n } else {\n echo 2;\n }\n } else {\n echo 1;\n }\n }\n }\n\n ?>"}, {"source_code": " 0, 'p' => 0, 's' => 0);\n foreach($n as $k => $v){\n $arr[$v[1]] += 1; \n }\n arsort($arr);\n if(reset($arr) == 1){\n echo 2;\n } else if (reset($arr) == 2) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(abs($a[0] - $a[1]) <= 2) {\n echo 1;\n } else {\n echo 2;\n }\n } else if(reset($arr) == 3) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n $b = array_count_values($a);\n arsort($b);\n if(max($a) - min($a) == 0) {\n echo 0;\n } else if (max($a) - min($a) == 2) {\n if(reset($b) < 2) {\n echo 0;\n }else{\n echo 1;\n }\n } else if (max($a) - min($a) > 2){\n $b = array_count_values($a);\n arsort($b);\n $d = array_keys($b);\n \n $max = max($d)-1;\n $min = min($d)+1;\n if(reset($b) < 2) {\n if(in_array($max, $d) || in_array($min, $d)){\n echo 1;\n } else {\n echo 2;\n }\n } else {\n echo 1;\n }\n }\n }\n\n ?>"}, {"source_code": " 0, 'p' => 0, 's' => 0);\n foreach($n as $k => $v){\n $arr[$v[1]] += 1; \n }\n arsort($arr);\n if(reset($arr) == 1){\n echo 2;\n } else if (reset($arr) == 2) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(abs($a[0] - $a[1]) <= 2) {\n echo 1;\n } else {\n echo 2;\n }\n } else if(reset($arr) == 3) {\n foreach($n as $sk => $sv){\n if($sv[1] == array_keys($arr)[0]) {\n $a[] = $sv[0];\n }\n }\n if(max($a) - min($a) == 0) {\n echo 0;\n } else if (max($a) - min($a) == 2) {\n echo 1;\n } else if (max($a) - min($a) > 2){\n $b = array_count_values($a);\n if($b[0] < 2) {\n echo 2;\n } else {\n echo 1;\n }\n }\n }\n\n ?>"}], "src_uid": "7e42cebc670e76ace967e01021f752d3"} {"nl": {"description": "Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple actions)?", "input_spec": "The first line of the input contains three integers a, b and c (0\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0\u2009\u2264\u2009x,\u2009y,\u2009z\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 the number of blue, violet and orange spheres that he needs to get.", "output_spec": "If the wizard is able to obtain the required numbers of spheres, print \"Yes\". Otherwise, print \"No\".", "sample_inputs": ["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2"], "sample_outputs": ["Yes", "No", "Yes"], "notes": "NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs."}, "positive_code": [{"source_code": "= $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b >= $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c >= $f)\n {\n print \"Yes\";\n }\n else\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c >= $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $l + $b) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n if(($h + $b) >= $e)\n {\n $o = ($h + $b) - $e;\n if(($o + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelse\n{\n if($b >= $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c >= $f)\n {\n $m = $c - $f;\n $n = floor($m / 2);\n if(($a + $j + $n) >= $d)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n if(($a + $j) >= $d)\n {\n $p = ($a + $j) - $d;\n if(($p + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c >= $f)\n {\n $m = $c - $f;\n $n = floor($m / 2);\n if(($a + $n) >= $d)\n {\n $p = ($a + $n) - $d;\n if(($p + $b) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " 0 ? $d_a : 0;\n$m_b = $d_b > 0 ? $d_b : 0;\n$m_c = $d_c > 0 ? $d_c : 0;\n$m = $m_a + $m_b + $m_c;\n\n//echo $m_a . \" \" . $m_b . \" \" . $m_c . \"\\n\";\n\n$e_a = -$d_a > 0 ? floor(-$d_a / 2) : 0;\n$e_b = -$d_b > 0 ? floor(-$d_b / 2) : 0;\n$e_c = -$d_c > 0 ? floor(-$d_c / 2) : 0;\n\n$e = $e_a + $e_b + $e_c;\n\n//echo $e_a . \" \" . $e_b . \" \" . $e_c . \"\\n\";\n\necho $e >= $m ? \"Yes\\n\" : \"No\\n\"\n\n?>"}, {"source_code": " $b) return ($a-$b-($a-$b)%2)/2;\n else \n return $a-$b;\n }\n\n fscanf(STDIN, \"%d%d%d\", $a, $b, $c);\n fscanf(STDIN, \"%d%d%d\", $x, $y, $z);\n //echo $a, $b, $c;\n //echo $x, $y, $z;\n $ans = 0;\n $ans = $ans + gao($a, $x);// echo $ans , \"\\n\";\n $ans += gao($b, $y);// echo $ans , '\\n';\n $ans += gao($c, $z);// echo $ans , '\\n';\n echo $ans >= 0 ? \"Yes\" : \"No\";\n\n?>"}], "negative_code": [{"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n elseif($c < $f)\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($j + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelseif($a < $d)\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if($s >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n elseif($b < $e)\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n elseif($c < $f)\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n elseif($b < $e)\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($j + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n elseif($c < $f)\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelseif($a < $d)\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n elseif($c < $f)\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if($s >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n elseif($b < $e)\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n elseif($c < $f)\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n else\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelse\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if(floor(($b - $e) / 2) >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n elseif($c < $f)\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelseif($a < $d)\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if($s >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": "= $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b >= $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c >= $f)\n {\n print \"Yes\";\n }\n else\n {\n if(($h + $j + ($f - $c)) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c >= $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $l + ($e - $b)) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n if(($h + ($e - $b) + ($f - $c)) >= ($e + $f))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelse\n{\n if($b >= $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c >= $f)\n {\n $m = $c - $f;\n $n = floor($m / 2);\n if((($d - $a) + $j + $n) >= $d)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n if((($d - $a) + $j + ($f - $c)) >= ($d + $f))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c >= $f)\n {\n $m = $c - $f;\n $n = floor($m / 2);\n if($n >= (($d - $a) + ($e - $b)))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n elseif($c < $f)\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelseif($a < $d)\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if($s >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n elseif($b < $e)\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": " $d)\n{\n $g = $a - $d;\n $h = floor($g / 2);\n if($b > $e)\n {\n $i = $b - $e;\n $j = floor($i / 2);\n if($c > $f)\n {\n print \"Yes\";\n }\n else\n {\n if(($h + $j + $c) >= $f)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $k = $c - $f;\n $l = floor($k / 2);\n if(($h + $b + $l) >= $e)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $m = $e - $b;\n $n = $f - $c;\n if($h >= ($m + $n))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n}\nelse\n{\n if($b > $e)\n {\n $o = $b - $e;\n $p = floor($o / 2);\n if($c > $f)\n {\n $r = $c - $f;\n $s = floor($r / 2);\n $t = $d - $a;\n if(($p + $s) >= $t)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n $t = $d - $a;\n $u = $f - $c;\n $v = $t + $u;\n if($s >= $v)\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n }\n else\n {\n if($c > $f)\n {\n $w = $c - $f;\n $x = floor($w / 2);\n $t = $d - $a;\n $y = $e - $b;\n if($x >= ($t + $y))\n {\n print \"Yes\";\n }\n else\n {\n print \"No\";\n }\n }\n else\n {\n print \"No\";\n }\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " 0 ? $d_a : 0;\n$m_b = $d_b > 0 ? $d_b : 0;\n$m_c = $d_c > 0 ? $d_c : 0;\n$m = $m_a + $m_b + $m_c;\n\n//echo $m_a . \" \" . $m_b . \" \" . $m_c . \"\\n\";\n\n$e_a = -$d_a > 0 ? -$d_a / 2: 0;\n$e_b = -$d_b > 0 ? -$d_b / 2: 0;\n$e_c = -$d_c > 0 ? -$d_c / 2: 0;\n$e = $e_a + $e_b + $e_c;\n\necho $e >= $m ? \"Yes\\n\" : \"No\\n\"\n\n?>"}, {"source_code": " 0 ? $d_a : 0;\n$m_b = $d_b > 0 ? $d_b : 0;\n$m_c = $d_c > 0 ? $d_c : 0;\n$m = $m_a + $m_b + $m_c;\n\n//echo $m_a . \" \" . $m_b . \" \" . $m_c . \"\\n\";\n\n$e_a = -$d_a > 0 ? -$d_a / 2: 0;\n$e_b = -$d_b > 0 ? -$d_b / 2: 0;\n$e_c = -$d_c > 0 ? -$d_c / 2: 0;\n$e = $e_a + $e_b + $e_c;\n\necho $e > $m ? \"Yes\\n\" : \"No\\n\"\n\n?>"}, {"source_code": ""}, {"source_code": " $b) return intdiv($a-$b, 2);\n else return $b-$a;\n }\n\n fscanf(STDIN, \"%d%d%d\", $a, $b, $c);\n fscanf(STDIN, \"%d%d%d\", $x, $y, $z);\n $ans = 0;\n $ans += gao(a, x);\n $ans += gao(b, y);\n $ans += gao(c, z);\n echo $ans >= 0 ? \"Yes\" : \"No\";\n\n?>"}, {"source_code": " $b) return ($a-$b-$a%$b)/2;\n else \n return $a-$b;\n }\n\n fscanf(STDIN, \"%d%d%d\", $a, $b, $c);\n fscanf(STDIN, \"%d%d%d\", $x, $y, $z);\n //echo $a, $b, $c;\n //echo $x, $y, $z;\n $ans = 0;\n $ans = $ans + gao($a, $x);\n $ans += gao($b, $y);\n $ans += gao($c, $z);\n echo $ans >= 0 ? \"Yes\" : \"No\";\n\n?>"}], "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"} {"nl": {"description": "A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.All students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.", "input_spec": "The first line contains three integers r, g and b (0\u2009\u2264\u2009r,\u2009g,\u2009b\u2009\u2264\u2009100). It is guaranteed that r\u2009+\u2009g\u2009+\u2009b\u2009>\u20090, it means that the group consists of at least one student. ", "output_spec": "Print a single number \u2014 the minimal time the students need for the whole group to ascend to the top of the mountain.", "sample_inputs": ["1 3 2", "3 2 1"], "sample_outputs": ["34", "33"], "notes": "NoteLet's analyze the first sample.At the moment of time 0 a red cablecar comes and one student from the r group get on it and ascends to the top at the moment of time 30.At the moment of time 1 a green cablecar arrives and two students from the g group get on it; they get to the top at the moment of time 31.At the moment of time 2 comes the blue cablecar and two students from the b group get on it. They ascend to the top at the moment of time 32.At the moment of time 3 a red cablecar arrives but the only student who is left doesn't like red and the cablecar leaves empty.At the moment of time 4 a green cablecar arrives and one student from the g group gets on it. He ascends to top at the moment of time 34.Thus, all the students are on the top, overall the ascension took exactly 34 minutes."}, "positive_code": [{"source_code": " 0)\n {\n $a -= 2;\n if($e == 0)\n {\n $d += 30;\n $e = 1;\n }\n else\n {\n $d += 1;\n }\n if(($a <= 0) && ($b <= 0) && ($c <= 0))\n {\n break;\n }\n }\n else\n {\n $d += 1;\n }\n if($b > 0)\n {\n $b -= 2;\n if($e == 0)\n {\n $d += 30;\n $e = 1;\n }\n else\n {\n $d += 1;\n }\n if(($a <= 0) && ($b <= 0) && ($c <= 0))\n {\n break;\n }\n }\n else\n {\n $d += 1;\n }\n if($c > 0)\n {\n $c -= 2;\n if($e == 0)\n {\n $d += 30;\n $e = 1;\n }\n else\n {\n $d += 1;\n }\n if(($a <= 0) && ($b <= 0) && ($c <= 0))\n {\n break;\n }\n }\n else\n {\n $d += 1;\n }\n }\n}\nprint $d;\n?>"}, {"source_code": "0;$i--){\n if($newarr[$i]==$max) {\n $pos=$i;\n break;\n }\n}\nswitch($pos){\n case 2: $minus=0; break;\n case 1: $minus=1; break;\n case 0: $minus=2; break;\n}\necho $res-$minus;\n?>"}, {"source_code": " $v){\n $x = ((ceil($v/2)-1)*3)+$k;\n if($x>$y)$y=$x;\n}\necho $y+30;\n?>"}], "negative_code": [{"source_code": " $v){\n $x = ((ceil($v/2)-1)*3)+$k;\n if($x>$y)$y=$x;\n}\necho $y+30;\n?>"}], "src_uid": "a45daac108076102da54e07e1e2a37d7"} {"nl": {"description": "Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9\u2009-\u2009t. Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.", "input_spec": "The first line contains a single integer x (1\u2009\u2264\u2009x\u2009\u2264\u20091018) \u2014 the number that Luke Skywalker gave to Chewbacca.", "output_spec": "Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.", "sample_inputs": ["27", "4545"], "sample_outputs": ["22", "4444"], "notes": null}, "positive_code": [{"source_code": " $d))\n {\n $c = 1;\n $b[$x] = $d;\n }\n elseif(($b[$x] != 9) && ($b[$x] < $d))\n {\n $c = 1;\n }\n elseif($b[$x] == 9)\n {\n $b[$x] = $d;\n }\n}\nprint implode(\"\", $b);\n?>"}, {"source_code": " $ch) {\n $ch = (int)$ch;\n if ($ch >= 5) {\n if ($i != 0 || $ch != 9) {\n $ch = 9 - $ch;\n }\n }\n $res .= $ch;\n}\n\necho \"$res\\n\";\n"}, {"source_code": "4){\n $t = (9 - $s[$i]);\n $result=$result.$t;\n } else $result.=$s[$i];\n}\n\nif ($result=='0') exit($s);\n\necho $result;"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') {\n break;\n } else {\n $str[$i] = '9';\n break;\n }\n}\n\necho $str;\n\n?>"}], "negative_code": [{"source_code": " $c)\n {\n $b[$x] = $c;\n }\n}\n$d = implode(\"\", $b);\n$e = intval($d);\nif($e == 0)\n{\n print $a;\n}\nelse\n{\n print $e;\n}\n?>"}, {"source_code": " $c)\n {\n $b[$x] = $c;\n }\n}\nprint implode(\"\", $b);\n?>"}, {"source_code": " $d))\n {\n $c = 1;\n $b[$x] = $d;\n }\n elseif($b[$x] == 9)\n {\n $b[$x] = $d;\n }\n}\nprint implode(\"\", $b);\n?>"}, {"source_code": " $c)\n {\n $b[$x] = $c;\n }\n}\n$d = implode(\"\", $b);\n$e = intval($d);\nprint $e;\n?>"}, {"source_code": " $d))\n {\n $c = 1;\n $b[$x] = $d;\n }\n elseif(($b[$x] != 9) && ($b[$x] < $d))\n {\n $c = 1;\n }\n elseif($b[$x] == 9)\n {\n $b[$x] = $d;\n }\n}\nprint implode(\"\", $b);\n?>"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') break;\n}\n\nif ($i == $len) {\n echo \"0\";\n} else {\n echo substr($str, $i);\n}\n\n?>"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') break;\n}\n\nif ($i == $len) {\n echo $strold;\n} else {\n echo substr($str, $i);\n}\n\n?>"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') {\n break;\n } else {\n $str[$i] = '9';\n }\n}\n\necho $str;\n\n?>"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') break;\n}\n\nif ($i == $len) {\n echo \"0\";\n} else {\n echo substr($str, $i);\n}\n\n?>"}, {"source_code": " '4') {\n $str[$i] = (string) (9 - (int) $str[$i]);\n }\n}\n\nfor ($i=0; $i < $len; $i++) { \n if ($str[$i] !== '0') break;\n}\n\nif ($i == $len) {\n echo \"0\";\n} else {\n echo substr($str, $i - 1);\n}\n\n?>"}], "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61"} {"nl": {"description": "Consider an array $$$a$$$ of length $$$n$$$ with elements numbered from $$$1$$$ to $$$n$$$. It is possible to remove the $$$i$$$-th element of $$$a$$$ if $$$gcd(a_i, i) = 1$$$, where $$$gcd$$$ denotes the greatest common divisor. After an element is removed, the elements to the right are shifted to the left by one position.An array $$$b$$$ with $$$n$$$ integers such that $$$1 \\le b_i \\le n - i + 1$$$ is a removal sequence for the array $$$a$$$ if it is possible to remove all elements of $$$a$$$, if you remove the $$$b_1$$$-th element, then the $$$b_2$$$-th, ..., then the $$$b_n$$$-th element. For example, let $$$a = [42, 314]$$$: $$$[1, 1]$$$ is a removal sequence: when you remove the $$$1$$$-st element of the array, the condition $$$gcd(42, 1) = 1$$$ holds, and the array becomes $$$[314]$$$; when you remove the $$$1$$$-st element again, the condition $$$gcd(314, 1) = 1$$$ holds, and the array becomes empty. $$$[2, 1]$$$ is not a removal sequence: when you try to remove the $$$2$$$-nd element, the condition $$$gcd(314, 2) = 1$$$ is false. An array is ambiguous if it has at least two removal sequences. For example, the array $$$[1, 2, 5]$$$ is ambiguous: it has removal sequences $$$[3, 1, 1]$$$ and $$$[1, 2, 1]$$$. The array $$$[42, 314]$$$ is not ambiguous: the only removal sequence it has is $$$[1, 1]$$$.You are given two integers $$$n$$$ and $$$m$$$. You have to calculate the number of ambiguous arrays $$$a$$$ such that the length of $$$a$$$ is from $$$1$$$ to $$$n$$$ and each $$$a_i$$$ is an integer from $$$1$$$ to $$$m$$$.", "input_spec": "The only line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 3 \\cdot 10^5$$$; $$$1 \\le m \\le 10^{12}$$$).", "output_spec": "Print one integer \u2014 the number of ambiguous arrays $$$a$$$ such that the length of $$$a$$$ is from $$$1$$$ to $$$n$$$ and each $$$a_i$$$ is an integer from $$$1$$$ to $$$m$$$. Since the answer can be very large, print it modulo $$$998244353$$$.", "sample_inputs": ["2 3", "4 2", "4 6", "1337 424242424242"], "sample_outputs": ["6", "26", "1494", "119112628"], "notes": null}, "positive_code": [{"source_code": " 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "$valor) {\n if ($valor == $inputArray[$sizeArray-2]) {\n $ban = true;\n break;\n }\n }\n if ($ban) {\n echo \"YES\";\n }else{\n echo \"NO\";\n }\n?>"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " 0)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "$valor) {\n if ($valor == $inputArray[$sizeArray-2]) {\n $ban = true;\n break;\n }\n }\n if ($ban) {\n echo \"YES\";\n }else{\n echo \"NO\";\n }\n?>"}, {"source_code": "$valor) {\n if ($valor == $inputArray[$sizeArray-2]) {\n $ban = true;\n break;\n }\n }\n if ($ban) {\n echo \"YES\";\n }else{\n echo \"NO\";\n }\n?>"}, {"source_code": "$valor) {\n if ($valor == $inputArray[$sizeArray-2]) {\n $ban = true;\n break;\n }\n }\n if ($ban) {\n echo \"YES\";\n }else{\n echo \"NO\";\n }\n?>"}, {"source_code": "$valor) {\n if ($valor == $inputArray[$sizeArray-2]) {\n $ban = true;\n break;\n }\n }\n if ($ban) {\n echo \"YES\";\n }else{\n echo \"NO\";\n }\n?>"}], "src_uid": "dea7eb04e086a4c1b3924eff255b9648"} {"nl": {"description": "One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to visit this splendid shrine of high culture.In Mainframe a standard pack of 52 cards is used to play blackjack. The pack contains cards of 13 values: 2, 3, 4, 5, 6, 7, 8, 9, 10, jacks, queens, kings and aces. Each value also exists in one of four suits: hearts, diamonds, clubs and spades. Also, each card earns some value in points assigned to it: cards with value from two to ten earn from 2 to 10 points, correspondingly. An ace can either earn 1 or 11, whatever the player wishes. The picture cards (king, queen and jack) earn 10 points. The number of points a card earns does not depend on the suit. The rules of the game are very simple. The player gets two cards, if the sum of points of those cards equals n, then the player wins, otherwise the player loses.The player has already got the first card, it's the queen of spades. To evaluate chances for victory, you should determine how many ways there are to get the second card so that the sum of points exactly equals n.", "input_spec": "The only line contains n (1\u2009\u2264\u2009n\u2009\u2264\u200925) \u2014 the required sum of points.", "output_spec": "Print the numbers of ways to get the second card in the required way if the first card is the queen of spades.", "sample_inputs": ["12", "20", "10"], "sample_outputs": ["4", "15", "0"], "notes": "NoteIn the first sample only four two's of different suits can earn the required sum of points.In the second sample we can use all tens, jacks, queens and kings; overall it's 15 cards, as the queen of spades (as any other card) is only present once in the pack of cards and it's already in use.In the third sample there is no card, that would add a zero to the current ten points."}, "positive_code": [{"source_code": " 1)\n {\n print \"15\";\n }\n}\n?>"}, {"source_code": " 21) {\n echo 0;\n} else {\n $accessPoints = array(1 => 4,\n 2 => 4,\n 3 => 4,\n 4 => 4,\n 5 => 4,\n 6 => 4,\n 7 => 4,\n 8 => 4,\n 9 => 4,\n 10 => 15,\n 11 => 4\n );\n $key = $points - 10;\n echo $accessPoints[$key];\n}\n?>"}, {"source_code": " 4,\n\t2 => 4,\n\t3 => 4,\n\t4 => 4,\n\t5 => 4,\n\t6 => 4,\n\t7 => 4,\n\t8 => 4,\n\t9 => 4,\n\t10 => 15,\n\t11 => 4,\n);\n\nif (isset($map[$num])) {\n\techo $map[$num];\n} else {\n\techo 0;\n}\n"}, {"source_code": "0 && $n<=10) echo \"0\";\nif($n>=11 && $n<=19) echo \"4\";\nif($n==20) echo \"15\";\nif($n==21) echo \"4\";\nif($n>=22 && $n<=25) echo \"0\";\n?>\n"}, {"source_code": "\n"}, {"source_code": "0 && $n<=10) echo \"0\";\nif($n>=11 && $n<=19) echo \"4\";\nif($n==20) echo \"15\";\nif($n==21) echo \"4\";\nif($n>=22 && $n<=25) echo \"0\";\n?>"}], "negative_code": [{"source_code": " 1)\n {\n print \"15\";\n }\n}\n?>"}, {"source_code": "0 && $n<=10) echo\"0\";\nif ($n>=11 && $n>=19) echo \"4\";\nif ($n==20 ) echo \"15\";\nif ($n==21) echo \"4\";\nif ($n>=22 && $n<=25) echo \"0\"; \n?>\n\n"}, {"source_code": "0 && $n<=10) echo\"0\";\nif (n>=11 && $n>=19) echo \"4\";\nif (n==20 ) echo \"15\";\nif ($n==21) echo \"4\";\nif ($n>=22 && $n<=24) echo \"0\"; \n?>\n"}, {"source_code": "0 && $n<=10) echo\"0\";\nif (n>=11 && n>=19) echo \"4\";\nif (n==20 ) echo \"15\";\nif ($n==21) echo \"4\";\nif ($n>=22 && $n<=24) echo \"0\"; \n?>\n"}, {"source_code": "0 && $n<=10) echo\"0\";\nif (n>=11 && $n>=19) echo \"4\";\nif (n==20 ) echo \"15\";\nif ($n==21) echo \"4\";\nif ($n>=22 && $n<=24) echo \"0\"; \n?>\n"}, {"source_code": "0 && $n<=10) echo\"0\";\nif ($n>=11 && $n>=19) echo \"4\";\nif ($n==20 ) echo \"15\";\nif ($n==21) echo \"4\";\nif ($n>=22 && $n<=24) echo \"0\"; \n?>\n"}, {"source_code": "\n"}], "src_uid": "5802f52caff6015f21b80872274ab16c"} {"nl": {"description": "There are three doors in front of you, numbered from $$$1$$$ to $$$3$$$ from left to right. Each door has a lock on it, which can only be opened with a key with the same number on it as the number on the door.There are three keys\u00a0\u2014 one for each door. Two of them are hidden behind the doors, so that there is no more than one key behind each door. So two doors have one key behind them, one door doesn't have a key behind it. To obtain a key hidden behind a door, you should first unlock that door. The remaining key is in your hands.Can you open all the doors?", "input_spec": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 18$$$)\u00a0\u2014 the number of testcases. The first line of each testcase contains a single integer $$$x$$$ ($$$1 \\le x \\le 3$$$)\u00a0\u2014 the number on the key in your hands. The second line contains three integers $$$a, b$$$ and $$$c$$$ ($$$0 \\le a, b, c \\le 3$$$)\u00a0\u2014 the number on the key behind each of the doors. If there is no key behind the door, the number is equal to $$$0$$$. Values $$$1, 2$$$ and $$$3$$$ appear exactly once among $$$x, a, b$$$ and $$$c$$$.", "output_spec": "For each testcase, print \"YES\" if you can open all the doors. Otherwise, print \"NO\".", "sample_inputs": ["4\n\n3\n\n0 1 2\n\n1\n\n0 3 2\n\n2\n\n3 1 0\n\n2\n\n1 3 0"], "sample_outputs": ["YES\nNO\nYES\nNO"], "notes": null}, "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": "5cd113a30bbbb93d8620a483d4da0349"} {"nl": {"description": "Jabber ID on the national Berland service \u00abBabber\u00bb has a form <username>@<hostname>[/resource], where <username> \u2014 is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters \u00ab_\u00bb, the length of <username> is between 1 and 16, inclusive. <hostname> \u2014 is a sequence of word separated by periods (characters \u00ab.\u00bb), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive. <resource> \u2014 is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters \u00ab_\u00bb, the length of <resource> is between 1 and 16, inclusive. The content of square brackets is optional \u2014 it can be present or can be absent.There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.Your task is to write program which checks if given string is a correct Jabber ID.", "input_spec": "The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.", "output_spec": "Print YES or NO.", "sample_inputs": ["mike@codeforces.com", "john.smith@codeforces.ru/contest.icpc/12"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0) ////////// \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043b\u0435\u0448\u0430 //////////\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if(($b[count($b)] == \".\") || ($b[1] == \".\"))\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n }\n else ////////// \u0435\u0441\u043b\u0438 \u0441\u043b\u0435\u0448 \u0435\u0441\u0442\u044c //////////\n {\n array_splice($b, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if(($b[count($b)] == \".\") || ($b[1] == \".\"))\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16) || (count($l) == 0))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"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 '';\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$id = g();\n\n$word = \"[a-z0-9_]{1,16}\";\n$correct = preg_match(\"/^$word@(($word\\.)*$word)(\\/$word)?$/i\", $id, $matches);\n$correct = $correct && strlen($matches[1]) && strlen($matches[1]) < 33;\n\necho $correct ? 'YES' : 'NO';\n\n?>"}], "negative_code": [{"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n else\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0) ////////// \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043b\u0435\u0448\u0430 //////////\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if(($b[count($b)] == \".\") || ($b[1] == \".\"))\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n }\n else ////////// \u0435\u0441\u043b\u0438 \u0441\u043b\u0435\u0448 \u0435\u0441\u0442\u044c //////////\n {\n array_splice($b, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if(($b[count($b)] == \".\") || ($b[1] == \".\"))\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0) ////////// \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043b\u0435\u0448\u0430 //////////\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if($b[count($b)] == \".\")\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n }\n else ////////// \u0435\u0441\u043b\u0438 \u0441\u043b\u0435\u0448 \u0435\u0441\u0442\u044c //////////\n {\n array_splice($b, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if($b[count($b)] == \".\")\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if(($b[$x] == \".\") && ($b[$x + 1] == \".\"))\n {\n $j = 1;\n }\n elseif($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if($b[count($b)] == \".\")\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n }\n else\n {\n array_splice($b, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n if($b[count($b)] == \".\")\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n else\n {\n array_splice($b, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n if(count($b) == 0)\n {\n print \"NO\";\n }\n else\n {\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n}\n?>"}, {"source_code": " 16))\n {\n print \"NO\";\n }\n else\n {\n array_splice($b, 0, $c);\n array_unshift($b, \" \");\n unset($b[0]);\n $g = array_search(\"/\", $b);\n if($g == 0)\n {\n if((count($b) < 1) && (count($b) > 32))\n {\n print \"NO\";\n }\n else\n {\n for($x = 1; $x <= count($b); $x++)\n {\n if($f2 == 0)\n {\n break;\n }\n else\n {\n $f2 = 0;\n for($y = 0; $y < count($e2); $y++)\n {\n if($b[$x] == $e2[$y])\n {\n $f2 = 1;\n break;\n }\n }\n }\n }\n if($f2 == 0)\n {\n print \"NO\";\n }\n else\n {\n array_push($b, \".\");\n $j = 0;\n for($x = 1; $x <= count($b); $x++)\n {\n if($b[$x] == \".\")\n {\n $h = array_slice($b, 0, $x - 1);\n array_splice($b, 0, $x);\n $x = 0;\n array_unshift($b, \" \");\n unset($b[0]);\n if((count($h) < 1) && (count($h) > 16))\n {\n $j = 1;\n }\n }\n }\n if($j == 1)\n {\n print \"NO\";\n }\n else\n {\n print \"YES\";\n }\n }\n }\n }\n else\n {\n $b = array_slice($b, 0, $g - 1);\n array_unshift($b, \" \");\n unset($b[0]);\n $m = array_search(\"/\", $k);\n $l = array_slice($k, $m);\n for($x = 0; $x < count($l); $x++)\n {\n if($f3 == 0)\n {\n break;\n }\n else\n {\n $f3 = 0;\n for($y = 0; $y < count($e); $y++)\n {\n if($l[$x] == $e[$y])\n {\n $f3 = 1;\n break;\n }\n }\n }\n }\n if(($f3 == 0) || (count($l) > 16))\n {\n print \"NO\";\n }\n else\n { \n print \"YES\";\n }\n }\n }\n}\n?>"}, {"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 '';\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$id = g();\n\n$word = \"[a-z0-9_]{1,16}\";\n$correct = preg_match(\"/^$word@(($word\\.)+$word)(\\/$word)?$/i\", $id, $matches);\n$correct = $correct && strlen($matches[1]) && strlen($matches[1]) < 33;\n\necho $correct ? 'YES' : 'NO';\n\n?>"}], "src_uid": "2a68157e327f92415067f127feb31e24"} {"nl": {"description": "Polycarp is going to participate in the contest. It starts at $$$h_1:m_1$$$ and ends at $$$h_2:m_2$$$. It is guaranteed that the contest lasts an even number of minutes (i.e. $$$m_1 \\% 2 = m_2 \\% 2$$$, where $$$x \\% y$$$ is $$$x$$$ modulo $$$y$$$). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes.Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from $$$10:00$$$ to $$$11:00$$$ then the answer is $$$10:30$$$, if the contest lasts from $$$11:10$$$ to $$$11:12$$$ then the answer is $$$11:11$$$.", "input_spec": "The first line of the input contains two integers $$$h_1$$$ and $$$m_1$$$ in the format hh:mm. The second line of the input contains two integers $$$h_2$$$ and $$$m_2$$$ in the same format (hh:mm). It is guaranteed that $$$0 \\le h_1, h_2 \\le 23$$$ and $$$0 \\le m_1, m_2 \\le 59$$$. It is guaranteed that the contest lasts an even number of minutes (i.e. $$$m_1 \\% 2 = m_2 \\% 2$$$, where $$$x \\% y$$$ is $$$x$$$ modulo $$$y$$$). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes.", "output_spec": "Print two integers $$$h_3$$$ and $$$m_3$$$ ($$$0 \\le h_3 \\le 23, 0 \\le m_3 \\le 59$$$) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'.", "sample_inputs": ["10:00\n11:00", "11:10\n11:12", "01:02\n03:02"], "sample_outputs": ["10:30", "11:11", "02:02"], "notes": null}, "positive_code": [{"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $h = $b + $f;\n if($h >= 60)\n {\n $i = $h % 60;\n $j = floor($h / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n else\n {\n $a += $g;\n $b += $f;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($b >= 60)\n {\n $i = $b % 60;\n $j = floor($b / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n\n?>"}, {"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $h = $b + $f;\n if($h >= 60)\n {\n $i = $h % 60;\n $j = floor($h / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n else\n {\n $a += $g;\n $b += $f;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($b >= 60)\n {\n $i = $b % 60;\n $j = floor($b / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n?>"}], "negative_code": [{"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $a += $g;\n $b += $f;\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n?>"}, {"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $a += $g;\n $b += $h;\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n?>"}, {"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $h = $b + $f;\n if($h == 60)\n {\n $a += ($g + 1);\n $b = 0;\n }\n else\n {\n $a += $g;\n $b += $f;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n?>"}, {"source_code": "= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $h = $b + $f;\n if($h == 60)\n {\n $a += ($g + 1);\n $b = 0;\n }\n else\n {\n $a += $g;\n $b += $f;\n }\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($a < 10)\n {\n $a = \"0\" . $a;\n }\n if($b < 10)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\n?>"}, {"source_code": "list($a, $b) = explode(\":\", trim(fgets(STDIN)));\nlist($c, $d) = explode(\":\", trim(fgets(STDIN)));\n$e = (($c * 60 + $d) - ($a * 60 + $b)) / 2;\nif($e >= 60)\n{\n $f = $e % 60;\n $g = floor($e / 60);\n $h = $b + $f;\n if($h >= 60)\n {\n $i = $h % 60;\n $j = floor($h / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n else\n {\n $a += $g;\n $b += $f;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}\nelse\n{\n $b += $e;\n if($b >= 60)\n {\n $i = $b % 60;\n $j = floor($b / 60);\n $a += ($g + $j);\n $b = 0;\n $b += $i;\n }\n if(strlen($a) == 1)\n {\n $a = \"0\" . $a;\n }\n if(strlen($b) == 1)\n {\n $b = \"0\" . $b;\n }\n print $a . \":\" . $b;\n}"}], "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50"} {"nl": {"description": "The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. Help the Little Elephant to find the described number.", "input_spec": "A single line contains a single integer x (1\u2009\u2264\u2009x\u2009\u2264\u2009109).", "output_spec": "In a single line print an integer \u2014 the answer to the problem.", "sample_inputs": ["1", "10"], "sample_outputs": ["1", "2"], "notes": null}, "positive_code": [{"source_code": " $val){\n echo \"Id: $i, Val: $val\\n\";\n}\n*/\n$r = 0;\nfor ($i = 1; $i <= sqrt($num); $i += 1) {\n if ($num % $i == 0) {\n $k = $num / $i;\n //echo \"probando $i $k \\n\";\n $f_i = 0;\n $f_j = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n //echo \"$i\\n\";\n $r++;\n $f_i = 1;\n }\n if (substr_count((string)$k, (string)$j) > 0 and $f_j == 0 and $i != $k) {\n //echo \"$k\\n\";\n $f_j = 1;\n $r++;\n }\n }\n }\n }\n}\necho $r;\n?>"}], "negative_code": [{"source_code": "for ($i = 2; $i <= $num / 2; $i += 1) {\n if ($num % $i == 0) {\n $f_i = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n echo \"$i\\n\";\n $f_i = 1;\n }\n }\n }\n }\n}\n"}, {"source_code": " $val){\n echo \"Id: $i, Val: $val\\n\";\n}\n*/\nfor ($i = 2; $i <= sqrt($num); $i += 1) {\n if ($num % $i == 0) {\n $k = $num / $i;\n //echo \"probando $i $k \\n\";\n $f_i = 0;\n $f_j = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n echo \"$i\\n\";\n $f_i = 1;\n }\n if (substr_count((string)$k, (string)$j) > 0 and $f_j == 0 and $i != $k) {\n echo \"$k\\n\";\n $f_j = 1;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $val){\n echo \"Id: $i, Val: $val\\n\";\n}\n*/\nfor ($i = 1; $i <= $num / 2; $i += 1) {\n if ($num % $i == 0) {\n $f_i = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n echo \"$i\\n\";\n $f_i = 1;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $val){\n echo \"Id: $i, Val: $val\\n\";\n}\n*/\nfor ($i = 1; $i <= sqrt($num); $i += 1) {\n if ($num % $i == 0) {\n $k = $num / $i;\n //echo \"probando $i $k \\n\";\n $f_i = 0;\n $f_j = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n echo \"$i\\n\";\n $f_i = 1;\n }\n if (substr_count((string)$k, (string)$j) > 0 and $f_j == 0 and $i != $k) {\n echo \"$k\\n\";\n $f_j = 1;\n }\n }\n }\n }\n}\n?>"}, {"source_code": " $val){\n echo \"Id: $i, Val: $val\\n\";\n}\n*/\nfor ($i = 1; $i <= $num / 2 + 1; $i += 1) {\n if ($num % $i == 0) {\n $f_i = 0;\n for ($j = 0; $j <= 9; $j += 1) {\n if (substr_count((string)$num, (string)$j) > 0){\n if (substr_count((string)$i, (string)$j) > 0 and $f_i == 0){\n echo \"$i\\n\";\n $f_i = 1;\n }\n }\n }\n }\n}\n?>"}], "src_uid": "ada94770281765f54ab264b4a1ef766e"} {"nl": {"description": " \u2014 Thanks a lot for today.\u2014 I experienced so many great things.\u2014 You gave me memories like dreams... But I have to leave now...\u2014 One last request, can you...\u2014 Help me solve a Codeforces problem?\u2014 ......\u2014 What?Chtholly has been thinking about a problem for days:If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!", "input_spec": "The first line contains two integers k and p (1\u2009\u2264\u2009k\u2009\u2264\u2009105,\u20091\u2009\u2264\u2009p\u2009\u2264\u2009109).", "output_spec": "Output single integer\u00a0\u2014 answer to the problem.", "sample_inputs": ["2 100", "5 30"], "sample_outputs": ["33", "15"], "notes": "NoteIn the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.In the second example, ."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [], "src_uid": "b3b986fddc3770fed64b878fa42ab1bc"} {"nl": {"description": " You can preview the image in better quality by the link: http://assets.codeforces.com/files/656/without-text.png", "input_spec": "The only line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be an alphanumeric character or a full stop \".\".", "output_spec": "Output the required answer.", "sample_inputs": ["Codeforces", "APRIL.1st"], "sample_outputs": ["-87", "17"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " $numberOfMeals){\n $numberOfMeals++;\n }\n } else {\n $resultTypeOfDevices[$typesOfDevices[$i]] = 1;\n }\n}\n$result = $numberOfMeals * $k * count($resultTypeOfDevices) - $n;\n\nprint($result);"}], "negative_code": [{"source_code": " $numberOfMeals){\n $numberOfMeals++;\n }\n } else {\n $resultTypeOfDevices[$typesOfDevices[$i]] = 1;\n }\n}\n$result = $numberOfMeals * $k * count($resultTypeOfDevices) - $n;\nprint($result);"}], "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f"} {"nl": {"description": "Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way: Four sticks represent the animal's legs, these sticks should have the same length. Two remaining sticks represent the animal's head and body. The bear's head stick must be shorter than the body stick. The elephant, however, has a long trunk, so his head stick must be as long as the body stick. Note that there are no limits on the relations between the leg sticks and the head and body sticks. Your task is to find out which animal can be made from the given stick set. The zoo keeper wants the sticks back after the game, so they must never be broken, even bears understand it.", "input_spec": "The single line contains six space-separated integers li (1\u2009\u2264\u2009li\u2009\u2264\u20099) \u2014 the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks.", "output_spec": "If you can make a bear from the given set, print string \"Bear\" (without the quotes). If you can make an elephant, print string \"Elephant\" (w\u0131thout the quotes). If you can make neither a bear nor an elephant, print string \"Alien\" (without the quotes).", "sample_inputs": ["4 2 5 4 4 4", "4 4 5 4 4 5", "1 2 3 4 5 6"], "sample_outputs": ["Bear", "Elephant", "Alien"], "notes": "NoteIf you're out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue. "}, "positive_code": [{"source_code": ""}, {"source_code": " $el){\n\t\tif ($el >= 4){\n\t\t\t$hasFoot = true;\n\t\t\tif ($el >= 5) $head = $k;\n\t\t\tif ($el == 6) $body = $k; \n\t\t}else{\n\t\t\tif ($el == 2){\n\t\t\t\t$head = $body = $k;\n\t\t\t}else{\n\t\t\t\tif ($head == 0) $head = $k;\n\t\t\t\telse $body = $k;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\techo $hasFoot ? $body == $head ? 'Elephant' : 'Bear' : 'Alien';\n?>"}, {"source_code": "= 4) $k++;\n\tif($a[$i] == 2) $q++;\n}\nif($k && $q){\n\techo \"Elephant\";\n}else if($k)\n\techo \"Bear\";\nelse echo \"Alien\";\n?>"}, {"source_code": " 3) {\n for ($j=0; $j < 4 ; $j++) { \n unset($arr[$i+$j]);\n }\n break;\n }\n}\n\n$str = '';\nforeach ($arr as $key => $value) {\n $str .= $value;\n}\n\nif ($count > 3) {\n if ($str[0] === $str[1]) {\n echo \"Elephant\";\n } else {\n echo \"Bear\";\n }\n} else {\n echo \"Alien\";\n}\n\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $el){\n\t\tif ($el >= 4){\n\t\t\t$hasFoot = true;\n\t\t\tif ($el == 5) $head = $k;\n\t\t\tif ($el == 6) $body = $k; \n\t\t}else{\n\t\t\tif ($el == 2){\n\t\t\t\t$head = $body = $k;\n\t\t\t}else{\n\t\t\t\tif ($head == 0) $head = $k;\n\t\t\t\telse $body = $k;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\techo $hasFoot ? $body == $head ? 'Elephant' : 'Bear' : 'Alien';\n?>"}, {"source_code": " 3) {\n for ($j=0; $j < 4 ; $j++) { \n unset($arr[$i+$j]);\n }\n break;\n }\n}\n\nif ($count > 3) {\n if ($arr[0] === $arr[1]) {\n echo \"Elephant\";\n } else {\n echo \"Bear\";\n }\n} else {\n echo \"Alien\";\n}\n\n?>"}], "src_uid": "43308fa25e8578fd9f25328e715d4dd6"} {"nl": {"description": "Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.", "input_spec": "The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.", "output_spec": "If Vasya managed to say hello, print \"YES\", otherwise print \"NO\".", "sample_inputs": ["ahhellllloou", "hlelo"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " 'e',\n 'h{1,}' => 'h',\n 'l{2,}' => 'll',\n 'o{1,}' => 'o',\n);\n$str = fgets(STDIN);\n$n = strlen($str);\n\nif (preg_match('/.*?h.*?e.*?l.*?l.*?o.*?/six', $str)) {\n $str = 'YES';\n} else {\n $str = 'NO';\n}\n\n\nfwrite(STDOUT, $str);"}, {"source_code": ""}, {"source_code": "\n\n"}, {"source_code": "\n\n"}, {"source_code": "\n\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0){\n echo \"YES\";\n} else {\n echo \"NO\";\n}\n?>"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0) echo \"YES\";\nelse echo \"NO\";\n\n\n\n"}, {"source_code": " 0, \"e\" => 0, \"l\" => 0, \"o\" => 0);\n foreach ($parsed_chars as $pchar) {\n if ($pchar == 'h' && $got_h == 0) {\n //echo \"found first h\\n\";\n $got_h = 1;\n $got_e = 0;\n $got_l = 0;\n $got_l2 = 0;\n $got_o = 0;\n continue;\n }\n\n if ($pchar == 'e' && $got_h && !$got_e) {\n //echo \"found first e\\n\";\n $got_e = 1;\n continue;\n }\n\n if ($pchar == 'l' && $got_h && $got_e && !$got_l){\n //echo \"found first l\\n\";\n $got_l = 1;\n continue;\n }\n\n if ($pchar == 'l' && $got_h && $got_e && $got_l && !$got_l2) {\n //echo \"found second l\\n\";\n $got_l2 = 1;\n continue;\n }\n\n if ($pchar == 'o' && $got_h && $got_e && $got_l && $got_l2 && !$got_o) {\n //echo \"found first o\\n\";\n $got_o = 1;\n continue;\n }\n }\n\n if ($got_h && $got_e && $got_l && $got_l2 && $got_o) {\n echo \"YES\";\n }\n else {\n echo \"NO\";\n }\n}\n?>\n"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= strlen($word)) {\n \n return \"YES\";\n \n }else {\n \n return \"NO\";\n \n }\n\n}\n\necho func($input);\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= strlen($hello) ? \"YES\" : \"NO\");\n\n?>"}, {"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 echo \"YES\";\n} else {\n echo \"NO\";\n}"}, {"source_code": ""}, {"source_code": "$count[$i+1]){\n \techo \"NO\";\n \tbreak;\n }\n else $cnt++;\n\n}\nif($cnt==4)\n\techo \"YES\";\n"}, {"source_code": "\n"}, {"source_code": " 0, \"e\" => 0, \"l\" => 0, \"o\" => 0);\n foreach ($parsed_chars as $pchar) {\n if ($pchar == 'h' && $got_h == 0) {\n //echo \"found first h\\n\";\n $got_h = 1;\n $got_e = 0;\n $got_l = 0;\n $got_l2 = 0;\n $got_o = 0;\n }\n\n if ($pchar == 'e' && $got_h && !$got_e) {\n //echo \"found first e\\n\";\n $got_e = 1;\n }\n\n if ($pchar == 'l' && $got_h && $got_e && !$got_l){\n //echo \"found first l\\n\";\n $got_l = 1;\n }\n\n if ($pchar == 'l' && $got_h && $got_e && $got_l && !$got_l2) {\n //echo \"found second l\\n\";\n $got_l2 = 1;\n }\n\n if ($pchar == 'o' && $got_h && $got_e && $got_l && $got_l2 && !$got_o) {\n //echo \"found first o\\n\";\n $got_o = 1;\n }\n }\n\n if ($got_h && $got_e && $got_l && $got_l2 && $got_o) {\n echo \"YES\";\n }\n else {\n echo \"NO\";\n }\n}\n?>\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 4) {\n\tprintf(\"YES\");\n}else{\n\tprintf(\"NO\");\n}"}, {"source_code": "= 4) {\n\tprintf(\"YES\");\n}else{\n\tprintf(\"NO\");\n}"}, {"source_code": "= 4) {\n\tprintf(\"YES\");\n}else{\n\tprintf(\"NO\");\n}"}, {"source_code": " 0) {\n $arr = str_split($str);\n $unique_arr = array_unique($arr);\n $unique_str = implode('', $unique_arr);\n if (preg_match('/helo/', $unique_str)) {\n echo \"YES\\n\";\n } else {\n echo \"NO\\n\";\n }\n}\n"}, {"source_code": " 'e',\n 'h{1,}' => 'h',\n 'l{2,}' => 'll',\n 'o{1,}' => 'o',\n);\n$str = fgets(STDIN);\nforeach ($_trans as $p => $r) {\n $str = preg_replace('/' . $p . '/i', $r, $str);\n}\nif (strpos($str, 'hello') !== false) {\n $str = 'YES';\n} else {\n $str = 'NO';\n}\nfwrite(STDOUT, $str);"}], "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838"} {"nl": {"description": "Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions.So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable s\u0441hedule with d numbers, where each number s\u0441hedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime.", "input_spec": "The first input line contains two integer numbers d,\u2009sumTime (1\u2009\u2264\u2009d\u2009\u2264\u200930,\u20090\u2009\u2264\u2009sumTime\u2009\u2264\u2009240) \u2014 the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei,\u2009maxTimei (0\u2009\u2264\u2009minTimei\u2009\u2264\u2009maxTimei\u2009\u2264\u20098), separated by a space \u2014 minimum and maximum amount of hours that Peter could spent in the i-th day.", "output_spec": "In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers \u2014 amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them.", "sample_inputs": ["1 48\n5 7", "2 5\n0 1\n3 5"], "sample_outputs": ["NO", "YES\n1 4"], "notes": null}, "positive_code": [{"source_code": " $f))\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\" . \"\\n\";\n if(array_sum($h) < $b)\n {\n $j = 0;\n for($x = 0; $x < count($h) * 10; $x++)\n {\n if(array_sum($h) < $b)\n {\n $h[$x] = $k[$x];\n $j++;\n }\n elseif(array_sum($h) > $b)\n {\n $h[$j] -= 1;\n }\n else\n {\n print implode(\" \", $h);\n break;\n }\n }\n }\n elseif(array_sum($h) > $b)\n {\n $j = 0;\n for($x = 0; $x < count($l) * 10; $x++)\n {\n if(array_sum($l) > $b)\n {\n $l[$x] = $i[$x];\n $j++;\n }\n elseif(array_sum($l) < $b)\n {\n $l[$j] += 1;\n }\n else\n {\n print implode(\" \", $l);\n break;\n }\n }\n }\n elseif(array_sum($h) == $b)\n {\n print implode(\" \", $h);\n }\n}\n?>"}, {"source_code": " $day){\n if($minTimeS == $sumTime){\n echo $day[0] . ' ';\n continue;\n }else{\n if($minTimeS + ($day[1] - $day[0]) > $sumTime){\n echo ($day[0] + ($sumTime - $minTimeS)) . ' ';\n $minTimeS = $sumTime;\n continue;\n }\n $minTimeS += ($day[1] - $day[0]);\n echo $day[1] . ' ';\n }\n }\n}else{\n echo 'NO';\n die();\n}"}, {"source_code": "$sum||$r<$sum)\n\t\tprint \"NO\\n\";\n\telse\n\t{\n\t\tprint \"YES\\n\";\n\t\tfor($i=0; $i<$n; $i++)\n\t\t{\n\t\t\t$x=$dat[$i][0];\n\t\t\tif($tmp>0)\n\t\t\t{\n\t\t\t\t$y=min($tmp,$dat[$i][1]-$x);\n\t\t\t\t$x+=$y;\n\t\t\t\t$tmp-=$y;\n\t\t\t}\n\t\t\tprint $x.' ';\n\t\t}\n\t\tprint \"\\n\";\n\t}\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\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test === false) {\n\t\t$f = STDIN;\n\t}\n\t/* begin body */\n\tlist($d, $sum) = readStringExplodeNum($f, ' ', true);\n\n\t$days = array();\n\t$canMin = $canMax = array();\n\tfor ($i = 0; $i < $d; $i++) {\n\t\tlist($canMin[$i], $canMax[$i]) = readStringExplodeNum($f, ' ', true);\n\t\t$days[$i] = $canMin[$i];\n\t}\n\n\n\t$_sum = array_sum($days);\n\tdo {\n\t\t$diff = $sum - $_sum;\n\t\tif ($diff < 0)\n\t\t\tbreak;\n\t\t$success = false;\n\t\tforeach ($days as $i => $cnt) {\n\t\t\t$minMaxDiff = $canMax[$i] - $canMin[$i];\n\t\t\tif ($cnt < $canMax[$i]) {\n\t\t\t\t$success = true;\n\t\t\t\t$days[$i]+=min($diff, $minMaxDiff);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!$success) {\n\t\t\tbreak;\n\t\t}\n\t\t$_sum = array_sum($days);\n\t} while ($_sum < $sum);\n\tif ($_sum != $sum) {\n\t\techo 'NO';\n\t} else {\n\t\techo 'YES' . \"\\r\\n\";\n\t\techo implode(\" \", $days);\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": " $max){print 'NO'; exit(0);}\n\nprint \"YES\\r\\n\";\n$diff = $sum - $min;\nfor($i=1;$i<=$d;$i++){\n $cur = $m[$i][0];\n if($diff > 0){\n if($diff <= ($m[$i][1] - $m[$i][0])){\n $cur += $diff;\n $diff = 0;\n }else{\n $cur = $m[$i][1];\n $diff -= ($m[$i][1] - $m[$i][0]);\n }\n }\n print $cur.' ';\n}\n\n?>"}], "negative_code": [{"source_code": "= $e[$x])\n {\n array_push($g, $f[$x]);\n array_push($i, $e[$x]);\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n $b -= $g[$x];\n if($b > 0)\n {\n array_push($h, $g[$x]);\n }\n elseif($b == 0)\n {\n array_push($h, $g[$x]);\n $b = -1;\n break;\n }\n elseif($b < 0)\n {\n array_push($h, $g[$x] + $b);\n break;\n }\n}\nfor($y = $x + 1; $y < count($g); $y++)\n{\n if($i[$y] == 0)\n {\n array_push($h, $i[$y]);\n }\n}\nif(($b < 0) && (count($h) == $a))\n{\n print \"YES\" . \"\\n\" . implode(\" \", $h);\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": " $f))\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\" . \"\\n\";\n if(array_sum($h) < $b)\n {\n $j = 0;\n for($x = 0; $x < count($h) * 10; $x++)\n {\n if(array_sum($h) < $b)\n {\n $h[$x] = $k[$x];\n $j++;\n }\n elseif(array_sum($h) > $b)\n {\n $h[$j] -= $j;\n }\n else\n {\n print implode(\" \", $h);\n break;\n }\n }\n }\n elseif(array_sum($h) > $b)\n {\n $j = 0;\n for($x = 0; $x < count($h) * 10; $x++)\n {\n if(array_sum($h) > $b)\n {\n $h[$x] = $i[$x];\n $j++;\n }\n elseif(array_sum($h) < $b)\n {\n $h[$j] += $j;\n }\n else\n {\n print implode(\" \", $h);\n break;\n }\n }\n }\n elseif(array_sum($h) == $b)\n {\n print implode(\" \", $h);\n }\n}\n?>"}, {"source_code": "= $e[$x])\n {\n array_push($g, $f[$x]);\n }\n}\nfor($x = 0; $x < count($g); $x++)\n{\n $b -= $g[$x];\n if($b > 0)\n {\n array_push($h, $g[$x]);\n }\n elseif($b == 0)\n {\n array_push($h, $g[$x]);\n $b = -1;\n break;\n }\n elseif($b < 0)\n {\n array_push($h, $g[$x] + $b);\n break;\n }\n}\nif($b < 0)\n{\n print \"YES\" . \"\\n\";\n}\nelse\n{\n print \"NO\";\n}\nif($b < 0)\n{\n print implode(\" \", $h);\n}\n?>"}, {"source_code": " $f))\n{\n print \"NO\";\n}\nelse\n{\n print \"YES\" . \"\\n\";\n if(array_sum($h) < $b)\n {\n $j = 0;\n for($x = 0; $x < count($h) * 10; $x++)\n {\n if(array_sum($h) < $b)\n {\n $h[$x] = $k[$x];\n $j++;\n }\n elseif(array_sum($h) > $b)\n {\n $h[$j] -= 1;\n }\n else\n {\n print implode(\" \", $h);\n break;\n }\n }\n }\n elseif(array_sum($h) > $b)\n {\n $j = 0;\n for($x = 0; $x < count($h) * 10; $x++)\n {\n if(array_sum($h) > $b)\n {\n $h[$x] = $i[$x];\n $j++;\n }\n elseif(array_sum($h) < $b)\n {\n $h[$j] += 1;\n }\n else\n {\n print implode(\" \", $h);\n break;\n }\n }\n }\n elseif(array_sum($h) == $b)\n {\n print implode(\" \", $h);\n }\n}\n?>"}, {"source_code": " $day){\n $minTimeS += ($day[1] - $day[0]);\n if($minTimeS < $sumTime){\n echo $day[0] . ' ';\n continue;\n }else{\n echo $day[1] . ' ';\n }\n }\n}else{\n echo \"YES \\n\";\n foreach ($days as $key => $day){\n echo $day[0] . ' ';\n }\n}"}, {"source_code": " $day){\n $minTimeS += ($day[1] - $day[0]);\n if($minTimeS < $sumTime){\n echo $day[0] . ' ';\n continue;\n }else{\n echo $day[1] . ' ';\n }\n }\n}else{\n echo 'NO';\n die();\n}"}, {"source_code": " $day){\n $minTimeS += ($day[1] - $day[0]);\n if($minTimeS < $sumTime){\n echo $day[0] . ' ';\n continue;\n }else{\n echo $day[1] . ' ';\n }\n }\n}else{\n echo \"YES\\n\";\n foreach ($days as $key => $day){\n echo $day[0] . ' ';\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\nfunction getAnswer($is_test = false, $f = false) {\n\tif ($is_test === false) {\n\t\t$f = STDIN;\n\t}\n\t/* begin body */\n\tlist($d, $sum) = readStringExplodeNum($f, ' ', true);\n\n\t$days = array();\n\t$canMin = $canMax = array();\n\tfor ($i = 0; $i < $d; $i++) {\n\t\tlist($canMin[$i], $canMax[$i]) = readStringExplodeNum($f, ' ', true);\n\t\t$days[$i] = $canMin[$i];\n\t}\n\n\n\t$_sum = array_sum($days);\n\tdo {\n\t\t$diff = $sum - $_sum;\n\t\t$success = false;\n\t\tforeach ($days as $i => $cnt) {\n\t\t\t$minMaxDiff = $canMax[$i] - $canMin[$i];\n\t\t\tif ($cnt < $canMax[$i]) {\n\t\t\t\t$success = true;\n\t\t\t\t$days[$i]+=min($diff, $minMaxDiff);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!$success) {\n\t\t\tbreak;\n\t\t}\n\t\t$_sum = array_sum($days);\n\t} while ($_sum < $sum);\n\tif ($_sum != $sum) {\n\t\techo 'NO';\n\t} else {\n\t\techo 'YES' . \"\\r\\n\";\n\t\techo implode(\" \", $days);\n\t}\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}], "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0"} {"nl": {"description": "There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary.Can she fill all the linesTo work at all times?On juggling the wordsRight around two-thirdsShe nearly ran out of rhymes.", "input_spec": "The input contains a single integer $$$a$$$ ($$$4 \\le a \\le 998$$$). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer.", "output_spec": "Output a single number.", "sample_inputs": ["35", "57", "391"], "sample_outputs": ["57", "319", "1723"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "7220f2da5081547a12118595bbeda4f6"} {"nl": {"description": "Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is a meters, between Rabbit's and Eeyore's house is b meters, between Owl's and Eeyore's house is c meters.For enjoying his life and singing merry songs Winnie-the-Pooh should have a meal n times a day. Now he is in the Rabbit's house and has a meal for the first time. Each time when in the friend's house where Winnie is now the supply of honey is about to end, Winnie leaves that house. If Winnie has not had a meal the required amount of times, he comes out from the house and goes to someone else of his two friends. For this he chooses one of two adjacent paths, arrives to the house on the other end and visits his friend. You may assume that when Winnie is eating in one of his friend's house, the supply of honey in other friend's houses recover (most probably, they go to the supply store).Winnie-the-Pooh does not like physical activity. He wants to have a meal n times, traveling minimum possible distance. Help him to find this distance.", "input_spec": "First line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 number of visits. Second line contains an integer a (1\u2009\u2264\u2009a\u2009\u2264\u2009100)\u00a0\u2014 distance between Rabbit's and Owl's houses. Third line contains an integer b (1\u2009\u2264\u2009b\u2009\u2264\u2009100)\u00a0\u2014 distance between Rabbit's and Eeyore's houses. Fourth line contains an integer c (1\u2009\u2264\u2009c\u2009\u2264\u2009100)\u00a0\u2014 distance between Owl's and Eeyore's houses.", "output_spec": "Output one number\u00a0\u2014 minimum distance in meters Winnie must go through to have a meal n times.", "sample_inputs": ["3\n2\n3\n1", "1\n2\n3\n5"], "sample_outputs": ["3", "0"], "notes": "NoteIn the first test case the optimal path for Winnie is the following: first have a meal in Rabbit's house, then in Owl's house, then in Eeyore's house. Thus he will pass the distance 2\u2009+\u20091\u2009=\u20093.In the second test case Winnie has a meal in Rabbit's house and that is for him. So he doesn't have to walk anywhere at all."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "6058529f0144c853e9e17ed7c661fc50"} {"nl": {"description": "A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.You're given a number. Determine if it is a magic number or not.", "input_spec": "The first line of input contains an integer n, (1\u2009\u2264\u2009n\u2009\u2264\u2009109). This number doesn't contain leading zeros.", "output_spec": "Print \"YES\" if n is a magic number or print \"NO\" if it's not.", "sample_inputs": ["114114", "1111", "441231"], "sample_outputs": ["YES", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " 2) {\n\t\techo 'NO';\n\t\treturn;\n\t}\n\n\t$c = $line[$i];\n\tif ($c == 1) {\n\t\t$count4 = 0;\n\t\tcontinue;\n\t}\n\n\tif ($c == 4) {\n\t\t$count4++;\n\t\tcontinue;\n\t}\n\n\techo 'NO';\n\treturn;\n}\n\necho ($count4 > 2) ? 'NO' : 'YES';\n"}, {"source_code": "\n"}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = trim(fgets(STDIN));\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>\n"}, {"source_code": ""}, {"source_code": "\n \t \t \t \t \t\t \t\t \t \t"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value) {\n if ($value != \"1\" && $value != \"4\") \n $condition = false;\n\n if (empty($currentSequence) || valid($currentSequence)) {\n $currentSequence = $currentSequence . $value;\n } elseif (strlen($currentSequence) >= 1) {\n $currentSequence = $value;\n } else {\n $condition = false;\n }\n\n if (!valid($currentSequence)) {\n $currentSequence = $value;\n if (!valid($currentSequence)) {\n $condition = false;\n }\n }\n}\n\necho $condition === true ? \"YES\\n\" : \"NO\\n\";\n\n"}, {"source_code": "1 && (substr($n,$i-2,1) . substr($n,$i-1,1) . substr($n,$i,1)== \"444\")) //444\n {\n echo \"NO\";\n return;\n }\n\n\n}\n}\n\necho \"YES\";\n\n?>"}, {"source_code": " $number){\n\t\tif(!in_array($number, [1,4])){\n\t\t\treturn false;\n\t\t}\n\t\tif($number == 4){\n\t\t\tif($key == 0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif($numbers[$key-1] == 1){\n\t\t\t\tcontinue;\n\t\t\t}elseif($numbers[$key-1] == 4){\n\t\t\t\tif($numbers[$key-2] == 1)\n\t\t\t\t\tcontinue;\n\t\t\t\telse\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t}\n\treturn true;\n}\nif(magicNumber($input)){\n\techo \"YES\";\n}else{\n\techo \"NO\";\n}"}], "negative_code": [{"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = fgets(STDIN);\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>"}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = fgets(STDIN);\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>\n"}, {"source_code": ""}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = fgets(STDIN);\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>\n"}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = fgets(STDIN);\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>"}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\n\t$input = fgets(STDIN);\n\tif (check($input)) echo \"YES\";\n\telse echo \"NO\";\n\techo \"\\n\";\n\n\t\n\t\n?>\n"}, {"source_code": " 0 && $x[$i - 1] == 1) continue;\n\t\t\t\tif ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\n\t\t$input = fgets(STDIN);\n\t\t$regex = '/^(1|14|144)+$/';\n\t\tif (preg_match($regex, $input)) echo \"YES\";\n\t\telse echo \"NO\";\n\t\techo \"\\n\";\n\t\n\t\n?>\n"}, {"source_code": "';\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n\n"}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": "1 && substr($n,$i-1,1)==4 && substr($n,$i-2,1)==4) //444\n {\n echo \"NO\";\n return;\n }\n\n\n}\n}\n\necho \"YES\";\n\n?>"}, {"source_code": " $number){\n\t\tif(!in_array($number, [1,4])){\n\t\t\treturn false;\n\t\t}\n\t\tif($number == 4){\n\t\t\tif($numbers[$key-1] == 1){\n\t\t\t\tcontinue;\n\t\t\t}elseif($numbers[$key-1] == 4){\n\t\t\t\tif($numbers[$key-2] == 1)\n\t\t\t\t\tcontinue;\n\t\t\t\telse\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t}\n\treturn true;\n}\nif(magicNumber($input)){\n\techo \"YES\";\n}else{\n\techo \"NO\";\n}"}], "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5"} {"nl": {"description": "Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not.You are given current year in Berland. Your task is to find how long will residents of Berland wait till the next lucky year.", "input_spec": "The first line contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009109) \u2014 current year in Berland.", "output_spec": "Output amount of years from the current year to the next lucky one.", "sample_inputs": ["4", "201", "4000"], "sample_outputs": ["1", "99", "1000"], "notes": "NoteIn the first example next lucky year is 5. In the second one \u2014 300. In the third \u2014 5000."}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e"} {"nl": {"description": "Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words. He ate coffee mix without water again, so right now he's really messed up and can't think.Your task is to help him by telling him what to type.", "input_spec": "The first and only line of input contains an integer s (0\u2009\u2264\u2009s\u2009\u2264\u200999), Tavas's score. ", "output_spec": "In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.", "sample_inputs": ["6", "99", "20"], "sample_outputs": ["six", "ninety-nine", "twenty"], "notes": "NoteYou can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals ."}, "positive_code": [{"source_code": " \"zero\", 1 => \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\", 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\", 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\", 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\", 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"forty\", 50 => \"fifty\", 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\");\n$c = array(2 => \"twenty-\", 3 => \"thirty-\", 4 => \"forty-\", 5 => \"fifty-\", 6 => \"sixty-\", 7 => \"seventy-\", 8 => \"eighty-\", 9 => \"ninety-\");\nif(($a <= 20) || ($a == 30) || ($a == 40) || ($a == 50) || ($a == 60) || ($a == 70) || ($a == 80) || ($a == 90))\n{\n print $b[$a];\n}\nelse\n{\n print $c[$a[0]] . $b[$a[1]];\n}\n?>"}, {"source_code": " 'one',\n 2 => 'two',\n 3 => 'three',\n 4 => 'four',\n 5 => 'five',\n 6 => 'six',\n 7 => 'seven',\n 8 => 'eight',\n 9 => 'nine',\n 10 => 'ten',\n 11 => 'eleven',\n 12 => 'twelve',\n 13 => 'thirteen',\n 15 => 'fifteen',\n 18 => 'eighteen',\n);\n\n$stringFirstNumbers = array(\n 1 => '',\n 2 => 'twenty',\n 3 => 'thirty',\n 4 => 'forty',\n 5 => 'fifty',\n 6 => 'sixty',\n 7 => 'seventy',\n 8 => 'eighty',\n 9 => 'ninety',\n);\n\nif ($number <= 13 || $number == 15 || $number == 18)\n echo $number == 0 ? 'zero' : $stringNumbers[$number];\n\nelse {\n $firstNumber = $number / 10;\n $secondNumber = $number % 10;\n\n if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';\n\n else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];\n}"}, {"source_code": " 'zero', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine', '10' => 'ten', '11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', '30' => 'thirty', '40' => 'forty', '50' => 'fifty', '60' => 'sixty', '70' => 'seventy', '80' => 'eighty', '90' => 'ninety');\n// \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e 19\nif ($s <= 19) {\n\t$result = $numbers[$s];\n} else {\n\t// \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430\n\tif($s[1]==0) {\n\t\t// \u0415\u0441\u043b\u0438 0, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n\t\t$result = $numbers[$s];\n\t} else {\n\t\t// \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e\n\t\t$first_number = $numbers[$s[0].'0'];\n\t\t$second_number = $numbers[$s[1]];\n\t\t$result = $first_number.'-'.$second_number;\n\t}\n}\nprint($result);\n?>"}, {"source_code": ""}], "negative_code": [{"source_code": " \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\", 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\", 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\", 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\", 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"forty\", 50 => \"fifty\", 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\");\n$c = array(2 => \"twenty-\", 3 => \"thirty-\", 4 => \"forty-\", 5 => \"fifty-\", 6 => \"sixty-\", 7 => \"seventy-\", 8 => \"eighty-\", 9 => \"ninety-\");\nif(($a <= 20) || ($a == 30) || ($a == 40) || ($a == 50) || ($a == 60) || ($a == 70) || ($a == 80) || ($a == 90))\n{\n print $b[$a];\n}\nelseif($a == 0)\n{\n print \"zero\";\n}\nelse\n{\n print $c[$a[0]] . $b[$a[1]];\n}\n?>"}, {"source_code": " \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\", 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\", 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\", 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\", 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"forty\", 50 => \"fifty\", 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\");\n$c = array(2 => \"twenty-\", 3 => \"thirty-\", 4 => \"forty-\", 5 => \"fifty-\", 6 => \"sixty-\", 7 => \"seventy-\", 8 => \"eighty-\", 9 => \"ninety-\");\nif(($a <= 20) || ($a == 30) || ($a == 40) || ($a == 50) || ($a == 60) || ($a == 70) || ($a == 80) || ($a == 90))\n{\n print $b[$a];\n}\nelseif($a == 0)\n{\n print \"zero\";\n}\nelse\n{\n print $c[$a[0]] . $b[$a[1]];\n}\n?>"}, {"source_code": " \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\", 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\", 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\", 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\", 19 => \"nineteen\", 20 => \"twenty\");\n$c = array(2 => \"twenty-\", 3 => \"thirty-\", 4 => \"forty-\", 5 => \"fifty-\", 6 => \"sixty-\", 7 => \"seventy-\", 8 => \"eighty-\", 9 => \"ninety-\");\nif($a <= 20)\n{\n print $b[$a];\n}\nelse\n{\n print $c[$a[0]] . $b[$a[1]];\n}\n?>"}, {"source_code": " 'one',\n 2 => 'two',\n 3 => 'three',\n 4 => 'four',\n 5 => 'five',\n 6 => 'six',\n 7 => 'seven',\n 8 => 'eight',\n 9 => 'nine',\n 10 => 'ten',\n 11 => 'eleven',\n 12 => 'twelve',\n 13 => 'thirteen',\n 15 => 'fifteen'\n);\n\n$stringFirstNumbers = array(\n 1 => '',\n 2 => 'twenty',\n 3 => 'thirty',\n 4 => 'forty',\n 5 => 'fifty',\n 6 => 'sixty',\n 7 => 'seventy',\n 8 => 'eighty',\n 9 => 'ninety',\n);\n\nif ($number <= 13 || $number == 15)\n echo $number == 0 ? 'zero' : $stringNumbers[$number];\n\nelse {\n $firstNumber = $number / 10;\n $secondNumber = $number % 10;\n\n if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';\n\n else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];\n}"}, {"source_code": " 'one',\n 2 => 'two',\n 3 => 'three',\n 4 => 'four',\n 5 => 'five',\n 6 => 'six',\n 7 => 'seven',\n 8 => 'eight',\n 9 => 'nine',\n 10 => 'ten',\n 11 => 'eleven',\n 12 => 'twelve',\n 13 => 'thirteen',\n 15 => 'fifteen'\n);\n\n$stringFirstNumbers = array(\n 1 => '',\n 2 => 'twenty',\n 3 => 'thirty',\n 4 => 'forty',\n 5 => 'fifty',\n 6 => 'sixty',\n 7 => 'seventy',\n 8 => 'eighty',\n 9 => 'ninety',\n);\n\nif ($number <= 13 || $number === 15)\n echo $number == 0 ? 'zero' : $stringNumbers[$number];\n\nelse {\n $firstNumber = $number / 10;\n $secondNumber = $number % 10;\n\n if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';\n\n else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];\n}"}, {"source_code": " 'one',\n 2 => 'two',\n 3 => 'three',\n 4 => 'four',\n 5 => 'five',\n 6 => 'six',\n 7 => 'seven',\n 8 => 'eight',\n 9 => 'nine',\n 10 => 'ten',\n 11 => 'eleven',\n 12 => 'twelve',\n 13 => 'thirteen',\n 15 => 'fifteen'\n);\n\n$stringFirstNumbers = array(\n 1 => '',\n 2 => 'twenty',\n 3 => 'thirty',\n 4 => 'forty',\n 5 => 'fifty',\n 6 => 'sixty',\n 7 => 'seventy',\n 8 => 'eighty',\n 9 => 'ninety',\n);\n\nif ($number <= 13 || $number === 15)\n echo $number == 0 ? 'zero' : $stringNumbers[$number];\n\nelse {\n $firstNumber = $number / 10;\n $secondNumber = $number % 10;\n\n if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';\n\n else echo $stringFirstNumbers[(int)$firstNumber].$stringNumbers[(int)$secondNumber];\n}"}, {"source_code": " 'one',\n 2 => 'two',\n 3 => 'three',\n 4 => 'four',\n 5 => 'five',\n 6 => 'six',\n 7 => 'seven',\n 8 => 'eight',\n 9 => 'nine',\n 10 => 'ten',\n 11 => 'eleven',\n 12 => 'twelve',\n 13 => 'thirteen',\n 15 => 'fifteen'\n);\n\n$stringFirstNumbers = array(\n 1 => '',\n 2 => 'twenty',\n 3 => 'thirty',\n 4 => 'forty',\n 5 => 'fifty',\n 6 => 'sixty',\n 7 => 'seventy',\n 8 => 'eighty',\n 9 => 'ninety',\n);\n\nif ($number <= 13 || $number === 15)\n echo $number == 0 ? 'zero' : $stringNumbers[$number];\n\nelse {\n $firstNumber = $number / 10;\n $secondNumber = $number % 10;\n\n if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';\n\n else echo $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber];\n}"}, {"source_code": " 'zero', '1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', '8' => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety');\n// \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e 19\nif ($s <= 19) {\n\t$result = $numbers[$s];\n} else {\n\t// \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430\n\tif($s[1]==0) {\n\t\t// \u0415\u0441\u043b\u0438 0, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n\t\t$result = $numbers[$s];\n\t} else {\n\t\t// \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e\n\t\t$first_number = $numbers[$s[0].'0'];\n\t\t$second_number = $numbers[$s[1]];\n\t\t$result = $first_number.'-'.$second_number;\n\t}\n}\nprintf($result);\n?>"}], "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7"} {"nl": {"description": "Little Petya was given this problem for homework:You are given function (here represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x)\u2009=\u2009x.It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers with property that probability that f(x)\u2009=\u2009x is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number x if there exist at least 7 permutations of numbers p1,\u2009p2,\u2009p3,\u2009p4, for which f(x)\u2009=\u2009x.", "input_spec": "First line of the input will contain 6 integers, separated by spaces: p1,\u2009p2,\u2009p3,\u2009p4,\u2009a,\u2009b (1\u2009\u2264\u2009p1,\u2009p2,\u2009p3,\u2009p4\u2009\u2264\u20091000,\u20090\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u200931415). It is guaranteed that numbers p1,\u2009p2,\u2009p3,\u2009p4 will be pairwise distinct.", "output_spec": "Output the number of integers in the given range that have the given property.", "sample_inputs": ["2 7 1 8 2 8", "20 30 40 50 0 100", "31 41 59 26 17 43"], "sample_outputs": ["0", "20", "9"], "notes": null}, "positive_code": [{"source_code": "7){\n $coolxcnt++;\n break;\n }\n \n } \n } \n}\necho $coolxcnt;\n\n\n?>"}, {"source_code": "$b)\n echo $b-$a+1;\nelseif (($min>$a)&&($min<$b))\n echo $min - $a;\nelse \n echo 0;\n?>\n"}, {"source_code": ""}], "negative_code": [{"source_code": "$b)\n echo $b-$a;\nelseif (($min>$a)&&($min<$b))\n echo $min - $a;\nelse \n echo 0;\n?>"}, {"source_code": ""}], "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a"} {"nl": {"description": "Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation $$$a + 1 = b$$$ with positive integers $$$a$$$ and $$$b$$$, but Kolya forgot the numbers $$$a$$$ and $$$b$$$. He does, however, remember that the first (leftmost) digit of $$$a$$$ was $$$d_a$$$, and the first (leftmost) digit of $$$b$$$ was $$$d_b$$$.Can you reconstruct any equation $$$a + 1 = b$$$ that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.", "input_spec": "The only line contains two space-separated digits $$$d_a$$$ and $$$d_b$$$ ($$$1 \\leq d_a, d_b \\leq 9$$$).", "output_spec": "If there is no equation $$$a + 1 = b$$$ with positive integers $$$a$$$ and $$$b$$$ such that the first digit of $$$a$$$ is $$$d_a$$$, and the first digit of $$$b$$$ is $$$d_b$$$, print a single number $$$-1$$$. Otherwise, print any suitable $$$a$$$ and $$$b$$$ that both are positive and do not exceed $$$10^9$$$. It is guaranteed that if a solution exists, there also exists a solution with both numbers not exceeding $$$10^9$$$.", "sample_inputs": ["1 2", "4 4", "5 7", "6 2"], "sample_outputs": ["199 200", "412 413", "-1", "-1"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "3eff6f044c028146bea5f0dfd2870d23"} {"nl": {"description": "Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.Note, that during capitalization all the letters except the first one remains unchanged.", "input_spec": "A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.", "output_spec": "Output the given word after capitalization.", "sample_inputs": ["ApPLe", "konjac"], "sample_outputs": ["ApPLe", "Konjac"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "= 'a' && $s[0] <= 'z'){\n $s[0] = strtoupper($s[0]);\n }\n echo $s;\n echo \"\\n\";\n}"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 'a' && $c <= 'z');\n }\n \n $s = trim(fgets(STDIN));\n \n if (islower($s[0])) {\n $char = ord($s[0]) + ord(\"A\") - ord(\"a\");\n $s[0] = chr($char);\n }\n \n echo $s;\n?>"}, {"source_code": ""}, {"source_code": "#!/usr/bin/php\n"}, {"source_code": "='a') $str[0] = chr(ord($str[0]) - 32);\necho $str;"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "96 && ord($a)<123) { $stri[0] = chr((ord($a)-32)); \n\t\t//for($i=0;$i<$n;$i++){echo $stri[$i];}\n\t\t}\n//echo ord($a);\n\necho $stri;\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value) {\n $stdIn[$key] = (int)$value;\n }\n }\n\n return $stdIn;\n}\n\nfunction stdOut($output)\n{\n fwrite(STDOUT, $output);\n}\n\nfunction solve(): void\n{\n [$word] = getStdIn();\n stdOut(ucfirst($word));\n}\n\nsolve();\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "= 97 )\n{\n $s[0] = strtoupper( $s[0] ) ;\n}\necho $s ;\n\nfwrite($stdout);\n\nfclose($stdin);\nfclose($stdout);\n\n?>"}, {"source_code": ""}, {"source_code": "= 97 && $oldOrd <= 122) {\n $newOrd = ord($str_chars[0]) - 32;\n $str_chars[0] = chr($newOrd);\n}\n\n$new_str = implode(\"\", $str_chars);\n\necho $new_str;\n\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 'A' && $in[$x] <= 'Z') {\n\t\t\t$flag = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ($flag) {\n\t\techo strtoupper(substr($in,0,1)).substr($in,1,$len-1);\n\t} else echo $in;"}, {"source_code": ""}, {"source_code": " $value) {\n $stdIn[$key] = (int)$value;\n }\n }\n\n return $stdIn;\n}\n\nfunction stdOut($output)\n{\n fwrite(STDOUT, $output);\n}\n\nfunction solve(): void\n{\n [$word] = getStdIn(true);\n stdOut(ucfirst($word));\n}\n\nsolve();\n"}, {"source_code": ""}], "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"nl": {"description": "Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all: 'U': go up, (x, y) \u2009\u2192\u2009 (x, y+1); 'D': go down, (x, y) \u2009\u2192\u2009 (x, y-1); 'L': go left, (x, y) \u2009\u2192\u2009 (x-1, y); 'R': go right, (x, y) \u2009\u2192\u2009 (x+1, y). The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a,\u2009b).", "input_spec": "The first line contains two integers a and b, (\u2009-\u2009109\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009109). The second line contains a string s (1\u2009\u2264\u2009|s|\u2009\u2264\u2009100, s only contains characters 'U', 'D', 'L', 'R') \u2014 the command.", "output_spec": "Print \"Yes\" if the robot will be located at (a,\u2009b), and \"No\" otherwise.", "sample_inputs": ["2 2\nRU", "1 2\nRU", "-1 1000000000\nLRRLU", "0 0\nD"], "sample_outputs": ["Yes", "No", "Yes", "Yes"], "notes": "NoteIn the first and second test case, command string is \"RU\", so the robot will go right, then go up, then right, and then up and so on.The locations of its moves are (0, 0) \u2009\u2192\u2009 (1, 0) \u2009\u2192\u2009 (1, 1) \u2009\u2192\u2009 (2, 1) \u2009\u2192\u2009 (2, 2) \u2009\u2192\u2009 ...So it can reach (2, 2) but not (1, 2)."}, "positive_code": [{"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n \n if ($i<$length)\n {\n if ($min_x>$c_posx) $min_x=$c_posx;\n if ($min_y>$c_posy) $min_y=$c_posy;\n \n if ($max_x<$c_posx) $max_x=$c_posx;\n if ($max_y<$c_posy) $max_y=$c_posy;\n }\n \n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n$plav_x=$max_x-$min_x;\n$plav_y=$max_y-$min_y;\n\n\nif ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-$plav;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*($plav+1))\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n if ($c_posx==$a && $c_posy==$b && $plav==0) die('Yes');\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n //echo $current_word.' '.$c_posx.' '.$c_posy.'
';\n \n \n $i++;\n \n //if (($i % $length) == 0 && $i!=0) echo '
';\n \n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "= 0) && ($diffy >= 0)) {\n\t\techo \"Yes\"; return 0;\n\t}\n}\necho \"No\";"}], "negative_code": [{"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-2;\n\n\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=$a/$itog_x;\n$num_y_cycles=$b/$itog_y;\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-2;\n\n$c_posx=$itog_x*abs($go_iterations);\n$c_posy=$itog_y*abs($go_iterations);\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-5;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*7)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n\n $i++;\n \n\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n \n if ($i<$length)\n {\n if ($min_x>$c_posx) $min_x=$c_posx;\n if ($min_y>$c_posy) $min_y=$c_posy;\n \n if ($max_x<$c_posx) $max_x=$c_posx;\n if ($max_y<$c_posy) $max_y=$c_posy;\n }\n \n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n$plav_x=$max_x-$min_x;\n$plav_y=$max_y-$min_y;\n\n\nif ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-$plav;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*($plav+1))\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n //echo $current_word.' '.$c_posx.' '.$c_posy.'
';\n \n \n $i++;\n \n //if (($i % $length) == 0 && $i!=0) echo '
';\n \n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n if ($c_posx==$a && $c_posy==$b) die('Yes');\n if ($c_posx<$max_x || $c_posx>$max_y || $c_posy>$max_y || $c_posy<$max_x) die('No');\n\n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=$a/$itog_x;\n$num_y_cycles=$b/$itog_y;\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-1;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*2)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=$a/$itog_x;\n$num_y_cycles=$b/$itog_y;\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-1;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*2)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=$a/$itog_x;\n$num_y_cycles=$b/$itog_y;\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-2;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=$a/$itog_x;\n$num_y_cycles=$b/$itog_y;\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=$num_cycles-2;\nif ($go_iterations<0) $go_iterations=1;\n\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-5;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n \n $i++;\n \n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n \n if ($i<$length)\n {\n if ($min_x>$c_posx) $min_x=$c_posx;\n if ($min_y>$c_posy) $min_y=$c_posy;\n \n if ($max_x<$c_posx) $max_x=$c_posx;\n if ($max_y<$c_posy) $max_y=$c_posy;\n }\n \n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n$plav_x=$max_x-$min_x;\n$plav_y=$max_y-$min_y;\n\nif ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-$plav;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n//echo $num_cycles.' '.$itog_x.' '.$itog_y.'
';\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*($plav+1))\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n //echo $current_word.' '.$c_posx.' '.$c_posy.'
';\n \n \n $i++;\n \n //if (($i % $length) == 0 && $i!=0) echo '
';\n \n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}, {"source_code": "=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n if ($i==$length)\n {\n $change_x=$c_posx;\n $change_y=$c_posy;\n }\n if ($i==$length*2)\n {\n $change_x_2=$c_posx;\n $change_y_2=$c_posy;\n }\n $cur_pos++;\n}\n\n\n\n$itog_x=$change_x_2-$change_x;\n$itog_y=$change_y_2-$change_y;\n\n$num_x_cycles=abs($a)/abs($itog_x);\n$num_y_cycles=abs($b)/abs($itog_y);\n\nif ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;\n\n$go_iterations=ceil($num_cycles)-2;\n\n$c_posx=$itog_x*$go_iterations;\n$c_posy=$itog_y*$go_iterations;\n\n$i=0;\n$cur_pos=0;\nwhile($i<$length*3)\n{\n if ($cur_pos>=$length) $cur_pos=0;\n $current_word=$path[$cur_pos];\n \n switch ($current_word)\n {\n case 'U':\n $c_posy=$c_posy+1;\n break;\n case 'D':\n $c_posy=$c_posy-1;\n break;\n case 'L':\n $c_posx=$c_posx-1;\n break;\n case 'R':\n $c_posx=$c_posx+1;\n break;\n }\n $i++;\n $cur_pos++;\n if ($c_posx==$a && $c_posy==$b) die('Yes');\n}\ndie('No');\n?>"}], "src_uid": "5d6212e28c7942e9ff4d096938b782bf"} {"nl": {"description": "Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides, Vova has several splitters.A splitter is a construction that consists of one input (it can be connected to a water pipe) and x output pipes. When a splitter is connected to a water pipe, water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example, you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe. The figure shows a 4-output splitter Vova has one splitter of each kind: with 2, 3, 4, ..., k outputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.Vova needs the pipeline to have exactly n pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.", "input_spec": "The first line contains two space-separated integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u20091018, 2\u2009\u2264\u2009k\u2009\u2264\u2009109). 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.", "output_spec": "Print a single integer \u2014 the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1.", "sample_inputs": ["4 3", "5 5", "8 4"], "sample_outputs": ["2", "1", "-1"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid+1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n if($n==1) $r = 0;\n // echo $l.PHP_EOL.$r.PHP_EOL;\n\n\n\n\n\n\n echo $r;\n "}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid+1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n // echo $l.PHP_EOL.$r.PHP_EOL;\n\nif($n == 499999999500000000) $r = 999999998;\n echo $r;"}, {"source_code": "= $s[1])echo \"-1\"; else echo $t;}\nelse \n{\n echo \"1\";\n}\n"}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid+1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n // echo $l.PHP_EOL.$r.PHP_EOL;\n\n\n\n\n\n\n echo $r;\n "}, {"source_code": " (($k*($k+1)/2)-$k +1)) {$r = -1;}\n \n else \n {\n while($l<$r)\n {\n $mid = $l + ($r - $l) / 2;\n if ($n <= $mid)\n {\n $r = $mid;\n }\n else\n {\n $l = $mid + 1;\n }\n }\n \n }\n if($n==$k) $r = 1;\n echo $r;"}, {"source_code": " ceil(($k*($k+1)/2)-$k +1)) {$r = -1;}\n \n else \n {\n while($l<$r)\n {\n $mid = ceil($l + ($r - $l) / 2);\n if ($n <= $mid)\n {\n $r = $mid;\n }\n else\n {\n $l = $mid + 1;\n }\n }\n \n }\n if($n==$k) $r = 1;\n if($n == 499999998500000001 )$r = 999955279;\n\n echo $r;"}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid +1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n\n echo $r;"}, {"source_code": " ($k+$k +1)/2 *$k ) {$r = -1;}\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid +1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n\n echo $r;"}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid+1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n // echo $l.PHP_EOL.$r.PHP_EOL;\n\n\n\n\n\n\n echo $r;\n "}, {"source_code": " ($k+1)/2 * $k+1) {$r = -1; }\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid+1; \n } \n } \n }\n if($n==$k+1) $r = 1;\n // echo $l.PHP_EOL.$r.PHP_EOL;\n\n\n\n\nif($n == 499999999500000002) $r = -1;\nif($n == 499999999500000001) $r = 999999999;\nif($n == 499999999500000000) $r = 999999998;\n\n echo $r;\n "}, {"source_code": " ceil(($k*($k+1)/2)-$k +1)) {$r = -1;}\n else \n {\n while(($l-$r)<0)\n {\n $mid = floor(($l + $r ) / 2); \n //$Mmid = (($mid*($mid+1)/2)-$mid +1) ; \n $Mmid = ($k+$k -$mid +1)/2 *$mid ; \n if ($n <= $Mmid)\n {\n $r = $mid; \n }\n else\n {\n $l = $mid +1; \n } \n } \n }\n if($n==$k) $r = 1;\n \n echo $r;"}], "src_uid": "83bcfe32db302fbae18e8a95d89cf411"} {"nl": {"description": "One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm \u2009\u00d7\u2009 b mm sheet of paper (a\u2009>\u2009b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting the excess part. After making a paper ship from the square piece, Vasya looked on the remaining (a\u2009-\u2009b) mm \u2009\u00d7\u2009 b mm strip of paper. He got the idea to use this strip of paper in the same way to make an origami, and then use the remainder (if it exists) and so on. At the moment when he is left with a square piece of paper, he will make the last ship from it and stop.Can you determine how many ships Vasya will make during the lesson?", "input_spec": "The first line of the input contains two integers a, b (1\u2009\u2264\u2009b\u2009<\u2009a\u2009\u2264\u20091012) \u2014 the sizes of the original sheet of paper.", "output_spec": "Print a single integer \u2014 the number of ships that Vasya will make.", "sample_inputs": ["2 1", "10 7", "1000000000000 1"], "sample_outputs": ["2", "6", "1000000000000"], "notes": "NotePictures to the first and second sample test. "}, "positive_code": [{"source_code": " $b)\n {\n $a -= bcmul($b, $g);\n }\n else\n {\n $b -= bcmul($a, $g);\n }\n } \n}\nprint $c;\n?>"}, {"source_code": ""}], "negative_code": [], "src_uid": "ce698a0eb3f5b82de58feb177ce43b83"} {"nl": {"description": "Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take). Your task is to determine by the given a, b and n who wins the game.", "input_spec": "The only string contains space-separated integers a, b and n (1\u2009\u2264\u2009a,\u2009b,\u2009n\u2009\u2264\u2009100) \u2014 the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.", "output_spec": "If Simon wins, print \"0\" (without the quotes), otherwise print \"1\" (without the quotes).", "sample_inputs": ["3 5 9", "1 1 100"], "sample_outputs": ["0", "1"], "notes": "NoteThe greatest common divisor of two non-negative integers a and b is such maximum positive integer k, that a is divisible by k without remainder and similarly, b is divisible by k without remainder. Let gcd(a,\u2009b) represent the operation of calculating the greatest common divisor of numbers a and b. Specifically, gcd(x,\u20090)\u2009=\u2009gcd(0,\u2009x)\u2009=\u2009x.In the first sample the game will go like that: Simon should take gcd(3,\u20099)\u2009=\u20093 stones from the heap. After his move the heap has 6 stones left. Antisimon should take gcd(5,\u20096)\u2009=\u20091 stone from the heap. After his move the heap has 5 stones left. Simon should take gcd(3,\u20095)\u2009=\u20091 stone from the heap. After his move the heap has 4 stones left. Antisimon should take gcd(5,\u20094)\u2009=\u20091 stone from the heap. After his move the heap has 3 stones left. Simon should take gcd(3,\u20093)\u2009=\u20093 stones from the heap. After his move the heap has 0 stones left. Antisimon should take gcd(5,\u20090)\u2009=\u20095 stones from the heap. As 0\u2009<\u20095, it is impossible and Antisimon loses.In the second sample each player during each move takes one stone from the heap. As n is even, Antisimon takes the last stone and Simon can't make a move after that."}, "positive_code": [{"source_code": ""}, {"source_code": "$b)\n $a -= $b;\n else\n $b -= $a;\n return $a;\n}\nfunction lite($a,$b,$n){\n $f=nod($a,$n);\n if (($n-$f)==0) return 0;\n $f1=nod($b,$n-$f);\n if (($n-$f-$f1)==0) return 1;\n return lite($a,$b,$n-=($f+$f1));\n} \nprint lite($a, $b, $n);\n?>"}, {"source_code": "=0){\n $a = $n;\n $b = $k[$cur];\n if ($a > $b) $a ^= $b ^= $a ^= $b;\n for($i = $b; $i >= 1; $i--) \n if(($b%$i==0)&&($a%$i==0)) {$turn = $i; break;}\n if($turn<=$n) {$n-=$turn; $cur ^= 1;} else break; \n }\n $cur ^= 1;\n echo $cur;\n?>"}, {"source_code": " $b && $a > 0) {\n $a -= $b;\n }\n if($a === 0) {\n return $b;\n }\n }\n}\n\n$i = explode(' ',trim(fgets(STDIN)));\n$a = intval($i[0]);\n$b = intval($i[1]);\n$n = intval($i[2]);\n$cur = 1;\nwhile(1) {\n if( ($cur%2) !== 0 ) {\n $n -= gcd($a, $n);\n }\n else {\n $n -= gcd($b, $n);\n }\n if($n < 0) {\n break;\n }\n else {\n $cur++;\n if($n === 0) {\n break;\n }\n }\n}\necho( ($cur%2)!==0?'1':'0' );\n"}, {"source_code": " 0)\n{\n while ($k != $n)\n {\n if ($k > $n)\n $k -= $n;\n else\n $n -= $k;\n }\n \n if ($sem)\n {\n $sem = false;\n $k = $b;\n }\n else\n {\n $sem = true;\n $k = $a;\n } \n \n $n = $nn - $n; \n $nn = $n; \n if ($n <= 0)\n {\n switch ($sem)\n {\n case true:\n echo \"1\";\n break;\n case false:\n echo \"0\";\n break;\n }\n break;\n } \n}\n?>"}, {"source_code": " 0)) {\n $n -= $gcd;\n $flag = $flag ^ true;\n } else {\n break;\n } \n}\n\nif ($flag) {\n echo '1';\n} else {\n echo '0';\n}\n\n?>"}, {"source_code": "$a) {$tmp=$b; $b=$a; $a=$tmp; unset($tmp);}\n if ($b==0) $b=$a;\n while ($a%$b>0){\n $r=$a%$b;\n $a=$b;\n $b=$r; \n }\n return $b; \n }\n //\n \n while (1==1){\n $nod=gcd($a,$n);\n $n=$n-$nod;\n if ($n<0) {print(1); break;}\n \n $nod=gcd($b,$n);\n $n=$n-$nod;\n if ($n<0) {print(0); break;}\n }\n \n?>"}, {"source_code": " 0) {\n if(!$player) {\n $c = $a;\n } else {\n $c = $b;\n }\n $n -= NWD($c, $n);\n $player = !$player;\n}\n\necho intVal(!$player);\n\n"}, {"source_code": " $j) return gcd($i % $j, $j); else return gcd($i, $j % $i);\n}\n\nlist($a, $b, $n) = explode(' ',trim(fgets(STDIN)));\n\n$r = 1;\nwhile($n > 0){\n if($r == 1) $n -= gcd($n, $a); else $n -= gcd($n, $b);\n $r = 1 - $r;\n}\n\nprint $r;\n\n?>"}, {"source_code": ""}, {"source_code": " 0)\n{\n while ($k != $n)\n {\n if ($k > $n)\n $k -= $n;\n else\n $n -= $k;\n }\n \n if ($sem)\n {\n $sem = false;\n $k = $b;\n $m++;\n }\n else\n {\n $sem = true;\n $k = $a;\n $l++;\n } \n \n $n = $nn - $n; \n $nn = $n; \n}\nif ($k == max($k, $l))\n echo \"0\";\nelse\n echo \"1\";\n?>"}, {"source_code": ""}, {"source_code": " 0)) {\n $n -= $gcd;\n $flag = $flag ^ true;\n } else {\n break;\n } \n}\n\nif ($flag) {\n echo '1';\n} else {\n echo '0';\n}\n\n?>"}, {"source_code": ""}, {"source_code": ""}], "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2"} {"nl": {"description": "In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4\u2009\u00d7\u20094 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2\u2009\u00d7\u20092 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed. Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2\u2009\u00d7\u20092 square, consisting of cells of the same color.", "input_spec": "Four lines contain four characters each: the j-th character of the i-th line equals \".\" if the cell in the i-th row and the j-th column of the square is painted white, and \"#\", if the cell is black.", "output_spec": "Print \"YES\" (without the quotes), if the test can be passed and \"NO\" (without the quotes) otherwise.", "sample_inputs": ["####\n.#..\n####\n....", "####\n....\n####\n...."], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2\u2009\u00d7\u20092 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column."}, "positive_code": [{"source_code": "= 3|| $tmp <= 1){\n\t\t\t\t$ok=true;\n\t\t\t//\tprint(\"yes\");\n\t\t\t}\n\t\t}\n\t//\tprint_r($pre);\n\t\tfor ($i=0;$i<$sz;++$i) $pre[$i] = $cur[$i];\n\t//\tprint_r($pre);\n\t}\n\n\techo($ok==true ? \"YES\":\"NO\");\n?>\n"}, {"source_code": ""}, {"source_code": "= 3 || ($a[$i][$j] == '.') + ($a[$i+1][$j] == '.') + ($a[$i][$j+1] == '.') + ($a[$i+1][$j+1] == '.') >= 3) {\n\t\t\t\t$chk = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\techo ($chk) ? 'YES' : 'NO';\n?> "}, {"source_code": ""}, {"source_code": "= 3) || ($p >= 3))\n {\n $r = 1;\n break;\n }\n else\n {\n $o = 0;\n $p = 0;\n }\n}\nif($r == 1)\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "1,'.'=>-1);\n$s = '';\nfor($i =0;$i<4;$i++)\n\t$s .= trim(fgets(STDIN));\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])>=2&&$a = \"YES\")\n\t\t\tbreak 2;\necho $a;\nreturn;\n?>"}], "negative_code": [{"source_code": "\n"}, {"source_code": "= 3|| $tmp <= 1){\n\t\t\t\t$ok=true;\n\t\t\t\tprint(\"yes\");\n\t\t\t}\n\t\t}\n\t\tfor ($i=0;$i<$sz && $ok == false;++$i) $pre[i] = $cur[i];\n\t}\n\n\techo($ok==true ? \"YES\":\"NO\");\n?>\n"}, {"source_code": "= 3|| $tmp <= 1){\n\t\t\t\t$ok=true;\n\t\t//\t\tprint(\"yes\");\n\t\t\t}\n\t\t}\n\t\tfor ($i=0;$i<$sz && $ok == false;++$i) $pre[i] = $cur[i];\n\t}\n\n\techo($ok==true ? \"YES\":\"NO\");\n?>\n"}, {"source_code": "= 3) {\n\t\t\t\t$chk = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\techo ($chk) ? 'YES' : 'NO';\n?> "}, {"source_code": " 2)\n echo \"YES\\n\";\n else echo \"NO\\n\";\n?>"}, {"source_code": ""}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2&&$a = \"YES\")\n\t\t\tbreak 2;\n\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n for($j=0;$j<3;$j++)\n if(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n echo \"YES\";\n return;\n }\necho \"NO\";\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n\t\t\techo \"YES\";\n\t\t\treturn;\n\t\t}\necho \"NO\";\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n\t\t\techo \"YES\";\n\t\t\treturn;\n\t\t}\necho \"NO\";\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n\t\t\techo \"YES\";\n\t\t\treturn;\n\t\t}\necho \"NO\";\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[$i*5+$j]]+$m[$s[$i*5+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[$i*5+$j]]+$m[$s[$i*5+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2){\n\t\t\t$a = \"YES\";\n\t\t\tbreak 2;\n\t\t}\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$a = \"NO\";\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2&&$a = \"YES\")\n\t\t\tbreak 2;\n\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n\t\t\techo \"YES\";\n\t\t\treturn;\n\t\t}\necho \"NO\";\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\n$s = '';\nfor($i =0;$i<4;$i++)\n\t$s .= trim(fgets(STDIN));\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i*4+$j]]+$m[$s[$i*4+$j+1]]+$m[$s[($i+1)*4+$j]]+$m[$s[($i+1)*4+$j+1]])==2&&$a = \"YES\")\n\t\t\tbreak 2;\necho $a;\nreturn;\n?>"}, {"source_code": "1,'.'=>-1);\nfor($i=0;$i<3;$i++)\n\tfor($j=0;$j<3;$j++)\n\t\tif(abs($m[$s[$i][$j]]+$m[$s[$i][$j+1]]+$m[$s[$i+1][$j]]+$m[$s[$i+1][$j+1]])==2){\n\t\t\techo \"YES\";\n\t\t\treturn;\n\t\t}\necho \"NO\";\nreturn;\n?>"}], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"nl": {"description": "You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Sylveon.You know the length of the word in the crossword, and you already know some letters. Designers of the crossword made sure that the answer is unambiguous, so you can assume that exactly one pokemon out of the 8 that Eevee evolves into fits the length and the letters given. Your task is to find it.", "input_spec": "First line contains an integer n (6\u2009\u2264\u2009n\u2009\u2264\u20098) \u2013 the length of the string. Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword).", "output_spec": "Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter).", "sample_inputs": ["7\nj......", "7\n...feon", "7\n.l.r.o."], "sample_outputs": ["jolteon", "leafeon", "flareon"], "notes": "NoteHere's a set of names in a form you can paste into your solution:[\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"]{\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"}"}, "positive_code": [{"source_code": ""}, {"source_code": "8) exit;\n\nforeach($names as $k=>$v){\nif(strlen($v)==$num){\n$temp=0;\nfor($i=0;$i<=strlen($str)-1;$i++){\n\nif($v[$i]==$str[$i] || $str[$i]=='.'){\n$temp++;\n}\n\n}\nif($temp==$num){$rezult=$v;}\n}\n}\n\nprint $rezult;\n?>"}, {"source_code": " 8) exit;\n\n$letter = trim(fgets(STDIN));\n\nif ($len !== strlen($letter)) exit;\n\n$pokemons = array(\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\");\n\n$letters = array();\nfor ($i=0; $i<$len; $i++)\n{\n if ($letter{$i} === '.') continue;\n $letters[$i] = $letter{$i};\n}\n\n$result = '';\nforeach ($pokemons as $pokemon)\n{\n if (strlen($pokemon) !== $len) continue;\n\n $find = TRUE;\n foreach ($letters as $k => $v)\n if ($pokemon{$k} !== $v)\n $find = FALSE;\n\n if ($find)\n {\n $result = $pokemon;\n break;\n }\n}\n\nprint $result;\n"}, {"source_code": "\"vaporeon\",\n\t\t 1=>\"jolteon\",\n\t\t 2=>\"flareon\", \n\t\t 3=>\"espeon\", \n\t\t 4=>\"umbreon\",\n\t\t 5=>\"leafeon\", \n\t\t 6=>\"glaceon\", \n\t\t 7=>\"sylveon\"\n ];\n $ev1=\"vaporeon\";\n $ev2=\"jolteon\";\n $ev3=\"flareon\";\n $ev4=\"espeon\";\n $ev5=\"umbreon\";\n $ev6=\"leafeon\";\n $ev7=\"glaceon\";\n $ev8=\"sylveon\";\nif($str=='......')\necho \"espeon\";\nelseif ($str=='........')\n {\n \techo \"vaporeon\";\n\t# code...\n}\n\n\n\nelse\n{\n\n\n \n \n $flag=0;\n $max=0;\n //$length=9;\n $trgetStr=findTrgtStr($str);\nfor ($i=0; $i =$max&&strlen($eve[$i])==$n)\n {\n \t$max=$count;\n \t//$length=strlen($eve[$i]);\n \t$str3=$eve[$i];\n }\n //echo \"$max\\n\";\n\n \n \n}\t\nprint_r($str3);\n}\n\nfunction findTrgtStr($str)\n{\n\t$trgetStr=\"\";\nfor ($i=0; $i \"vaporeon\",\n\t\t 1=>\"jolteon\",\n\t\t 2=>\"flareon\", \n\t\t 3=>\"espeon\", \n\t\t 4=>\"umbreon\",\n\t\t 5=>\"leafeon\", \n\t\t 6=>\"glaceon\", \n\t\t 7=>\"sylveon\"\n ];\n\nif($str=='......')\necho \"espeon\";\nelseif ($str=='........')\n {\n \techo \"vaporeon\";\n\t# code...\n}\n\n\n\nelse\n{\n\n\n \n \n $flag=0;\n $max=0;\n //$length=9;\n $trgetStr=findTrgtStr($str);\nfor ($i=0; $i =$max&&strlen($eve[$i])==$n)\n {\n \t$max=$count;\n \t//$length=strlen($eve[$i]);\n \t$str3=$eve[$i];\n }\n //echo \"$max\\n\";\n\n \n \n}\t\nprint_r($str3);\n}\n\nfunction findTrgtStr($str)\n{\n\t$trgetStr=\"\";\nfor ($i=0; $i $name){\n if($pos[$k] && $s[$i]!=$name[$i]){\n $pos[$k] = 0;\n $c--;\n }\n }\n if($c==1){\n break;\n }\n }\n }\n\n for($i=0; $i<$n; $i++){\n if($pos[$i]){\n echo $names[$i];\n break;\n }\n }\n\n}\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "\"vaporeon\",\n\t\t 1=>\"jolteon\",\n\t\t 2=>\"flareon\", \n\t\t 3=>\"espeon\", \n\t\t 4=>\"umbreon\",\n\t\t 5=>\"leafeon\", \n\t\t 6=>\"glaceon\", \n\t\t 7=>\"sylveon\"\n ];\n \n \n $flag=0;\n $max=0;\nfor ($i=0; $i =$max)\n {\n \t$max=$count;\n \t$str3=$eve[$i];\n }\n //echo \"$max\\n\";\n\n if($flag==1)\n \tbreak;\n \n}\t\necho \"$str3\\n\";\n"}, {"source_code": "\"vaporeon\",\n\t\t 1=>\"jolteon\",\n\t\t 2=>\"flareon\", \n\t\t 3=>\"espeon\", \n\t\t 4=>\"umbreon\",\n\t\t 5=>\"leafeon\", \n\t\t 6=>\"glaceon\", \n\t\t 7=>\"sylveon\"\n ];\n \n \n $flag=0;\n $max=0;\nfor ($i=0; $i =$max)\n {\n \t$max=$count;\n \t$str3=$eve[$i];\n }\n //echo \"$max\\n\";\n\n if($flag==1)\n \tbreak;\n \n}\t\necho \"$str3\\n\";\n}"}], "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0"} {"nl": {"description": "While playing with geometric figures Alex has accidentally invented a concept of a $$$n$$$-th order rhombus in a cell grid.A $$$1$$$-st order rhombus is just a square $$$1 \\times 1$$$ (i.e just a cell).A $$$n$$$-th order rhombus for all $$$n \\geq 2$$$ one obtains from a $$$n-1$$$-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better). Alex asks you to compute the number of cells in a $$$n$$$-th order rhombus.", "input_spec": "The first and only input line contains integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 order of a rhombus whose numbers of cells should be computed.", "output_spec": "Print exactly one integer\u00a0\u2014 the number of cells in a $$$n$$$-th order rhombus.", "sample_inputs": ["1", "2", "3"], "sample_outputs": ["1", "5", "13"], "notes": "NoteImages of rhombus corresponding to the examples are given in the statement."}, "positive_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "758d342c1badde6d0b4db81285be780c"} {"nl": {"description": "Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.You know that there will be n interesting minutes t1,\u2009t2,\u2009...,\u2009tn. Your task is to calculate for how many minutes Limak will watch the game.", "input_spec": "The first line of the input contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u200990)\u00a0\u2014 the number of interesting minutes. The second line contains n integers t1,\u2009t2,\u2009...,\u2009tn (1\u2009\u2264\u2009t1\u2009<\u2009t2\u2009<\u2009... tn\u2009\u2264\u200990), given in the increasing order.", "output_spec": "Print the number of minutes Limak will watch the game.", "sample_inputs": ["3\n7 20 88", "9\n16 20 30 40 50 60 70 80 90", "9\n15 20 30 40 50 60 70 80 90"], "sample_outputs": ["35", "15", "90"], "notes": "NoteIn the first sample, minutes 21,\u200922,\u2009...,\u200935 are all boring and thus Limak will turn TV off immediately after the 35-th minute. So, he would watch the game for 35 minutes.In the second sample, the first 15 minutes are boring.In the third sample, there are no consecutive 15 boring minutes. So, Limak will watch the whole game."}, "positive_code": [{"source_code": ""}, {"source_code": " $min) {\n\t\t$min = (int)$min;\n\t\tif($min - $prevMin > 15) {\n\t\t\t$result = $prevMin + 15;\n\t\t\tbreak;\n\t\t}\n\t\tif($min == 90) {\n\t\t\t$result = 90;\n\t\t\tbreak;\n\t\t}\n\t\tif($key == $count - 1 && $min + 15 < 90) {\n\t\t\t$result = $min + 15;\n\t\t\tbreak;\n\t\t}\n\t\t$prevMin = $min;\n\t}\n\techo $result;\n?>"}, {"source_code": " 15) return ($start+15) >= 90 ? 90 : $start+15 ;\n $start = $arr[$i];\n }\n return ($arr[$n-1] + 15) >= 90 ? 90 : $arr[$n-1]+15;\n}\n // \u00a0Bear and Game\n $in = 'php://stdin';\n $input = fopen($in, \"r\");\n $n = fgets($input);\n $t = [];\n $t = array_merge($t, explode(\" \", trim(fgets($input))));\n echo (test($n,$t));\n\n?>"}, {"source_code": " $maxWait){\n\t\techo $maxWait;die;\n\t}else{\n\t\t$maxWait = $interestMin + 15;\n\t}\n}\necho $maxWait > 90 ? 90 : $maxWait;\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\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$n = readNum($f);\n\t$times = readStringExplodeNum($f, ' ', true);\n\t$f = 0;\n\t$viewTime = 0;\n\tfor ($i = 1; $i <= 90; $i++) {\n\t\tif (in_array($i, $times)) {\n\t\t\t$f = 0;\n\t\t} else {\n\t\t\t$f ++;\n\t\t}\n\n\t\t$viewTime++;\n\t\tif ($f >= 15) {\n\t\t\tbreak;\n\t\t}\n\t}\n\techo $viewTime;\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": " 15) {\n echo($t[$i] + 15);\n $isTVOff = true;\n break;\n }\n}\nif (!$isTVOff) {\n echo(90);\n}"}, {"source_code": " 15) {\n echo($tt[$i] + 15);\n $isTVOff = true;\n break;\n }\n}\nif (!$isTVOff) {\n echo(90);\n}"}, {"source_code": " 15) break;\n\n $watchTime = $t[$i];\n }\n echo $watchTime+15 > 90 ? 90 : $watchTime+15;\n}\n\nwatchTime($n,$t);"}, {"source_code": " 1){\n break;\n } else {\n $watchTime = $t[$i];\n }\n }\n echo $watchTime+15 > 90 ? 90 : $watchTime+15 ;\n}\n\nwatchTime($n,$t);"}], "negative_code": [{"source_code": " 15) {\n\t\t\techo $prevMin + 15;\n\t\t\tbreak;\n\t\t}\n\t\t$prevMin = $min;\n\t}\n\t\n?>"}, {"source_code": " 15) {\n\t\t\techo $prevMin + 15;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n?>"}, {"source_code": " 15) {\n\t\t\t$result = $prevMin + 15;\n\t\t\tbreak;\n\t\t}\n\t\t$prevMin = $min;\n\t}\n\techo $result;\n?>"}, {"source_code": " 15) {\n\t\t\techo $min + 15;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n?>"}, {"source_code": " $min) {\n\t\t$min = (int)$min;\n\t\tif($min == 90) {\n\t\t\t$result = 90;\n\t\t\tbreak;\n\t\t}\n\t\tif($min - $prevMin > 15) {\n\t\t\t$result = $prevMin + 15;\n\t\t\tbreak;\n\t\t}\n\t\tif($key == $count - 1 && $min + 15 < 90) {\n\t\t\t$result = $min + 15;\n\t\t\tbreak;\n\t\t}\n\t\t$prevMin = $min;\n\t}\n\techo $result;\n?>"}, {"source_code": " 15) return $start+15;\n $start = $arr[$i];\n }\n return $arr[$n-1] + 15;\n}\n // \u00a0Bear and Game\n $in = 'php://stdin';\n $input = fopen($in, \"r\");\n $n = fgets($input);\n $t = [];\n $t = array_merge($t, explode(\" \", trim(fgets($input))));\n echo (test($n,$t));\n\n?>"}, {"source_code": " $maxWait){\n\t\techo $maxWait;die;\n\t}else{\n\t\t$maxWait = $interestMin + 15;\n\t}\n}\necho 90;\n\n?>"}, {"source_code": " 1){\n break;\n } else {\n $watchTime = $t[$i];\n }\n }\n echo $watchTime+15 > 90 ? $watchTime : $watchTime+15 ;\n}\n\nwatchTime($n,$t);"}, {"source_code": " 1){\n $watchTime+=15;\n break;\n } else {\n $watchTime = $t[$i];\n }\n }\n echo $watchTime;\n}\n\necho watchTime($n,$t);"}, {"source_code": " 1){\n $watchTime+=15;\n break;\n } else {\n $watchTime = $t[$i];\n }\n }\n echo $watchTime > 90 ? 90 : $watchTime;\n}\n\necho watchTime($n,$t);"}, {"source_code": "= 15) {\n return $temp + 15;\n }\n\n $temp = $t[$i];\n }\n\n $temp += 15;\n\n return $temp >= 90 ? 90 : $temp;\n}\n\necho kq($t,$n);"}, {"source_code": " 1){\n $watchTime+=15;\n break;\n } else {\n $watchTime = $t[$i];\n }\n }\n echo $watchTime > 90 ? 90 : $watchTime;\n}\n\nwatchTime($n,$t);"}, {"source_code": " 1){\n $watchTime+=15;\n echo \"inTime=$inTime\".PHP_EOL;\n break;\n } else {\n $watchTime = $t[$i];\n }\n\n echo \"inTime=$inTime\".PHP_EOL;\n }\n\n echo $watchTime;\n}\n\necho watchTime($n,$t);"}], "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27"} {"nl": {"description": "A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your task is to determine the size of the rectangular display \u2014 the number of lines (rows) of pixels a and the number of columns of pixels b, so that: there are exactly n pixels on the display; the number of rows does not exceed the number of columns, it means a\u2009\u2264\u2009b; the difference b\u2009-\u2009a is as small as possible. ", "input_spec": "The first line contains the positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009106)\u00a0\u2014 the number of pixels display should have.", "output_spec": "Print two integers\u00a0\u2014 the number of rows and columns on the display. ", "sample_inputs": ["8", "64", "5", "999999"], "sample_outputs": ["2 4", "8 8", "1 5", "999 1001"], "notes": "NoteIn the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.In the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels."}, "positive_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*/ $dxs = new stdIn(false);\n\n$n = $dxs->GL();\n$a = (int) sqrt($n);\n\nfor( ; $a ; $a--) {\n\tif($n % $a == 0) {\n\t\t$t = $n / $a;\n\t\techo min($t, $a) . ' ' . max($t, $b);\n\t\tbreak;\n\t}\n}\n"}, {"source_code": "= $g)\n {\n $f[$x]++;\n }\n }\n $g--;\n}\nprint implode(\" \", $f);\n?>"}, {"source_code": " $input[$x+1]){\n $z = $input[$x];\n $input[$x] = $input[$x+1];\n $input[$x+1] = $z;\n }\n }\n}\n\n$output = implode(\" \", $input);\n\nprint $output;\n\n?>"}, {"source_code": ""}, {"source_code": "\n "}, {"source_code": ""}, {"source_code": " $col[$i]){\n $t = $col[$i + 1];\n $col[$i + 1] = $col[$i];\n $col[$i] = $t;\n\n $end = false;\n }\n }\n}while(!$end);\n\n$col = array_reverse($col);\nw(implode(' ', $col));"}, {"source_code": ""}, {"source_code": " "}, {"source_code": ""}, {"source_code": "=0;$i--){\n for($j=$n-1;$j>=0;$j--){\n\t\tif ($cube[$i] > $cube[$j]){\n\t\t\t$sisa = $cube[$i] - $cube[$j];\n\t\t\t$cube[$j] += $sisa;\n\t\t\t$cube[$i] -= $sisa;\n\t\t}\n\t}\n}\nforeach($cube as $value){\n\techo $value . \" \";\n}\n?>"}, {"source_code": ""}, {"source_code": " &$value) {\n $value = (int) $value;\n}\nunset($value);\n\nsort($arr);\n\n$out = implode(\" \", $arr);\n\necho $out;\n\n?>"}, {"source_code": ""}, {"source_code": "= $m - $j);\n }\n}\n\n$output = '';\n\nfor ($i = 0; $i < $n; $i ++) {\n $answer = 0;\n for ($j = 0; $j < $m; $j ++) {\n $answer += ($b[$j] >= $n - $i);\n }\n $output .= ($i > 0 ? ' ' : '') . $answer;\n}\n\nprint $output;\n\nfunction line() {\n return trim(fgets(STDIN));\n}\n"}, {"source_code": ""}], "negative_code": [{"source_code": " $input[$x+1]){\n $z = $input[$x];\n $input[$x] = $input[$x+1];\n $input[$x+1] = $z;\n } else {\n break;\n }\n }\n}\n\n$output = implode(\" \", $input);\n\nprint $output;\n\n?>"}, {"source_code": " $input[$x+1]){\n $z = $input[$x];\n $input[$x] = $input[$x+1];\n $input[$x+1] = $z;\n }\n }\n}\n\n$output = implode(\" \", $input);\n\nprint $output;\n\n?>"}, {"source_code": "\n "}, {"source_code": ""}, {"source_code": ""}], "src_uid": "ae20712265d4adf293e75d016b4b82d8"} {"nl": {"description": "There are n students who have taken part in an olympiad. Now it's time to award the students.Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.", "input_spec": "The first (and the only) line of input contains two integers n and k (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u20091012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.", "output_spec": "Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible. It's possible that there are no winners.", "sample_inputs": ["18 2", "9 10", "1000000000000 5", "1000000000000 499999999999"], "sample_outputs": ["3 6 9", "0 0 9", "83333333333 416666666665 500000000002", "1 499999999999 500000000000"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": " $b[count($b) - 1])\n {\n $b[0] = $b[0] - $b[count($b) - 1];\n rsort($b);\n }\n else\n {\n break;\n }\n}\nprint array_sum($b);\n?>"}, {"source_code": "#!/usr/bin/env php\n"}], "negative_code": [{"source_code": " $b[1])\n {\n $b[0] = $b[0] - $b[1];\n rsort($b);\n }\n else\n {\n break;\n }\n}\nprint array_sum($b);\n?>"}, {"source_code": "#!/usr/bin/env php\n"}], "negative_code": [{"source_code": ""}], "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3"} {"nl": {"description": "Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a \"war\"-like card game. The rules are following. On each turn a fight happens. Each of them picks card from the top of his stack and puts on the table. The one whose card value is bigger wins this fight and takes both cards from the table to the bottom of his stack. More precisely, he first takes his opponent's card and puts to the bottom of his stack, and then he puts his card to the bottom of his stack. If after some turn one of the player's stack becomes empty, he loses and the other one wins. You have to calculate how many fights will happen and who will win the game, or state that game won't end.", "input_spec": "First line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u200910), the number of cards. Second line contains integer k1 (1\u2009\u2264\u2009k1\u2009\u2264\u2009n\u2009-\u20091), the number of the first soldier's cards. Then follow k1 integers that are the values on the first soldier's cards, from top to bottom of his stack. Third line contains integer k2 (k1\u2009+\u2009k2\u2009=\u2009n), the number of the second soldier's cards. Then follow k2 integers that are the values on the second soldier's cards, from top to bottom of his stack. All card values are different.", "output_spec": "If somebody wins in this game, print 2 integers where the first one stands for the number of fights before end of game and the second one is 1 or 2 showing which player has won. If the game won't end and will continue forever output \u2009-\u20091.", "sample_inputs": ["4\n2 1 3\n2 4 2", "3\n1 2\n2 1 3"], "sample_outputs": ["6 2", "-1"], "notes": "NoteFirst sample: Second sample: "}, "positive_code": [{"source_code": " $c[$d])\n {\n array_push($b, $c[$d]);\n array_push($b, $b[$d]);\n unset($c[$d]);\n unset($b[$d]);\n $d++;\n if(count($c) == 0)\n {\n $e = 1;\n break;\n }\n }\n else\n {\n array_push($c, $b[$d]);\n array_push($c, $c[$d]);\n unset($b[$d]);\n unset($c[$d]);\n $d++;\n if(count($b) == 0)\n {\n $e = 2;\n break;\n }\n }\n}\nif($e == 0)\n{\n print \"-1\";\n}\nelseif($e == 1)\n{\n print $x . \" 1\";\n}\nelseif($e == 2)\n{\n print $x . \" 2\";\n}\n?>"}], "negative_code": [], "src_uid": "f587b1867754e6958c3d7e0fe368ec6e"} {"nl": {"description": "There is a card game called \"Durak\", which means \"Fool\" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly \u2014 you can find them later yourselves if you want.To play durak you need a pack of 36 cards. Each card has a suit (\"S\", \"H\", \"D\" and \"C\") and a rank (in the increasing order \"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" and \"A\"). At the beginning of the game one suit is arbitrarily chosen as trump. The players move like that: one player puts one or several of his cards on the table and the other one should beat each of them with his cards.A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. Besides, a trump card can beat any non-trump card whatever the cards\u2019 ranks are. In all other cases you can not beat the second card with the first one.You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.", "input_spec": "The first line contains the tramp suit. It is \"S\", \"H\", \"D\" or \"C\". The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank (\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" and \"A\"), and the second one stands for the suit (\"S\", \"H\", \"D\" and \"C\").", "output_spec": "Print \"YES\" (without the quotes) if the first cards beats the second one. Otherwise, print \"NO\" (also without the quotes).", "sample_inputs": ["H\nQH 9S", "S\n8D 6D", "C\n7H AS"], "sample_outputs": ["YES", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": " $i)\n {\n print \"YES\";\n }\n else\n {\n print \"NO\";\n }\n}\nelse\n{\n print \"NO\";\n}\n?>"}, {"source_code": "$d[1])) echo 'YES';\nelseif(($c[0][1]==$k) && ($c[1][1]!=$k)) echo 'YES';\nelse echo 'NO';\n?>"}, {"source_code": " $m[$c2[0]] && $c1[1] == $c2[1]) || ($c1[1] == $k && $c2[1] == $k && $m[$c1[0]] > $m[$c2[0]])){\n\t\techo 'YES';\n\t}else{\n\t\techo 'NO';\n\t}"}, {"source_code": "$b) return 1;\n else return 0; \n}\nif($first[1]==$root){\n if($second[1]==$root){\n if(differ($first[0],$second[0])) echo \"YES\";\n else echo \"NO\";\n }else{\n echo \"YES\";\n }\n}else{\n if($second[1]==$root) echo \"NO\";\n else{\n if($first[1]==$second[1]){\n if(differ($first[0],$second[0])) echo \"YES\";\n else echo \"NO\";\n }else{\n echo \"NO\";\n }\n }\n}\n?>"}, {"source_code": "$key_2)?'YES':'NO';\nelse\n echo ($first{1}==$jok)?'YES':'NO';\n?>"}], "negative_code": [{"source_code": "$b) return 1;\n}\nif($first[1]==$root){\n if($second[1]==$root){\n if(differ($first[0],$second[0])) echo \"YES\";\n else echo \"NO\";\n }else{\n echo \"YES\";\n }\n}else{\n if($second[1]==$root) echo \"NO\";\n else{\n if($first[1]==$second[1]){\n if(differ($first[0],$second[0])) echo \"YES\";\n else echo \"NO\";\n }else{\n echo \"NO\";\n }\n }\n}\n?>"}, {"source_code": "$key_2) or $first{1}==$jok)?'YES':'NO';\n?>"}], "src_uid": "da13bd5a335c7f81c5a963b030655c26"} {"nl": {"description": "Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. Figure out who became the champion.", "input_spec": "The input contains two strings of equal length (between 2 and 20 characters, inclusive). Each line describes the actions of one team.", "output_spec": "Output \"TEAM 1 WINS\" if the first team won, \"TEAM 2 WINS\" if the second team won, and \"TIE\" if there was a tie.", "sample_inputs": ["[]()[]8<\n8<[]()8<", "8<8<()\n[]8<[]"], "sample_outputs": ["TEAM 2 WINS", "TIE"], "notes": null}, "positive_code": [{"source_code": " $d)\n{\n print \"TEAM 1 WINS\";\n}\n?>"}, {"source_code": "1,\n'[8'=>-1,\n'[('=>1,\n'(['=>-1,\n'(8'=>1,\n'8('=>-1,\n);\nfor($i = 0; $i < strlen($s1); $i+=2){\n if($s1{$i} == $s2{$i}) continue;\n $a += $b[$s1{$i} . $s2{$i}];\n //echo $a.\"\\n\";\n}\nif($a > 0)\nfputs(STDOUT,'TEAM 1 WINS');\nelseif($a < 0)\nfputs(STDOUT,'TEAM 2 WINS');\nelse\nfputs(STDOUT,'TIE');\n"}], "negative_code": [], "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf"} {"nl": {"description": "Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action \u2014 multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k.", "input_spec": "The first line contains a single integer k (2\u2009\u2264\u2009k\u2009\u2264\u200910) \u2014 the radix of the system.", "output_spec": "Output the multiplication table for the system of notations with the radix k. The table must contain k\u2009-\u20091 rows and k\u2009-\u20091 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity).", "sample_inputs": ["10", "3"], "sample_outputs": ["1 2 3 4 5 6 7 8 9\n2 4 6 8 10 12 14 16 18\n3 6 9 12 15 18 21 24 27\n4 8 12 16 20 24 28 32 36\n5 10 15 20 25 30 35 40 45\n6 12 18 24 30 36 42 48 54\n7 14 21 28 35 42 49 56 63\n8 16 24 32 40 48 56 64 72\n9 18 27 36 45 54 63 72 81", "1 2\n2 11"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "a705144ace798d6b41068aa284d99050"} {"nl": {"description": "This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to color all its characters one of the two colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in $$$s$$$).After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times.The goal is to make the string sorted, i.e. all characters should be in alphabetical order.Your task is to say if it is possible to color the given string so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps.", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 200$$$) \u2014 the length of $$$s$$$. The second line of the input contains the string $$$s$$$ consisting of exactly $$$n$$$ lowercase Latin letters.", "output_spec": "If it is impossible to color the given string so that after coloring it can become sorted by some sequence of swaps, print \"NO\" (without quotes) in the first line. Otherwise, print \"YES\" in the first line and any correct coloring in the second line (the coloring is the string consisting of $$$n$$$ characters, the $$$i$$$-th character should be '0' if the $$$i$$$-th character is colored the first color and '1' otherwise).", "sample_inputs": ["9\nabacbecfd", "8\naaabbcbb", "7\nabcdedc", "5\nabcde"], "sample_outputs": ["YES\n001010101", "YES\n01011011", "NO", "YES\n00000"], "notes": null}, "positive_code": [{"source_code": "\n"}], "negative_code": [{"source_code": "\n"}], "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b"} {"nl": {"description": "Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x\u2009=\u2009A\u2009\u00d7\u200910B is true. In our case A is between 0 and 9 and B is non-negative.Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.", "input_spec": "The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0\u2009\u2264\u2009a\u2009\u2264\u20099,\u20090\u2009\u2264\u2009d\u2009<\u200910100,\u20090\u2009\u2264\u2009b\u2009\u2264\u2009100)\u00a0\u2014 the scientific notation of the desired distance value. a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.", "output_spec": "Print the only real number x (the desired distance value) in the only line in its decimal notation. Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes. Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).", "sample_inputs": ["8.549e2", "8.549e3", "0.33e0"], "sample_outputs": ["854.9", "8549", "0.33"], "notes": null}, "positive_code": [{"source_code": " $f)\n{\n $g = array_slice($d, 0, $f);\n $h = array_slice($d, $f);\n $i = array_merge($b, $g);\n $h2 = array_unique($h);\n sort($h2);\n if((count($h2) == 1) && ($h2[0] == 0))\n {\n $j = $i;\n if(count($j) == 1)\n {\n print implode($j);\n }\n else\n {\n $k = count($j);\n for($x = 0; $x < $k; $x++)\n {\n if($j[$x] == 0)\n {\n unset($j[$x]);\n }\n else\n {\n break;\n }\n }\n print implode($j);\n }\n }\n else\n {\n array_push($i, \".\");\n $j = array_merge($i, $h);\n if($j[1] == \".\")\n {\n print implode($j);\n }\n else\n {\n $k = count($j);\n for($x = 0; $x < $k; $x++)\n {\n if($j[$x] == 0)\n {\n unset($j[$x]);\n }\n else\n {\n break;\n }\n }\n print implode($j);\n }\n }\n}\n?>"}, {"source_code": " $b) {\n\t\t$realNumber .= '.';\n\t}\n\n\t$realNumber .= substr($d, $b);\n\n\t$realNumber = removeLeadingZeroes($realNumber);\n}\n\nfunction removeLeadingZeroes($realNumber)\n{\n\tif (! strpos($realNumber, '.')) {\n\t\treturn $realNumber;\n\t}\n\n\tfor ($i = strlen($realNumber); $i> 0; $i--) {\n\t\tif ($realNumber[$i-1] != 0) {\n\t\t\treturn $realNumber;\n\t\t}\n\n\t\t$realNumber = substr($realNumber, 0, $i-1);\n\t}\n\n\treturn $realNumber;\n}\n\nfprintf($fw, $realNumber);\n\nfclose($fr);\nfclose($fw);"}], "negative_code": [{"source_code": " $f)\n{\n $g = array_slice($d, 0, $f);\n $h = array_slice($d, $f);\n $i = array_merge($b, $g);\n array_push($i, \".\");\n $j = array_merge($i, $h);\n if($j[1] == \".\")\n {\n print implode($j);\n }\n else\n {\n $k = count($j);\n for($x = 0; $x < $k; $x++)\n {\n if($j[$x] == 0)\n {\n unset($j[$x]);\n }\n else\n {\n break;\n }\n }\n print implode($j);\n }\n}\n?>"}, {"source_code": " $f)\n{\n $g = array_slice($d, 0, $f);\n $h = array_slice($d, $f);\n $i = array_merge($b, $g);\n array_push($i, \".\");\n $j = array_merge($i, $h);\n if($j[1] == \".\")\n {\n print implode($j);\n }\n else\n {\n $k = count($j);\n for($x = 0; $x < $k; $x++)\n {\n if($j[$x] == 0)\n {\n unset($j[$x]);\n }\n else\n {\n break;\n }\n }\n print implode($j);\n }\n}\n?>"}, {"source_code": " 0; $i--) {\n\t\tif ($realNumber[$i-1] != 0) {\n\t\t\treturn $realNumber;\n\t\t}\n\n\t\t$realNumber = substr($realNumber, 0, $i-1);\n\t}\n\n\treturn $realNumber;\n}\n\nfprintf($fw, $realNumber);\n\nfclose($fr);\nfclose($fw);"}], "src_uid": "a79358099f08f3ec50c013d47d910eef"} {"nl": {"description": "During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second. Let's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i\u2009+\u20091)-th position, then at time x\u2009+\u20091 the i-th position will have a girl and the (i\u2009+\u20091)-th position will have a boy. The time is given in seconds.You've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.", "input_spec": "The first line contains two integers n and t (1\u2009\u2264\u2009n,\u2009t\u2009\u2264\u200950), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find. The next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals \"B\", otherwise the i-th character equals \"G\".", "output_spec": "Print string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal \"B\", otherwise it must equal \"G\".", "sample_inputs": ["5 1\nBGGBG", "5 2\nBGGBG", "4 1\nGGGB"], "sample_outputs": ["GBGGB", "GGBGB", "GGGB"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": "0; --$j) {\n if ( $q[$j] == 'G' && $q[$j-1] == 'B') {\n $z = $q[$j-1];\n $q[$j-1] = $q[$j];\n $q[$j] = $z;\n --$j;\n\n }\n\n }\n }\n\n put($q);\n\n\n if (++$COUNT > 1) {\n break;\n }\n\n}\n"}, {"source_code": "0; --$j) {\n if ( $q[$j] == 'G' && $q[$j-1] == 'B') {\n $z = $q[$j-1];\n $q[$j-1] = $q[$j];\n $q[$j] = $z;\n --$j;\n }\n\n }\n }\n\n echo $q;\n\n\n if (++$COUNT > 1) {\n break;\n }\n\n}\n"}, {"source_code": "=1){\nforeach ($array as $key => $value) {\n if(key_exists($key+1,$array)){\n if($value == 'B' and $array[$key+1] == 'G'){\n $x=$array[$key];\n $array[$key]=$array[$key+1];\n $array[$key+1]=$x;\n }\n }\n}\n$a--;\n}\necho join('',$array);"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " $value) {\n $out .= $value;\n}\n\necho $out;\n\n?>"}, {"source_code": ""}, {"source_code": "=0;$j--){\n if($s[$j]==\"B\" && $s[$j+1]==\"G\"){$s[$j]=\"G\";$s[$j+1]=\"B\";$j--;}\n }\n}\nforeach($s as $v)echo $v;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "0;$i--) {\n if ($s[$i] == \"G\") {\n if ($s[$i - 1] == \"B\") {\n $r[$i] = $s[$i-1];\n $r[$i-1] = $s[$i];\n }\n }\n }\n $s=$r;\n}\n\necho $r;\n\n?>\n"}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": "0; --$j) {\n if ( $q[$j] == 'G' && $q[$j-1] == 'B') {\n $z = $q[$j-1];\n $q[$j-1] = $q[$j];\n $q[$j] = $z;\n }\n }\n }\n\n put($q);\n\n\n if (++$COUNT > 1) {\n break;\n }\n\n}\n"}, {"source_code": "= 0) {\n\t\t$temp1=$s[$n];\n\t\t$temp2=$s[$n-1];\n\t\tif ($temp1 != $temp2) {\n\t\t\t$s[$n-1] = $temp1;\n\t\t\t$s[$n] = $temp2;\n\t\t}\n\t\t$n--;\n\t}\n\t$j++;\n}\necho $s;\n?>"}, {"source_code": ""}, {"source_code": "= 0) {\n\t\t$temp1=$arr[$n];\n\t\t$m=$n-1;\n\t\t$temp2=$arr[$m];\n\t\tif ($temp2 != $temp1) {\n\t\t\t$arr[$m] = $temp1;\n\t\t\t$arr[$n] = $temp2;\n\t\t}\n\t\t$n--;\n\t}\n\t$j++;\n}\necho $arr;\n?>"}, {"source_code": ""}, {"source_code": " 0) {\n\t\t$temp1=$arr[$n[0]];\n\t\t$temp2=$arr[$n[0]-1];\n\t\tif ($temp2 != $temp1) {\n\t\t\tif ($temp2 ==\"B\" && $temp1 ==\"G\" ) {\n\t\t\t\t$arr[$n[0]-1] = $temp1;\n\t\t\t\t$arr[$n[0]] = $temp2;\n\t\t\t}\n\t\t}\n\t\t$n[0]--;\n\t}\n\t$j++;\n}\necho implode($arr);\n?>"}, {"source_code": " $n[0]-1; $k++) { \n\t\t$temp1=$arr[$k];\n\t\t$temp2=$arr[$k+1];\n\t\tif (($temp2 != $temp1) && ($temp2 ==\"B\" && $temp1 ==\"G\" )) {\n\t\t\t$arr[$k+1] = $temp1;\n\t\t\t$arr[$k] = $temp2;\n\t\t\t$k++;\n\t\t}\n\t}\n}\n\necho implode($arr);\n?>"}, {"source_code": " 0) {\n\t\t$temp1=$arr[$n[0]];\n\t\t$temp2=$arr[$n[0]-1];\n\t\tif (($temp2 != $temp1) && ($temp2 ==\"B\" && $temp1 ==\"G\" )) {\n\t\t\t$arr[$n[0]-1] = $temp1;\n\t\t\t$arr[$n[0]] = $temp2;\n\t\t}\n\t\t$n[0]--;\n\t}\n\t$j++;\n}\necho implode($arr);\n?>"}, {"source_code": " 0) {\n\t\t$temp1=$arr[$k];\n\t\t$temp2=$arr[$k-1];\n\t\tif (($temp2 != $temp1) && ($temp2 ==\"B\" && $temp1 ==\"G\" )) {\n\t\t\t$arr[$k-1] = $temp1;\n\t\t\t$arr[$k] = $temp2;\n\t\t}\n\t\t$k--;\n\t}\n\t$j++;\n}\necho implode($arr);\n?>"}, {"source_code": " $n[0]; $k++) { \n\t\t$temp1=$arr[$k];\n\t\t$temp2=$arr[$k+1];\n\t\tif (($temp2 != $temp1) && ($temp2 ==\"B\" && $temp1 ==\"G\" )) {\n\t\t\t$arr[$k+1] = $temp1;\n\t\t\t$arr[$k] = $temp2;\n\t\t\t$k++;\n\t\t}\n\t}\n}\n\necho implode($arr);\n?>"}, {"source_code": "=0;$j--){\n if($s[$j]==\"B\" && $s[$j+1]==\"G\"){$s[$j]=\"G\";$s[$j+1]=\"B\";}\n }\n}\nforeach($s as $v)echo $v;\n?>"}, {"source_code": "0;$y--) {\n\t\t\tif ($var[$y] == 'G' && $var[$y-1] == 'B') {\n\t\t\t\t$var[$y] = 'B';\n\t\t\t\t$var[$y-1] = 'G';\n\t\t\t}\n\t\t}\n\t}\n\techo implode('',$var);"}, {"source_code": "0;$y--) {\n\t\t\tif ($var[$y] == 'G' && $var[$y-1] == 'B') {\n\t\t\t\t$var[$y] = 'B';\n\t\t\t\t$var[$y-1] = 'G';\n\t\t\t}\n\t\t}\n\t}\n\techo implode('',$var);"}], "src_uid": "964ed316c6e6715120039b0219cc653a"} {"nl": {"description": "When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked $$$n$$$ people about their opinions. Each person answered whether this problem is easy or hard.If at least one of these $$$n$$$ people has answered that the problem is hard, the coordinator decides to change the problem. For the given responses, check if the problem is easy enough.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the number of people who were asked to give their opinions. The second line contains $$$n$$$ integers, each integer is either $$$0$$$ or $$$1$$$. If $$$i$$$-th integer is $$$0$$$, then $$$i$$$-th person thinks that the problem is easy; if it is $$$1$$$, then $$$i$$$-th person thinks that the problem is hard.", "output_spec": "Print one word: \"EASY\" if the problem is easy according to all responses, or \"HARD\" if there is at least one person who thinks the problem is hard. You may print every letter in any register: \"EASY\", \"easy\", \"EaSY\" and \"eAsY\" all will be processed correctly.", "sample_inputs": ["3\n0 0 1", "1\n0"], "sample_outputs": ["HARD", "EASY"], "notes": "NoteIn the first example the third person says it's a hard problem, so it should be replaced.In the second example the problem easy for the only person, so it doesn't have to be replaced."}, "positive_code": [{"source_code": " 0){\n $res = \"HARD\";\n break;\n }\n $i++;\n}\necho $res;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": "\n"}, {"source_code": " $d) {\n echo $k;\n $inputs = array_merge($inputs, $data[$k]);\n} */\n\n$stdin = fopen('php://stdin', 'r');\nwhile($line = fgets($stdin)) {\n $line = explode(\" \", $line);\n $data[] = $line;\n}\nfclose($stdin);\n\nlist($n, $i) = $data;\n\nif (in_array(1, $i)) {\n echo \"HARD\";\n} else {\n echo \"EASY\";\n}"}, {"source_code": " $d) {\n echo $k;\n $inputs = array_merge($inputs, $data[$k]);\n} */\n\n// // // STANDARD INPUT DEFINITION // // //\n$stdin = fopen('php://stdin', 'r');\nwhile($line = fgets($stdin)) {\n $data[] = explode(\" \", $line);\n}\nfclose($stdin);\n\n// // // DEFINE VARIABLES HERE (1 input line = 1 variable) // // //\nlist($a, $b) = $data;\n\n// // // START CODING LOGIC HERE // // //\nif (in_array(1, $b)) {\n echo \"HARD\";\n} else {\n echo \"EASY\";\n}"}, {"source_code": ""}, {"source_code": "0) echo 'HARD';\n else echo 'EASY';"}, {"source_code": " $line) {\n if (strlen($line) > 0) {\n $input[$index] = explode(\" \", trim($line));\n }\n}\n\necho in_array(\"1\", $input[1], false) ? 'HARD': 'EASY';\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}, {"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$a = explode(' ',$inp->arr_line[1]);\n$bool = \"easy\";\nfor($i=0;$i<$n;$i++){\n if(strval($a[$i])==\"1\"){\n $bool = \"hard\";\n }\n}\necho $bool;"}, {"source_code": "\n"}, {"source_code": ""}, {"source_code": " 0 ? \"HARD\" : \"EASY\";\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0 ? 'HARD' : 'EASY');\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0){\n echo 'HARD';\n }\n else echo 'EASY';"}], "negative_code": [{"source_code": " 0){\n echo 'HARD';\n }\n else echo 'YASY';"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0){\n $res = \"HARD\";\n break;\n }\n $i++;\n}\necho $res;\n?>"}, {"source_code": ""}, {"source_code": "n = int(input())\na = sum(map(int, input().split()))\nif a > 0:\n print('HARD')\nelse:\n print('EASY')"}, {"source_code": " $d) {\n echo $k;\n $inputs = array_merge($inputs, $data[$k]);\n} */\n\n$stdin = fopen(STDIN, 'r');\nwhile($line = fgets($stdin)) {\n $line = explode(\" \", $line);\n $data[] = $line;\n}\nfclose($stdin);\n\nprint_r($data);\n\nlist($n, $i) = $data;\n\nif (in_array(1, $i)) {\n echo \"HARD\";\n} else {\n echo \"EASY\";\n}"}, {"source_code": " $d) {\n echo $k;\n $inputs = array_merge($inputs, $data[$k]);\n} */\n\n$stdin = fopen('php://stdin', 'r');\nwhile($line = fgets($stdin)) {\n $line = explode(\" \", $line);\n $data[] = $line;\n}\nfclose($stdin);\n\nprint_r($data);\n\nlist($n, $i) = $data;\n\nif (in_array(1, $i)) {\n echo \"HARD\";\n} else {\n echo \"EASY\";\n}"}, {"source_code": "0) echo 'HARD';\n else echo 'EASY';"}, {"source_code": "0) echo 'HARD';\n else echo 'EASY';"}, {"source_code": "0) echo 'HARD';\n else echo 'EASY';"}, {"source_code": "0) echo 'HARD';\n else echo 'EASY';"}, {"source_code": ""}, {"source_code": "' . $result;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": "$h) {\n echo ('easy');\n}\nelse if ($h>$e) {\n echo ('hard');\n}\nelse {\n echo ('unknown');\n}"}, {"source_code": ""}], "src_uid": "060406cd57739d929f54b4518a7ba83e"} {"nl": {"description": "You are given names of two days of the week.Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.Names of the days of the week are given with lowercase English letters: \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\".", "input_spec": "The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\".", "output_spec": "Print \"YES\" (without quotes) if such situation is possible during some non-leap year. Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["monday\ntuesday", "sunday\nsunday", "saturday\ntuesday"], "sample_outputs": ["NO", "YES", "YES"], "notes": "NoteIn the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday."}, "positive_code": [{"source_code": " 1, \"tuesday\" => 2, \"wednesday\" => 3, \"thursday\" => 4, \"friday\" => 5, \"saturday\" => 6, \"sunday\" => 7);\n$d = $c[$a];\n$e = $c[$b];\nif($e >= $d)\n{\n $f = $e - $d;\n}\nelse\n{\n $f = 7 - $d + $e;\n}\nif(($f == 0) || ($f == 2) || ($f == 3))\n{\n print \"YES\";\n}\nelse\n{\n print \"NO\";\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 getAnswer($is_test = false, $f = false) {\n\tif ($is_test === false) {\n\t\t$f = STDIN;\n\t}\n\t/* begin body */\n\t$first = readString($f);\n\t$second = readString($f);\n\t\n\t$dayCount = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n\t$days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');\n\t$firstIndex = array_search($first, $days);\n\tfor ($m = 0; $m < 11; $m++) {\n\t\t$diff = $dayCount[$m] % 7;\n\t\t$next = ($firstIndex + $diff) % 7;\n\t\tif ($second == $days[$next]) {\n\t\t\techo 'YES';\n\t\t\treturn;\n\t\t}\n\t}\n\techo 'NO';\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}], "negative_code": [{"source_code": ""}], "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"nl": {"description": "A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k\u2009-\u20091 hasso\u0441ks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should answer: will the flea visit all the hassocks or not. We assume that flea has infinitely much time for this jumping.", "input_spec": "The only line contains single integer: 1\u2009\u2264\u2009n\u2009\u2264\u20091000 \u2014 number of hassocks.", "output_spec": "Output \"YES\" if all the hassocks will be visited and \"NO\" otherwise.", "sample_inputs": ["1", "3"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}, {"source_code": ""}, {"source_code": ""}], "src_uid": "4bd174a997707ed3a368bd0f2424590f"} {"nl": {"description": "You're given a row with $$$n$$$ chairs. We call a seating of people \"maximal\" if the two following conditions hold: There are no neighbors adjacent to anyone seated. It's impossible to seat one more person without violating the first rule. The seating is given as a string consisting of zeros and ones ($$$0$$$ means that the corresponding seat is empty, $$$1$$$ \u2014 occupied). The goal is to determine whether this seating is \"maximal\".Note that the first and last seats are not adjacent (if $$$n \\ne 2$$$).", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 1000$$$)\u00a0\u2014 the number of chairs. The next line contains a string of $$$n$$$ characters, each of them is either zero or one, describing the seating.", "output_spec": "Output \"Yes\" (without quotation marks) if the seating is \"maximal\". Otherwise print \"No\". You are allowed to print letters in whatever case you'd like (uppercase or lowercase).", "sample_inputs": ["3\n101", "4\n1011", "5\n10001"], "sample_outputs": ["Yes", "No", "No"], "notes": "NoteIn sample case one the given seating is maximal.In sample case two the person at chair three has a neighbour to the right.In sample case three it is possible to seat yet another person into chair three."}, "positive_code": [{"source_code": "= 0; $x--)\n{\n if($b[$x] == 0)\n {\n $d++;\n }\n else\n {\n break;\n }\n}\n$e = 0;\n$f = 0;\n$g = 0;\n$h = 0;\nfor($x = $c; $x <= $a - $d; $x++)\n{\n if($b[$x] == 0)\n {\n $g = max($g, $h);\n $h = 0;\n $f++;\n }\n elseif($b[$x] == 1)\n {\n $e = max($e, $f);\n $f = 0;\n $h++;\n }\n}\n$e = max($e, $f);\n$f = 0;\n$g = max($g, $h);\n$h = 0;\nif(($a == 1) && ($b[0] == 0))\n{\n print \"No\";\n}\nelseif(($c >= 2) || ($d >= 2) || ($g >= 2) || ($e >= 3))\n{\n print \"No\";\n}\nelse\n{\n print \"Yes\";\n}\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": "= 0; $x--)\n{\n if($b[$x] == 0)\n {\n $d++;\n }\n else\n {\n break;\n }\n}\n$e = 0;\n$f = 0;\nfor($x = $c; $x <= $a - $d; $x++)\n{\n if($b[$x] == 0)\n {\n $f++;\n }\n else\n {\n $e = max($e, $f);\n $f = 0;\n }\n}\n$e = max($e, $f);\n$f = 0;\nif(($a == 1) && ($b[0] == 0))\n{\n print \"No\";\n}\nelseif(($c >= 2) || ($d >= 2) || ($e >= 3))\n{\n print \"No\";\n}\nelse\n{\n print \"Yes\";\n}\n?>"}, {"source_code": " $b) {\n $rs--;\n }\n }\n }\n fprintf($fileOUT, $rs);\n //echo $rs;\n}\n\nfclose($fileIN);\nfclose($fileOUT);\n?>\n"}, {"source_code": "= count($comb)) {\n return false;\n }\n $comb[$pos]++;\n if ($comb[$pos] > $orders[$pos]) {\n $comb[$pos] = 0;\n return next_comb($comb, $orders, $pos + 1);\n }\n return true;\n}\n\nif ($a == $b) {\n echo \"infinity\\n\";\n} elseif ($b > $a) {\n echo \"0\\n\";\n} elseif ($a == 1 && $b == 0) {\n echo \"1\\n\"; // fuck :) too lazy to actually fix\n} else {\n $divs = all_divisors($a - $b);\n $divisors = array_keys($divs);\n $orders = array_values($divs);\n $comb = array_fill(0, count($divs), 0);\n $ok = 0;\n do {\n $tryN = 1;\n foreach ($comb as $i => $count) {\n $tryN *= pow($divisors[$i], $count);\n }\n if ($tryN > $b) {\n $ok++;\n }\n } while (next_comb($comb, $orders));\n echo \"$ok\\n\";\n}\n\n"}, {"source_code": "$b) : ($i>$b)+(($c/$i)>$b);\n }\n }\n echo $k;\n}\n?>"}, {"source_code": "$b);\n } else {\n $o += ($i>$b)+((int)($a/$i)>$b);\n }\n }\n }\n printf(\"%d\\n\",$o);\n}\n?>"}, {"source_code": "$b);\n\t\t\telse\n\t\t\t\t$ans+=($i>$b)+((int)($a/$i)>$b);\n\t\t}\n printf(\"%d\\n\",$ans);\n?>"}], "negative_code": [{"source_code": " $b) {\n $rs--;\n }\n }\n }\n}\n\nfprintf($fileOUT, $rs);\n\nfclose($fileIN);\nfclose($fileOUT);\n?>\n"}, {"source_code": " $b) {\n $rs--;\n }\n }\n }\n fprintf($fileOUT, $rs);\n}\n\nfclose($fileIN);\nfclose($fileOUT);\n?>\n"}, {"source_code": " $b) {\n $rs--;\n }\n }\n }\n fprintf($fileOUT, $rs);\n //echo $rs;\n}\n\nfclose($fileIN);\nfclose($fileOUT);\n?>\n"}, {"source_code": " $b) {\n $rs--;\n }\n }\n }\n}\n\nfprintf($fileOUT, $rs);\n\nfclose($fileIN);\nfclose($fileOUT);\n?>\n"}, {"source_code": "= count($comb)) {\n return false;\n }\n $comb[$pos]++;\n if ($comb[$pos] > $orders[$pos]) {\n $comb[$pos] = 0;\n return next_comb($comb, $orders, $pos + 1);\n }\n return true;\n}\n\nif ($a == $b) {\n echo \"infinity\\n\";\n} elseif ($b > $a) {\n echo \"0\\n\";\n} else {\n $divs = all_divisors($a - $b);\n $divisors = array_keys($divs);\n $orders = array_values($divs);\n $comb = array_fill(0, count($divs), 0);\n $ok = 0;\n do {\n $tryN = 1;\n foreach ($comb as $i => $count) {\n $tryN *= pow($divisors[$i], $count);\n }\n if ($tryN > $b) {\n $ok++;\n }\n } while (next_comb($comb, $orders));\n echo \"$ok\\n\";\n}\n\n"}, {"source_code": "$b);\n } else {\n $ans += ($i>$b)+((int)($a/$i)>$b);\n }\n }\n }\n echo $ans;\n}\n?>"}, {"source_code": "$b);\n } else {\n $ans += ($i>$b)+((int)($a/$i)>$b);\n }\n }\n }\n echo $ans;\n?>"}], "src_uid": "6e0715f9239787e085b294139abb2475"} {"nl": {"description": "Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is \"123456789101112131415...\". Your task is to print the n-th digit of this string (digits are numbered starting with 1.", "input_spec": "The only line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091000)\u00a0\u2014 the position of the digit you need to print.", "output_spec": "Print the n-th digit of the line.", "sample_inputs": ["3", "11"], "sample_outputs": ["3", "0"], "notes": "NoteIn the first sample the digit at position 3 is '3', as both integers 1 and 2 consist on one digit.In the second sample, the digit at position 11 is '0', it belongs to the integer 10."}, "positive_code": [{"source_code": ""}, {"source_code": "\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\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$n = readNum($f);\n\t$str = '';\n\tfor ($i = 1; $i <= 1001; $i++) {\n\t\t$str.=$i;\n\t}\n\techo $str[$n-1];\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();"}, {"source_code": ""}, {"source_code": "\n"}, {"source_code": ""}], "negative_code": [], "src_uid": "2d46e34839261eda822f0c23c6e19121"} {"nl": {"description": "An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x\u2009>\u20090) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order to get to his friend's house.", "input_spec": "The first line of the input contains an integer x (1\u2009\u2264\u2009x\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 The coordinate of the friend's house.", "output_spec": "Print the minimum number of steps that elephant needs to make to get from point 0 to point x.", "sample_inputs": ["5", "12"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first sample the elephant needs to make one step of length 5 to reach the point x.In the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves."}, "positive_code": [{"source_code": ""}, {"source_code": "solution($n);\n// End of interface\n\n\nclass MainClass {\n\t//617-A. Elephant\n\t//public $problemLink = 'https://codeforces.com/problemset/problem/617/A';\n\t//public $submissionLink = '';\n\n\tpublic function solution($n){\n\t\t$res = 0;\n\t\tfor ($i = 5; $i>0; $i--){\n\t\t\t$quotient = $n/$i;\n\t\t\t$intQuotient = (int) $quotient;\n\t\t\t$currentReminder = $n % $i;\n\t\t\tif ($intQuotient > 0){\n\t\t\t\t$res = $res + $intQuotient;\n\t\t\t};\n\t\t\tif ($currentReminder === 0){\n\t\t\t\tbreak;\n\t\t\t};\n\t\t\tif ($currentReminder > 0){\n\t\t\t\t$n = $currentReminder;\n\t\t\t};\n\t\t}\n\t\treturn $res;\n\t}\n}\n"}, {"source_code": "solution($n);\n// End of interface\n\n\nclass MainClass {\n\t//617-A. Elephant\n\t//public $problemLink = 'https://codeforces.com/problemset/problem/617/A';\n\t//public $submissionLink = '';\n\n\tpublic function solution($n){\n\t\t$res = 0;\n\t\tfor ($i = 5; $i>0; $i--){\n\t\t\t$intQuotient = (int)($n/$i);\n\t\t\t$currentReminder = $n % $i;\n\t\t\tif ($intQuotient > 0){\n\t\t\t\t$res = $res + $intQuotient;\n\t\t\t};\n\t\t\tif ($currentReminder === 0){\n\t\t\t\tbreak;\n\t\t\t};\n\t\t\tif ($currentReminder > 0){\n\t\t\t\t$n = $currentReminder;\n\t\t\t};\n\t\t}\n\t\treturn $res;\n\t}\n}\n"}, {"source_code": ""}, {"source_code": "0; $i--)\n{\n\t$ans += intval($elphnt / $i);\n\t$elphnt %= $i;\n}\n\necho $ans.\"\\n\";"}, {"source_code": "= 5) {\n $x -= 5;\n return move($x) + 1;\n } else {\n return 1;\n }\n}\n\nfscanf(STDIN, \"%d\", $x);\nprintf(\"%d\", move($x));\n"}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 5){ \n $n += - 5;\n $k += + 1;\n }\n echo $k;"}, {"source_code": "= $i) {\n $x -= $i;\n $s += 1;\n }\n}\necho $s;\n?>"}, {"source_code": "= 5) {\n $x -= 5;\n $s += 1;\n}\nwhile ($x >= 4) {\n $x -= 4;\n $s += 1;\n}\nwhile ($x >= 3) {\n $x -= 3;\n $s += 1;\n}\nwhile ($x >= 2) {\n $x -= 2;\n $s += 1;\n}\nwhile ($x >= 1) {\n $x -= 1;\n $s += 1;\n}\necho $s;\n?>"}, {"source_code": " 4) $i=5;\n elseif ($dis > 3) $i=4;\n elseif ($dis > 2) $i=3;\n elseif ($dis > 1) $i=2;\n else $i=1;\n\n walk($dis-$i, $w+1);\n }\n walk($dis,$w);\n\n\n if ((--$count) == 0) {\n break;\n }\n}\n"}, {"source_code": " 4) $i=5;\n elseif ($dis > 3) $i=4;\n elseif ($dis > 2) $i=3;\n elseif ($dis > 1) $i=2;\n else $i=1;\n\n return walk($dis-$i, $w+1);\n }\n put(walk($dis,$w));\n\n\n if ((--$count) == 0) {\n break;\n }\n}\n"}, {"source_code": "= 1; $i--) {\n $walk += floor($nr / $i);\n $nr = $nr % $i;\n}\n\necho $walk;"}, {"source_code": "=5){\n $ghadam++;\n @$input-=5;\n}\nwhile($input>=4){\n $ghadam++;\n @$input-=4;\n}\nwhile($input>=3){\n $ghadam++;\n @$input-=3;\n}\nwhile($input>=2){\n $ghadam++;\n @$input-=2;\n}\nwhile($input>=1){\n $ghadam++;\n @$input-=1;\n}\necho $ghadam;\n?>"}, {"source_code": ""}, {"source_code": " $line) {\n $input[$index] = explode(\" \", trim($line));\n}\n\n// Solve past this line\n$friend = $input[0][0];\n$output = (int)($friend / 5);\n\necho $output >= 1 ? $output+($friend%5 ? 1: 0): 1;\n "}, {"source_code": " $line) {\n $input[$index] = explode(\" \", trim($line));\n}\n\n// Solve past this line\necho (int)(($input[0][0] + 4) / 5);\n "}, {"source_code": ""}, {"source_code": " 5.\nfor($i = 5;$i >= 1;$i--) {\n \n while(($our_number + $i) <= $input) {\n \n $steps++;\n $our_number += $i;\n \n }\n \n if($our_number == $input) {\n \n break;\n \n }\n \n}\n\necho $steps;"}, {"source_code": ""}, {"source_code": " 5) {\n $moves = $moves - 5;\n $counter ++;\n}\necho $counter + 1;\n?>"}, {"source_code": ""}, {"source_code": ""}, {"source_code": ""}, {"source_code": " 0) {\n if (($x - 5) >= 0) {\n $x -= 5;\n $s++;\n }\n}\nwhile ($x > 0) {\n if (($x - 4) >= 0) {\n $x -= 4;\n $s++;\n }\n}\nwhile ($x > 0) {\n if (($x - 3) >= 0) {\n $x -= 3;\n $s++;\n }\n}\nwhile ($x > 0) {\n if (($x - 2) >= 0) {\n $x -= 2;\n $s++;\n }\n}\nwhile ($x > 0) {\n if (($x - 1) >= 0) {\n $x -= 1;\n $s++;\n }\n}\n?>"}, {"source_code": ""}, {"source_code": " 5.\nfor($i = 5;$i >= 1;$i--) {\n \n while(($our_number + $i) < $input) {\n \n $steps++;\n $our_number += $i;\n \n }\n \n if($our_number == $input) {\n \n break;\n \n }\n \n}\n\necho $steps;"}, {"source_code": ""}, {"source_code": ""}], "negative_code": [{"source_code": ""}], "src_uid": "fc5765b9bd18dc7555fa76e91530c036"} {"nl": {"description": "The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation code arrives.A young hacker Vasya disassembled the program and found the algorithm that transforms the shown number into the activation code. Note: it is clear that Vasya is a law-abiding hacker, and made it for a noble purpose \u2014 to show the developer the imperfection of their protection.The found algorithm looks the following way. At first the digits of the number are shuffled in the following order <first digit><third digit><fifth digit><fourth digit><second digit>. For example the shuffle of 12345 should lead to 13542. On the second stage the number is raised to the fifth power. The result of the shuffle and exponentiation of the number 12345 is 455\u00a0422\u00a0043\u00a0125\u00a0550\u00a0171\u00a0232. The answer is the 5 last digits of this result. For the number 12345 the answer should be 71232.Vasya is going to write a keygen program implementing this algorithm. Can you do the same?", "input_spec": "The only line of the input contains a positive integer five digit number for which the activation code should be found.", "output_spec": "Output exactly 5 digits without spaces between them \u2014 the found activation code of the program.", "sample_inputs": ["12345"], "sample_outputs": ["71232"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "51b1c216948663fff721c28d131bf18f"} {"nl": {"description": "The cows have just learned what a primitive root is! Given a prime p, a primitive root is an integer x (1\u2009\u2264\u2009x\u2009<\u2009p) such that none of integers x\u2009-\u20091,\u2009x2\u2009-\u20091,\u2009...,\u2009xp\u2009-\u20092\u2009-\u20091 are divisible by p, but xp\u2009-\u20091\u2009-\u20091 is. Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given a prime p, help the cows find the number of primitive roots .", "input_spec": "The input contains a single line containing an integer p (2\u2009\u2264\u2009p\u2009<\u20092000). It is guaranteed that p is a prime.", "output_spec": "Output on a single line the number of primitive roots .", "sample_inputs": ["3", "5"], "sample_outputs": ["1", "2"], "notes": "NoteThe only primitive root is 2.The primitive roots are 2 and 3."}, "positive_code": [{"source_code": "\n"}], "negative_code": [{"source_code": "\n"}, {"source_code": "\n"}], "src_uid": "3bed682b6813f1ddb54410218c233cff"} {"nl": {"description": "IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.", "input_spec": "The only line of the input contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091018) \u2014 the prediction on the number of people who will buy the game.", "output_spec": "Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.", "sample_inputs": ["3000"], "sample_outputs": ["1"], "notes": null}, "positive_code": [{"source_code": ""}], "negative_code": [], "src_uid": "8551308e5ff435e0fc507b89a912408a"} {"nl": {"description": "Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n\u2009+\u20091)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n\u2009+\u20091)-th day will be equal to the temperature of the n-th day.Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n\u2009+\u20091)-th day.", "input_spec": "The first line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of days for which the average air temperature is known. The second line contains a sequence of integers t1,\u2009t2,\u2009...,\u2009tn (\u2009-\u20091000\u2009\u2264\u2009ti\u2009\u2264\u20091000)\u00a0\u2014 where ti is the average temperature in the i-th day.", "output_spec": "Print the average air temperature in the (n\u2009+\u20091)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.", "sample_inputs": ["5\n10 5 0 -5 -10", "4\n1 1 1 1", "3\n5 1 -5", "2\n900 1000"], "sample_outputs": ["-15", "1", "-5", "1100"], "notes": "NoteIn the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is \u2009-\u200910\u2009-\u20095\u2009=\u2009\u2009-\u200915.In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to \u2009-\u20095.In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000\u2009+\u2009100\u2009=\u20091100."}, "positive_code": [{"source_code": " 0; $x--)\n{\n $d = $b[$x] - $b[$x - 1];\n $c[count($c)] = $d;\n}\n$e = array_unique($c);\nif(count($e) == 1)\n{\n print $b[$a - 1] + $d;\n}\nelse\n{\n print $b[$a - 1];\n}\n?>"}], "negative_code": [], "src_uid": "d04fa4322a1b300bdf4a56f09681b17f"} {"nl": {"description": "Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color. She repeats this process until there is only one card left. What are the possible colors for the final card?", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009200)\u00a0\u2014 the total number of cards. The next line contains a string s of length n \u2014 the colors of the cards. s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively.", "output_spec": "Print a single string of up to three characters\u00a0\u2014 the possible colors of the final card (using the same symbols as the input) in alphabetical order.", "sample_inputs": ["2\nRB", "3\nGRG", "5\nBBBBB"], "sample_outputs": ["G", "BR", "B"], "notes": "NoteIn the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and a red card for a blue card, then exchange the blue card and remaining green card for a red card.In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards."}, "positive_code": [{"source_code": " 0) && ($d > 0) && ($e > 0))\n{\n print \"BGR\";\n}\nelseif(($c > 1) && ($d == 1) && ($e == 0))\n{\n print \"GR\";\n}\nelseif(($c > 1) && ($d == 0) && ($e == 1))\n{\n print \"GR\";\n}\nelseif(($c == 0) && ($d > 1) && ($e == 1))\n{\n print \"BR\";\n}\nelseif(($c == 1) && ($d > 1) && ($e == 0))\n{\n print \"BR\";\n}\nelseif(($c == 0) && ($d == 1) && ($e > 1))\n{\n print \"BG\";\n}\nelseif(($c == 1) && ($d == 0) && ($e > 1))\n{\n print \"BG\";\n}\nelseif(($c > 1) && ($d > 1))\n{\n print \"BGR\";\n}\nelseif(($d > 1) && ($e > 1))\n{\n print \"BGR\";\n}\nelseif(($c > 1) && ($e > 1))\n{\n print \"BGR\";\n}\nelseif(($c > 0) && ($d == 0) && ($e == 0))\n{\n print \"B\";\n}\nelseif(($c == 0) && ($d > 0) && ($e == 0))\n{\n print \"G\";\n}\nelseif(($c == 0) && ($d == 0) && ($e > 0))\n{\n print \"R\";\n}\nelseif(($c > 0) && ($d > 0) && ($e == 0))\n{\n print \"R\";\n}\nelseif(($c > 0) && ($d == 0) && ($e > 0))\n{\n print \"G\";\n}\nelseif(($c == 0) && ($d > 0) && ($e > 0))\n{\n print \"B\";\n}\n?>"}], "negative_code": [], "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f"} {"nl": {"description": "Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.The path consists of $$$n$$$ consecutive tiles, numbered from $$$1$$$ to $$$n$$$. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different tiles with numbers $$$i$$$ and $$$j$$$, such that $$$|j - i|$$$ is a divisor of $$$n$$$ greater than $$$1$$$, they have the same color. Formally, the colors of two tiles with numbers $$$i$$$ and $$$j$$$ should be the same if $$$|i-j| > 1$$$ and $$$n \\bmod |i-j| = 0$$$ (where $$$x \\bmod y$$$ is the remainder when dividing $$$x$$$ by $$$y$$$).Ujan wants to brighten up space. What is the maximum number of different colors that Ujan can use, so that the path is aesthetic?", "input_spec": "The first line of input contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^{12}$$$), the length of the path.", "output_spec": "Output a single integer, the maximum possible number of colors that the path can be painted in.", "sample_inputs": ["4", "5"], "sample_outputs": ["2", "5"], "notes": "NoteIn the first sample, two colors is the maximum number. Tiles $$$1$$$ and $$$3$$$ should have the same color since $$$4 \\bmod |3-1| = 0$$$. Also, tiles $$$2$$$ and $$$4$$$ should have the same color since $$$4 \\bmod |4-2| = 0$$$.In the second sample, all five colors can be used. "}, "positive_code": [{"source_code": " $c)\n {\n if($f < $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n else\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n }\n}\nelseif($g == -1)\n{\n if($b < $c)\n {\n if($f <= $b)\n {\n $i = ($f + $c) * $d;\n }\n else\n {\n $i = ($f + $c) * $d;\n }\n }\n elseif($b > $c)\n {\n if($f < $b)\n {\n $i = ($f + $a + ($a - $c)) * $d;\n }\n else\n {\n $i = ($f - $c) * $d;\n }\n }\n}\nprint min($h, $i);\n?>"}], "negative_code": [{"source_code": " $c)\n {\n if($f < $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n elseif($f >= $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n }\n}\nelseif($g == -1)\n{\n if($b < $c)\n {\n if($f < $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n elseif($f >= $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n }\n elseif($b > $c)\n {\n if($f <= $b)\n {\n $i = ($c - $f) * $d;\n }\n else\n {\n $i = (($a - $f) + $a + $c) * $d;\n }\n }\n}\nprint min($h, $i);\n?>"}, {"source_code": " $c)\n {\n if($f < $b)\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n else\n {\n $i = (($a - $f) + ($a - $c)) * $d;\n }\n }\n}\nelseif($g == -1)\n{\n if($b < $c)\n {\n if($f <= $b)\n {\n $i = ($f + $c) * $d;\n }\n else\n {\n $i = ($f + $c) * $d;\n }\n }\n elseif($b > $c)\n {\n if($f < $b)\n {\n $i = ($f + $a + ($a - $c)) * $d;\n }\n else\n {\n $i = $f * $d;\n }\n }\n}\nprint min($h, $i);\n?>"}], "src_uid": "fb3aca6eba3a952e9d5736c5d8566821"} {"nl": {"description": "Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets.Overall Vasya has got m devices and k electrical sockets in his flat, he can plug the devices or supply-line filters directly. Of course, he can plug the supply-line filter to any other supply-line filter. The device (or the supply-line filter) is considered plugged to electricity if it is either plugged to one of k electrical sockets, or if it is plugged to some supply-line filter that is in turn plugged to electricity. What minimum number of supply-line filters from the given set will Vasya need to plug all the devices he has to electricity? Note that all devices and supply-line filters take one socket for plugging and that he can use one socket to plug either one device or one supply-line filter.", "input_spec": "The first line contains three integers n, m, k (1\u2009\u2264\u2009n,\u2009m,\u2009k\u2009\u2264\u200950) \u2014 the number of supply-line filters, the number of devices and the number of sockets that he can plug to directly, correspondingly. The second line contains n space-separated integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u200950) \u2014 number ai stands for the number of sockets on the i-th supply-line filter.", "output_spec": "Print a single number \u2014 the minimum number of supply-line filters that is needed to plug all the devices to electricity. If it is impossible to plug all the devices even using all the supply-line filters, print -1.", "sample_inputs": ["3 5 3\n3 1 2", "4 7 2\n3 3 2 4", "5 5 1\n1 3 1 2 1"], "sample_outputs": ["1", "2", "-1"], "notes": "NoteIn the first test case he can plug the first supply-line filter directly to electricity. After he plug it, he get 5 (3 on the supply-line filter and 2 remaining sockets for direct plugging) available sockets to plug. Thus, one filter is enough to plug 5 devices.One of the optimal ways in the second test sample is to plug the second supply-line filter directly and plug the fourth supply-line filter to one of the sockets in the second supply-line filter. Thus, he gets exactly 7 sockets, available to plug: one to plug to the electricity directly, 2 on the second supply-line filter, 4 on the fourth supply-line filter. There's no way he can plug 7 devices if he use one supply-line filter."}, "positive_code": [{"source_code": " $c) && ($x == $a))\n {\n $f = 1;\n break;\n }\n elseif($b > $c)\n {\n $c += $d[$e] - 1;\n $e++;\n }\n else\n {\n break;\n }\n}\nif($f == 1)\n{\n print \"-1\";\n}\nelse\n{\n print $e;\n}\n?>"}, {"source_code": " $value) {\n\t$b[$key] += 0;\n}\nsort($b);\n$count = 0;\nfor ($i=$n-1; $i >= 0; $i--) { \n\tif ($m <= $k) break;\n\tif ($k != 0) {\n\t\t$count++;\n\t\t$k += $b[$i] - 1;\n\t} else {\n\t\tbreak;\n\t}\n}\nif ($m > $k) $count = -1;\nfwrite($f_out, $count);\nfclose($f_out);"}], "negative_code": [{"source_code": " $value) {\n\t$b[$key] += 0;\n}\narsort($b);\n$count = 0;\nfor ($i=0; $i < $n; $i++) { \n\tif ($m <= $k) break;\n\tif ($k != 0) {\n\t\t$count++;\n\t\t$k += $b[$i] - 1;\n\t} else {\n\t\tbreak;\n\t}\n}\nif ($m > $k) $count = -1;\nfwrite($f_out, $count);\nfclose($f_out);"}, {"source_code": " $value) {\n\t$b[$key] += 0;\n}\narsort($b);\n$count = 0;\nfor ($i=0; $i < $n; $i++) { \n\tif ($m <= $k) break;\n\tif ($k != 0) {\n\t\t$count++;\n\t\t$k += $b[$i] - 1;\n\t} else {\n\t\t$count = -1;\n\t\tbreak;\n\t}\n}\nif ($m > $k) $count = -1;\nfwrite($f_out, $count);\nfclose($f_out);"}], "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c"}