{"lang": "PHP", "source_code": "<?php\nwhile($s = fgets(STDIN)){\n        $input .= $s;\n}\n$input = explode(\"\\r\\n\", $input);\n$digits = explode (\" \", $input[0]);\n$n=$digits[0];\n$m=$digits[1];\n$result=0;\nfor ($i=0;$i<33;$i++) {\n    $t=$i*$i;\n    if ($t*$t-2*$t*$m+$m*$m+$i-$n == 0) {   \n        $a=$m-$t;\n        if ($a >= 0) {\n            $result++;\n        }\n    }\n}\necho $result;\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "253faac134fb53f380428bff1196315b", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = fgets(STDIN);\nlist($n, $m) = explode(\" \", $s);\nfor ($a=0; $a<$n+$m; $a++)\n{ for($b=0; $b<$n+$m; $b++)\n { if (($a*$a+$b==$n) and ($a+$b*$b==$m)) { $rez=$rez+1;}\n }\n};\nif ($rez!=0){\nprint ($rez);} else print (0);\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "a73df1fa6c1941327cb58fe802a06347", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%d %d %d\",$participate,$pens,$notebook);\nif($pens>=$participate&&$notebook>=$participate)\n\techo \"Yes\";\nelse\n\techo \"No\";", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "8e3d9e3f7775180c59ae9e2b6edd8868", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nwhile(! feof(STDIN)){\n    $arr[]=fgets(STDIN);\n}\n$value=explode(\" \", $arr[0]);\n\n$value[2]-=0;\nif($value[0]<=$value[1] && $value[0]<=$value[2]) echo \"Yes\";\nelse echo \"No\";\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "e27c63ee284cbf027f172171775353f5", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input=fgets(STDIN);\n$input=str_replace('WUB',' ',$input);\n$input=str_word_count($input,1);\necho implode(' ',$input);\n?>\n", "lang_cluster": "PHP", "tags": ["strings"], "code_uid": "f9d8a0e2d71d133aaf091c48ea10efa9", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php print trim(str_replace('WUB',' ',fgets(STDIN))); ?>", "lang_cluster": "PHP", "tags": ["strings"], "code_uid": "8399dca56dca1773081490b9fce41fb0", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "\n<?php\n/*RH*/\n\n$T=str_split(trim(fgets(STDIN)));\n$magic=0;\n\n\tforeach($T as $spell)\n\t\t\t{\n\t\t\tif($spell==4 or $spell==7)\n\t\t\t$magic++;\n\t\t\t}\n\t\t\tif($magic==4 or $magic==7)\n\t\t\techo \"YES\";\n\t\t\telse \n\t\t\techo \"NO\";\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "797fae55411b5b6d93982ad729ed2c49", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \nfscanf(STDIN, \"%s\",$s);\n$correct = Array(4,7);\nfor($i=0;$i<strlen($s);$i++)\n  in_array((int)$s[$i], $correct)?$cnt++:\"\";\necho in_array($cnt, $correct)?\"YES\":\"NO\";  \n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "6ff815e9a92bfd6a80a98322fc987d23", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN, \"%d%d\", $n, $m);\n$ch = 0;\nwhile ($n != 0 && $m != 0) {\n   $ch = $ch + 1; \n   $n = $n - 1;\n   $m = $m - 1;\n}\nif ($ch % 2 == 0) {\n    print(\"Malvika\");\n} else {\n    print(\"Akshat\");\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "3c2d32f3eea7a7296daef712602c459d", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = explode(\" \", trim(fgets(STDIN)));\nsort($n);\nif ($n[0] % 2 == 0)\n    echo \"Malvika\";\nelse\n    echo \"Akshat\";\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "74e43a99211c51834714ba1234024b9e", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n# 1143B\n$start = microtime(true);\n$arrayMultiply = function(array $arr){\n    $res = 1;\n    array_walk($arr, function($i) use (&$res){$res *= $i;});\n    return $res;\n};\n\n$n = trim(fgets(STDIN));\n$nLength = strlen($n);\nif ($nLength === 1) {\n    die($n);\n}\nif (substr($n, 1, $nLength - 1) === str_repeat('9', $nLength - 1)) {\n    die((string)$arrayMultiply(str_split($n)));\n}\n$n = str_split($n);\n$max = $arrayMultiply($n);\nfor ($i = 0; $i < $nLength - 1; $i++) {\n    $arr = $n;\n    $arr[$i] = ((int)$arr[$i]) - 1;\n    for ($j = $i + 1; $j < $nLength; $j++) {\n        $arr[$j] = 9;\n    }\n    for ($j = $nLength - 1; $j > 0; $j--) {\n        if ($arr[$j] === 0) {\n            $arr[$j] = 9;\n            $arr[$j - 1]--;\n        }\n        if ($arr[$j] === -1) {\n            $arr[$j] = 9;\n            $arr[$j - 1]--;\n        }\n    }\n    if ($arr[0] === 0) {\n        unset($arr[0]);\n    }\n    $max = max($max, $arrayMultiply($arr));\n}\n\necho $max;\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "number theory"], "code_uid": "08dbbebbf4c127ef2e25f11b33a68cfb", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = str_split(trim(fgets(STDIN)));\n$a2 = $a;\n$b = array_product($a);\n$c = 1;\nfor($x = 0; $x < count($a) - 1; $x++)\n{\n     $c *= 9;\n}\n$d = 0;\nfor($x = count($a) - 1; $x >= 0; $x--)\n{\n     if(($a[$x] != 0) && ($a[$x] != 1))\n     {\n          $e = array_slice($a, 0, $x);\n          $f = $a[$x] - 1;\n          $e = array_merge($e, array($f));\n          for($y = $x + 1; $y < count($a); $y++)\n          {\n               $e[count($e)] = 9;\n          }\n          $g = array_product($e);\n          if($g > $d)\n          {\n               $d = $g;\n          }\n          $a = $a2;\n     }\n}\nprint max($b, $c, $d);\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "number theory"], "code_uid": "bb0c29f35b20a1a910fcbcfed29e4239", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n) = explode(' ', trim(fgets(STDIN)));\n$iCount = strlen($n) == 1 ? 9 : 10;\n$bFlag = strlen($n) == 1 ? true : false;\nif(!$bFlag){\n    foreach (str_split($n) as $sK => $sV){\n        if($sK != 0){\n            $iCount += 9 - $sV;\n        }\n    }\n}\n\necho $iCount;\n\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5caa44f937392ab3d7b2fca2fa6c0091", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n\n/**\n * @author Sunwarul\n */\n\n$a = (int) fgets(STDIN);\n$b = (int) fgets(STDIN);\n$c = (int) fgets(STDIN);\n\n$m0 = $a + $b + $c;\n$m1 = $a * $b * $c;\n$m2 = ($a + $b) * $c;\n$m3 = $a + ($b * $c);\n$m4 = $a * ($b + $c);\n\necho max($m0, $m1, $m2, $m3, $m4);\necho \"\\n\";", "lang_cluster": "PHP", "tags": ["brute force", "math"], "code_uid": "698516ed9539ce12bf8f200a24795b34", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$stdin = fopen('php://stdin', 'r');\n$v1 = trim(fgets($stdin));\n$v2 = trim(fgets($stdin));\n$v3 = trim(fgets($stdin));\n\n\n\n$arr = [];\n$arr[] = $v1 + $v2 + $v3;\n$arr[] = $v1 * $v2 + $v3;\n$arr[] = $v1 + $v2 * $v3;\n$arr[] = $v1 * $v2 * $v3;\n$arr[] = ($v1 + $v2) * $v3;\n$arr[] = ($v1 + $v2) * $v3;\n$arr[] = ($v1 * $v2) * $v3;\n$arr[] = ($v1 * $v2) + $v3;\n\n$arr[] = $v1 + ($v2 + $v3);\n$arr[] = $v1 * ($v2 + $v3);\n$arr[] = $v1 + ($v2 * $v3);\n$arr[] = $v1 * ($v2 * $v3);\n\necho max($arr);\n", "lang_cluster": "PHP", "tags": ["brute force", "math"], "code_uid": "2dd7d5b92d0d949e14ba28ea669dce33", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($spots, $height, $r) = explode(' ', trim(fgets(STDIN)));\n$zone = array_fill(0, ($spots), (int)$height);\n\n/*\n3 3 3\n1 1 1\n2 2 3\n3 3 2\n*/\nwhile( $line = trim(fgets( STDIN )) ) {\n\tlist($start, $stop, $rr) = explode(' ', $line);\n\tfor(;$start <= $stop; $start++) {\n\t\t$zone[($start - 1)] = min($rr, $zone[($start - 1)]);\n\t}\n}\n\n$max = 0;\nfor($i = 0; $i < sizeof($zone); $i++) {\n\t$max += pow($zone[$i], 2);\n}\necho $max;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "3fd6c5cfe6e5f24f67c104030c2197e8", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n# 1162A\n\n[$houseAmount, $maxHeight, $limitsCount] = fscanf(STDIN, '%d %d %d');\n$profitList = array_fill(0, $houseAmount, $maxHeight * $maxHeight);\nfor ($i = 0; $i < $limitsCount; $i++) {\n    [$houseIndex, $endHouseIndex, $limit] = fscanf(STDIN, '%d %d %d' . PHP_EOL);\n    $profit = $limit * $limit;\n    for ($j = $houseIndex - 1; $j < $endHouseIndex; $j++) {\n        $profitList[$j] = min($profitList[$j], $profit);\n    }\n}\necho array_sum($profitList);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5c093401f3071ece04f6cf3d76c7014c", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$flag = 1; //must be not zero for STDIN\n$in = 'php://stdin';\nif (!$flag)\n{\n    $in = \"input.txt\";\n}\n$fd = fopen($in, \"r\");\nfscanf($fd, \"%d %d\\n\", $n, $k);\n$data = fgets($fd);\n$grade = explode(\" \", $data);\nfclose($fd);\n\nfor ($c = 0, $result = 0; $c < $n; $c++)\n{\n    $grade[$c] = intval($grade[$c]);\n}\nrsort($grade);\n$limit = $grade[$k - 1];\n\nfor ($c = 0, $result = 0; $c < $n; $c++)\n{\n    if ($grade[$c] >= $limit)\n    {\n        {\n            if ($grade[$c] > 0)\n            {\n                $result++;\n            }\n        }\n    }\n}\nprint \"$result\";\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f52e7d8ec760774fc4be56ce4fee295d", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n  $input = dataProvider::get();\n  $i = 0;\n  foreach($input['results'] as $result) {\n      if ((int) $result > 0 && (int) $result >= (int) $input['results'][$input['k'] - 1]) {\n          $i++;\n      } else {\n          break;\n      }\n  }\n  dataProvider::set($i);\n\n\n  class dataProvider\n  {\n      public static function get()\n      {\n          $stdin = file_get_contents('php://stdin');\n          $lines = explode(\"\\n\", $stdin, 2);\n          $lines[0] = explode(' ', $lines[0], 2);\n          $lines[1] = explode(' ', $lines[1]);\n          return array(\n            'n' => intval($lines[0][0]),\n            'k' => intval($lines[0][1]),\n            'results' => $lines[1],\n          );\n      }\n\n      public static function set($data)\n      {\n        file_put_contents('php://stdout', $data);\n      }\n  }\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "997856a6977b01e6f4d2ef0720d4ea7f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $n) = explode(' ', trim(fgets(STDIN)));\n\n$k = $a;\n$nn = $n;\n$sem = true;\n\nwhile ($n > 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?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "ab89fcff33b7365605ae1d82521a63b2", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction gcd($a,$b) {\n    while(1) {\n        if($a == $b) {\n            return $a;\n        }\n        else if($a < $b) {\n            list($a, $b) = array($b, $a);\n        }\n        while($a > $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", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "fe23c46d3e4600edcfe2dc37d3826f0d", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = 0;\n$d = 0;\n$e = 1;\nwhile(TRUE)\n{\n     $f = ($d + $b) % $a;\n     if($f == 0)\n     {\n          $c = ($d + $b) / $a;\n          break;\n     }\n     elseif($e == 0)\n     {\n          $c = $d / $a;\n          break;\n     }\n     else\n     {\n          $d += 10;\n     }\n     $e = $d % $a;\n}\nprint $c;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "366f8bd7a12c5be0a2873bfc873418dc", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($oneshovel, $coin)=explode(\" \", trim(fgets(STDIN)));\n$x=1;\nwhile (TRUE) {\n     \n     if (($oneshovel * $x) % 10 == 0 or (($oneshovel * $x) - $coin) % 10 == 0) {\n          \n          break;\n     }else $x++;\n     \n}\necho $x;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "29e3d256769c869b07b268bcf07597d4", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$in = fopen('php://stdin', 'r');\n\nlist($n,$d) = explode(\" \", rtrim(fgets($in)));\n$a = explode(\" \", rtrim(fgets($in)));\n\n$s = (($n-1)*10)+array_sum($a);\nif($s>$d){\n    echo \"-1\";\n}else{\n    $j = floor(($d-$s)/5) + ($n-1)*2;\n    echo \"$j\";\n}\n", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "e89acf3ceb1698f6b644df46758d1303", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$f = fopen (\"php://stdin\", 'r' ) ;\n$lines = file(\"php://stdin\");\n\n\nfunction parseint($n){\n    return(intval($n));\n}\n\n$n_time = array_map(\"parseint\", explode(\" \",(strval($lines[0]))));\n$n = $n_time[0];\n$times = $n_time[1];\n\n$t = array_map(\"parseint\", explode(\" \",(strval($lines[1]))));\n\n$song_duration = array_sum($t) + (10 * ($n - 1));\nif($song_duration > $times){\n    print \"-1\" ;\n    \n}\nelse{\n    print intval(($times - array_sum($t))/5);\n}\n\n?>", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "f48c3319b0f771563e55ba3880b3d31d", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$length = (int) trim(fgets(STDIN));\n$steps = [5, 4, 3, 2, 1];\n\n$total = 0;\nforeach ($steps as $step) {\n    if ($length < $step) continue;\n    $temp = $length % $step;\n    $total = $total + ($length - $temp)/$step;\n    $length = $temp;\n}\necho $total;", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "3e3ce0969a279c818c5e18c3b28a52b7", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$number = (int)fgets(STDIN);\nprint_r(intdiv($number, 5) + ($number % 5 == 0 ? 0 : 1));\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "37a36440774a1025da6c1c096350b3c0", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = str_split(trim(fgets(STDIN)));\n$b = array();\n$c = 0;\nfor($x = 0; $x < count($a) - 1; $x++)\n{\n     if(($a[$x] == \"V\") && ($a[$x + 1] == \"K\"))\n     {\n               $b[$x] = TRUE;\n               $b[$x + 1] = TRUE;\n               $c++;\n     }\n}\n$d = 0;\nfor($x = 0; $x < count($a) - 1; $x++)\n{\n     if(($a[$x] == \"V\") && ($a[$x + 1] == \"V\") && ($b[$x] == FALSE) && ($b[$x + 1] == FALSE))\n     {\n          $d++;\n          break;\n     }\n     if(($a[$x] == \"K\") && ($a[$x + 1] == \"K\") && ($b[$x] == FALSE) && ($b[$x + 1] == FALSE))\n     {\n          $d++;\n          break;\n     }\n     \n}\nprint $c + $d;\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "7cde592b1761c0ef24e12f717e0b4d2f", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($num, $k) = fscanf(STDIN, \"%d %d\");\nfor ($i = 0; $i < $k; ++$i) {\n  $num % 10 ? --$num : $num = intdiv($num, 10);\n}\nprintf(\"%d\", $num);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "6da8d1ff017dac862853052216ff49b2", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$line = trim(fgets(STDIN));\n// $line = \"1000000000 9\";\n\nlist($n,$k) = explode(' ',$line);\n\nfor ($i = 0; $i < $k; $i++) {\n    if ($n % 10 == 0) {\n        $n = $n / 10;\n    } else {\n        $n = $n - 1;\n    }\n}\n\necho $n;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "ed07fedc47917214bc614d8214d746da", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = trim(fgets(STDIN));\n$s = fgets(STDIN);\n$a = 0;\nfor($i = 0; $i < $n; $i++) {\n\tif($s[$i] == $s[$i+1]) {\n\t\t++$a;\n\t}\n}\necho $a;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "2d60d988a2d2d3b8287bb43980650397", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$jlh = trim(fgets(STDIN));\n\t$str = str_split(trim(fgets(STDIN)));\n\t$hps = 0;\n\t$i = 1;\n\twhile($i < $jlh)\n\t{\n\t\tif($str[$i-1] == $str[$i])\n\t\t\t$hps = $hps + 1;\n\t\t$i++;\n\t}\n\techo $hps;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "fe6140955d526e902e433b7c8095ae6f", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction findOne($matrix) {\n    for($i = 0; $i < 5; $i++) {\n        for ($j = 0; $j < 5; $j++) {\n            if ($matrix[$i][$j] == 1) return array('x' => $i, 'y' => $j); \n        }\n    }\n\n    return false;\n}\n\n\n$matrix = array();\nfor ($i = 0; $i < 5; $i++) {\n    $matrix[$i] = explode(' ', fgets(STDIN));\n}\n\n$point = findOne($matrix);\n\necho abs($point['x'] - 2) + abs($point['y'] - 2);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "b8de9e9bc67611c5cebe99d903343eea", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\n\nfor ($i = 0; $i < 5; $i++) {\n    $inputs[$i] = (explode(\" \",readline()));\n    if(array_sum($inputs[$i]) == 1){\n        $r = $i+1;\n        for($x = 0; $x < 5; $x++){\n            if($inputs[$i][$x] == 1){\n                $c = $x+1;\n            }\n        }\n    }\n}\n\n\n\necho abs($r-3) + abs($c-3);\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "b1f08ea0a634418bf54c59b4ead74f31", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nerror_reporting(0);\nob_end_clean();\n\nsolve();\n\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$A = (int)$Scanner->Scan();\n\n\t$star = 1 + 6 * ($A * $A - $A); \n\t\n\tprintf(\"%.0f\", $star);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>", "lang_cluster": "PHP", "tags": ["combinatorics"], "code_uid": "b360e73fe00249b2be8fca0c796fe58f", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\t$string = trim(fgets(STDIN));\n\n\t$string = str_replace('+','',$string);\n\n\t$string = str_split($string);\n\n\t$result = \"\";\n\n\tsort($string);\n\n\tforeach ($string as $element) {\n\n\t\t$result .= \"+{$element}\";\n\t}\n\n\t$result = trim($result,'+');\n\n\techo $result;\n\n\t?>", "lang_cluster": "PHP", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "86737ca234a0eef890e5110bc8835dd3", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = explode(\"+\", trim(fgets(STDIN)));\nsort($a);\nprint implode(\"+\", $a);\n?>", "lang_cluster": "PHP", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "3d07a961e8e8a10d503f25af19308aa4", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$a = trim(fgets(STDIN));\n\t$b = array(\"a\" => 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?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "a75f31e8af8922e8bd6e40b3871b03e6", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n# Alireza\n# JAHANI\n# PH_PY_LA\n# Dont Repeat Your self ...\n\n$input = str_split(trim(fgets(STDIN)));\n$alpha = range('a','z');\n$alpha = array_flip($alpha);\n$s = 0 ;\n\nfor ($i=0;$i<count($input)-1;$i++) {\n      $a = abs($alpha[$input[$i]] - $alpha[$input[$i+1]]);\n      $b =26 - $a ;  \n      $s += min($a,$b);    \n}\n$a = abs($alpha[$input[0]] - $alpha['a']);\n$b =26 - $a ;  \necho $s+min($a,$b);", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "3f64fa7f63932a1c09ffbc6fc1c9af79", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%d %d\", $n, $t);\n    fscanf(STDIN, \"%s\", $arr);\n    $sw = 0;\n       for ($i = 0; $i < $t; $i++){\n           for ($j = 0; $j < $n; $j++){\n               if ($arr[$j] == 'B' && $arr[$j+1] == 'G'){\n                  $sw = $arr[$j];\n                  $arr[$j] = $arr[$j+1];\n                  $arr[$j+1] = $sw;\n                  $j += +1;\n                 \n               }\n           }\n       }\n       for ($i=0; $i < $n; $i++){\n           echo ($arr[$i]);\n       }", "lang_cluster": "PHP", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "8bc41ad7b6ce52a350400525200f5f0a", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n=trim(fgets(STDIN));\n$n=explode(' ',$n);\n$input=trim(fgets(STDIN));\n$array=str_split($input);\n$a=$n[1];\nwhile($a>=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);", "lang_cluster": "PHP", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "d258dcae2ae205176744d137cbecc214", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$data = rtrim(fgets(STDIN));\n$uniqued = count_chars($data, 3);// return string(5) \"abfor\"\n$count = strlen($uniqued);\nif($count%2==0){\n    echo \"CHAT WITH HER!\";\n}else {\n    echo \"IGNORE HIM!\";\n}", "lang_cluster": "PHP", "tags": ["brute force", "strings", "implementation"], "code_uid": "2fff3ea829ab2ce82bfaee3b10ad65be", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, '%s', $s);\n\nfunction getAlfaArray() {\n    $arr = array();\n    for ($i = 0; $i < 26; ++$i) {\n        $arr[$i] = 0;\n    }\n    return $arr;\n}\n\n$alfa = getAlfaArray();\n$count = 0;\n$length = strlen($s);\nfor ($i = 0; $i < $length; ++$i) {\n    if ( !$alfa[ord($s[$i]) - ord('a')] ) {\n        $count++;\n        $alfa[ord($s[$i]) - ord('a')] = 1;\n    }\n}\n\necho ($count % 2) ? 'IGNORE HIM!' : 'CHAT WITH HER!';\n", "lang_cluster": "PHP", "tags": ["brute force", "strings", "implementation"], "code_uid": "a1c66b5195b2b409c47f28e1ed6dbf77", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$word = trim(fgets(STDIN));\n\t$counter = 0;\n\tforeach (str_split($word) as $i)\n\t\tif (ctype_upper($i))\n\t\t\t$counter++;\n\tfwrite(STDOUT,($counter > (strlen($word)/2))? strtoupper($word) : strtolower($word));", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "ab978433948cbe184c1af46bf495e772", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$s = trim(fgets(STDIN));\nif(preg_match_all('/[a-z]/',$s,$o)>=preg_match_all('/[A-Z]/',$s,$o))\n print strtolower($s); else print strtoupper($s);\n\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "03313e834bb7580a476e16e87401d999", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nerror_reporting(E_ALL);\nini_set(\"memory_limit\", \"256M\");\nini_set(\"max_execution_time\", 1);\n\n$fd     = fopen(\"php://stdin\", 'r');\n$count  = (int) fgets($fd);\n$groups = explode(\" \", trim(fgets($fd)));\n\n$sum = 0;\nforeach ($groups as $group) {\n    $sum += $group;\n}\n\necho $sum / $count;\n", "lang_cluster": "PHP", "tags": ["sortings", "implementation"], "code_uid": "6f99b6b31e5e217b60ad68f20f5c71d0", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($a, $b) = explode(' ', readline());\n\n$one = explode(' ', readline());\n$two = explode(' ', readline());\n\nfor($i=0; $i<$a; $i++)\n\tfor($j=0; $j<$b; $j++)\n\t\tif($one[$i] == $two[$j])\n\t\t\techo $one[$i]. \" \";", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "da43b1605c7a7bf2a814c8b38b27e847", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = explode(\" \", trim(fgets(STDIN)));\n$e = array();\nfor($x = 0; $x < $b; $x++)\n{\n     $e[$d[$x]] = 1;\n}\n$f = array();\nfor($x = 0; $x < $a; $x++)\n{\n     if($e[$c[$x]] == TRUE)\n     {\n          $f[count($f)] = $c[$x];\n     }\n}\nprint implode(\" \", $f);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "2c0bfa716f40c798c4e660e1816606fd", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif($b == 0)\n{\n     print $a . \" \" . $a;\n}\nelse\n{\n     $c = max(0, $a - $b * 2);\n     $d = 0;\n     $e = 0;\n     $f = 0;\n     while(TRUE)\n     {\n          $e += $f;\n          $d++;\n          if($b <= $e)\n          {\n               $g = $a - $d;\n               break;\n          }\n          $f++;\n     }\n     print $c . \" \" . $g;\n}\n?>", "lang_cluster": "PHP", "tags": ["constructive algorithms", "graphs"], "code_uid": "9300749b2da434e708e6dff48931b5bf", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d %d\",$m,$n);\n$r=floor($m*$n/2);\necho $r;", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "d9ddd2ea7c082d4c4fad577b09a91d6e", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$str = trim(fgets(STDIN));\n\t$nilai = explode(\" \",$str);\n\techo floor(intval($nilai[0])*intval($nilai[1])*0.5);\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "5cf245c10953c0f43cdc76a944b04a13", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $stdin = fopen('php://stdin', 'r');\n    $stdout = fopen('php://stdout', 'w');\n    $matrix[0] = fgets($stdin);\n    $matrix[1] = fgets($stdin);\n    $matrix[2] = fgets($stdin);\n    \n    function illegal(){\n        fputs(fopen('php://stdout', 'w'), \"illegal\");\n        exit();\n    }  \n    \n    function checkingForWinner($matr, $nulls, $crosses){\n        $won = null;\n    \n        for($i=0; $i<3; ++$i){\n            if(($matr[$i][0]==$matr[$i][1])&&($matr[$i][1]==$matr[$i][2])){\n                if($matr[$i][0]==\".\") continue;\n                \n                if($won != null) illegal();\n                $won = $matr[$i][0]==\"X\" ? \"first\" : \"second\";\n            \n                if(($won==\"first\")&&($nulls == $crosses)) illegal();\n            \n                else if(($won==\"second\")&&($nulls < $crosses)) illegal();\n            }\n        }\n    \n        if($won!=null){\n            fputs(fopen('php://stdout', 'w'), \"the \" . $won . \" player won\");\n            exit();\n        }\n    }\n    \n    //Checking for legacy\n    $nulls = 0;\n    $crosses = 0;\n    $reversed = array();\n    \n    for($i=0; $i<3; ++$i){\n        for($j=0; $j<3; ++$j){\n            if($matrix[$i][$j] == \"0\") $nulls++;\n            else if($matrix[$i][$j] == \"X\") $crosses++;\n            \n            $reversed[$j][$i] = $matrix[$i][$j];\n        }\n    }\n    \n    if(($crosses - $nulls != 1)&&($crosses - $nulls != 0)) illegal();\n    \n    checkingForWinner($matrix, $nulls, $crosses);\n    checkingForWinner($reversed, $nulls, $crosses);\n    \n    //checking the crosses for winner\n    if(((($matrix[0][0]==$matrix[1][1])&&($matrix[1][1]==$matrix[2][2]))||\n    (($matrix[0][2]==$matrix[1][1])&&($matrix[1][1]==$matrix[2][0])))\n            &&($matrix[1][1]!=\".\")){\n\n        $won = $matrix[1][1]==\"X\" ? \"first\" : \"second\";\n\n        if(($won == \"first\")&&($nulls == $crosses)) illegal();\n        \n        else if(($won==\"second\")&&($nulls < $crosses)) illegal();\n        \n        fputs($stdout, \"the \" . $won . \" player won\");\n        return;   \n    }\n    \n    if($nulls + $crosses > 8) {\n        fputs($stdout, \"draw\");\n        return;\n    }\n    \n    if($crosses > $nulls) {\n        fputs($stdout, \"second\");\n    } else {\n        fputs($stdout, \"first\");\n    }\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation", "games"], "code_uid": "7c0d2ca0cb4a5af1c2fe216699079f2e", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = str_split(trim(fgets(STDIN)));\nlist($d, $e, $f) = str_split(trim(fgets(STDIN)));\nlist($g, $h, $i) = str_split(trim(fgets(STDIN)));\n$j = array($a, $b, $c, $d, $e, $f, $g, $h, $i);\n$k = 0;\n$l = 0;\n$m = 0;\n$n = 0;\n$o = 0;\n$p = 0;\n$r = 0;\n$s = 0;\n$t = 0;\nfor($x = 0; $x < count($j); $x++)\n{\n    if($j[$x] == \"X\")\n    {\n        $k++;    // \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438\n    }\n    elseif($j[$x] == \"0\")\n    {\n        $l++;    // \u043d\u043e\u043b\u0438\u043a\u0438\n    }\n    else\n    {\n        $m++;    // \u043f\u0443\u0441\u0442\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438\n    }\n}\nif((($a == \"X\") && ($b == \"X\") && ($c == \"X\")) || (($d == \"X\") && ($e == \"X\") && ($f == \"X\")) || (($g == \"X\") && ($h == \"X\") && ($i == \"X\")) || (($a == \"X\") && ($d == \"X\") && ($g == \"X\")) || (($b == \"X\") && ($e == \"X\") && ($h == \"X\")) || (($c == \"X\") && ($f == \"X\") && ($i == \"X\")) || (($a == \"X\") && ($e == \"X\") && ($i == \"X\")) || (($c == \"X\") && ($e == \"X\") && ($g == \"X\")))\n{\n    $n = 1;\n}\nif((($a == \"0\") && ($b == \"0\") && ($c == \"0\")) || (($d == \"0\") && ($e == \"0\") && ($f == \"0\")) || (($g == \"0\") && ($h == \"0\") && ($i == \"0\")) || (($a == \"0\") && ($d == \"0\") && ($g == \"0\")) || (($b == \"0\") && ($e == \"0\") && ($h == \"0\")) || (($c == \"0\") && ($f == \"0\") && ($i == \"0\")) || (($a == \"0\") && ($e == \"0\") && ($i == \"0\")) || (($c == \"0\") && ($e == \"0\") && ($g == \"0\")))\n{\n    $o = 1;\n}\nif(($l > $k) || (($n == 1) && ($o == 1)) || (($k > $l) && ($o == 1)) || (($k == $l) && ($n == 1)) || ((($k - $l) > 1) && ($n == 1)) || (($k - $l) > 1))\n{\n    $p = 1;\n}\nif($m == 0)\n{\n    $r = 1;\n}\nif($k == $l)\n{\n    $s = 1;\n}\nif($k > $l)\n{\n    $t = 1;\n}\nif($p == 1)\n{\n    print \"illegal\";\n}\nelseif($n == 1)\n{\n    print \"the first player won\";\n}\nelseif($o == 1)\n{\n    print \"the second player won\";\n}\nelseif($r == 1)\n{\n    print \"draw\";\n}\nelseif($s == 1)\n{\n    print \"first\";\n}\nelseif($t == 1)\n{\n    print \"second\";\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation", "games"], "code_uid": "f547a80b7df05529a2ac3e4d0e96d72d", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$values = [\n\t[0, 1, 2],\n\t[1, 0, 2],\n\t[1, 2, 0],\n\t[2, 1, 0],\n\t[2, 0, 1],\n\t[0, 2, 1]\n];\n\n$n = (int) fgets(STDIN);\n$i = (int) fgets(STDIN);\n\necho $values[$n % 6][$i];\n", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "f74240c0ac87c296fd44e47e7e8ae0d4", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n=str_replace(\"\n\",\"\",fgets(STDIN));\n$a=str_split($n);\n$c=count($a);\nfor($i=($c-1);$i>=0;$i--)\n{\n   if($a[$i]!=0){ \n    break;\n    }\n}\n$c=$i+1;\n//echo $c;\n//print_r($a);\n$sum=0;\nfor($i=0;$i<(int)($c/2);$i++)\n{\n  //echo $a[$i].\"/\".$a[($c-1-$i)].\"\\n\";\n       if($a[$i]!=$a[($c-1-$i)]) \n           {$sum=1;\n              break; }\n\n}\n//echo $sum;\nif($sum) echo \"NO\";\n  else echo \"YES\";\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "700ac08787be8a354bab33e62401f6fe", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$a[0] = trim(fgets(STDIN));\n$a[1] = trim(fgets(STDIN));\n$a[2] = $a[0] + $a[1];\nif(str_replace(\"0\", \"\", $a[0])+str_replace(\"0\", \"\", $a[1])==str_replace(\"0\", \"\", $a[2]))\n{echo \"YES\";}else{echo \"NO\";}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "343d5cc591dd70fa72476af7847ad6da", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n//First Get The Input.\n$input = file_get_contents(\"php://stdin\");\n\n$curr = $input[0];\n\n$count = 1;\n\n$done = false;\n\n//Loop Throw The Input.\nfor($i = 1;$i < strlen($input);$i++) {\n    \n    if($input[$i] == $curr) {\n        \n        $count++;\n        \n    }else {\n        \n        $curr = $input[$i];\n        \n        if($count > 6) {\n            \n            echo \"YES\";\n            \n            $done = true;\n            \n            break;\n            \n        }\n        \n        $count = 1;\n        \n    }\n    \n}\n\nif($done == false) {\n    \n    echo \"NO\";\n    \n}\n\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "5f38ed703bc531492f145dbca3ce9eca", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = trim(fgets(STDIN));\n$k = 1;\n$b = 'NO';\nfor ($i=0; $i < iconv_strlen($s); $i++) {\n\tif ($s[$i] == $s[$i+1]) {\n\t\t$k++;\n\t} else {\n\t\t$k = 1;\n\t}\n\t\n\tif ($k > 6) $b = 'YES';\n}\nprint($b);\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "b57de4e18421b4f7472c86a427cf1de5", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = ceil(strlen($a) / 2) - 1;\n$c = $b;\n$d = $a[$b];\n$e = 0;\nfor($x = 0; $x < strlen($a) - 1; $x++)\n{\n     $f = $e % 2;\n     $e++;\n     if($f == 0)\n     {\n          $b++;\n          $d .= $a[$b];\n     }\n     else\n     {\n          $c--;\n          $d .= $a[$c];\n     }\n}\nprint $d;\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "9910adb6d495566b397ced0bae058989", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = intval(readline());\n\n$n = 0;\nwhile(true)\n{\n\tif($s >= 100)\n\t{\n\t\t$s -= 100;\n\t\t$n++;\n\t}\n\telse if($s >= 20)\n\t{\n\t\t$s -= 20;\n\t\t$n++;\n\t}\n\telse if($s >= 10)\n\t{\n\t\t$s -= 10;\n\t\t$n++;\n\t}\n\telse if($s >= 5)\n\t{\n\t\t$s -= 5;\n\t\t$n++;\n\t}\n\telse if($s >= 1)\n\t{\n\t\t$s -= 1;\n\t\t$n++;\n\t}\n\telse\n\t{\n\t\techo $n;\n\t\tbreak;\n\t}\n}\n?>", "lang_cluster": "PHP", "tags": ["greedy", "dp"], "code_uid": "d1b367056b9f842ef9b4c3fa4a1d1733", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$main = new MainClass;\n\nfscanf(STDIN, \"%d\", $n);\n\necho $main->solution($n);\n// End of interface\n\nclass MainClass {\n\t//996-A. Hit the Lottery\n\tpublic $problemLink = 'https://codeforces.com/problemset/problem/996/A';\n\tpublic $submissionLink = '';\n\n\tpublic function solution($n){\n\t\t$denominations = [1, 5, 10, 20, 100];\n\t\t$res = 0;\n\t\t$remainder = $n;\n\t\tforeach (array_reverse($denominations) as $value){\n\t\t\t$intQuotient = intval($remainder/$value);\n\t\t\t$currentReminder = $remainder % $value;\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\t$remainder = $currentReminder;\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n}\n", "lang_cluster": "PHP", "tags": ["greedy", "dp"], "code_uid": "31b754b4901c5ae59bb2a6eaf0370cca", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    list($a, $b) = explode(' ', trim(fgets(STDIN)));\n    \n    $x = log($b/$a, 1.5);\n    if ($x == ceil($x)) {\n        $x = ceil($x) + 1;\n    } else {\n        $x = ceil($x);\n    }\n    \n    echo $x;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "d1c4fc6ca65c785c1c9077365329d315", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction ab($a, $b){\n    $year = 0;\n    while($a<=$b){\n        $a=3*$a;\n        $b=2*$b;\n        $year++;\n    }\n    return $year;\n}\n$ab = explode(\" \" , trim(fgets(STDIN))); \necho ab($ab[0],$ab[1]);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "4219c8ab7599030b384cda082dda8fdd", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = array();\nfor($x = 1; $x <= 5; $x++)\n{\n    $b = explode(\" \", trim(fgets(STDIN)));\n    array_unshift($b, \" \");\n    unset($b[0]);\n    $a[$x] = $b;\n}\n$c = array(array(\"1\", \"2\"), array(\"2\", \"1\"));\n$d = 3;\n$e = count($c);\nfor($z = 1; $z <= 3; $z++)\n{\n    for($x = 0; $x < $e; $x++)\n    {\n        for($y = 0; $y < $d; $y++)\n        {\n            $f = $c[$x];\n            if(count($f) == $d - 1)\n            {\n                $g = array_slice($f, 0, $y);\n                $h = array_slice($f, $y);\n                array_push($g, $d);\n                $i = array_merge($g, $h);\n                array_push($c, $i);\n            }\n        }\n    }\n    $j = count($c);\n    for($x = 0; $x < $j; $x++)\n    {\n        $f = $c[$x];\n        if(count($f) != $d)\n        {\n            unset($c[$x]);\n        }\n    }\n    sort($c);\n    $e = count($c);\n    $d++;\n}\n$k = 0;\nfor($x = 0; $x < count($c); $x++)\n{\n    $l = $c[$x];\n    $m = $a[$l[0]][$l[1]] + $a[$l[1]][$l[0]] + $a[$l[2]][$l[3]] + $a[$l[3]][$l[2]] + $a[$l[1]][$l[2]] + $a[$l[2]][$l[1]] + $a[$l[3]][$l[4]] + $a[$l[4]][$l[3]] + $a[$l[2]][$l[3]] + $a[$l[3]][$l[2]] + $a[$l[3]][$l[4]] + $a[$l[4]][$l[3]];\n    $k = max($k, $m);\n}\nprint $k;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "149b8eda1c99a28d5ba562df51380c9e", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$fr = fopen(\"php://stdin\",\"r\");\n\t$input = fgets($fr);\n\tlist( $y, $w ) = explode(' ', $input);\n\tfclose ($fr);\n\n\t$dice = 6;\n\t$r = min( $dice-$y, $dice-$w ) + 1;\n\tif ( $r == 0 )\n\t\tdie('0/1');\n\tforeach ( array(2,3,5) as $d )\n\t{\n\t\twhile ( (($r % $d) == 0) && (($dice % $d) == 0) )\n\t\t{\n\t\t\t$r /= $d;\n\t\t\t$dice /= $d;\n\t\t}\n\t}\n\techo $r.'/'.$dice;\n?>", "lang_cluster": "PHP", "tags": ["math", "probabilities"], "code_uid": "9662f83ffa1c8cb4b304d53f25fbd60c", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($y, $w) = explode(\" \", fgets(STDIN));\n$a = min(6 - $y, 6 - $w) + 1;\nif($a == 1) { print \"1/6\"; }\nif($a == 2) { print \"1/3\"; }\nif($a == 3) { print \"1/2\"; }\nif($a == 4) { print \"2/3\"; }\nif($a == 5) { print \"5/6\"; }\nif($a == 6) { print \"1/1\"; }\n?>", "lang_cluster": "PHP", "tags": ["math", "probabilities"], "code_uid": "abe92a0578f54865fca082eea00ffcb8", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c, $d, $e) = explode(\" \", trim(fgets(STDIN)));\n$f = ($a * $b) + ($d * 2);\n$g = ($a * $c) + ($e * 2);\nif($f > $g)\n{\n     print \"Second\";\n}\nelseif($f == $g)\n{\n     print \"Friendship\";\n}\nelseif($f < $g)\n{\n     print \"First\";\n}\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "37234fc2cd9e0e5c9c52a00c74d7879a", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n###### IO ######\nerror_reporting(E_ALL);\n#error_reporting(0);\n\nfunction readString($f) {\n\t$r = array(\n\t\t\"\\r\" => '',\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\tlist($s, $v1, $v2, $t1, $t2) = array_map('trim', readStringExplode($f, ' '));\n\t$answer1 = $t1 * 2 + $v1 * $s;\n\t$answer2 = $t2 * 2 + $v2 * $s;\n\tif ($answer1 < $answer2) {\n\t\techo 'First';\n\t} elseif ($answer1 > $answer2) {\n\t\techo 'Second';\n\t} else {\n\t\techo 'Friendship';\n\t}\n\n\t/* / end body */\n}\n\nif (!isset($is_test)) {\n\t$is_test = false;\n}\nif (empty($is_test)) {\n\tgetAnswer();\n}", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "aace53f67a5ef2c60f0e9bad73f13425", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/*****************************************/\nclass InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\nclass Utils {\n\t/* Perform action N times. Can return values in array */\n\tstatic public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\t/* Integral. Keys preserved. By reference. */\n\tstatic public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\t/* Difference. Keys preserved. By reference. */\n\tstatic public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\tstatic public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n$s = $ir->readString();\n\n$t = [];\n$i = 0;\n$k = 1;\nwhile ($i<$n) {\n\t$t[] = $s[$i];\n\t$i+=$k;\n\t$k+=1;\n}\n\necho implode('', $t);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "358a4154166266a413e99d54e7f9e8f3", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$len = readline();\n$str = readline();\n\n$temp = 0;\n$ans = null;\n\nfor($i = 0; $temp < (int) $len; $temp += $i) {\n    $ans .= $str[$temp];\n    $i++;\n}\n\necho $ans.\"\\n\";", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "4147d1a44ed71501f1a145eea22494f8", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nclass Resolver\n{\n    /**\n     * @param int $n\n     * @return int\n     */\n    public static function resolve(int $n) : int\n    {\n        if ($n == 0) {\n            return 1;\n        }\n\n        switch ($n % 4) {\n            case 1:\n                return 8;\n            case 2:\n                return 4;\n            case 3:\n                return 2;\n            case 0:\n                return 6;\n        }\n    }\n}\n\n$input = fopen(\"php://stdin\", 'r');\n$n = intval(fgets($input));\nfclose($input);\n\necho Resolver::resolve($n);\n", "lang_cluster": "PHP", "tags": ["math", "implementation", "number theory"], "code_uid": "324ca9e6c18517dc69b3374a9b40e78d", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$f = fopen('php://stdin', 'r');\n//$f = fopen('1.txt', 'r');\n$s = trim(fgets($f));\n\nif (strpos($s,\"H\")===false && strpos($s,\"Q\")===false && strpos($s,\"9\")===false){\n    echo \"NO\";\n} else echo \"YES\";\n\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "ce5baf9a1168d95480299f27c18530bb", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input = file_get_contents(\"php://stdin\");\n\n$input = str_split($input);\n\nfunction doo ($in) {\n    \n    for($i = 0;$i < count($in);$i++) {\n        \n        if(in_array($in[$i],array('H','9','Q'))) {\n            \n            echo \"YES\";\n            return;\n            \n        }\n        \n    }\n    \n    echo \"NO\";\n   \n}\n\ndoo($input);\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f62e0ae6c6935d1f6257b11030aea75d", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $n = trim(fgets(STDIN));\n    echo interes($n);\n    function interes($n) {\n        if (array_sum(str_split($n))%4 == 0) {\n            return $n;\n        } else {\n            return interes($n + 1);\n        }\n    }\n     \n    \n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "120a59024a73363343f3f9675eff773f", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n$c = 0;\n$d = 0;\n$e = 0;\nfor($x = 0; $x < $a; $x++)\n{\n     switch($b[$x])\n     {\n          case \"B\":\n          $c++;\n          break;\n          case \"G\":\n          $d++;\n          break;\n          case \"R\":\n          $e++;\n          break;\n     }\n}\nif(($c > 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?>", "lang_cluster": "PHP", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "2fc5d23af011053f2190a8a1ea8d7f92", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $wt = (int)fgets(STDIN);\n    \n    if(($wt%2 == 0) && ($wt > 2))\n        echo \"YES\".\"\\n\";\n    else\n        echo \"NO\".\"\\n\";\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math"], "code_uid": "174f8c262df7f7130120d056785ddd7f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$son  = trim(fgets(STDIN));\necho ($son % 2) === 0 && $son > 2 ? 'YES' : 'NO';", "lang_cluster": "PHP", "tags": ["brute force", "math"], "code_uid": "d3ba3e9e79c10d3f078d0665b3f4506b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($sn, $sm, $sa) = explode(\" \", trim(fgets(STDIN)));\nprint number_format(ceil($sn/$sa) * ceil($sm/$sa), 0, '', '');\n?>\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "169a1c7b9d303f2868c5eaca3b3dfeab", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nerror_reporting(0);\n$dir = fopen(\"php://stdin\", 'r');\n$datatxt = stream_get_contents($dir);\n$text = explode(\" \",$datatxt);\n$file = ceil($text[0]/$text[2])*ceil($text[1]/$text[2]);\necho str_replace(\",\",\"\",number_format($file,0));\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "ce276c121725194b82c42f04ddba0256", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $storeStr = (string)readline();\n    $storeInt = (int)$storeStr;\n    $arrayStore = str_split($storeStr);\n    $findEight = false;\n    $count = 0;\n\n    while(!$findEight) {\n        if (!$findEight) {\n            $storeInt++;\n            $storeStr = (string)$storeInt;\n            $arrayStore = str_split($storeStr);\n            $count++;\n        }\n\n        foreach ($arrayStore as $number) {\n            if ($number === '8') $findEight = true;\n        }\n    }\n\n    echo $count;\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "27adf0cc93a6127b6b681d75cb311251", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$file = STDIN;\n//$file = fopen('giga','r');\n\n$s = trim(fgets($file));\n\nfor($i=0;$i<=21;$i++){\n\n    $s++;\n    if (strpos($s, '8')!==false){\n        echo ($i+1);\n        break;\n    }\n}", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "690d02d7b5c955eaecfaefc0c28d0333", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\n$answer = \"No\";\n\n$na = ceil($c / $a);\n\nif ( ($c%$a == 0) || ($c%$b == 0) ) {\n\t$answer = \"Yes\";\n} else {\n\tfor ($i=0; $i < $na; $i++) { \n\t\tif ( ($c-$i*$a) % $b == 0 ) {\n\t\t\t$answer = \"Yes\";\n\t\t\tbreak;\n\t\t}\n\t}\n}\t\nprint $answer;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "number theory"], "code_uid": "3c9d4c3ccaae8c780c0addbda84a0e2a", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\nlist($d, $e, $f) = explode(\" \", trim(fgets(STDIN)));\nlist($g, $h, $i) = explode(\" \", trim(fgets(STDIN)));\n$j = 1;\n$k = 1;\n$l = 1;\n\n$m = 1;\n$n = 1;\n$o = 1;\n\n$p = 1;\n$r = 1;\n$s = 1;\nif(($a % 2) != 0)\n{\n    if($j == 1)\n    {\n        $j = 0;\n    }\n    else\n    {\n        $j = 1;\n    }\n    if($k == 1)\n    {\n        $k = 0;\n    }\n    else\n    {\n        $k = 1;\n    }\n    if($m == 1)\n    {\n        $m = 0;\n    }\n    else\n    {\n        $m = 1;\n    }\n}\n\nif(($b % 2) != 0)\n{\n    if($j == 1)\n    {\n        $j = 0;\n    }\n    else\n    {\n        $j = 1;\n    }\n    if($k == 1)\n    {\n        $k = 0;\n    }\n    else\n    {\n        $k = 1;\n    }\n    if($l == 1)\n    {\n        $l = 0;\n    }\n    else\n    {\n        $l = 1;\n    }\n    if($n == 1)\n    {\n        $n = 0;\n    }\n    else\n    {\n        $n = 1;\n    }\n}\n\nif(($c % 2) != 0)\n{\n    if($k == 1)\n    {\n        $k = 0;\n    }\n    else\n    {\n        $k = 1;\n    }\n    if($l == 1)\n    {\n        $l = 0;\n    }\n    else\n    {\n        $l = 1;\n    }\n    if($o == 1)\n    {\n        $o = 0;\n    }\n    else\n    {\n        $o = 1;\n    }\n}\n\nif(($d % 2) != 0)\n{\n    if($j == 1)\n    {\n        $j = 0;\n    }\n    else\n    {\n        $j = 1;\n    }\n    if($n == 1)\n    {\n        $n = 0;\n    }\n    else\n    {\n        $n = 1;\n    }\n    if($m == 1)\n    {\n        $m = 0;\n    }\n    else\n    {\n        $m = 1;\n    }\n    if($p == 1)\n    {\n        $p = 0;\n    }\n    else\n    {\n        $p = 1;\n    }\n}\n\nif(($e % 2) != 0)\n{\n    if($k == 1)\n    {\n        $k = 0;\n    }\n    else\n    {\n        $k = 1;\n    }\n    if($m == 1)\n    {\n        $m = 0;\n    }\n    else\n    {\n        $m = 1;\n    }\n    if($n == 1)\n    {\n        $n = 0;\n    }\n    else\n    {\n        $n = 1;\n    }\n    if($o == 1)\n    {\n        $o = 0;\n    }\n    else\n    {\n        $o = 1;\n    }\n    if($r == 1)\n    {\n        $r = 0;\n    }\n    else\n    {\n        $r = 1;\n    }\n}\n\nif(($f % 2) != 0)\n{\n    if($l == 1)\n    {\n        $l = 0;\n    }\n    else\n    {\n        $l = 1;\n    }\n    if($n == 1)\n    {\n        $n = 0;\n    }\n    else\n    {\n        $n = 1;\n    }\n    if($o == 1)\n    {\n        $o = 0;\n    }\n    else\n    {\n        $o = 1;\n    }\n    if($s == 1)\n    {\n        $s = 0;\n    }\n    else\n    {\n        $s = 1;\n    }\n}\n\nif(($g % 2) != 0)\n{\n    if($m == 1)\n    {\n        $m = 0;\n    }\n    else\n    {\n        $m = 1;\n    }\n    if($p == 1)\n    {\n        $p = 0;\n    }\n    else\n    {\n        $p = 1;\n    }\n    if($r == 1)\n    {\n        $r = 0;\n    }\n    else\n    {\n        $r = 1;\n    }\n}\n\nif(($h % 2) != 0)\n{\n    if($n == 1)\n    {\n        $n = 0;\n    }\n    else\n    {\n        $n = 1;\n    }\n    if($p == 1)\n    {\n        $p = 0;\n    }\n    else\n    {\n        $p = 1;\n    }\n    if($r == 1)\n    {\n        $r = 0;\n    }\n    else\n    {\n        $r = 1;\n    }\n    if($s == 1)\n    {\n        $s = 0;\n    }\n    else\n    {\n        $s = 1;\n    }\n}\n\nif(($i % 2) != 0)\n{\n    if($o == 1)\n    {\n        $o = 0;\n    }\n    else\n    {\n        $o = 1;\n    }\n    if($r == 1)\n    {\n        $r = 0;\n    }\n    else\n    {\n        $r = 1;\n    }\n    if($s == 1)\n    {\n        $s = 0;\n    }\n    else\n    {\n        $s = 1;\n    }\n}\nprint $j . $k . $l . \"\\n\";\nprint $m . $n . $o . \"\\n\";\nprint $p . $r . $s;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "b359373b87c4918eb54836a96d3c4ad7", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = trim(fgets(STDIN));\n$n = 0;\n$t = $s;\ndo{\n\t$t++;\n\t$a = str_split($t);\n\tfor($i=0;$i<3;$i++){\n\t\tfor ($j=$i+1;$j<4;$j++){\n\t\t\tif ($a[$i] == $a[$j]){\n\t\t\t\tbreak 2;\n\t\t\t}\n\t\t\telse if ($i == 2 && $j == 3){\n\t\t\t\t$n = 1;\n\t\t\t}\n\t\t}\n\t}\n}\nwhile ($n == 0);\necho $t;\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "35f95b8e0ec7f383232d170e93f038d4", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$year = readline(\"Enter:\");\n$yearInt = intval($year);\n\n\n\nfor($i = 0;$i < 9000;$i++){\n\t$yearInt++;\n\t\n\t$arr  = array_map('intval', str_split($yearInt));\n\t$arrUnique = array_unique($arr);\n\n\n\tif($arr == $arrUnique){\n\t\techo $yearInt;\n\t\tbreak;\n\t}\n}\n\n\t\n\t\n\n\n\n", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "911011e2fdb1216a382445ce6fd95f3b", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\tfunction process($n, $m, $a, $b){\n\t\t$one_ride = $n * $a;\n\t\t$multi_ride = 0;\n\t\t$half_multi_ride = (((int)($n/$m))*$b);\n\t\t$other_half_one = $a *($n%$m);\n\t\t$other_half_two = $b;\n\t\tif((int)($n/$m) != 0){\n\t\t\tif($n%$m != 0){\n\t\t\t\tif($half_multi_ride+$other_half_one > $half_multi_ride+$other_half_two)\n\t\t\t\t\t$multi_ride = $half_multi_ride+$other_half_two;\n\t\t\t\telse\n\t\t\t\t\t$multi_ride = $half_multi_ride+$other_half_one;\n\t\t\t}else{\n\t\t\t\t$multi_ride = ((int)($n/$m))*$b;\n\t\t\t}\n\t\t}else{\n\t\t\t$multi_ride = $b;\n\t\t}\n\t\tif($one_ride > $multi_ride)\n\t\t\treturn $multi_ride;\n\t\telse\n\t\t\treturn $one_ride;\n\t}\n\t\n\t$handle = fopen(\"php://stdin\", 'r');\n\t$readAll = stream_get_contents($handle);\n\t$contents = explode(' ', $readAll);\n\techo process($contents[0], $contents[1], $contents[2], $contents[3]);\n\n?>\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f1977150f99f64225f9fb0738acb147f", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d %d %d %d\", $n, $m, $a, $b);\n\n$sisa = floor($n / $m);\n$ride = $sisa * $m;\n$rubles = ($sisa * $b) + (($n - $ride)*$a);\n\t\n$rubles2 = ($sisa + 1) * $b;\n\n$rubles3 = $n * $a;\necho min ($rubles, $rubles2, $rubles3);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "ca1225128577a47e08c67d4835080cd9", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "25", "lang_cluster": "PHP", "tags": ["number theory"], "code_uid": "0fda6e35c4cc8f43d72373e460de7571", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "25", "lang_cluster": "PHP", "tags": ["number theory"], "code_uid": "d293231fc1566257c150acbdd283d323", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n$c = array_fill(0, $a, 0);\n$d = 1;\nfor($x = 0; $x < $a - 2; $x++)\n{\n     if(($b[$x] == \"o\") && ($b[$x + 1] == \"g\") && ($b[$x + 2] == \"o\") && ($c[$x] == 0) && ($c[$x + 1] == 0) && ($c[$x + 2] == 0))\n     {\n          $c[$x] = $d;\n          $c[$x + 1] = $d;\n          $c[$x + 2] = $d;\n          for($y = $x + 3; $y < $a - 1; $y++)\n          {\n               if(($b[$y] == \"g\") && ($b[$y + 1] == \"o\"))\n               {\n                    $c[$y] = $d;\n                    $c[$y + 1] = $d;\n                    $y++;\n               }\n               else\n               {\n                    break;\n               }\n          }\n          $d++;\n     }\n}\n$e = \"\";\nfor($x = 0; $x < $a; $x++)\n{\n     if($c[$x] == 0)\n     {\n          $e .= $b[$x];\n     }\n     else\n     {\n          $e .= \"***\";\n          $f = 0;\n          for($y = $x; $y < $a; $y++)\n          {\n               if(($c[$y] == 0) || ($c[$y] != $c[$x]))\n               {\n                    break;\n               }\n               else\n               {\n                    $f++;\n               }\n          }\n          $x += ($f - 1);\n     }\n}\nprint $e;\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "efe35abd92e41f4fa0ae26908fb9c8b9", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$F = fopen('php://stdin', 'r');\n$n = fgets($F);\n$s = fgets($F);\nfclose($F);\n\necho preg_replace('/ogo(go)*/', '***', $s);\n\n?>\n", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "6f480ba19427ed7434fc750fd720e0c0", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = trim(fgets(STDIN));\n$t = trim(fgets(STDIN));\n\necho (strrev($s) == $t ? \"YES\" : \"NO\");\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "9883a3a4f94f6591852255e4228fd91e", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \nfscanf(STDIN, \"%s\",$s1);\nfscanf(STDIN, \"%s\",$s2);\nif (strlen($s1)==strlen($s2)){\n    $r=\"YES\";\n    for ($i=0; $i<strlen($s1); $i++){\n        if ($s1[$i]!=$s2[strlen($s1)-1-$i]){\n            $r=\"NO\";\n            break;\n        }\n    }\n} else \n    $r=\"NO\";\n\necho $r;\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "4746af893baabefb3c99470143aaf0a4", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfunction debug($data, $die = true) {\n    echo '<pre>';\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 '</pre>';\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\nfunction eratosphen($n) {\n    $isPrime = array();\n    for ($i = 0; $i < $n; $i++) {\n        $isPrime[$i] = 1;\n    }\n\n    $isPrime[0] = 0;\n    $isPrime[1] = 0;\n\n    for ($i = 2; $i * $i < $n; $i++)\n        if ($isPrime[$i])\n            for ($j = $i * $i; $j < $n; $j += $i)\n                $isPrime[$j] = 0;\n\n    $simple = array();\n    for ($i = 0; $i < $n; $i++) {\n        if ($isPrime[$i] == 1) {\n            $simple[] = $i;\n        }\n    }\n\n    echo implode(', ', $simple);\n}\n\n$stdin = stdin();\n/****************************************************** Solving block *****************************************************/\n$n = g();\n\n$simple = array(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499);\n\nfunction del($num, $simple) {\n    $cnt = 0;\n    $find = false;\n\n    foreach ($simple as $item) {\n        if ($item > $num) {\n            break;\n        }\n\n        while (true) {\n            if ($num % $item == 0) {\n                $num /= $item;\n                $find = true;\n            } else {\n                break;\n            }\n        }\n\n        if ($find) {\n            $cnt++;\n            $find = false;\n        }\n    }\n\n    return $num == 1 && $cnt == 2;\n}\n\n$sum = 0;\nfor ($num = 0; $num <= $n; $num++) {\n    if (del($num, $simple)) {\n        $sum++;\n    }\n}\n\necho $sum;\n?>", "lang_cluster": "PHP", "tags": ["number theory"], "code_uid": "94cdc2ce46efc0d1c4406b3ebde38cd8", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$n = trim(fgets(STDIN));\n\t$str = strtoupper(trim(fgets(STDIN)));\n\t$A = ord(\"A\");\n\tfor ($i = 0; $i < 26; $i++) {\n\t\tif (strpos($str, chr($A + $i)) === false) {\n\t\t\techo \"No\\n\";\n\t\t\texit();\n\t\t}\n\t}\n\techo \"Yes\\n\";\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "388b7ad5037606d25ae80ef17836afdd", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%d\", $n);\n    fscanf(STDIN, \"%s\", $arr);\n    $v = array();\n    $arr = strtolower($arr);\n        for ($i = 0; $i < $n; $i++){\n            $v[$arr[$i]] = 1;\n        }\n        if (count($v) == 26){\n            echo 'YES';\n        }\n        else echo 'NO';", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "6dbedb04e74539f70b851967e2be2460", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$n = trim(fgets(STDIN));\n$arr = explode(\" \", trim(fgets(STDIN)));\n\nsort($arr);\n$s=0;\nfor($i=0;$i<$n;$i++){\n    if($s*$arr[$i]+$s<=$i)$s++;\n    \n}\n\necho $s.PHP_EOL;", "lang_cluster": "PHP", "tags": ["sortings", "greedy"], "code_uid": "4246e95c302ba2df84b3a9d8ed44b37e", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/*\n * Secdra @2020\n */\n\nfscanf(STDIN, \"%s\", $encrypted_pass);\n$decrypted_pass = str_split($encrypted_pass,10);\nfor ($i = 0; $i < 10; $i++) {\n    fscanf(STDIN, \"%s\", $code);\n    $decrypted_pass = str_replace($code, $i, $decrypted_pass);\n}\nprintf(\"%s\", implode('', $decrypted_pass));\n", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "1e6a2dd4b345cf8425aea6cd9985e345", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$file = fopen('php://stdin','r');\n\n$data = fgets($file);\n\nfor ($i = 0, $j = 0; $i < 8; $i++)\n{\n\t$num[$i] = substr($data,$j,10);\n\t$j += 10;\n}\n\nfor ($i = 0; $i < 10; $i++)\n{\n\t$dic[$i] = substr(fgets($file),0,10);\n}\n\n$res = \"\";\nfor ($i = 0; $i < 8; $i++)\n{\n\tfor ($j = 0; $j < 10; $j++)\n\t{\n\t\t//echo $dic[$j], \" \", $num[$i], \"\\n\";\n\t\tif ($dic[$j] == $num[$i])\n\t\t{\n\t\t\t//echo $dic[$j], \"==\", $num[$i], \"\\n\";\n\t\t\t$res .= $j;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\t\necho $res;\t\n\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "faa334ded0a1fc7032a38bab11a3669f", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN, \"%d\\n\", $n);\n\n$resultCount = 0;\nfor ($a = 1; $a <= $n; $a++) {\n    for ($b = $a; $b <= $n; $b++) {\n        $c = $a ^ $b;\n        if (\n            $c <= $n &&\n            $c >= $b &&\n            (($a + $b) > $c) &&\n            (($a + $c) > $b) &&\n            (($c + $b) > $a)\n        ) {\n            $resultCount++;\n        }\n    }\n}\n\necho $resultCount;", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "9f0c1223e7ab4a78c358dec0c942a907", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d\", $n);\n\nif ($n % 2 === 0) {\n    echo \"Mahmoud\";\n}\nelse {\n    echo \"Ehab\";\n}\n\n?>", "lang_cluster": "PHP", "tags": ["math", "games"], "code_uid": "39dca9d808feda56d10b7610de00c9ea", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\nif($a&1) print \"Ehab\";\nelse print \"Mahmoud\";\n?>\n", "lang_cluster": "PHP", "tags": ["math", "games"], "code_uid": "6e3d997b05ea74ea6ebe34abb64de272", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n# 1141A\n\n$input = fopen('php://stdin', 'rb');\n[$n, $m] = explode(' ', fgets($input));\n$n = (int)$n;\n$m = (int)$m;\n\nif ($m === $n) {\n    die('0');\n}\n\nif ($m % $n) {\n    die('-1');\n}\n\n$result = 0;\n$mod32 = $m / $n;\nwhile (($mod32 % 3) === 0 && $mod32 > 1) {\n    $mod32 /= 3;\n    $result++;\n}\nwhile (($mod32 % 2) === 0) {\n    $mod32 /= 2;\n    $result++;\n}\n\necho $mod32 === 1 && $result > 0 ? $result : '-1';\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "f77784a5a5aff5c6d19aed72134d41da", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$buf=trim(fgets(STDIN));\n\tlist($a,$b)=explode(\" \",$buf);\n\tif($b % $a !== 0){\n\t\tprint \"-1\";\n\t}\n\telse{\n\t\t$c=$b/$a;\n\t\t//if($c % 2 !== 0 && $c % 3 !== 0 && $a!==$b) print \"-1\";\n\t\tif($a===$b) print \"0\";\n\t\telse{\n\t\t\t$ans=0;\n\t\t\t\twhile($c % 3 === 0){\n\t\t\t\t\t$c = $c / 3;\n\t\t\t\t\t$ans = $ans + 1;\n\t\t\t\t}\n\t\t\t\twhile($c % 2 ===0){\n\t\t\t\t\t$c = $c / 2;\n\t\t\t\t\t$ans = $ans + 1;\n\t\t\t\t}\n\t\t\tif($c===1) print $ans;\n\t\t\telse print \"-1\";\n\t\t}\n\t}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "cd63ea8f0bf0a4088edf520cefb724f9", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$result = array('Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard');\n$w = intval(trim(fgets(STDIN)))-1;\n$max = 0;\n$last = 0;\n$i = 0;\nwhile(1) {\n    $max = 5 * pow(2, $i)+$last;\n    if($max > $w) {\n        break;\n    }\n    $last = $max;\n    $i++; \n}\n$t1 = $w - $last;\n$t3 = floor($t1/pow(2,$i)); \necho( $result[$t3] );\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "2ffccf5a111bda29425a1a1dd61eb691", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$flag = 1; //must be not zero for STDIN\n$in = 'php://stdin';\nif (!$flag)\n{\n    $in = \"input.txt\";\n}\n$fd = fopen($in, \"r\");\nfscanf($fd, \"%d\\n\", $n);\nfclose($fd);\n\n$names = array(\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\");\nfor ($c = 0, $l = 0; $l < $n; $c++)\n{\n    $l = 5 * pow(2, $c + 1) - 5;\n}\n$c--;\n$f = 5 * pow(2, $c) - 5;\n$d = $n - $f;\n$div = pow(2, $c);\n$r = ceil($d / $div);\n$r--;\nprint $names[$r] . \"\\n\";\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "def42ae06505bb8b29691701aa4b52f0", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/**\n * Preparing Olympiad\n *\n * http://codeforces.com/contest/550/problem/B\n *\n * You have n problems. You have estimated the difficulty of the i-th one as integer ci.\n * Now you want to prepare a problemset for a contest, using some of the problems you've made.\n *\n * A problemset for the contest must consist of at least two problems.\n * You think that the total difficulty of the problems of the contest must be\n * at least l and at most r.\n * Also, you think that the difference between difficulties of the easiest and the hardest\n * of the chosen problems must be at least x.\n *\n * Find the number of ways to choose a problemset for the contest.\n *\n * Input\n * The first line contains four integers n, l, r, x (1\u2009\u2264\u2009n\u2009\u2264\u200915, 1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009109, 1\u2009\u2264\u2009x\u2009\u2264\u2009106)\n * \u2014 the number of problems you have, the minimum and maximum value of total difficulty\n * of the problemset and the minimum difference in difficulty between the hardest problem\n * in the pack and the easiest one, respectively.\n *\n * The second line contains n integers c1,\u2009c2,\u2009...,\u2009cn (1\u2009\u2264\u2009ci\u2009\u2264\u2009106)\n * \u2014 the difficulty of each problem.\n *\n * Output\n * Print the number of ways to choose a suitable problemset for the contest.\n *\n * Input:\n * 4 40 50 10\n * 10 20 30 25\n*/\n\n$problems = trim(fgets(STDIN));\n$difficulties = trim(fgets(STDIN));\n\n$problemsArray = explode(' ', $problems);\n$difficultiesArray = explode(' ', $difficulties);\n\n// Number of problems\n$n = $problemsArray[0];\n// Min sum\n$l = $problemsArray[1];\n// Max sum\n$r = $problemsArray[2];\n// Difference between min and max\n$x = $problemsArray[3];\n\n$count = 0;\n\nif ($n == 0)\n{\n    echo 0;\n    exit;\n}\nelse\n{\n    $subArrays = subArrays($difficultiesArray);\n\n    foreach ($subArrays as $key => $value)\n    {\n        if (!empty($value))\n        {\n            $sum = array_sum($value);\n            $max = max($value);\n            $min = min($value);\n\n            if ($sum <= $r && $sum >= $l && $x <= ($max - $min))\n            {\n                $count++;\n            }\n        }\n    }\n}\n\necho $count;\n\n/**\n * Get all the sub arrays of a given array\n *\n * @param array $difficulties The given array\n *\n * @return array All the sub arrays\n */\nfunction subArrays($difficulties)\n{\n    $len = count($difficulties);\n    $list = array();\n\n    for ($i = 1; $i < (1 << $len); $i++)\n    {\n        $subArray = array();\n\n        for ($j = 0; $j < $len; $j++)\n        {\n            if ($i & (1 << $j))\n            {\n                $subArray[] = (int)$difficulties[$j];\n            }\n        }\n\n        $list[] = $subArray;\n    }\n\n    return $list;\n}", "lang_cluster": "PHP", "tags": ["brute force", "bitmasks"], "code_uid": "c28cd8e6118122c35cdea488627aabae", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfunction readArrayInt($std)\n{\n    $str = fgets($std);\n    $str = explode(' ', $str);\n    $a = [];\n    $n = count($str);\n    for ($i = 0; $i < $n; ++$i)\n    {\n        $a[] = $str[$i] + 0;\n    }\n    return $a;\n}\n\nfunction isDelimiter($ch)\n{\n\n    if ($ch == '(' || $ch == ')' || $ch == '_')\n    {\n        return true;\n    }\n    return false;\n}\n\n$stdin = fopen(\"php://stdin\", 'r');\nfscanf($stdin, \"%d\\n\", $n);\n$str = trim(fgets($stdin));\n$res1 = 0;\n$res2 = 0;\n$inB = false;\nfor ($i = 0; $i < strlen($str); ++$i)\n{\n    if (isDelimiter($str[$i]))\n    {\n        if ($str[$i] != '_')\n        {\n            $inB = ($str[$i] == '(');\n        }\n        continue;\n    }\n    $word = '';\n    while ($i < strlen($str) && !isDelimiter($str[$i]))\n    {\n        $word .= $str[$i];\n        $i++;\n    }\n    if ($inB == true)\n    {\n        $res2++;\n    }\n    else\n    {\n        $res1 = max($res1, strlen($word));\n    }\n    $i--;\n}\necho $res1 . \" \" . $res2;\n\nfclose($stdin);\n?>", "lang_cluster": "PHP", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "53ffba4d83fc39d6c3d81aa319e9b59f", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = 0;\nfor($x = 0; $x < $a - 1; $x++)\n{\n     if(($b[$x] == $b[$x + 1]) || (($b[$x] == 2) && ($b[$x + 1] == 3) || (($b[$x] == 3) && ($b[$x + 1] == 2))))\n     {\n          $c = 1;\n          break;\n     }\n}\nif($c == 0)\n{\n     $d = array(1 => array(2 => 3, 3 => 4), 2 => array(1 => 3), 3 => array(1 => 4));\n     $e = 0;\n     for($x = 0; $x < $a - 1; $x++)\n     {\n          $e += $d[$b[$x]][$b[$x + 1]];\n     }\n     for($x = 0; $x < $a - 2; $x++)\n     {\n          if(($b[$x] == 3) && ($b[$x + 1] == 1) && ($b[$x + 2] == 2))\n          {\n               $e--;\n          }\n     }\n     print \"Finite\\n\";\n     print $e;\n}\nelse\n{\n     print \"Infinite\";\n}\n?>", "lang_cluster": "PHP", "tags": ["geometry"], "code_uid": "23c674f675930842d221218ef3ebb968", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$str = fgets(STDIN, 1000);\n$len = strlen($str);\nif($len>=1 && $len<=1000){\n\t$vowels = \"AOYEUIaoyeui\";\n\tif(preg_match('/[a-zA-Z]+/', $str)){\n\t\t$str = preg_replace('/[^AOYEUIaoyeui\\\\s]/', '.$0', $str);\n\t\t$str = preg_replace('/[AOYEUIaoyeui]/i', '', $str);\n\t\techo strtolower($str);\t\n\t}\n}\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "4774577dd2206370b5a2dd408b746334", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\n\nfunction read_word() {\n    \n    fscanf(STDIN, \"%s\", $word);\n    return $word;\n}\n\nfunction abbreviateWord($word) {\n\n    $vowels = array(\"a\", \"o\", \"y\", \"e\", \"u\", \"i\");\n    $result = array();\n\n    foreach (str_split($word) as $w) {\n        if (!in_array($w, $vowels)) {\n            $result[] = $w;\n        }\n    }\n    \n    return \".\" . implode(\".\", $result);\n}\n\n\n$word = read_word();\n$word = strtolower($word);\n$abbr = abbreviateWord($word);\necho $abbr;\n", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "6308317d14ee0cd173deecc377c009fb", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfunction debug($data, $die = true) {\n    echo '<pre>';\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 '</pre>';\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?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "b12553e176ac07b34630ce1e2c8c45eb", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n//  21A - Jabber ID \n$a = trim(fgets(STDIN));\n$b = str_split($a);\narray_unshift($b, \" \");\nunset($b[0]);\n$k = $b;\n$c = array_search(\"@\", $b);\nif($c == 0)\n{\n    print \"NO\";\n}\nelseif($c == 1)\n{\n    print \"NO\";\n}\nelse\n{\n    $d = array_slice($b, 0, $c - 1);\n    $e = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\", \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"_\");\n    $e2 = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\", \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"_\", \".\");\n    $f = 1;\n    $f2 = 1;\n    $f3 = 1;\n    for($x = 0; $x < count($d); $x++)\n    {\n        if($f == 0)\n        {\n            break;\n        }\n        else\n        {\n            $f = 0;\n            for($y = 0; $y < count($e); $y++)\n            {\n                if($d[$x] == $e[$y])\n                {\n                    $f = 1;\n                    break;\n                }\n            }\n        }\n    }\n    if(($f == 0) || (count($d) > 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?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "20d02a63734c867b2292acc8f5bf501a", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $c = str_split(trim(fgets(STDIN)));\n     $b[$x] = $c;\n}\n$d = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $e = str_split(trim(fgets(STDIN)));\n     $d[$x] = $e;\n}\n$f = array($d);\n$g = $f[0];\n$h = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $i = 0;\n     for($y = $a - 1; $y >= 0; $y--)\n     {\n          $h[$x][$i] = $g[$y][$x];\n          $i++;\n     }\n}\n$f[1] = $h;\n$j = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $i = 0;\n     for($y = $a - 1; $y >= 0; $y--)\n     {\n          $j[$x][$i] = $h[$y][$x];\n          $i++;\n     }\n}\n$f[2] = $j;\n$k = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $i = 0;\n     for($y = $a - 1; $y >= 0; $y--)\n     {\n          $k[$x][$i] = $j[$y][$x];\n          $i++;\n     }\n}\n$f[3] = $k;\n$o = array();\nfor($x = 0; $x < count($f); $x++)\n{\n     $l = $f[$x];\n     $m = array();\n     $n = 0;\n     for($y = $a - 1; $y >= 0; $y--)\n     {\n          $m[$n] = $l[$y];\n          $n++;\n     }\n     $o[count($o)] = $m;\n     $m = array();\n     for($y = 0; $y < $a; $y++)\n     {\n          $n = $l[$y];\n          $p = 0;\n          for($z = $a - 1; $z >= 0; $z--)\n          {\n               $m[$y][$p] = $n[$y][$z];\n          }\n     }\n     $o[count($o)] = $m;\n}\n$q = array_merge($f, $o);\n$r = 0;\nfor($x = 0; $x < count($q); $x++)\n{\n     $s = $q[$x];\n     if($b == $s)\n     {\n          $r = 1;\n          break;\n     }\n}\nif($r == 0)\n{\n     print \"No\";\n}\nelse\n{\n     print \"Yes\";\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "15be3a212c3b2f54eef87e6b52f43d7f", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$fr = fopen(\"php://stdin\", \"r\");\n$fw = fopen(\"php://stdout\", \"w\");\n\nfscanf($fr, \"%s\", $r1);\nfscanf($fr, \"%s\", $r2);\nfscanf($fr, \"%s\", $r3);\n\nfunction isSymmetric() \n{\n\tglobal $r1, $r2, $r3;\n\treturn ($r1[0] == $r3[2]) && ($r1[1] == $r3[1]) && ($r1[2] == $r3[0]) \n\t\t&& ($r2[0] == $r2[2]);\n}\n\nisSymmetric() ? fprintf($fw, 'YES') : fprintf($fw, 'NO');\n?>\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "930b65ca875f01b6ab4fd3d4d8aef8e8", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n//$in = 'input.txt';\n$in = 'php://stdin';\n\n$r = fopen($in, 'r');\n\n$m = array();\nfor ($i = -1; $i <= 1; $i++) {\n    $string = fgets($r);\n    for ($j = -1; $j <= 1; $j++) {\n        $h = ($string[$j + 1] == 'X');\n        if (isset($m[-$i][-$j]) && $m[-$i][-$j] != $h) {\n            die('NO');\n        }\n        $m[-$i][-$j] = $m[$i][$j] = $h;\n    }\n}\necho 'YES';\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "a97df3c88f93b1a0bdd8cfa5648efca2", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%f\", $n);\n        if ($n % 2 == 0){\n            printf(\"%.0f\" , $n / 2);\n        }\n        else\n            printf(\"%.0f\", (floor($n / 2) - $n));\n        ", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "0faf535e89f3ef2cd21ca223abe47704", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n/**\n * @author Sunwarul Islam \n */\n\n$n = trim(fgets(STDIN));\n$m = $n[strlen($n) - 1];\n\nif ($m % 2 == 0) {\n    echo sprintf(\"%.0f\", ($n / 2));\n}\nif ($m % 2 != 0) {\n    echo sprintf(\"%.0f\", (- ($n + 1) / 2));\n}\n\necho \"\\n\";", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "66b4a5f4799279c3ec0e3d9e20592a82", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = array();\nfor($x = $a - 1; $x > 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?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "fdd2059254c8a281c95e80993bad2a6b", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\nif(($a == $b) && ($c == 0))\n{\n     print \"YES\";\n}\nelseif(($a != $b) && ($c == 0))\n{\n     print \"NO\";\n}\nelse\n{\n     $d = ($b - $a) / $c;\n     $e = abs(($b - $a) / $c);\n     $f = floor(($b - $a) / $c);\n     if(($d == $e) && ($d == $f))\n     {\n          print \"YES\";\n     }\n     else\n     {\n          print \"NO\";\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "08b2283f2c1277937cb7672e1891033f", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// 450A     Jzzhu \u0438 \u0434\u0435\u0442\u0438 \n$in = fopen(\"php://stdin\", 'r');\n\n//$input_line = fgets($in);\n//$n = (int) $input_line;\n\n$input_line = fgets($in);\nlist($n, $m) = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);\n$n = (int) $n;\n$m = (int) $m;\n\n$input_line = fgets($in);\n$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);\n\nwhile (count($arr) > 0) {\n    foreach ($arr as $key => &$value) {\n        $number = $key + 1;\n        $value -= $m;\n        if ($value <= 0) unset($arr[$key]);\n    }\n    unset($value);\n}\n\necho \"$number\\n\";\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "b9b89b2d0fd63e4724b18b3202bb94ba", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = str_split(readline());\n$test = ['h', 'e', 'l', 'l', 'o'];\n$i= 0;\nforeach($s as $letter){\n    if($letter == $test[$i]){\n        $i++;\n        if($i == 5){\n            break;\n        }\n    }\n}\n\nif($i == 5){\n    echo \"YES\";\n}else{\n    echo \"NO\";\n}", "lang_cluster": "PHP", "tags": ["greedy", "strings"], "code_uid": "7768c107878ba3a704ba50d7eb5329be", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$s = trim(fgets(STDIN));\necho (preg_match(\"/h.*e.*l.*l.*o/\", $s) ? \"YES\" : \"NO\");\n?>", "lang_cluster": "PHP", "tags": ["greedy", "strings"], "code_uid": "77caadc1354746736f59ecc72a61523b", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nwhile($s = fgets(STDIN)){\n    $input .= $s;\n}\n\n$directory = '/';\n$input = explode(\"\\r\\n\", $input);\n$s = $input[0];\n/*/\n$s = 'oOPS';\n//*/\n\nif(preg_match('/^([a-z]|[A-Z])([A-Z]+)?$/', $s, $tmp)) {\n    $s = strtolower($s);\n    if($s[0] == $tmp[1]) {\n        $s[0] = strtoupper($s[0]);\n    }\n}\necho $s;", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "edc0451ed054567c20ab65e75e73048c", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%s\", $arr);\n$c = strtoupper($arr);\n$c[0] = strtolower($arr[0]);\n$x = strtolower($arr);\n$x[0] = strtoupper($arr[0]);\n   if ($arr == strtoupper($arr) ){\n      for ($i = 0; $i < strlen ($arr); $i++)\n      echo strtolower($arr[$i]); \n   }\n   else if ($arr == $c){\n       for ($i=0; $i < strlen($arr); $i++)\n       echo $x[$i];\n   }\n     else{\n         for ($i = 0; $i < strlen ($arr); $i++)\n      echo $arr[$i];}\n ", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "381d449f932324c484753b3f3238ccbc", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$wWeight = 0;\n$bWeight = 0;\nfor($i=0; $i < 8; $i++){\n    $line[$i] = trim(fgets(STDIN));\n    for($j=0; $j < 8; $j++){\n\n        if($line[$i][$j] == 'Q'){\n            $wWeight = $wWeight + 9;\n        }\n        if($line[$i][$j] == 'R'){\n            $wWeight = $wWeight+ 5;\n        }\n        if($line[$i][$j] == 'B' or $line[$i][$j] == 'N'){\n            $wWeight = $wWeight + 3;\n        }\n        if($line[$i][$j] == 'P'){\n            $wWeight++;\n        }\n\n        if($line[$i][$j] == 'q'){\n            $bWeight = $bWeight + 9;\n        }\n        if($line[$i][$j] == 'r'){\n            $bWeight = $bWeight + 5;\n        }\n        if($line[$i][$j] == 'b' or $line[$i][$j] == 'n'){\n            $bWeight = $bWeight + 3;\n        }\n        if($line[$i][$j] == 'p'){\n            $bWeight++;\n        }\n\n    }\n}\n\nif($wWeight > $bWeight){\n    echo \"White\";\n}\nif($wWeight < $bWeight){\n    echo \"Black\";\n}\nif($wWeight == $bWeight){\n    echo \"Draw\";\n}\n\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "b6c5bf69d16e2793bd819a4694068a12", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($prob, $min)=explode(\" \",trim(fgets(STDIN)));\n\nif ($min > 240) {\n    \n    echo 0;\n}\n\n$turbo=240 - $min;\n\nfor ($i=1; $i <= $prob; $i++) {\n    \n      $num += $i * 5;\n      \n      if ($i == $prob and $num < $turbo) {\n          $final = $i;\n          break;\n      }elseif ($num == $turbo) {\n          $final = $i;\n          break;\n    }elseif ($num > $turbo) {\n          $final = $i - 1;\n          break;\n    }\n    \n    }\n\nif (!isset($final)) {\n    echo 0;\n}else echo $final;\n\n\n\n\n\n\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "6145e2959252aca050aafb6bfea3b051", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d %d\", $n, $k);\n$time = $k;\n$i = 1;\nwhile ($time + 5*$i <= 240 && $i <= $n){\n\t$time += 5*$i;\n\t$i++;\n}\necho $i-1;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "153cb54bfae53f1508de92e89ac63ca6", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$keyboard = array(\n    0 => array('q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'),\n    1 => array('a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';'),\n    2 => array('z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/'),\n);\n\nfunction generateMap($keyboard) {\n    $arr = array();\n    foreach ($keyboard as $k1 => $v1) {\n        foreach ($v1 as $k2 => $v2) {\n            if ($k2 != 0 && $k2 != 9) {\n                $tmp = array('L' => $keyboard[$k1][$k2 - 1], 'R' => $keyboard[$k1][$k2 + 1]); \n            } else if ($k2 == 0) {\n                $tmp = array('R' => $keyboard[$k1][$k2 + 1]);\n            } else if ($k2 == 9) {\n                $tmp = array('L' => $keyboard[$k1][$k2 - 1]);\n            }\n            $arr[$v2] = $tmp;\n        }\n    }\n    \n    return $arr;\n}\n\n$arr = generateMap($keyboard);\nfscanf(STDIN, \"%s\", $d);\nfscanf(STDIN, \"%s\", $s);\n\n$c = ($d == 'R') ? 'L' : 'R';\n\nfor ($i = 0; $i < strlen($s); $i++) {\n    echo $arr[$s[$i]][$c];\n}\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "18aebf8ea101da9fc2be0064f1d1db4a", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$keyboard=array();\n$keyboard[0]=\"qwertyuiop\";\n$keyboard[1]=\"asdfghjkl;\";\n$keyboard[2]=\"zxcvbnm,./\";\n$d=trim(fgets(STDIN));\n$input=trim(fgets(STDIN));\nfunction solve($d,$input){\n    global $keyboard;\n    $wo = 0;\n    $d==\"R\" ? $wo=-1 : $wo=1;\n    for($i=0;$i<strlen($input);$i++) {\n    \tforeach ($keyboard as $k2 => $v2) {\n    \t\tif(strpos($v2, $input[$i])!==false){\n    \t\t\t$input[$i]=$keyboard[$k2][strpos($v2, $input[$i])+$wo];\n    \t\t}\n    \t}\n    }\n    return $input;\n}\necho solve($d,$input);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "1fd682624d03cb1131cf7f41503bacd0", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%s\", $sr);\nfscanf(STDIN, \"%s %s %s %s %s\", $sr1, $sr2, $sr3, $sr4, $sr5);\n\n$cards = [$sr1, $sr2, $sr3, $sr4, $sr5];\n\n$own = str_split($sr);\nforeach ($cards as $card) {\n    $c = str_split($card);\n    if (count(array_diff($c, $own)) != count($own)) {\n        echo 'YES';\n        exit;\n    }\n}\necho 'NO';\n\n\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "33dce29a111e52dba0b18ad9c93c8eb1", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$table = str_split(trim(fgets(STDIN)));\n$hand = explode(' ', trim(fgets(STDIN)));\n\nforeach ($hand as $card) {\n    $card = str_split($card);\n    if ($card[0] === $table[0] || $card[1] === $table[1]) {\n        echo \"YES\";\n        exit();\n    }\n}\necho 'NO';", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "15acd41d3961208aae5d2628add52d66", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN,\"%d\\n\",$n);\n$array = trim(fgets(STDIN));\n\n$array = explode(' ', $array);\n$array = array_map('intval', $array);\n\n$mapArray = [];\nforeach ($array as $index => $arr) {\n    $mapArray[$arr] = $index;\n}\n\n$result = [];\nforeach ($array as $index => $arr) {\n    if(isset($mapArray[$arr]) && $mapArray[$arr] != $index) continue;\n    $result[] = $arr;\n}\n\necho count($result).\"\\n\";\necho implode(\" \", $result);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "60e6dde34214320d127f2651950cd227", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/**\n * Created by PhpStorm.\n * User: jianzjzhang\n * Date: 2018/5/13\n * Time: 17:05\n */\n\nfunction unique($arr)\n{\n    $map = array();\n    $result = array();\n\n    foreach (array_reverse($arr) as $x){\n        if(!array_key_exists($x, $map)){\n            $map[$x] = true;\n            $result[] = $x;\n        }\n    }\n\n    return array_reverse($result);\n}\n\n\nfunction main()\n{\n    $n = intval(fgets(STDIN));\n    $arr = array();\n\n    for($i=0; $i<$n-1; $i++){\n        $arr[] = intval(stream_get_line(STDIN, 4096, \" \"));\n    }\n    $arr[] = intval(stream_get_line(STDIN, 4096, \"\\n\"));\n\n    $unique_arr = unique($arr);\n\n    echo count($unique_arr).\"\\n\";\n    foreach ($unique_arr as $x){\n        echo $x.' ';\n    }\n}\n\nmain();", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "841a12d007a37da8723d9e5574091bbc", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$n = fgets(STDIN);\n$arr = explode(\" \", trim(fgets(STDIN)));\n$sum = 0;\nfor($i = 0; $i < $n; ++$i)\n    $sum += $arr[$i];\n$sum--;\n$ans =0;\nfor($i = 1; $i <= 5; ++$i)\n    if(($sum + $i) % ($n+1))\n        ++$ans;\nprintf(\"%d\",$ans);\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "0f8b55482d7e767d38867c25954ffa40", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = array_sum($b);\n$d = array(1 + $c, 2 + $c, 3 + $c, 4 + $c, 5 + $c);\n$e = array(\"1\");\n$g = 0;\nfor($x = 1; $x <= $d[count($d) - 1]; $x++)\n{\n    $f = $e[count($e) - 1] + $a + 1;\n    array_push($e, $f);\n}\narray_unshift($d, \" \");\nunset($d[0]);\narray_unshift($e, \" \");\nunset($e[0]);\nfor($x = 1; $x <= count($d); $x++)\n{\n    for($y = 1; $y <= count($e); $y++)\n    {\n        if($d[$x] == $e[$y])\n        {\n            $g++;\n        }\n    }\n}\nprint 5 - $g;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "b37cc9c5dea2ad572c25ec6be5b02d1b", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = trim(fgets(STDIN));\nsort($c);\n$e = 0;\nfor($x = 0; $x < $d; $x++)\n{\n    $e += $c[$x];\n}\n$f = $d - $a;\nif($f > 0)\n{\n    print $e - ($f * $b);\n}\nelse\n{\n    print $e;\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "184c2b49c00ffc362de3b7ea717b3ae4", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = floor($a / 2);\n$d = $b + 1;\n$e = floor($c / $d);\nif($e == 0)\n{\n     print \"0 0 \" . $a;\n}\nelse\n{\n     $f = $e * $b;\n     $g = $a - ($e + $f);\n     print $e . \" \" . $f . \" \" . $g;\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "dd495fba53f60d46492a8f981dd5f5ee", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = 0;\n$e = 0;\n$f = $b;\nfor($x = 0; $x < $a; $x++)\n{\n    $d += $c[$x];\n    if(($d == $f) && ($d != $c[$x]))\n    {\n        $d = 0;\n        $f = $b;\n    }\n    elseif($d == $f)\n    {\n        $e++;\n        $d = 0;\n        $f = $b;\n    }\n    elseif($d > $f)\n    {\n        if($c[$x] == $b)\n        {\n            $e++;\n            $d = 0;\n            $f = $b;\n        }\n        elseif($c[$x] < $b)\n        {\n            $e++;\n            $d = $c[$x];\n        }\n        elseif($c[$x] > $b)\n        {\n            $f += $b;\n        }\n    }\n    elseif(($d < $f) && ($d == $c[$x]))\n    {\n        $e++;\n    }\n}\nprint $e;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5ccdba6498c4d135d71770d8ccf7289a", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = \"1\";\nfor($x = 1; $x <= $b; $x++)\n{\n     $c .= \"0\";\n}\n$d = 0;\n$e = str_split($a);\nwhile(TRUE)\n{\n     $f = implode($e);\n     $g = $f % $c;\n     if(strlen($f) <= strlen($c))\n     {\n          if($g == 0)\n          {\n               break;\n          }\n          else\n          {\n               $h = 1;\n               break;\n          }\n     }\n     else\n     {\n          if($g == 0)\n          {\n               break;\n          }\n          else\n          {\n               $d++;\n               $e = str_split($f);\n               for($x = count($e) - 1; $x >= 0; $x--)\n               {\n                    if($e[$x] != 0)\n                    {\n                         array_splice($e, $x, 1);\n                         break;\n                    }\n               }\n          }\n     }\n}\nif($h == 1)\n{\n     print strlen($a) - 1;\n}\nelse\n{\n     print $d;\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "greedy"], "code_uid": "2647145830dcc814b257636637e786a4", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%s %s\\n\",$s[0],$s[1]);\n$rez=$s[0][0].$s[1][0];\nfor ($i=1; $i<=strlen($s[0]); $i++)\n{\n    for ($j=1; $j<=strlen($s[1]); $j++)\n    {\n        $q=substr($s[0],0,$i).substr($s[1],0,$j);\n        #echo \"$q\\n\";\n        if ($q<$rez)\n            $rez=$q;\n    }\n}\necho $rez;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "sortings", "greedy"], "code_uid": "0e69acebb683bfba4f88aab41d4ff9d6", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n$c = array(\"monday\" => 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?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "7f008dfb20fed6ad8237c6bd3d23ee32", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $n = explode(\" \", trim(fgets(STDIN)));\n    $arr = array('m' => 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 ?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "ea3620248e0b5e9c01d6ceb1c30ad09f", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = 0;\n$c = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n     if(($a[$x] == 1) && ($b == 0))\n     {\n          $b = 1;\n     }\n     elseif(($a[$x] == 0) && ($b == 1))\n     {\n          $c++;\n     }\n}\nif($c >= 6)\n{\n     print \"yes\";\n}\nelse\n{\n     print \"no\";\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0e767f1dbbd9eb143a28ed2d1d19c60b", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input = readline();\n$input = explode(' ', $input);\n$price_banan = $input[0];\n$have_many = $input[1];\n$max_banan = $input[2];\n$potracheno=0;\n\n\nfor ($i=0; $i<$max_banan; $i++) {\n       $potracheno = $potracheno + $price_banan * ($i+1);\n}      $need_many = $potracheno - $have_many;\n     if ($need_many <=0) {\n         echo '0';\n     }\n     else {\n         echo $need_many;\n     }", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "4552ea91f03119c6cbc10f776a2c2634", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input = rtrim(fgets(STDIN));\n$raw   = explode(' ', $input);\n\n$k = (int)$raw[0];\n$n = (int)$raw[1];\n$w = (int)$raw[2];\n\n$priceFirst = $k;\n$priceLast  = $k + $k * ($w - 1);\n$sum        = ($priceFirst + $priceLast) * $w / 2;\n\necho max(0, $sum - $n) . PHP_EOL;\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "d4378e28e69f6524b284905911a5cf05", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$points= (int) fgets(STDIN);\nif ($points < 11 || $points > 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?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "783406c0604e863a17e411bf2b014d4a", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = trim(fgets(STDIN));\n$a = trim(fgets(STDIN));\n$a = explode( ' ' , $a);\nsort($a);\necho join(' ', $a);", "lang_cluster": "PHP", "tags": ["sortings", "implementation", "greedy"], "code_uid": "370ee82ae7ac400d8594051f5698a93c", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = trim(fgets(STDIN));\n$cube = explode(\" \", trim(fgets(STDIN)));\nfor($i=$n-1;$i>=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?>", "lang_cluster": "PHP", "tags": ["sortings", "implementation", "greedy"], "code_uid": "05a56e1ed6f0c29c25b20a94f7f2c259", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$rez=0;\nfscanf(STDIN,\"%s\\n\",$s);\nfor ($i=0; $i<strlen($s); $i++)\n    if ($s[$i]=='e' || $s[$i]=='u' || $s[$i]=='i' || $s[$i]=='o' || $s[$i]=='a' || $s[$i]=='1' || $s[$i]=='3' || $s[$i]=='5' || $s[$i]=='7' || $s[$i]=='9')\n        $rez++;\necho $rez;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "7b7e859014f6805ed4c96d7e364a60be", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$str = trim(fgets(STDIN));\n$count = 0;\n$targets = '13579aiueo';\nfor ($i = 0; $i < strlen($str); $i++)\n{\n\tif (strpos($targets, $str[$i]) !== false)\n\t{\n\t\t$count++;\n\t}\n}\n\necho $count;\n", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "fcaf07162e1e68d32a154ee0e0f718be", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input = rtrim(fgets(STDIN));\n$input2 = rtrim(fgets(STDIN));\n$cmp= strcmp(strtolower($input),strtolower($input2));\nif($cmp==0){\n  echo 0;\n}else if($cmp<0){\n  echo -1;\n}else{\n  echo 1;\n}", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "c1aad2772e21265b411c02f3769c7681", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = strtolower(trim(fgets(STDIN)));\n$b = strtolower(trim(fgets(STDIN)));\n$c = array(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\");\narray_unshift($c, \" \");\nunset($c[0]);\n$f = 0;\n$g = 0;\nfor($x = 0; $x < strlen($a); $x++)\n{\n    $d = array_search($a[$x], $c);\n    $e = array_search($b[$x], $c);\n    $f += $d;\n    $g += $e;\n    if($f < $g)\n    {\n        print \"-1\";\n        break;\n    }\n    elseif($f > $g)\n    {\n        print \"1\";\n        break;\n    }\n    elseif(($f == $g) && ($x == strlen($a) - 1))\n    {\n        print \"0\";\n        break;\n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "7840cc6e82ef8e44adc39a1499649959", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN,\"%d\\n\",$n);\n$string = trim(fgets(STDIN));\n\n$inputN = $n;\n\nwhile(true) {\n    $string = str_replace('xxx', 'xx', $string);\n    $len = strlen($string);\n    if($len == $n) break;\n    $n = $len;\n}\n\nif($len == $inputN) {\n    echo \"0\";\n} else {\n    echo $inputN - $len;\n}\n", "lang_cluster": "PHP", "tags": ["greedy", "strings"], "code_uid": "904ff01eefd04479ca82ee7deb7a4d21", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/**\n * Created by PhpStorm.\n * User: jianzjzhang\n * Date: 2018/5/13\n * Time: 17:25\n */\n\nfunction removeCount($str)\n{\n    $char_arr = str_split($str, 1);\n\n    $counter = 0;\n\n    $need_remove = 0;\n    foreach ($char_arr as $ch){\n        if($ch === 'x'){\n            $counter++;\n        }\n        else{\n            $counter = 0;\n        }\n\n        if($counter === 3){\n            $need_remove++;\n            $counter--;\n        }\n    }\n\n    return $need_remove;\n}\n\nfunction main()\n{\n    $n = intval(fgets(STDIN));\n    $str = fgets(STDIN);\n\n    echo removeCount($str).\"\\n\";\n}\n\nmain();", "lang_cluster": "PHP", "tags": ["greedy", "strings"], "code_uid": "75932f09d75de5c03dae5121c9825bbd", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$ns = explode(\" \", fgets(STDIN));\n$s2arr = explode(\" \", fgets(STDIN));\n\n$n = $ns[0];\n$s = $ns[1];\nsort($s2arr);\n$s2 = array_sum($s2arr) - $s2arr[($n-1)];\nif ($s2 > $s)\n    print \"NO\";\nelse\n    print \"YES\";", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "c9c518d9bbde2ec6d8198d1533c4802f", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN, \"%s\", $s);\n$n = strlen($s);\n$ans = (1 << ($n - 1)) - 1;\n$good = true;\nfor ($i = 0; $i < $n && $good; $i++) {\n\tfor ($c = ($i == 0 ? '1' : '0'); $c < $s[$i] && $c <= '1'; $c++)\n\t\t$ans += 1 << ($n - $i - 1);\n\tif ($s[$i] != '0' && $s[$i] != '1')\n\t\t$good = false;\n}\n$ans += $good;\necho \"$ans\\n\";\n?>\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "eb4b4b6b20d44897c32b65177678e18d", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input=str_split(trim(fgets(STDIN)));\n$input2=str_split(trim(fgets(STDIN)));\n$a=null;\nfor ($i=0;$i<count($input);$i++) { \n      if($input[$i] == $input2[$i]){\n        $a.='0';\n      }else{\n            $a.='1';\n      }\n}\necho $a;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "3fe0d1b708ce6fae405c80685e46cb05", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$line1 = trim(fgets(STDIN));\n$line2 = trim(fgets(STDIN));\n$length = strlen($line1);\nfor ($i=0;$i<$length;$i++)\n{\n    if ($line1[$i]==$line2[$i])echo 0;\n    else echo 1;\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5327e74b1c004e524786f28c4e688a66", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = array(\" \", \"2\", \"3\", \"5\", \"7\");\nunset($c[0]);\nfor($x = 10; $x <= 50; $x++)\n{\n    if(($x % 2 == 0) || ($x % 3 == 0) || ($x % 5 == 0) || ($x % 7 == 0) || ($x % 9 == 0))\n    {\n        continue;\n    }\n    else\n    {\n        array_push($c, $x);\n    }\n}\n$d = array_search($a, $c);\nif($b == $c[$d + 1])\n{\n    print \"YES\";\n}\nelse\n{\n    print \"NO\";\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "f51dd75652c5dada536476139538ef31", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n\t$length = trim(fgets(STDIN));\n\t$string = (string) trim(fgets(STDIN));\n\t$array = array();\n\n\tfor ($i=0; $i < $length; $i++) { \n\t\t   if($string[$i] == '1')\n\t\t   \t\t continue;\n\t\t   if($string[$i] == '2')\n\t\t   \t\tarray_push($array, 2);\n\t\t   if($string[$i] == '3')\n\t\t   \t\tarray_push($array, 3);\n\t\t   if($string[$i] == '4')\n\t\t   \t\tarray_push($array, 2, 2, 3);\n\t\t   if($string[$i] == '5')\n\t\t   \t\tarray_push($array, 5);\n\t\t   if($string[$i] == '6')\n\t\t   \t\tarray_push($array, 5, 3);\n\t\t   if($string[$i] == '7')\n\t\t   \t\tarray_push($array, 7);\n\t\t   if($string[$i] == '8')\n\t\t   \t\tarray_push($array, 2, 2, 2, 7);\n\t\t   if($string[$i] == '9')\n\t\t   \t\tarray_push($array, 7, 2, 3, 3);\n\t}\n\n\tsort($array);\n\tfor ($i=count($array) - 1; $i >= 0; $i--) { \n\t\t\t   echo $array[$i];\n\t}\n?>", "lang_cluster": "PHP", "tags": ["math", "sortings", "greedy"], "code_uid": "7c72383d20034a583a8a12d0ced8f9fe", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = 1;\nunset($b[0]);\nunset($c[0]);\n$e = 0;\nfor($x = 1; $x <= 10000; $x++)\n{\n    if($b[$d] > $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?>", "lang_cluster": "PHP", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "657b378dd6c33a4dc99bd8c57dea70ec", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif($b <= $a / 2)\n{\n     $c = ($b - 1) + ($b + 1) + $b + ($a - 1) + ($a - $b) + ($a - $b);\n}\nelse\n{\n     $d = $a - $b + 1;\n     $b = $d;\n     $c = ($b - 1) + ($b + 1) + $b + ($a - 1) + ($a - $b) + ($a - $b);\n}\nprint $c;\n?>", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms"], "code_uid": "db67cf2a47fbbc671794cceeb6eef71c", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input = fgets(STDIN);\n$res= ($input + 1)/2;\nif ($res%2 == 0) {\n    echo 0;\n} else {\n    echo 1;\n}", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "1085e9a7acd0e3f7bdc817d395ae2d05", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$number = fgets(STDIN);\n$number = trim($number);\n\n$counter = 0;\n\nfor ($i=0; $i < strlen($number); $i++) { \n\tif(($number[$i] == \"4\") || ($number[$i] == \"7\")){\n\t\t$counter++;\n\t}\n\n}\n\nif($counter == strlen($number)){\n\t\techo \"YES\";\n\t\texit();\n\t} elseif(intval($number) % 4 == 0) {\n\t\techo \"YES\";\n\t\texit();\n\t} elseif(intval($number) % 7 == 0) {\n\t\techo \"YES\";\n\t\texit();\n\t} elseif(intval($number) % 47 == 0) {\n\t\techo \"YES\";\n\t} elseif(intval($number) % 74 == 0) {\n\t\techo \"YES\";\n\t} else {\n\t\techo \"NO\";\n\t\texit();\n\t}\n", "lang_cluster": "PHP", "tags": ["brute force", "number theory"], "code_uid": "f098ebc85b374342bf3a2008ae621ddc", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$flag = false;\n\t$lucky = array(4,7,44,47,74,77,444,447,474,477,744,747,774,777);\n\t$var = trim(fgets(STDIN));\n\tif ((strlen($var) - substr_count($var, '4') - substr_count($var, '7')) > 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';", "lang_cluster": "PHP", "tags": ["brute force", "number theory"], "code_uid": "43c4f4381c21704fc7696a7e1da34b19", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($n, $m) = explode(' ', fgets(STDIN));\n\n$n = (int)$n;\n$m = (int)$m;\n\n$output = $n;\n\n$t = $m;\n\nwhile ($t <= $output) {\n\t$output ++;\n\t$t += $m;\n}\n\nprint $output;\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "2048149762775cc59f742a02866a1c03", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfunction Finddays($nm){\n   \n    $nm = explode(\" \", $nm);\n    $n  = $nm[0];\n    $m  = $nm[1];\n    \n    $count = 0;\n    \n    $d = (int)($n/$m);\n    $mod = $n%$m;\n    $s = $d+$n;\n    $dc = $d +$mod;\n    $mod=0;\n    while($dc>=$m){\n        $d = (int)($dc/$m);\n        $s += $d;\n        $mod = $dc%$m;\n        \n        $dc =$d+$mod;\n        \n    }\n   \n    echo $s;\n}\n \n\n\n$nm = trim(fgets(STDIN));\n\n\n \nFinddays($nm);\n\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "bd432f93297e02b89ba65490ca42cbf0", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n=fgets(STDIN);\n$input=str_split(fgets(STDIN));\n$grop=[];\n$b=0;\nfor ($i=0; $i <count($input);$i++) { \n      if ($input[$i] == 'B' and $input[$i+1] == 'B') {\n            @$grop[$b]+=1;\n      }else if($input[$i] == 'B' and $input[$i+1] != 'B'){\n            @$grop[$b]+=1;\n            $b++;\n      }\n}\necho count($grop);\nif(count($grop) == 0){\n   return 0;\n}\necho \"\\n\";\nforeach ($grop as $value) {\n      echo $value.' ';\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0f74184dd69f44a47940ce01d0993233", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN)) + 2;\n$b = \"A\" . trim(fgets(STDIN)) . \"A\";\n$c = 0;\n$d = 0;\n$e = 0;\n$f = array();\nfor($x = 0; $x < $a; $x++)\n{\n     if(($b[$x] == \"B\") && ($e == 0))\n     {\n          $c++;\n          $d++;\n          $e = 1;\n     }\n     elseif(($b[$x] == \"B\") && ($e != 0))\n     {\n          $d++;\n          $e = 1;\n     }\n     elseif(($b[$x] != \"B\") && ($e != 0))\n     {\n          $e = 0;\n          array_push($f, $d);\n          $d = 0;\n     }\n}\nprint $c . \"\\n\";\nprint implode(\" \", $f);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "fed1d847762005b4520169881ca13a0c", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($h,$m) = explode(\":\",trim(fgets(STDIN)));\nlist($sh,$sm) = explode(\":\",trim(fgets(STDIN)));\n$h = ltrim($h,\"0\") == \"\" ? 0 : ltrim($h,\"0\");\n$m = ltrim($m,\"0\") == \"\" ? 0 : ltrim($m,\"0\");\n$sh = ltrim($sh,\"0\") == \"\" ? 0 : ltrim($sh,\"0\");\n$sm = ltrim($sm,\"0\") == \"\" ? 0: ltrim($sm,\"0\");\n\n\n//echo \"h: $h m:$m  sh:$sh  sm: $sm \" . PHP_EOL;\nwhile($sh--){\n    $h--;\n    if($h == -1)\n        $h=23;\n}\nwhile($sm--){\n    $m--;\n    if($m == -1){\n        $m = 59;\n        $h--;\n        if($h == -1)\n            $h=23;\n    }\n}\n\n\nif(strlen($m) == 1) $m = \"0\".$m;\nif(strlen($h) == 1) $h = \"0\".$h;\necho \"$h:$m\" . PHP_EOL;\n\nexit;\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "8e0b4deeb4d2c36461d9c0b9c955a300", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $n = fgets(STDIN);\n    $a = explode(\" \", fgets(STDIN));\n    \n    foreach ($a AS $k => $v) {\n        if ($v == 0) {\n            unset($a[$k]);\n        }\n    }\n    funcMax($a, max($a), array());\n    function funcMax($a, $max, $count) {\n        $count[] = $max;\n        foreach ($a AS $key => $val) {\n            if ((int)$val == (int)$max) {\n                unset($a[$key]);\n            }\n        }\n        if ($a) {  \n            funcMax($a, max($a), $count);\n        } else {\n            echo count($count);\n        }\n    }\n    \n?>", "lang_cluster": "PHP", "tags": ["sortings", "implementation"], "code_uid": "defd9487be09c302f1de081ae4b438cd", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = intval(fgets(STDIN, 255));\n$classA = explode(' ', fgets(STDIN, 255));\n$classB = explode(' ', fgets(STDIN, 255));\n\nfor ($i = 0; $i < $n; ++$i)\n    $classA[$i] = intval($classA[$i]);\nfor ($i = 0; $i < $n; ++$i)\n    $classB[$i] = intval($classB[$i]);\n\n$arrayCount = [\n    'ALL' => [\n        1 => 0,\n        2 => 0,\n        3 => 0,\n        4 => 0,\n        5 => 0,\n    ],\n    'A' => [\n        1 => 0,\n        2 => 0,\n        3 => 0,\n        4 => 0,\n        5 => 0,\n    ],\n    'B' => [\n        1 => 0,\n        2 => 0,\n        3 => 0,\n        4 => 0,\n        5 => 0,\n    ]\n];\n\nforeach ($classA as $value) {\n    ++$arrayCount['A'][$value];\n    ++$arrayCount['ALL'][$value];\n}\nforeach ($classB as $value) {\n    ++$arrayCount['B'][$value];\n    ++$arrayCount['ALL'][$value];\n}\n\nforeach ($arrayCount['ALL'] as $value) {\n    if ($value % 2 != 0)\n        exit('-1');\n}\n\n$result = 0;\n$ok = 0;\n$swap = 0;\nwhile ($ok != 5) {\n    $ok = 0;\n    for ($i = 1; $i <= 5; ++$i) {\n        if ($arrayCount['A'][$i] != $arrayCount['B'][$i]) {\n            if ($arrayCount['A'][$i] > $arrayCount['B'][$i]) {\n                --$arrayCount['A'][$i];\n                ++$arrayCount['B'][$i];\n            } else {\n                ++$arrayCount['A'][$i];\n                --$arrayCount['B'][$i];\n            }\n            $swap++;\n            if ($swap % 2 == 0)\n                $result++;\n        }\n\n        if ($arrayCount['A'][$i] == $arrayCount['B'][$i])\n            $ok++;\n    }\n}\n\necho $result;", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms"], "code_uid": "722c52b0867e057a7354b70b93965782", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$n = (int) readline();\n$str = readline();\n$ans1 = $ans = 0;\n$lnth = strlen($str);\nfor($i=0; $i<$lnth-1; $i++)\n{\n\tif($str[$i]==\"S\" and $str[$i+1]==\"F\")  $ans++;\n\telseif ($str[$i]=='F' and $str[$i+1]=='S')  $ans1++;\n}\necho ($ans>$ans1) ? \"YES\" : \"NO\" .\"\\n\";", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "a746de81656c190b2e32e5744a4a1b14", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d\", $n);\nfscanf(STDIN, \"%s\", $s);\necho (substr_count($s, \"SF\") > substr_count($s, \"FS\") ? \"YES\" : \"NO\");\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "74f5d64e711c2e44a245f8456e6b3a6e", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$data = fgets(STDIN);\n$data = explode(\" \", $data);\n$n = (int)$data[0];\n$a = $data[1];\n$b = $data[2];\n$c = $data[3];\nif ($n % 4 == 1) {\n    echo min(3 * $a, min($a + $b, $c));\n} else {\n    if ($n % 4 == 2) {\n        echo min(2 * $a, min($b, 2 * $c));\n    } else {\n        if ($n % 4 == 3) {\n            echo min($a, min(3 * $c, $b + $c));\n        } else {\n            if ($n % 4 == 0) {\n                echo 0;\n            }\n        }\n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "0a8a7d1c8d142f46440974fb330e2258", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$in = fgets(STDIN,4096);\n$in = rtrim($in);\n$a = explode(' ', $in);\n$b = ceil($a[0] * $a[2] * 0.01);\n$b -= $a[1];\nif ($b < 0) $b = 0;\necho $b;", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "e3f8e764a82f48bf5f17f2e2f120bacf", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nerror_reporting(0);\nob_end_clean();\n\nsolve();\n\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$N = (int)$Scanner->Scan();\n\t$X = (int)$Scanner->Scan();\n\t$Y = (int)$Scanner->Scan();\n\t\n\t$temp = (string)(($N * ($Y / 100)));\n\t$temp = ceil($temp);\n\t$need = max($temp - $X, 0);\n\t\n\tprint($need);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "fa02af370c210e6fc73e90a671fae88f", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input = trim(fgets(STDIN));\n$input = explode(' ',$input);\n$difColor = min($input[0],$input[1]);\n$oneColor = floor((max($input[0],$input[1])-$difColor)*0.5);\nfwrite(STDOUT,$difColor.' '.$oneColor);\n?>\n\n\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "594ac48cbc5a953974a5ffeb0ecd9194", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n//$file = fopen('input.in', 'r');\n$file = STDIN;\nlist($a, $b) = explode(\" \", trim(fgets($file)));\nif ($a > $b) {\n    $c = $a;\n    $a = $b;\n    $b = $c;\n}\necho $a . \" \" . floor(($b - $a)/2);", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "7574e6cd7b31a5cb71d17fc3fd92beaa", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "#!/usr/bin/env php\n<?php\n\nif (PHP_OS == 'WINNT') {\n    $line = stream_get_line(STDIN, 1024, PHP_EOL);\n} else {\n    $line = readline();\n}\n\n\n$n = explode(' ', $line)[0];\n$k = explode(' ', $line)[1];\n\n\n$count = ceil(2*$n/$k) + ceil(5*$n/$k) + ceil(8*$n/$k);\n\necho $count;", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "8b430b312ca52dff5b9877c84fac135e", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t\n\t$input = trim(fgets(STDIN)); \n\t$input_split=explode(\" \",$input);\n\t$friend=$input_split[0];\n\t$paper=$input_split[1];\n\t$red_paper_needed=2*$friend;\n\t$green_paper_needed=5*$friend;\n\t$blue_paper_needed=8*$friend;\n\t$book_with_red_paper_needed=$red_paper_needed/$paper;\n\t$book_with_green_paper_needed=$green_paper_needed/$paper;\n\t$book_with_blue_paper_needed=$blue_paper_needed/$paper;\n\tif(is_float($book_with_red_paper_needed)){\n\t\t$book_with_red_paper_needed=intval($book_with_red_paper_needed)+1;\n\t}\n\tif(is_float($book_with_green_paper_needed)){\n\t\t$book_with_green_paper_needed=intval($book_with_green_paper_needed)+1;\n\t}\n\tif(is_float($book_with_blue_paper_needed)){\n\t\t$book_with_blue_paper_needed=intval($book_with_blue_paper_needed)+1;\n\t}\n\techo $book_with_red_paper_needed+$book_with_green_paper_needed+$book_with_blue_paper_needed;\n\n\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "7117d93cf2fd23f84085e36962815fb2", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$e = array();\n$f = array();\n$i = array();\nfor($x = 1; $x <= $b; $x++)\n{\n    list($c, $d) = explode(\" \", trim(fgets(STDIN)));\n    array_push($e, $c);\n    array_push($f, $d);\n}\narsort($f);\n$h = array_keys($f);\nfor($x = 0; $x < $b; $x++)\n{\n    if($a > $e[$h[$x]])\n    {\n        $g = $e[$h[$x]] * $f[$h[$x]];\n        array_push($i, $g);\n    }\n    else\n    {\n        $g = $a * $f[$h[$x]];\n        array_push($i, $g);\n        break;\n    }\n    $a -= $e[$h[$x]];\n}\nprint array_sum($i);\n?>", "lang_cluster": "PHP", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c0a4e2f1845ae7bca68add2495c54a22", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nlist($c, $d) = explode(\" \", trim(fgets(STDIN)));\n$e = $c - 2;\n$f = array();\n$g = $a;\nfor($x = 1; $x <= $e; $x++)\n{\n    $g += $d;\n    array_push($f, $g);\n}\narray_unshift($f, $a);\narray_push($f, $b);\nif($f[count($f) - 1] >= $f[count($f) - 2])\n{\n    print array_sum($f);\n}\nelse\n{\n    $f = array_reverse($f);\n    for($x = 1; $x < count($f); $x++)\n    {\n        $h = $f[$x] - $f[$x - 1];\n        if($h > $d)\n        {\n            $f[$x] = $f[$x - 1] + $d;\n        }\n        else\n        {\n            break;\n        }\n    }\n    print array_sum($f);\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "dp"], "code_uid": "252e47cb78c854cfeacd17f3a7d8c172", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = 0;\nwhile(TRUE)\n{\n    if($a == 1)\n    {\n        $b++;\n        break;\n    }\n    $c = $a % 2;\n    $a = floor($a / 2);\n    if($c == 1)\n    {\n        $b++;\n    }\n}\nprint $b;\n?>", "lang_cluster": "PHP", "tags": ["bitmasks"], "code_uid": "0e7d782159d02f44d8e6ddd4374e648e", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\tfscanf(STDIN, \"%d\", $n);\n\t$ans = 0;\n\twhile($n > 0)\n\t{\n\t\t$ans += $n & 1;\n\t\t$n /= 2;\n\t}\n\techo $ans;\n?>", "lang_cluster": "PHP", "tags": ["bitmasks"], "code_uid": "7b6d744eeea47c648dc15ff86e3957f5", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$line = trim(fgets(STDIN));\n\nfor ($i = 0; $i <= 20; $i++) {\n    $line = str_replace('///', '/', $line);\n    $line = str_replace('//', '/', $line);\n}\n\nif ((substr($line, -1, 1) == '/') && ($line != '/')) $line = substr($line, 0, strlen($line) - 1);\n\necho $line;\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "036c333fe75377890f47a248ab1a816a", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$co=trim(fgets(STDIN));\n$str=str_split($co);\nif ($str[0] == \"a\" and $str[1] == \"1\" or $str[0] == \"a\" and $str[1] == \"8\" or $str[0] == \"h\" and $str[1] == \"1\" or $str[0] == \"h\" and $str[1] == \"8\") {\n   echo 3; \n}elseif ($str[0] == \"a\" or $str[0] == \"h\" or $str[1] == \"1\" or $str[1] == \"8\") {\n    echo 5;\n}else echo 8;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "06ab5c96b355b7e8227dd8a68eae3624", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$stdin = fopen('php://stdin', 'r');\n$str = trim(fgets($stdin));\n$stri = strrev($str);\n$len = strlen($str) % 2 == 0 ? intval(strlen($str) / 2) : intval(strlen($str) / 2) + 1;\n$counter = 0;\nfor ($i = 0; $i < $len; $i++) {\n    if ($str[$i] != $stri[$i]) {\n        $counter++;\n    }\n    if ($counter > 1) {\n        break;\n    }\n}\nif ($counter == 0) {\n    if (strlen($str) % 2 == 1) {\n        echo \"YES\";\n    } else {\n\n        echo \"NO\";\n    }\n} else if ($counter == 1) {\n    echo \"YES\";\n} else {\n    echo \"NO\";\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "931706a36a31485901297526cdfc401c", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n###### IO ######\nerror_reporting(E_ALL);\n#error_reporting(0);\n\nfunction readString($f) {\n\t$r = array(\n\t\t\"\\r\" => '',\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\tlist($first, $last) = array_map('trim', readStringExplode($f, ' '));\n\t$sec = readNum($f);\n\t$sec %= 4;\n\n\t$path = '^>v<';\n\t$cwPath = $path . $path . $path . $path;\n\t$cwwPath = strrev($path) . strrev($path) . strrev($path) . strrev($path);\n\t$firstPos = strpos($cwPath, $first);\n\t$endCwChar = $cwPath[$firstPos + $sec];\n\n\t$firstPos = strpos($cwwPath, $first);\n\t$endCcwChar = $cwwPath[$firstPos + $sec];\n\tif ($endCwChar == $endCcwChar) {\n\t\techo 'undefined';\n\t} elseif ($endCwChar == $last) {\n\t\techo 'cw';\n\t} elseif ($endCcwChar == $last) {\n\t\techo 'ccw';\n\t} else {\n\t\techo 'undefined';\n\t}\n\n\t/* / end body */\n}\n\nif (!isset($is_test)) {\n\t$is_test = false;\n}\nif (empty($is_test)) {\n\tgetAnswer();\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5a51aa6e9c2b8d89d8b782ef5a48284e", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif($b == 0)\n{\n     print \"No\";\n}\nelseif($b == 1)\n{\n     if($a == 0)\n     {\n          print \"Yes\";\n     }\n     else\n     {\n          print \"No\";\n     }\n}\nelseif($b > 1)\n{\n     if($a < $b)\n     {\n          $c = $b - $a;\n          if($c == 1)\n          {\n               print \"Yes\";\n          }\n          else\n          {\n               print \"No\";\n          }\n     }\n     elseif($a == $b)\n     {\n          print \"No\";\n     }\n     elseif($a > $b)\n     {\n          $a -= ($b - 1);\n          $c = $a % 2;\n          if($c == 0)\n          {\n               print \"Yes\";\n          }\n          else\n          {\n               print \"No\";\n          }\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "e4e82c2bd508b46fb0dfb71821eb5c1a", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN, \"%d %d\\n\", $copy, $original);\nif ($original === 1 && $copy === 0) {\n    echo 'Yes';\n    exit;\n}\n\nif (\n    (($original - 1) < 1) ||\n    (1 === ($copy - $original + 1) % 2) ||\n    (($copy - $original + 1) < 0)\n) {\n    echo 'No';\n} else {\n    echo 'Yes';\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "4380406ea14a1cfe093eaaee810f0d46", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n, $b, $p) = explode(\" \", trim(fgets(STDIN)));\n$y = $p * $n;\n$x = ($n - 1) * (2*$b + 1);\n\nprint $x.\" \".$y;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "b1248654b61019ee942735a41b06ad51", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?PHP\n    $a = fgets(STDIN);\n    echo $a+$a/2;\n?>\n", "lang_cluster": "PHP", "tags": ["math", "number theory"], "code_uid": "cca36035ce50fa766ebe4c04d1eaa302", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = floor($a / 2);\n$c = $a - $b;\n$d = $a - $b;\nprint $b + $c + $d;\n?>", "lang_cluster": "PHP", "tags": ["math", "number theory"], "code_uid": "cf382ced99feff9959a66ad59417635c", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n###### IO ######\nerror_reporting(E_ALL);\n#error_reporting(0);\n\nfunction readString($f) {\n\t$r = array(\n\t\t\"\\r\" => '',\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$chars = array('A' => true, 'E' => true, 'I' => true, 'O' => true, 'U' => true, 'Y' => true);\n\n\t$str = strtoupper(readString($f));\n\t$len = strlen($str);\n\t$max = 1;\n\t$current = 1;\n\tfor ($i = 0; $i < $len; $i++) {\n\t\tif (!empty($chars[$str[$i]])) {\n\t\t\t$current = 1;\n\t\t\tcontinue;\n\t\t}\n\t\t$current++;\n\t\t$max = max($max, $current);\n\t}\n\techo $max;\n\t/* / end body */\n}\n\nif (empty($is_test))\n\tgetAnswer();", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "895990e52b308e84ad2bee528fcd9b30", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n# 1182A\n$stdin = STDIN;\n[$n] = fscanf($stdin, '%u');\ndie((string)(($n % 2) === 0 ? 2 ** ($n / 2) : 0));\n", "lang_cluster": "PHP", "tags": ["math", "dp"], "code_uid": "64c848cc9ee31911f19f72c8046baed1", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n $f = fopen('php://stdin','r');\n $s = fgets($f, 1024);\n $a = array(0,0,0);\n\n if (preg_match('#(\\d+)\\s+(\\d+)\\s+(\\d+)#', $s, $pregs)) {\n    $a = array($pregs[1], $pregs[2], $pregs[3]);\n }\n\n sort($a);\n\n $sum1 = ($a[0]*$a[1]);\n $sum2 = ($a[2] - 1)* $a[0];\n $sum3 = (($a[2] - 1) * ($a[1] - 1));\n\n $sum = $sum1 + $sum2 + $sum3;\n\n echo $sum;\n\n?>\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "1627da5d280c87196614221e080b35c0", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a,$b,$c) = explode(' ',trim(fgets(STDIN)));\n\nprint $b*$c+($a-1)*($b+$c-1);\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "de341babcd014427c8ec56d3b17bee85", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n  list( $grownups, $childs ) = explode( ' ', file_get_contents( \"php://stdin\" ) );\n\n\n  if( $grownups == 0 && $childs != 0 )\n      die( \"Impossible\" );\n\n  $grownups = (int)$grownups;\n  $childs   = (int)$childs;\n\n  $min = 0;\n  $max = 0;\n\n  if( $grownups > $childs )\n      $min = $grownups;\n  else\n      $min = $grownups + abs( $grownups - $childs );\n\n  $max = $grownups + ( $childs > 0 ? $childs - 1 : 0 );\n\n  echo $min, ' ', $max;\n", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "6dd4df26724736387b9e266b08c075a9", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($Parent, $Childs) = explode(' ', trim(fgets(STDIN)));\n\nif ($Childs == 0)\n    $max = $Parent;\nelse\n    $max = $Parent + $Childs - 1;\nif ($Childs >= $Parent)\n    $min = $Parent + ($Childs - $Parent);\nelse\n    $min = $Parent;\n\nif (($Parent == 0) && ($Childs != 0))\n    echo \"Impossible\";\nelse\n    print $min . ' ' . $max;\n\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "4b145b6e9a72ee935d634d7ded966256", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = trim(fgets(STDIN));\n$d = 0;\n$e = 0;\nwhile(TRUE)\n{\n     if(($e == $a - 1) || ($f == 1))\n     {\n          break;\n     }\n     else\n     {\n          for($x = $e + $b; $x >= 0; $x--)\n          {\n               if($c[$x] == 1)\n               {\n                    break;\n               }\n          }\n          $f = 0;\n          if($x == $e)\n          {\n               $f = 1;\n          }\n          else\n          {\n               $d++;\n               $e = $x;\n          }\n     }\n}\nif($f == 0)\n{\n     print $d;\n}\nelse\n{\n     print \"-1\";\n}\n?>", "lang_cluster": "PHP", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "80b0149cfaa34eefd8ad9a3bba0c0266", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%d\", $n);\n    for($i = 0; $i < $n; $i++) {\n        fscanf(STDIN, \"%d %d\", $h, $v);\n        $array[$i][0] = $h;\n        $array[$i][1] = $v;\n    }\n    $con = 0;\n    for($i = 0; $i < $n - 1; $i++) {\n        for($j = $i + 1; $j < $n; $j++) {\n            if($array[$i][0] == $array[$j][1]) $con++;\n            if($array[$i][1] == $array[$j][0]) $con++;\n        }\n    }\n    print $con;\n?>\n", "lang_cluster": "PHP", "tags": ["brute force"], "code_uid": "ea97fe330796140756056324633026c1", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = trim(fgets(STDIN));\n$as = trim(fgets(STDIN));\n$an = explode(\" \", $as);\n$as = str_replace(\" \", \"  \", $as);\n$as = \" \" . $as . \" \";\n$p = 1;\nfor ($i = 0; $i < $n; $i++) {\n    $q = substr_count($as, \" \" . $an[$i] . \" \");\n    if ($q > $p) {\n        $p = $q;\n    }\n}\nprint $p;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "a3b7f716c42f7de1afdd3dc01b86aa4e", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$count = (int) trim(fgets(STDIN));\n$array = explode(' ', trim(fgets(STDIN)));\n\n$iMax = 0;\n$countMax = 0;\n$resultArray = [];\nfor ($i = 0; $i < $count; $i++) {\n    if (!isset($resultArray[$array[$i]])) {\n        $resultArray[$array[$i]] = 1;\n    } else {\n        $resultArray[$array[$i]]++;\n    }\n    if ($resultArray[$array[$i]] > $countMax) {\n        $countMax = $resultArray[$array[$i]];\n    }\n    \n}\necho $countMax;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "e2b85297e0ae94dc498d97b5d06877e6", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nwhile ($s = fgets(STDIN))\n{\n    $kto[] = trim($s);\n}\n\n$kol_vo = $kto[count($kto) - 1];\narray_pop($kto);\n\nfor ($i = 0; $i < $kol_vo; $i++)\n{\n    $mas[$i] = $i + 1;\n}\nfor ($i = 0; $i < count($kto); $i++)\n{\n    for ($j = 0; $j < $kol_vo; $j++)\n    {\n        if ($mas[$j] % $kto[$i] == 0)\n            unset($mas[$j]);\n    }\n}\n$vsego = $kol_vo - count($mas);\necho $vsego;\n\n?>", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "89193142d543b6f85b2a8ecddbbb228d", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$d1 = readline();\n$d2 = readline();\n$d3 = readline();\n$d4 = readline();\n$vsego = readline();\n$killed = 0;\n\nfor ($drag = 1; $drag < $vsego+1 ; $drag++) {\n\n    if ($drag % $d1 == 0 || $drag % $d2 == 0 || $drag % $d3 == 0 || $drag % $d4 == 0) {\n        $killed += 1;\n    }\n}\necho $killed;", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "151d680ce42b6c6d0c4ea12175dbda8f", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = array_fill(1, $a, 0);\n$e = 0;\nfor($x = 0; $x < $b - 1; $x++)\n{\n     if($c[$x + 1] > $c[$x])\n     {\n          $f = $c[$x + 1] - $c[$x];\n          if($d[$c[$x]] == 0)\n          {\n               $d[$c[$x]] = $f;\n          }\n          elseif($d[$c[$x]] != $f)\n          {\n               $e = 1;\n               break;\n          }\n     }\n     elseif($c[$x + 1] <= $c[$x])\n     {\n          $f = $a + $c[$x + 1] - $c[$x];\n          if($d[$c[$x]] == 0)\n          {\n               $d[$c[$x]] = $f;\n          }\n          elseif($d[$c[$x]] != $f)\n          {\n               $e = 1;\n               break;\n          }\n     }\n}\nif($e == 0)\n{\n     $g = array_unique($d);\n     sort($g);\n     $h = array_slice($g, 1);\n     sort($g);\n     $i = range(1, $a);\n     $j = array_diff($i, $g);\n     sort($j);\n     $k = 0;\n     for($x = 1; $x <= $a; $x++)\n     {\n          if($d[$x] == 0)\n          {\n               $d[$x] = $j[$k];\n               $k++;\n          }\n     }\n     $l = array_unique($d);\n     if(count($l) == count($d))\n     {\n          print implode(\" \", $d);\n     }\n     else\n     {\n          print \"-1\";\n     }\n}\nelse\n{\n     print \"-1\";\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "2deee71a7b0f652967d4c1bbbae9044b", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$stdin = fopen('php://stdin', 'r');\n$s = '';\nwhile(!feof($stdin))\n{\n    $s .= fgets($stdin);\n}\nlist($n,$p,$k) = explode(' ' ,$s);\n\nfunction pagination($n,$p,$k)\n{\n    $s = '';\n    if($p < 1 || $p > $n)\n    {\n        return $s;\n    }\n    \n    if($p - $k >= 1)\n    {\n        if($p - $k > 1)\n        {\n            $s .= '<< ';\n        }\n        \n        for($i = ($p-$k); $i < $p; $i++)\n        {\n            $s .= $i . ' ';\n        }\n    }\n    else if($p - $k < 1)\n    {\n        for($i = 1; $i < $p;$i++)\n        {\n            $s .= $i . ' ';\n        }\n    }\n    \n    $s .= '(' . $p . ') ';\n    \n    if($p + $k >= $n)\n    {\n        for($i = ($p+1); $i < $n+1; $i++)\n        {\n            $s .= $i . ' ';\n        }\n    }\n    else if($p + $k < $n)\n    {\n        for($i = ($p+1); $i <= $p+$k; $i++)\n        {\n            $s .= $i . ' ';\n        }\n        $s .= ' >>';\n    }\n    \n    return $s;\n}\n\n\necho pagination($n, $p, $k);", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "4966bfd71d9bedc24e1158c6b57c07ae", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// $n = 8;\n// $p = 5;\n// $k = 4;\nlist($n, $p, $k) = explode(\" \", trim(fgets(STDIN)));\n\nif( $p-$k>1) {\n\t$str .= '<< ';\n}\n\nfor($i = max($p-$k, 1); $i<=min($p+$k, $n); $i++){\n\t$str .= ($p==$i) ? \"($i) \" : \"$i \";\n}\n\nif($p+$k<$n) {\n\t$str .= '>>';\n}\n\nprint(trim($str));\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "bbde303ea1aeef70a89836317c262947", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$f = fopen('php://stdin', 'r');\n\nlist($n) = fscanf($f, \"%d\");\n\nprint ($n-2) * ($n-2);", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "a9a271138b12ae45f0f14cc35f32db5b", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c, $d) = explode(\" \", trim(fgets(STDIN)));\n$e = $b / $a;\n$f = $c / $d;\nif($a > $b)\n{\n    if((($a - $b) == ($b - $c)) && (($b - $c) == ($c - $d)))\n    {\n        print $d - ($a - $b);\n    }\n    elseif((($c / $d) == $f) && (($b / $c) == $f) && (($a / $b) == $f))\n    {\n        $g = $d / $f;\n        $h = floor($d / $f);\n        if($g == $h)\n        {\n            print $g;\n        }\n        else\n        {\n            print \"42\";\n        }\n    }\n    else\n    {\n        print \"42\";\n    }\n}\nelse\n{\n    if((($b - $a) == ($c - $b)) && (($c - $b) == ($d - $c)))\n    {\n        print $d + ($b - $a);\n    }\n    elseif((($b / $a) == $e) && (($c / $b) == $e) && (($d / $c) == $e))\n    {\n        $g = $e * $d;\n        $h = floor($e * $d);\n        if($g == $h)\n        {\n            print $g;\n        }\n        else\n        {\n            print \"42\";\n        }\n    }\n    else\n    {\n        print \"42\";\n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "1cce05ebd6f557b9f98fd43806769a90", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d %d\", $n, $m);\n$c = 0;\nwhile ( $n < $m )\n{\n    if ( $m % 2 )\n        $m+= 1;\n    else\n        $m/= 2;\n    $c+= 1;\n}\necho $c + $n - $m;\n?>", "lang_cluster": "PHP", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "8dc8353aebb7cdea12a5e3211511b3f6", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($n,$m)=fscanf(STDIN,\"%d %d\");\n$stps=0;\nwhile($n<$m)    {\n\tif($m%2)    $m++;\n\telse    $m/=2;\n\t$stps++;\n}\n\necho $stps+$n-$m.\"\\n\";\n\n?>", "lang_cluster": "PHP", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "054e61b3fcd8bf93b877eb0e7295bbdc", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$limit = trim(fgets(STDIN));\n\n$n = 1;\n$sum = 1;\n\nwhile (true) {\n    $level = (($n + 2) * ($n + 1)) / 2;\n    if ($sum + $level <= $limit) {\n        $sum += $level;\n        $n++;\n    } else {\n        break;\n    }\n}\n\necho $n;\n\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "2826451f8773ed96aa4aad5c4706e7ad", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = (int)fgets(STDIN);\n\n$cubes = 1;\n$plus = 2;\n\nfor ($i = 0; ; $i++) {\n  if ($n < $cubes) {\n    break;\n  }\n  $n -= $cubes;\n  $cubes += $plus++;\n}\n\necho $i;\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "c2e5588ce127caf6bfb9b3da07fe7a1d", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%d\",$n);\n$arr=explode(\" \",trim(fgets(STDIN)));\n//$n=$n-1;\nwhile($n--)\n{\n\tfor($i=0;$i<$n;$i++)\n\t{\n\t\tif($arr[$i]>$arr[$i+1])\n\t\t{\n\t\t\t$tmp=$arr[$i];\n\t\t\t$arr[$i]=$arr[$i+1];\n\t\t\t$arr[$i+1]=$tmp;\n\t\t}\n\t}\n}\n$res=0;\nwhile($i<count($arr))\n{\n\t$res+=$arr[$i+1]-$arr[$i];\n\t$i+=2;\n}\n\necho \"$res\";", "lang_cluster": "PHP", "tags": ["sortings"], "code_uid": "a0f55d12e5a44e58c58029a5c70bca32", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n) = explode(\" \", trim(fgets(STDIN)));\n\n$std = explode(\" \", trim(fgets(STDIN)));\nsort($std);\n\n$t = 0;\n\nfor ($i=0; $i < $n/2; $i++) { \n\t$t += abs($std[2 * $i] - $std[2 * $i + 1]);\n}\n\necho $t ,\"\\n\";\n", "lang_cluster": "PHP", "tags": ["sortings"], "code_uid": "67c1db19f280ef3ac663a7fc388cede2", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = $a - $b;\n$d = $b - 1;\nif($c <= $d)\n{\n     if($b - 1 == 0)\n     {\n          print \"1\";\n     }\n     else\n     {\n          print $b - 1;\n     }\n}\nelse\n{\n     print $b + 1;\n}\n?>", "lang_cluster": "PHP", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "7070bf77687ec053b7eacbcf052092bd", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n//$file = fopen('input.in', 'r');\n$file = STDIN;\nlist($n, $m) = explode(\" \", trim(fgets($file)));\n$result = 0;\nif ($n % 2 === 0) {\n    $middle = $n / 2;\n    if ($m <= $middle) {\n        $result = $m + 1;\n    } else {\n        $result = $m - 1;\n    }\n} else {\n    $middle = ($n + 1) / 2;\n    if ($m >= $middle) {\n        $result = $m - 1;\n    } else {\n        $result = $m + 1;\n    }\n}\nif ($result == 0) {\n    $result = 1;\n}\necho $result;", "lang_cluster": "PHP", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "bf4aec2bba82c0c5bf029e20795c9d62", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c[0] = 0;\n$c[1] = 0;\n$c[2] = 0;\nfor($i=0; $i<$a; ++$i)\n{\n    $c[0] += $b[$i];\n    $c[1] += $b[$i+1];\n    $c[2] += $b[$i+2];\n    $i = $i + 2;\n}\nif($c[0]>$c[1]){if($c[0]>$c[2]){echo \"chest\";}}\nif($c[1]>$c[0]){if($c[1]>$c[2]){echo \"biceps\";}}\nif($c[2]>$c[0]){if($c[2]>$c[1]){echo \"back\";}}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "df9a5fba2e4edbb23e8ac39d8d95c2b4", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$stdin = fopen(\"php://stdin\", \"r\");\n$stdout = fopen(\"php://stdout\", \"w\");\n$t = fgets($stdin);\n$l = strlen($t);\n$mx = 0;\n$cnt = 0;\nfor($i = 0; $i < $l; ++$i){\n    if(ord($t[$i]) > $mx){\n        $cnt = 1;\n        $mx = ord($t[$i]);\n        continue;\n    }\n    if(ord($t[$i]) == $mx){\n        $cnt ++;\n        continue;\n    }\n}\nfor($i = 0; $i < $cnt; ++$i){\n    fwrite($stdout,chr($mx));\n}\nfclose($stdin);\nfclose($stdout);\n?>\n", "lang_cluster": "PHP", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "a67edfb485a5494e8f80dcc5bf6cb29a", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $stdin = fopen('php://stdin', 'r');\n    $stdout = fopen('php://stdout', 'w');\n    $string = fgets($stdin);\n    \n    for($i=1;$i<strlen($string);++$i){\n        for($j=0;$j<$i;++$j){\n            $tmp[]=substr($string, $j, $i-$j);\n        }\n    }\n    \n    $curMaxLen=0;\n    $count = array_count_values($tmp);\n    foreach($tmp as $elem){\n        if(($count[$elem]>=2)&&($curMaxLen<strlen($elem))) $curMaxLen=strlen($elem);\n    }\n    \n    fputs($stdout, $curMaxLen);\n\n?>\n", "lang_cluster": "PHP", "tags": ["brute force", "greedy"], "code_uid": "c7672808027bffb8aa2ba641883f013b", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n$d = 0;\nfor($x = 1; $x <= 1000; $x++)\n{\n    $c = pow($a, $x);\n    if($b == $c)\n    {\n        $d = 1;\n        break;\n    }\n    elseif($b < $c)\n    {\n        break;\n    }\n}\nif($d == 1)\n{\n    print \"YES\" . \"\\n\";\n    print $x - 1;\n}\nelse\n{\n    print \"NO\";\n}\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "2843bfb90456976b85b5ed42fa95806a", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$flag = 1; //must be not zero for STDIN\n\n$in = 'php://stdin';\nif (!$flag)\n{\n    $in = \"input.txt\";\n}\n$fd = fopen($in, \"r\");\nfscanf($fd, \"%d\\n\", $k);\nfscanf($fd, \"%d\\n\", $l);\nfclose($fd);\n\n$r = (log($l, $k));\n$s = strstr ( $r, '.' );\nif (!$s)\n{\n    print \"YES\\n\";\n    $r--;\n    print \"$r\\n\";\n} else\n{\n    print \"NO\\n\";\n}\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "5c6660f2089854ad9329f36f1b6f596d", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n) = explode(\" \", trim(fgets(STDIN)));\n$a = explode(\" \", trim(fgets(STDIN)));\n\n$a = array_unique($a);\nsort($a);\n$s = \"NO\";\n\nfor ($i=2; $i < count($a); $i++) { \n\tif ( (($a[$i] - 1) == $a[$i-1]) && (($a[$i] - 2) == $a[$i-2]) ) {\n\t\t$s = \"YES\";\n\t\tbreak;\n\t}\n}\n\nprint $s;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "sortings", "implementation"], "code_uid": "65e6f26404e2c5960787d4f3a9431972", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $fp = fopen('php://stdin', 'r');\n    echo 4 - count(array_unique(explode(' ', rtrim(fgets($fp)))));\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "914baee692f6327c3581b8ea6ebcf619", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = explode(\" \", trim(fgets(STDIN)));\n$b = 0;\n$b2 = range(1, 100);\nfor($x = 1; $x <= 10; $x++)\n{\n     for($y = 1; $y <= 10; $y++)\n     {\n          for($z = 1; $z <= 10; $z++)\n          {\n               $c = array($x);\n               for($d = 1; $d <= 100; $d++)\n               {\n                    $e = $x + ($d * $a[0]);\n                    $c[count($c)] = $e;\n               }\n               $f = array($y);\n               for($d = 1; $d <= 100; $d++)\n               {\n                    $e = $y + ($d * $a[1]);\n                    $f[count($f)] = $e;\n               }\n               $g = array($z);\n               for($d = 1; $d <= 100; $d++)\n               {\n                    $e = $z + ($d * $a[2]);\n                    $g[count($g)] = $e;\n               }\n               $h = array_merge($c, $f, $g);\n               $i = array_unique($h);\n               sort($i);\n               $i = array_slice($i, 0, 100);\n               if($i == $b2)\n               {\n                    $b = 1;\n                    break;\n               }\n          }\n          if($b == 1)\n          {\n               break;\n          }\n     }\n     if($b == 1)\n     {\n          break;\n     }\n}\nif($b == 0)\n{\n     print \"NO\";\n}\nelse\n{\n     print \"YES\";\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "constructive algorithms"], "code_uid": "4c9b4df0dcb41f55cd59a408594dabd4", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = array(\"1\");\nfor($x = 1; $x < $a; $x++)\n{\n    $c[$x] = 0;\n}\n$i = 0;\nfor($x = count($c) - 1; $x >= 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?>", "lang_cluster": "PHP", "tags": ["greedy", "dp", "implementation"], "code_uid": "b9b5b62e1b35a95e037fe54ec1f23c5c", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$d = array_reverse($c);\n$e = array_fill(0, $a, 0);\nfor($x = 0; $x < $b; $x++)\n{\n    for($y = $d[$x] - 1; $y < $a; $y++)\n    {\n        $e[$y] = $d[$x];\n    }\n}\nprint implode(\" \", $e);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "d263269b2178732e0e96eb4e0a1d0fb1", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%d%d\",$x,$y);\n$t=abs($x)+abs($y);\n$t1=($x<0)?-$t:$t;\n$t2=($y<0)?-$t:$t;\nif($t1>0) echo \"0 \".$t2.\" \".$t1.\" 0\";\nelse echo $t1.\" 0 0 \".$t2;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "3629973911ccc2bd68a0259625fe6a21", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%d %d\",$len,$k);\nfscanf(STDIN,\"%s\",$str);\n$obstract=array();\nfor ($i=0; $i <$len ; $i++) \n{ \n\tif($str[$i]=='T')\n\t\t$target=$i+1;\n\t if($str[$i]=='G')\n\t \t$start=$i+1;\n\t \n\n}\nif($start>$target)\n {\n\t$tmp=$start;\n\t$start=$target;\n\t$target=$tmp;\n}\n\n\n\n     // $obstract=0;\n\n\t   for ($i=$start-1;; $i+=$k)\n\t    {      \n\t    \t   //echo \"i=$i target=$target\\n\";\n\t\t       if($i>$target-1)\n\t\t       {\n\t\t       \t  echo \"NO\\n\";\n\t\t       \t  break;\n\t\t       }\n\t\t   \t   if($i==$target-1)\n\t\t   \t   {\n\t\t   \t   \t   echo \"YES\\n\";\n\t\t   \t   \t   break;\n\t\t   \t   }\n\t\t   \t    \n\t\t   \t   if($str[$i]=='#')\n\t\t   \t   {\n\t\t   \t   \t  echo \"NO\\n\";\n\t\t   \t   \t  break;\n\t\t   \t   }\n\n\n\t    }\n\t    \n\t    \t\n\n/*\nif($flag==1)\n\techo \"YES\\n\";\nelse\n\techo \"NO\\n\";\n*/", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "2d0d8d71d9861df434aa07ea0b43e248", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($len, $jump)=explode(\" \", trim(fgets(STDIN)));\n$str=str_split(trim(fgets(STDIN)));\n$u=$jump;\n\n\nforeach ($str as $key => $value) {\n    if ($value == \"G\") {\n     $g=$key;\n    }\n    if ($value == \"T\") {\n        \n      $tg=$key;  \n    }\n    \n}\n\n\nwhile (TRUE) {\n$t= $g + $jump;\n$t1=$g - $jump;\n\n\nif ($tg < $g) {\nif ($str[$t1] == \"#\") {\n   \n    echo \"NO\";\n    break;\n}elseif ($str[$t1] == \"T\") {\n    \n    echo \"YES\";\n    break;\n}else $jump = $u + $jump;\n}\nif ($tg > $g) {\nif ($str[$t] == \"#\") {\n    \n    echo \"NO\";\n    break;\n}elseif ($str[$t] == \"T\") {\n    \n    echo \"YES\";\n    break;\n}else $jump = $u + $jump;\n\n\n\n } \n \n  if ($jump > $len){\n     \n     echo \"NO\";\n     break;\n \n}\n    \n}\n\n \n\n?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "8fffa4b2f37f9d9f7434d0e100bbd1cb", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = array_fill(0, $a, 1);\n$c = array(1);\n$d = array();\nfor($x = 1; $x <= $a; $x++)\n{\n    $d[$x] = $c;\n}\nunset($d[count($d) - 1]);\narray_unshift($d, $b);\nfor($x = 1; $x < $a; $x++)\n{\n    for($y = 1; $y < $a; $y++)\n    {\n        $d[$x][$y] = $d[$x - 1][$y] + $d[$x][$y - 1];\n    }\n}\nprint $d[$a - 1][$a - 1];\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "871d0be48ea127dfd0995e6ec44839d7", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nwhile(fscanf(STDIN,\"%d\",$n)){\n    $data = array();\n    for($i = 0; $i < $n; ++$i){\n        $data[$i][0] = 1;\n        $data[0][$i] = 1;\n    }\n    for($i =1; $i < $n; ++$i)\n        for($j = 1; $j < $n; ++$j){\n            $data[$i][$j] = $data[$i-1][$j] + $data[$i][$j-1];\n        }\n    echo $data[$n-1][$n-1].\"\\n\";\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "f3200b8dd359b5e759d1f6869e2fa543", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$e = 0;\nfor($x = 0; $x < $a - 1; $x++)\n{\n    $d  = $c[$x] - $c[$x + 1];\n    $e = max($d, $e);\n}\nif(($e - $b) > 0)\n{\n    print $e - $b;\n}\nelse\n{\n    print \"0\";\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "greedy", "implementation"], "code_uid": "9a03c57b97b830121d249c3a3436eec0", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($n, $c) = explode(' ', get_line());\n\n$n = (int)$n;\n$c = (int)$c;\n\n$x = explode(' ', get_line());\n$n = min($n, count($x));\n\nfor ($i = 0; $i < $n; $i ++) {\n  $x[$i] = (int)$x[$i];\n}\n\n$answer = 0;\n\nfor ($i = 0; $i+1 < $n; $i ++) {\n  if ($x[$i] - $c > $x[$i+1]) {\n    $answer = max($answer, $x[$i] - $c - $x[$i+1]);\n  }\n}\n\nprint $answer;\n\nfunction get_line() {\n  return trim(fgets(STDIN));\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "greedy", "implementation"], "code_uid": "cee848f4ca454d0d2dfb078e1902d6e8", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "#!/usr/bin/php -c -q\n<?php\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\t\n/*  //unuseful firstversion\n\tpublic function nextToken() {\n\t\t\n\t\tif (Token::$first === true) {\n \t\t\tif ($this->$firstToken !== false) {\n\t\t\t\tToken::$first = false;\n\t\t\t\t//self::$first = false;\n\t\t\t\treturn $this->$firstToken;\n\t\t\t} else {\n\t\t\t\treturn -1;\n\t\t} else {\n\t\t\t$nextToken = strtok(\" \");\n\t\t\tif ($nextToken !== false) {\n\t\t\t\treturn $nextToken;\n\t\t\t} else {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n*/\n\tpublic function nextToken() {\n\t\t$thisToken = $this->token;\n\t\t//$this->token = strtok(\" \");\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}\n\n/* \nfunction getLines($str_lines) {\n\twhile (true) {\n\n\t\t$str_line = rtrim(fgets(STDIN, 10), \"\\n\");\n\t\n\t\t//null\ufffd\ufffd\ufffd\ufffd\ufffdstrlen($num) < 1\ufffdH  \n    \tif (!ctype_digit($str_line) || strlen($str_line) < 1) { \n        \tbreak; \n    \t}\n\n\t\t$str_lines[] = $str_line;\n\t}\n\treturn $str_lines;\n}\nfunction putLinesIn(&$str_lines) {\n\twhile (true) {\n\n\t\t$str_line = rtrim(fgets(STDIN, 10), \"\\n\");\n\t\n\t\t//null\ufffd\ufffd\ufffd\ufffd\ufffdstrlen($num) < 1\ufffdH  \n    \tif (!ctype_digit($str_line) || strlen($str_line) < 1) { \n        \tbreak; \n    \t}\n\n\t\t$str_lines[] = $str_line;\n\t}\n}\nfunction getStringArray($str_line, $str_arr) {\n\t$firstToken = strtok($str, \" \");\n\tif ($firstToken === false) return -1;\n\telse $fl_arr[] = $firstToken;\n\t\n\t$nextToken = strtok($str);\n\twhile ($nextToken !== false) {\n\t\t$fl_arr[] = $nextToken;\n\t\t$nextToken = strtok($str);\n\t}\n\treturn $str_arr;\n}\n*/\n\n/*string \ufffd\ufffd array \n//\ufffd\ufffd\ufffdK\ufffd\\\ufffd\ufffd\ufffd\ufffd\ufffdK\ufffdv  preg_split\n//\ufffd\ufffd\ufffdK\ufffd\\\ufffd\ufffd\ufffd\ufffd\ufffds\ufffdv  explode(), str_split()(more speedy but more simple) \n\n//1.example of explode()  (best)\nfunction putStringsIn($str_line) {\n\tif ($str_line === null) $str_arr = null;\n\telseif (strpos($str_line, \" \") === false) $str_arr = $str_line;\n\telse $str_arr = explode(\" \", $str_line);\n\t\t\n\treturn $str_arr;\n}\n\n//2.example getting of arr from str, and using strtok  (unuseful)\nfunction putStringsIn($str_line) {\n\t$str_arr = array();\n\t\n\t$firstToken = strtok($str_line, \" \");\n\tif ($firstToken !== false) {\n\t\t$str_arr[] = $firstToken;\n\t\t$nextToken = strtok($str_line);\n\t\twhile ($nextToken !== false) {\n\t\t\t$str_arr[] = $nextToken;\n\t\t\t$nextToken = strtok($str_line);\n\t\t}\n\t}\n}\n\n//3.example getting of float arr from str, and using strtok  (unuseful)\nfunction getFloatArray($str_line, $fl_arr) {\n\t$firstToken = (float)strtok($str_line, \" \");\n\tif ($firstToken === false) return -1;\n\telse $fl_arr[] = $firstToken;\n\t\n\t$nextToken = (float)strtok($str_line);\n\twhile ($nextToken !== false) {\n\t\t$fl_arr[] = $nextToken;\n\t\t$nextToken = strtok($str_line);\n\t}\n\treturn $fl_arr;\n}\n\n//4.the same way, except using &$fl_arr  (unuseful)\nfunction putFloatsIn($str_line, &$fl_arr) {\n\t$firstToken = (float)strtok($str_line, \" \");\n\tif ($firstToken === false || count($fl_arr) !== 0) return -1;\n\telse $fl_arr[] = $firstToken;\n\t\n\t$nextToken = (float)strtok($str_line);\n\twhile ($nextToken !== false) {\n\t\t$fl_arr[] = $nextToken;\n\t\t$nextToken = strtok($str_line);\n\t}\n}\n*/\n\n/*\nchange of data fomat of arrays\n\n//1.basic code\narray_map('strval', $arr), array_map('floatval', $arr)\n//2.unuseful firstversion\nfunction nextFloat($str) {\n\treturn (float)$str;\n}\n*/\n\n/*solve using foreach for reading input\nfunction solve(){\n\n\t$str_lines = array();\n\tputLinesIn($str_lines);\n\tforeach ($str_lines as $str_line) {\n\t\t$str_arr = array();\n\t\tputStringsIn($str_line, &$str_arr);\n\t\t//$fl_arr = array();\n\t\t//foreach ($str_arr as $str) {\n\t\t\t//$fl_arr[] = (float)$str;\n\t\t//}\n\t\t$fl_arr = array_map('floatval', $arr);\n\t\t\n\t\t$vp = $fl_arr[0];\n\t\t$vd = $fl_arr[1];\n\t\t$t = $fl_arr[2];\n\t\t$f = $fl_arr[3];\n\t\t$c = $fl_arr[4];\n\n\t\t$ttake = ($vp * $t) / ($vd - $vp);\n\t\t$dis = $vp * ($t + $ttake);\n\t\t$less = $c - $dis;\n\t\t$int_count = 0;\n\t\t$EPS = 1e-9;\n\n\t\twhile ($less > $EPS) {\n\t\t\t$int_count++;\n\t\t\t$t = $t + 2 * $ttake + $f;\n\t\t\t$ttake = ($vp * $t) / ($vd - $vp);\n\t\t\t$dis = $vp * ($t + $ttake);\n\t\t\t$less = $c - $dis;\n\t\t}\n\n\t\tprintf(%d,$int_count);\n\t}\n}\n*/\n//solve using strtok or class Toke for reading input\nfunction solve(){\n\n/* basic coding (this code is not best, because changing token and float is not good)\n\t$vp = (float)strtok(rtrim(fgets(STDIN, 10), \"\\n\"), \" \");\n\t$vd = (float)strtok(\" \");\n\t$t = (float)strtok(\" \");\n\t$f = (float)strtok(\" \");\n\t$c = (float)strtok(\" \");\n*/\n\t//use Token class(advatage of using this class is changing token and float is more easy)\t\n\t//$Token = new Token(rtrim(fgets(STDIN, 5), \"\\n\"), \" \");\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$vp = $Token->nextFloat();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$vd = $Token->nextFloat();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$t = $Token->nextFloat();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$f = $Token->nextFloat();\n\t$Token = new Token(rtrim(fgets(STDIN), \"\\n\"), \" \");\n\t$c = $Token->nextFloat();\n\t\n/* another coding if possible\n\t1.for\n\tfor ($temp = $Token->nextFloat();;$temp = $Token->nextFloat();) {\n\t\tif ($temp === false) break;\n\t\t$vp = $temp;\n\t\t\ufffdE\n\t\t\ufffdE\n\t\t\ufffdE\n\t}\n\t\n\t2.while\n\t$temp = $Token->nextFloat();\n\twhile($temp !== false) {\n\t\t$vp = $temp;\n\t\t\ufffdE\n\t\t\ufffdE\n\t}\n*/\n\t$int_count = 0;\n\tif ($vd <= $vp) {\n\t\tprintf('%d', $int_count);\n\t\treturn;\n\t}\n\t\n\t$ttake = ($vp * $t) / ($vd - $vp);\n\t$dis = $vp * ($t + $ttake);\n\t$less = $c - $dis;\n\t$EPS = 1e-9;\n\twhile ($less > $EPS) {\n\t\t$int_count++;\n\t\t$t = $t + 2 * $ttake + $f;\n\t\t$ttake = ($vp * $t) / ($vd - $vp);\n\t\t$dis = $vp * ($t + $ttake);\n\t\t$less = $c - $dis;\n\t}\n\n\t//printf(%d, $int_count);\n\tprintf('%d', $int_count);\n}\n\nfunction run(){\n\tsolve();\n}\n\nob_end_clean();\nrun();\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "f4e95c8d133c7795a688ab5703db245a", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nclass Segment {\n\tpublic function __construct($a) {\n\t\tif ($a[0] < $a[2] || ($a[0] == $a[2] && $a[1] < $a[3]))\n\t\t\t$this->a = $a;\n\t\telse\n\t\t\t$this->a = array($a[2], $a[3], $a[0], $a[1]);\n\t}\n\tpublic static function create($a, $b, $c, $d) {\n\t\treturn new Segment(array($a, $b, $c, $d));\n\t}\n\t// public function __is_equal($other) {\n\t// \treturn $this->a == $other->a;\n\t// }\n\tpublic function __toString() {\n\t\treturn implode(', ', $this->a);\n\t} \n}\n\n$sa = array();\n$M = 10**9;\n$min_x = $M; $max_x = -$M;\n$min_y = $M; $max_y = -$M;\nfor ($i = 0; $i < 4; $i++) {\n\t$a = array_map(\"intval\", explode(' ', fgets(STDIN)));\n\t$min_x = min($min_x, min($a[0], $a[2]));\n\t$max_x = max($max_x, max($a[0], $a[2]));\n\t$min_y = min($min_y, min($a[1], $a[3]));\n\t$max_y = max($max_y, max($a[1], $a[3]));\n\t$sa[$i] = new Segment($a);\n}\n$sb = array(\n\tSegment::create($min_x, $min_y, $max_x, $min_y),\n\tSegment::create($min_x, $min_y, $min_x, $max_y),\n\tSegment::create($max_x, $max_y, $max_x, $min_y),\n\tSegment::create($max_x, $max_y, $min_x, $max_y)\n);\n// print(implode(' | ', $sa).\"\\n\");\n// print(implode(' | ', $sb).\"\\n\");\n$equal = (array_merge(array_diff($sa, $sb), array_diff($sb, $sa)) == array());\nprint($equal && $min_x != $max_x && $min_y != $max_y ? \"YES\\n\" : \"NO\\n\");\n?>\n", "lang_cluster": "PHP", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "a247497d731d347e44531a1efaf7a6d8", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n_c = explode(\" \", trim(fgets(STDIN)));\n$n_i = explode(\" \", trim(fgets(STDIN)));\n$t_i = explode(\" \", trim(fgets(STDIN)));\n$n = $n_c[0];\n$c = $n_c[1];\nfor ($i = 0; $i < $n; $i++) {\n    $tl += $t_i[$i];\n    $cr = $n_i[$i] - $c * $tl;\n    $l += max(0, $cr);\n    $cr = 0;\n}\nfor ($i = $n - 1; $i >= 0; $i--) {\n    $tr += $t_i[$i];\n    $cr = $n_i[$i] - $c * $tr;\n    $r += max(0, $cr);\n    $cr = 0;    \n}\nif ($l > $r) print \"Limak\";\nif ($r > $l) print \"Radewoosh\";\nif ($l == $r) print \"Tie\";\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "7b80b9aaf55e4e4b7b83c703874c0d05", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \" %d %d\", $n, $c);\n$p = array_map(function($x){ return (int)$x; }, explode(\" \", fgets(STDIN)));\n$t = array_map(function($x){ return (int)$x; }, explode(\" \", fgets(STDIN)));\n$l = 0;\n$r = 0;\n$t_l= 0;\n$t_r = 0;\nfor ($i = 0; $i < $n; $i++) {\n    $t_l += $t[$i];\n    $t_r += $t[$n - 1 - $i];\n    $l += max($p[$i] - $c*$t_l, 0);\n    $r += max($p[$n - 1 - $i] - $c*$t_r, 0);\n}\nif ($l > $r)\n    echo \"Limak\";\nelse if ($l < $r)\n    echo \"Radewoosh\";\nelse\n    echo \"Tie\";\n?>\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0d23e702b1cadc4d978368b9557c2684", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input = file_get_contents('php://stdin');\n$output = '';\n$tmp = explode(' ', $input);\n$x = intval($tmp[0]);\n$y = intval($tmp[1]);\n$dist = sqrt($x*$x+$y*$y);\nif($dist == intval($dist) || $x == 0 || $y == 0){\n\tfile_put_contents('php://stdout', 'black');\n\texit;\n}\nif($x*$y > 0){\n\tif(floor($dist)%2 == 0){\n\t\t$output = 'black';\n\t}else{\n\t\t$output = 'white';\n\t}\n}else{\n\tif(floor($dist)%2 == 0){\n\t\t$output = 'white';\n\t}else{\n\t\t$output = 'black';\n\t}\n}\nfile_put_contents('php://stdout', $output);\n?>", "lang_cluster": "PHP", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "5001664213575d99405ef49556224714", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$f = fopen( 'php://stdin', 'r' );\n$a = explode(' ', fgets($f));\n// a[0] la so phan trong hop(section)\n// a[1] la so hat (nut)\n// a[2] la so lan chia (divisor)\n// a[3] la so hat trong phan (nut in section)\n\n// tinh so section\n$section_necessary = ($a[1] % $a[3] == 0) ? ($a[1] / $a[3]) : (floor($a[1] / $a[3]) + 1);\n$so_hop_chia_toi_da = floor($a[2] / ($a[0]-1));\n$so_hop_duoc_chia = ceil($a[2] / ($a[0]-1));\n$so_phan_duoc_tao_ra = $so_hop_chia_toi_da * $a[0] + $a[2] - $so_hop_chia_toi_da * ($a[0]-1) + 1;\nif ($section_necessary <= $so_phan_duoc_tao_ra)\n    echo ceil($section_necessary/$a[0]);\nelse {\n    if( $so_hop_duoc_chia == $so_hop_chia_toi_da)\n        echo $so_hop_chia_toi_da + ($section_necessary - $so_hop_chia_toi_da * $a[0]);\n    else\n        echo $so_hop_duoc_chia + $section_necessary - $so_phan_duoc_tao_ra;\n}\n// echo $section_necessary; ", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "35d3b006770c5960248f3e461323b26e", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = 0;\nfor($x = 1; $x <= 1000; $x++)\n{\n     $b .= $x;\n}\nprint $b[$a];\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f35faf9054d272404c35bd28d52490f4", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$n = trim(fgets(STDIN));\n$cad = \"\";\nfor($i=1; $i<=1000;$i++)\n  $cad .= $i;\nprintf(\"%s\",$cad[$n - 1]);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "414e0b6e1dd5991bdd2a15a1a04f322a", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN,\"%d%d%d%d\",$a,$b,$c,$d);\n\nfunction solve($a,$b,$c,$d){\n    $MPoints = max($a*3/10,$a-$a/250*$c);\n    $VPoints = max($b*3/10,$b-$b/250*$d);\n    if($MPoints>$VPoints){\n        echo \"Misha\";\n    }else if($MPoints<$VPoints){\n        echo \"Vasya\";\n    }else if($MPoints ==$VPoints){\n        echo \"Tie\";\n    }\n}\n\n\nsolve($a,$b,$c,$d);\n\n\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "2184aa7457cbd474dfe7badb2545a2e0", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// for example, the input is '5 9'\n$input = trim(fgets(STDIN));\n\nfunction magicNumber($input){\n\t$numbers = str_split($input);\n\tforeach($numbers as $key => $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}", "lang_cluster": "PHP", "tags": ["brute force", "greedy"], "code_uid": "f9a8ecf569f58b95a75c5c30c4200c4c", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction main(){\n    $arr=[\"Danil\",\"Olya\",\"Slava\",\"Ann\",\"Nikita\"];\n    fscanf(STDIN,\"%s\",$x);\n    \n    foreach($arr as $s){\n        $cnt+=preg_match_all(\"/$s/\",$x);\n    }\n    if($cnt==1)echo \"YES\";\n    else echo \"NO\";\n}\nmain();", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "acfdbbdf5deac98b687a8f8223ff7485", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist ($n1, $n2) = explode(\" \", fgets(STDIN));\nif ($n2 >= $n1)\n{\n    echo \"Second\\n\";\n}\nelse\n{\n    echo \"First\\n\";\n}", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms"], "code_uid": "2f5f6fd3de72a4fd1fafe24a51632aab", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$fi=@fopen('test.inp',\"r\");\nlist($n1,$n2,$k1,$k2)=explode(\" \",trim(fgets(STDIN)));\nif ($n1>$n2) echo \"First\";\nelse echo \"Second\";\n?>", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms"], "code_uid": "87fb4fda31cc69b2683cfb7c05e2a073", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "         <?php\n  $fr = fopen(\"php://stdin\", \"r\");\n  $fw = fopen(\"php://stdout\", \"w\");\n \n  fscanf($fr, \"%s\", $r1);\n  fscanf($fr, \"%s\", $r2);\n   date_default_timezone_set(\"America/Los_Angeles\");\n   $s=  strtotime(\"+$r2 minutes\",  strtotime($r1));\n        \n fprintf($fw, date('H:i' , $s));\n  \n \n  fclose($fr);\n  fclose($fw);\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "a1b9d5c8d740cd29f538d1af29abfc07", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n        //Enter your code here, enjoy!\n\n$t = trim(fgets(STDIN));\n$a = trim(fgets(STDIN));\n\n$t = explode(\":\", trim($t));\n\n$h = $t[0];\n$m = $t[1];\n\n$m += ($h * 60) + $a;\n\n$h = floor($m / 60);\n$h = $h - (24 * floor($h / 24));\n$m = ($m % 60);\n\necho sprintf(\"%02d:%02d\", $h, $m);\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "53ed96b165aec7437ee5ee49f4e2ec3e", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$t = (int)fgets(STDIN);\nfor ($i = 0; $i < $t; $i += 1) {\n    $flag = false;\n    $x = (int)fgets(STDIN);\n    for ($j = 0; $j <= $x; $j +=7) {\n        if (($x - $j) % 3 === 0) {\n            echo \"YES\\n\";\n            $flag = true;\n            break;\n        }\n    }\n    if (! $flag) echo \"NO\\n\";\n}", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "34de31ea81053b9f66a685cb0bb83ac5", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\t$stdin = fopen('php://stdin', 'r');\n   $string = trim(fgets($stdin));\n  $arr = explode(\" \", $string);\n  rsort($arr);\n\n  echo ($arr[0] - $arr[2]);\n  \n", "lang_cluster": "PHP", "tags": ["math", "sortings", "implementation"], "code_uid": "9db80b7712b15cc400190596f03fdaf6", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$stdin = fopen(\"php://stdin\", 'r');\nfscanf($stdin, \"%d%d%d\", $x1, $x2, $x3);\necho min(array(\n    abs($x1 - $x2) + abs($x1 - $x3),\n    abs($x1 - $x2) + abs($x2 - $x3),\n    abs($x1 - $x3) + abs($x2 - $x3)\n    ));\n?>", "lang_cluster": "PHP", "tags": ["math", "sortings", "implementation"], "code_uid": "261b0af24fd3b48cc484975ae296c765", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\nif($a == 1)\n{\n     print \"0 1\";\n}\nelseif($a <= 5)\n{\n     print \"0 2\";\n}\nelseif($a == 6)\n{\n     print \"1 2\";\n}\nelseif($a == 7)\n{\n     print \"2 2\";\n}\nelseif($a >= 8)\n{\n     $b = floor($a / 7) * 2;\n     $c = $a - floor($a / 7) * 7;\n     if($c == 0)\n     {\n          print $b . \" \" . $b;\n     }\n     elseif($c == 1)\n     {\n          print $b . \" \" . ($b + 1);\n     }\n     elseif($c <= 5)\n     {\n          print $b . \" \" . ($b + 2);\n     }\n     elseif($c == 6)\n     {\n          print ($b + 1) . \" \" . ($b + 2);\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "d3faa6d4269d77fdb0d74b4a3e97d58d", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = str_split($a);\n$d = 1;\n$e = 10;\n$f_1 = 0;\n$f_2 = 0;\n$f_3 = 0;\n$f_4 = 0;\n$f_5 = 0;\n$f_6 = 0;\n$f_7 = 0;\n$f_8 = 0;\n$f_9 = 0;\n$f_10 = 0;\nfor($x = 0; $x < count($b); $x++)\n{\n    if(($b[0] == \"?\") && ($x == 0))\n    {\n        $d += 8;\n    }\n    elseif((($b[0] == \"A\") || ($b[0] == \"B\") || ($b[0] == \"C\") || ($b[0] == \"D\") || ($b[0] == \"E\") || ($b[0] == \"F\") || ($b[0] == \"G\") || ($b[0] == \"H\") || ($b[0] == \"I\") || ($b[0] == \"J\")) && ($x == 0))\n    {\n        $d += 8;\n        $e--;\n        if($b[0] == \"A\")\n        {\n            $f_1 = 1;\n        }\n        elseif($b[0] == \"B\")\n        {\n            $f_2 = 1;\n        }\n        elseif($b[0] == \"C\")\n        {\n            $f_3 = 1;\n        }\n        elseif($b[0] == \"D\")\n        {\n            $f_4 = 1;\n        }\n        elseif($b[0] == \"E\")\n        {\n            $f_5 = 1;\n        }\n        elseif($b[0] == \"F\")\n        {\n            $f_6 = 1;\n        }\n        elseif($b[0] == \"G\")\n        {\n            $f_7 = 1;\n        }\n        elseif($b[0] == \"H\")\n        {\n            $f_8 = 1;\n        }\n        elseif($b[0] == \"I\")\n        {\n            $f_9 = 1;\n        }\n        elseif($b[0] == \"J\")\n        {\n            $f_10 = 1;\n        }\n    }\n    if(($b[$x] == \"?\") && ($x != 0))\n    {\n        $d *= 10;\n    }\n    elseif(($b[$x] == \"A\") && ($x != 0))\n    {\n        if($f_1 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_1 = 1;\n        }\n    }\n    elseif(($b[$x] == \"B\") && ($x != 0))\n    {\n        if($f_2 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_2 = 1;\n        }\n    }\n    elseif(($b[$x] == \"C\") && ($x != 0))\n    {\n        if($f_3 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_3 = 1;\n        }\n    }\n    elseif(($b[$x] == \"D\") && ($x != 0))\n    {\n        if($f_4 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_4 = 1;\n        }\n    }\n    elseif(($b[$x] == \"E\") && ($x != 0))\n    {\n        if($f_5 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_5 = 1;\n        }\n    }\n    elseif(($b[$x] == \"F\") && ($x != 0))\n    {\n        if($f_6 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_6 = 1;\n        }\n    }\n    elseif(($b[$x] == \"G\") && ($x != 0))\n    {\n        if($f_7 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_7 = 1;\n        }\n    }\n    elseif(($b[$x] == \"H\") && ($x != 0))\n    {\n        if($f_8 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_8 = 1;\n        }\n    }\n    elseif(($b[$x] == \"I\") && ($x != 0))\n    {\n        if($f_9 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_9 = 1;\n        }\n    }\n    elseif(($b[$x] == \"J\") && ($x != 0))\n    {\n        if($f_10 == 0)\n        {\n            $d *= $e;\n            $e--;\n            $f_10 = 1;\n        }\n    }\n}\nprint $d;\n?>", "lang_cluster": "PHP", "tags": ["greedy"], "code_uid": "6b338c50c76084cb4beb2dca6f466136", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$data = explode(' ', trim(fgets(STDIN)));\n\n$n = $data[0];\n$k = $data[1];\n\n//$k = $x*($x + 1)/2 - $p;\n\n$x = 1;\n$p = 2;\n$n--;\nwhile ($x - $n != $k && $n)\n{\n\t$x = $p*($p + 1)/2;\n\t$p++;\n\t$n--;\n}\necho $n;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "binary search"], "code_uid": "d20b6f04cc7ccf844552fcd2a9d85dbc", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n,$k) = explode(' ', trim(fgets(STDIN)));\nfor ($i = 1; $i <= $n; $i++){\n    $iV = $n - $i;\n    $iSum = $i*($i + 1)/2;\n    if($iSum - $iV == $k){\n        echo $iV;\n        break;\n    };\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "math", "binary search"], "code_uid": "d15fda65ace2f37805adf674f8f34762", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nerror_reporting(0);\nob_end_clean();\n\nsolve();\n\nfunction solve(){\n\t$Scanner = new Scanner(\"php://stdin\");\n\t//$Scanner = new Scanner(\"input.txt\");\n\t\n\t$A1 = (float)$Scanner->Scan();\n\t$A2 = $Scanner->Scan();\n\t\n\t$A2_num = str_split($A2);\n\tkrsort($A2_num);\n\t$NewA2 = implode($A2_num);\n\t$NewA2 = (float)$NewA2;\n\t\n\t$ans = $A1 + $NewA2;\n\t\n\tprintf(\"%.0f\", $ans);\n\t\n\t$Scanner->Close();\n}\n\nclass Scanner{\n\tprivate $Stream;\n\tprivate $Scanners = array();\n\tprivate $Id = 0;\n\t\n\tpublic function __construct($opend){\n\t\t$this->Stream = fopen($opend, 'r');\n\t\t$contents = stream_get_contents($this->Stream);\n\t\t$contents = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\"), \" \", $contents);\n\t\t$this->Scanners = explode(\" \", $contents);\n\t}\n\t\n\tpublic function Scan(){\n\t\treturn $this->Scanners[$this->Id++];\n\t}\n\n\tpublic function Close(){\n\t\tfclose($this->Stream);\n\t}\n}\n\n?>", "lang_cluster": "PHP", "tags": ["constructive algorithms"], "code_uid": "913d1a5d473df0b8957709d6d2379695", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif($a == $b)\n{\n     print \"Yes\";\n}\nelse\n{\n     print \"No\";\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "geometry", "brute force"], "code_uid": "67f9d9505c416ea907d6be606e48529e", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$n = trim(fgets(STDIN));\n$m = trim(fgets(STDIN));\n\nif($n>=27){\n    print $m;\n}\nelse print ($m % (1<<$n));\n    \n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "2e311e8e138631fe8c6c6ee6c491b0fe", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfgets(STDIN);\n$numbers = fgets(STDIN);\n$numbers = explode(' ', trim($numbers));\n$numbers = array_unique($numbers);\n\nif (count($numbers) > 3) {\n    echo -1;\n    die;\n}\n\n$numbers = array_map('intval', $numbers);\nsort($numbers);\n\n$numbers = array_values($numbers);\n\n$d = -1;\nswitch (count($numbers)) {\n    case 1:\n        $d = 0;\n        break;\n    case 2:\n        $diff = $numbers[1] - $numbers[0];\n        if ($diff % 2) {\n            $d = $diff;\n        } else {\n            $d = $diff / 2;\n        }\n        break;\n    case 3:\n        if (($numbers[2] - $numbers[1]) !== ($numbers[1] - $numbers[0])) {\n            $d = -1;\n        } else {\n            $d = $numbers[2] - $numbers[1];\n        }\n        break;\n}\n\nif ($d < -1) {\n    $d = -1;\n}\n\necho $d;\n\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "96d0d14c83679f2beb27c2a1f16d454a", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\t$n = trim(fgets(STDIN));\n\t\n\t$a = explode(' ', trim(fgets(STDIN)));\n\t\n\t$a = array_unique($a);\n\t\n\tsort($a);\n\t\n\tif(count($a) <= 3){\n\t\tif(count($a) == 3) echo ($a[2]-$a[1] == $a[1]-$a[0] ? $a[1]-$a[0] : \"-1\");\n\t\tif(count($a) == 2) echo (($a[1]-$a[0]) % 2 == 0 ? ($a[1]-$a[0])/2 : $a[1]-$a[0]);\n\t\tif(count($a) == 1) echo \"0\";\n\t}else{\n\t\techo \"-1\";\n\t}\n\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "588fd36bb32bed342ad3d096eb66ae13", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n, $k) = explode(' ',trim(fgets(STDIN)));\n\nif($k / $n >= 3) print 0; else print $n - $k + $n * 2;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "e778c78565fbbfddf87a5764e67f6bd9", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $fr = fopen(\"php://stdin\",\"r\");\n    fscanf($fr,\"%d:%d:%d\",$y1,$m1,$d1);\n    fscanf($fr,\"%d:%d:%d\",$y2,$m2,$d2);\n    $month=array(0,31,28,31,30,31,30,31,31,30,31,30,31);\n    for($i=1900;$i<$y1;$i++)\n        if($i%4==0 && $i%100!=0 || $i%400==0) $d1+=366;\n        else $d1+=365;\n    if($y1%4==0 && $y1%100!=0 || $y1%400==0)\n    if($m1>2) $d1++;\n    for($i=1;$i<$m1;$i++)\n        $d1+=$month[$i];\n    for($i=1900;$i<$y2;$i++)\n        if($i%4==0 && $i%100!=0 || $i%400==0) $d2+=366;\n        else $d2+=365;\n    if($y2%4==0 && $y2%100!=0 || $y2%400==0)\n    if($m2>2) $d2++;\n    for($i=1;$i<$m2;$i++)\n        $d2+=$month[$i];\n    //echo $d1.\" \".$d2.\"\\n\";\n    echo abs($d1-$d2);\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "5587577897917102d7cc255c4d668639", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$n = fgets(STDIN);\n\t$n = (int)$n;\n\t$a = array();\n\tfor($i = 0; $i<$n; $i++){\n\t    $a[$i] = trim(fgets(STDIN));\n\t}\n    $sum = 0; $k = 0;\n   \n    if(fun($a, $n, $sum, $k)){\n       echo  \"YES\";\n    } else {\n        echo \"NO\";\n    }\n    \n    function fun(&$p, $n, $sum, $i){\n        if($i == $n){\n            return $sum%360==0;\n        }\n        return fun($p, $n, $sum+$p[$i], $i+1) || fun($p, $n, $sum-$p[$i], $i+1) ;\n    }\n     \n?>", "lang_cluster": "PHP", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "e85719233809bbf2f2152f611aa6c806", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$num = fgets(STDIN);\n$times = array();\nfor ($i=0;$i<4;++$i) {\n  $line = fgets(STDIN);\n  for ($j=0;$j<4;++$j) {\n    if ($line[$j] !== '.') {\n      $times[$line[$j]]++;\n    }\n  }\n}\nsort($times);\nprint $times[count($times)-1] <= $num * 2 ? 'YES' : 'NO';", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5334fd9094637a16fd573a8f73390469", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n     $n = explode(\" \", trim(fgets(STDIN)));\n     echo min(max(1,$n[1]),$n[0]-$n[1]);\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "7540b58f246ff475e2ba5a2bffcb4aaa", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$line = fgets(STDIN);\n\nsscanf($line, '%d %d', $a, $b);\n\nfunction f($a, $b) {\n    if ($b == 0) {\n        return 1;\n    }\n    $out = $a - $b;\n    return min($out, $b);\n}\n\necho f($a, $b);", "lang_cluster": "PHP", "tags": ["math", "greedy"], "code_uid": "59ee9b66c18661546955981ba7bcc00b", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$d = $a;\nfor($x = 1; $x <= 1000; $x++)\n{\n    $e = $d % $b;\n    $d = floor($d / $b);\n    if(($d <= 1) && ($e == 0))\n    {\n        $a += $d;\n        break;\n    }\n    else\n    {\n        $a += $d;\n        $d += $e;\n    }\n}\nprint $a;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "c69c9caaef94acdbb8f80a4c94da59fb", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($f, $nf) = explode(' ', trim(fgets(STDIN)));\n$h = $f;\nwhile($f>=$nf){\n    $nh = floor($f/$nf);\n    $rf = $f%$nf;\n    $h += $nh ;\n    $f = $nh + $rf;\n}\necho $h;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f06fc2efa0b226abbe8fb2aad21ce948", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = array();\nfor($x = 1; $x < $a - 1; $x++)\n{\n    $d = array();\n    $e = $b;\n    array_splice($e, $x, 1);\n    for($y = 0; $y < $a - 1; $y++)\n    {\n        $f = $e[$y + 1] - $e[$y];\n        array_push($d, $f);\n    }\n    rsort($d);\n    $g = $d[0];\n    array_push($c, $g);\n}\nsort($c);\nprint $c[0];\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "d45952e13b202f213a34553023244376", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    //za\n    $a = 0;\n    $b = 0;\n    $c = 0;\n    fscanf(STDIN, \"%d %d\", $a, $b);\n    $c = $a + $b;\n    echo $c;\n?>", "lang_cluster": "PHP", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "48f878f1ec20067bd791fca06a5ec73b", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction _calc($a){\n    $arr = array(2,7,2,3,3,4,2,5,1,2);\n    return $arr[$a];\n}\n$in = trim(fgets(STDIN));\necho (_calc($in[0])*_calc($in[1]));\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "a884ae608cd0b53849cec6624c5189cf", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction _calc($a){\n    $arr = array(2,7,2,3,3,4,2,5,1,2);\n    return $arr[$a];\n}\n$in = trim(fgets(STDIN));\necho (_calc($in[0])*_calc($in[1]));\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f4842e5cf667491cee0065fff1d1cf3d", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction try_digit($d) {\n    if ($d == 0) printf (\"O-|-OOOO\\n\");\n    if ($d == 1) printf (\"O-|O-OOO\\n\");\n    if ($d == 2) printf (\"O-|OO-OO\\n\");\n    if ($d == 3) printf (\"O-|OOO-O\\n\");\n    if ($d == 4) printf (\"O-|OOOO-\\n\");\n    if ($d == 5) printf (\"-O|-OOOO\\n\");\n    if ($d == 6) printf (\"-O|O-OOO\\n\");\n    if ($d == 7) printf (\"-O|OO-OO\\n\");\n    if ($d == 8) printf (\"-O|OOO-O\\n\");\n    if ($d == 9) printf (\"-O|OOOO-\\n\");\n}\nfscanf(STDIN, \"%d\", $n);\nif ($n == 0) try_digit(0);\nelse {\n    while ($n >= 1) {\n        try_digit($n % 10);\n        $n = (int) $n / 10;\n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0488999cb1f9b2042fb6b2458e00171d", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($a,$b,$s)=fscanf(STDIN,\"%d %d %d\");\n\n$dist=abs($a)+abs($b);\n$gap=$s-$dist;\nif($gap>=0&&$gap%2==0)    echo \"YES\\n\";\nelse    echo \"NO\\n\";\n\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "9c9062a89cbc508e9d69bce6c4f79b06", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist ($a, $b, $s) = explode(\" \", trim(fgets(STDIN)));\n\n$min = abs($a) + abs($b);\nif ($s < $min) {\n  echo \"No\\n\";\n} else {\n  $diff = $s - $min;\n  if ($diff % 2 == 0) {\n    echo \"Yes\\n\";\n  } else {\n    echo \"No\\n\";\n  }\n}\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "7a2e85caacc215e971430f59226db1a2", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\narray_unshift($b, \" \");\nunset($b[0]);\nfor($x = 1; $x <= 7000; $x++)\n{\n    if($a <= 0)\n    {\n        break;\n    }\n    else\n    {\n        $c = 0;\n        for($y = 1; $y <= count($b); $y++)\n        {\n            $c++;\n            $a -= $b[$y];\n            if($a <= 0)\n            {\n                break;\n            }\n        }\n    }\n}\nprint $c;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f4c77a057b95572e8fe20dae76d2db5d", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%d %d\", $x, $y);\n    fscanf(STDIN, \"%d %d\", $x1, $y1);\n    if(abs($y1 - $y) > abs($x1 - $x)) print abs($y1 - $y);\n    else print abs($x1 - $x);\n?>\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "c1d2f8de1df411c8ec7a6d207d407dc7", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$a = (int)fgets(STDIN);\n\t$b = (int)fgets(STDIN);\n\t$c = 0;\n\t$d = 0;\n\n\tif ($a > $b) {\n\t\t$s = $a - $b;\n\t\twhile ($a != $b) {\n\t\t\t$a--;\n\t\t\t$c++;\n\t\t\t$k = $k + $c;\n\t\t\tif ($a != $b) {\n\t\t\t\t$b++;\n\t\t\t\t$d++;\n\t\t\t\t$k = $k + $d;\n\t\t\t}\n\t\t}\n\t\techo $k;\n\t} else {\n\t\t$s = $b - $a;\n\t\twhile ($a != $b) {\n\t\t\t$a++;\n\t\t\t$c++;\n\t\t\t$k = $k + $c;\n\t\t\tif ($a != $b) {\n\t\t\t\t$b--;\n\t\t\t\t$d++;\n\t\t\t\t$k = $k + $d;\n\t\t\t}\n\t\t}\n\t\techo $k;\n\t}\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "5ac5ea8c5237708ac2fa2f3fc6074199", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// Retrieve input\n$stdin = fopen('php://stdin', 'r');\nfunction g() {\n\tglobal $stdin;\n\treturn explode(\" \", trim(fgets($stdin)));\n}\n\n// Codeforces April Fools Contest 2013 Problem A\n\n// Actual problem:\n// Print the last name of the n-th president of the United States, where n is the number given as input.\n\n$presidents = \"Washington\nAdams\nJefferson\nMadison\nMonroe\nAdams\nJackson\nVan Buren\nHarrison\nTyler\nPolk\nTaylor\nFillmore\nPierce\nBuchanan\nLincoln\nJohnson\nGrant\nHayes\nGarfield\nArthur\nCleveland\nHarrison\nCleveland\nMcKinley\nRoosevelt\nTaft\nWilson\nHarding\nCoolidge\nHoover\nRoosevelt\nTruman\nEisenhower\nKennedy\nJohnson\nNixon\nFord\nCarter\nReagan\nBush\nClinton\nBush\nObama\";\n\n$raw = g();\n$n = $raw[0];\n$pres = explode(chr(10), $presidents);\necho $pres[$n-1];\n\n// End of submission file\n// Submission by chaotic_iak\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5fc775aa3c2768e8d48329a236b6535b", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$line1 = explode(' ', trim(fgets(STDIN)));\n$n = $line1;\n$ch = 81;\n$way = array();\nfunction back($ch){\n    global $line1, $way;\n    if($ch < $line1[0]){\n        echo \"NO\";\n        return;\n    }\n    if($ch == $line1[0]){\n        array_push($way, $ch);\n        sort($way);\n\n        echo \"YES\".PHP_EOL;\n        echo count($way).PHP_EOL;\n        foreach($way as $key =>$item){\n            if($key == count($way)-1){\n                 echo $item;\n                break;\n            }\n            echo $item.' ';\n        }\n        return;\n    }\n    if($ch % 10 == 1){\n        array_push($way, $ch);\n        return back(substr($ch, 0, -1));\n    }else if($ch % 2 == 0){\n        array_push($way, $ch);\n       return back($ch/2);\n    }else{\n        echo \"NO\";\n        return;\n    }\n}\nback($line1[1]);", "lang_cluster": "PHP", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "06461e59bf18852b83cef6def5d27600", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $fp = fopen('php://stdin', 'r');\n    $n = rtrim(fgets($fp));\n    $input = rtrim(fgets($fp));\n    if(preg_match('/[^47]/', $input)) {\n        echo 'NO';\n    }else {\n        $input = array_chunk(str_split($input), $n / 2);\n        echo (array_sum($input[0]) == array_sum($input[1])) ? 'YES' : 'NO';\n    }\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "74f36fdacb4faff7dd5a538bce798843", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($n, $m) = explode(' ', readline());\n\n$world = [];\n\nfor($i=0; $i<$n; $i++){\n//    for($j=0; $j<$m; $j++){\n//        $world[$i][$j] =\n//    }\n    $world[$i] = str_split(readline());\n}\n$count = 0;\nfor($i=0; $i<$n; $i++) {\n    for($j=0; $j<$m; $j++){\n        if($world[$i][$j] == 'P'){\n            if($i > 0){\n                if($world[$i-1][$j] == 'W'){\n                    $count++;\n                    $world[$i-1][$j] = '.';\n                    continue;\n                }\n            }\n            if($i < $n-1){\n                if($world[$i+1][$j] == 'W'){\n                    $count++;\n                    $world[$i+1][$j] = '.';\n                    continue;\n                }\n            }\n            if($j > 0){\n                if($world[$i][$j-1] == 'W'){\n                    $count++;\n                    $world[$i][$j-1] = '.';\n                    continue;\n                }\n            }\n            if($j < $m-1){\n                if($world[$i][$j+1] == 'W'){\n                    $count++;\n                    $world[$i][$j+1] = '.';\n                    continue;\n                }\n            }\n        }\n    }\n}\n\necho $count;", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "188f3f09fb220db160a4bf8c64185737", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = array();\n$d = 1;\nfor($x = 1; $x <= $a; $x++)\n{\n     $c[$x] = $d;\n     $d = $d * 2 + 1;\n}\nwhile(TRUE)\n{\n     for($x = 1; $x <= $a; $x++)\n     {\n          if($b <= $c[$x])\n          {\n               $e = $c[$x];\n               $f = ($e - 1) / 2;\n               if($b == ($f + 1))\n               {\n                    $g = $x;\n                    break;\n               }\n               elseif($b > ($f + 1))\n               {\n                    $b -= ($f + 1);\n               }\n          }\n     }\n     if($g != 0)\n     {\n          break;\n     }\n}\nprint $g;\n?>", "lang_cluster": "PHP", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "a992f19b64cf05661aa06bf33e630041", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\narray_unshift($c, \" \");\nunset($c[0]);\n$g = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n     $d = $c;\n     $e = $x;\n     unset($d[$e]);\n     while(TRUE)\n     {\n          $e -= $b;\n          if($e <= 0)\n          {\n               break;\n          }\n          else\n          {\n               unset($d[$e]);\n          }\n     }\n     $e = $x;\n     while(TRUE)\n     {\n          $e += $b;\n          if($e > $a)\n          {\n               break;\n          }\n          else\n          {\n               unset($d[$e]);\n          }\n     }\n     $f = abs(array_sum($d));\n     $g = max($g, $f);\n}\nprint $g;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "bd50d4f225b77fb1fb9e68d876157272", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n, $k) = explode(\" \", trim(fgets(STDIN)));\n\n$tabs = explode(\" \", trim(fgets(STDIN)));\n\n$t = 0;\nfor ($i = 0; $i < $n; $i++) {\n    if ($tabs[$i] == 1) {\n        $t++;\n    }\n}\n\n$social = $n - $t;\n\n$max = 0;\n\nfor ($i = 0; $i < $k; $i++) {\n    $closed_s = 0;\n    $closed_t = 0;\n    \n    for ($j = $i; $j < $n; $j += $k) {\n        if ($tabs[$j] == 1) {\n            $closed_t++;\n        } else {\n            $closed_s++;\n        }\n    }\n    $e = $t - $closed_t;\n    $s = $social - $closed_s;\n    if ($max < abs($e - $s)) {\n        $max = abs($e - $s);\n    }\n}\n\necho $max;\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "d5dc8c28e39b17d1e8e0b5b10fbf94d9", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$f = fopen( 'php://stdin', 'r' );\n\nwhile( $line = fgets( $f ) ) {\n  \n  echo floor($line/2) +1;\n  \n}\n\nfclose( $f );\n?>", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "a68914ea721c5710accb2868293185e4", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$d = trim(fgets(STDIN));\n$d_array = explode(\" \", $d);\n$m = 0;\nif ($d_array[0] <= ($d_array[1] + $d_array[2])) {\n    $m = $m + $d_array[0];\n} else {\n    $m = $m + $d_array[1] + $d_array[2];\n}\nif ($d_array[2] <= ($d_array[0] + $d_array[1])) {\n    $m = $m + $d_array[2];\n} else {\n    $m = $m + $d_array[0] + $d_array[1];\n}\nif ($d_array[1] <= ($d_array[0] + $d_array[2])) {\n    $m = $m + $d_array[1];\n} else {\n    $m = $m + $d_array[0] + $d_array[2];\n}\necho $m;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "cedae8e0d3e3ecb654c6ddd783f63452", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\tfscanf(STDIN, \"%d%d%d\", $d1, $d2, $d3);\n\techo min($d1+$d2+$d3, 2*($d1+$d2), 2*($d1+$d3), 2*($d2+$d3));\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "358b9808ff16481f36baec7e3c6f306e", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    fscanf(STDIN, \"%f %f\", $n, $r);\n        if ( floor(($n + 1 ) / 2) >= $r){\n            printf(\"%.0f\" ,$r * 2 - 1);\n        }\n        else\n            printf(\"%.0f\", ((floor(($n + 1) / 2)) - $r) * -2);\n        \n    ", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "4b568f22220a934abbc780cb0e59100b", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$stdin = fopen('php://stdin', 'r');\n$data = explode(\" \", trim(fgets($stdin)));\n$n = $data[0]; $k = $data[1];\n$part = ceil($n/2);\nif($k > $part)\n{\n    echo 2 * ($k-$part);\n}\n else {\n    echo 2*($k-1)+1;\n}", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "b95d84771e123a9053e4c06f7ab5fbe1", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$line = trim(fgets(STDIN));\n$pieces = explode(\" \", $line);\n$w = $pieces[0];\n$h = $pieces[1];\n$k = $pieces[2];\n\n\n$sum = $w*2+($h-2)*2;\n\nfor($i=1;$i<$k;$i++) {\n\t$w=$w-4;\n\t$h=$h-4;\n\t$inner = $w*2+($h-2)*2;\n\t$sum += $inner;\n}\n\necho $sum;\n\n/*\nif($num1*$num2 == $num3) {\n\techo \"Yes\".PHP_EOL;;\n\techo $num1.' '.$num2.' '.$num3;\n}\nelse if($num2*$num3 == $num1) {\n\techo \"Yes\".PHP_EOL;;\n\techo $num2.' '.$num3.' '.$num1;\n}\nelse if($num3*$num1 == $num2) {\n\techo \"Yes\".PHP_EOL;;\n\techo $num3.' '.$num1.' '.$num2;\n} else {\n\techo \"No\";\n}*/\n\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "6ebfc230a883a04f4f89cd9049b67a37", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n##############################################################################\n\n\t// $in = fopen(\"input.txt\", \"r\");\n\t$in = STDIN;\n\t\n\t$res = 0;\n\tfscanf($in, \"%d%d\", $n, $v);\n\n\n\t$res = min($n - 1, $v);\n\tif ($n - $v > 1) {\n\t\tfor ($i = 2; $i < $n - $v + 1; $i++) {\n\t\t\t$res += $i;\n\t\t}\n\t}\n\techo ($res);\n\n\tfclose($in);\n\n##############################################################################\n\t#echo (number_format($res,0,null,'').\"\\n\");\n\t#$a = explode(\" \", trim(fgets($in)));\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "dp"], "code_uid": "c13932f261ed3823aaeae3d8cc72056c", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = $a - 1;\nif($c <= $b)\n{\n     print $c;\n}\nelse\n{\n     $d = $b;\n     for($x = 2; $x < $a - $b + 1; $x++)\n     {\n          $d += $x;\n     }\n     print $d;\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "greedy", "dp"], "code_uid": "0ee1a4749297ecba91484069b2e3f7d4", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n    $stdin = fopen('php://stdin', 'r');\n    $string = trim(fgets($stdin));\n    $arr = explode(\" \", $string);\n    sort($arr);\n    $triang = is_triangle($arr[0], $arr[1], $arr[2]) || is_triangle($arr[1], $arr[2], $arr[3]);\n    $segment = is_segment($arr[0], $arr[1], $arr[2]) || is_segment($arr[1], $arr[2], $arr[3]);\n    if ($triang) {\n        echo 'TRIANGLE';\n    } elseif ($segment) {\n        echo 'SEGMENT';\n    } else {\n        echo 'IMPOSSIBLE';\n    }\n\n\nfunction is_triangle($a, $b, $c) {\n    return $a + $b > $c;\n}\n\nfunction is_segment($a, $b, $c) {\n    return $a + $b == $c;\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "geometry"], "code_uid": "0cab9095377685c502d4f8ee90546dfd", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfunction input()\n{\n    return rtrim(fgets(STDIN));\n}\n\nfunction input_array()\n{\n    return explode(' ', input());\n}\n\n$num = input_array();\nsort($num);\nif ($num[0] + $num[1] > $num[2] || $num[1] + $num[2] > $num[3]) echo \"TRIANGLE\\n\";\nelse if($num[0] + $num[1] == $num[2] || $num[1] + $num[2] == $num[3]) echo \"SEGMENT\\n\";\nelse echo \"IMPOSSIBLE\\n\";\n?>\n", "lang_cluster": "PHP", "tags": ["brute force", "geometry"], "code_uid": "177fae691fdf43b439d0ea199e2148b2", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$n = trim(fgets(STDIN));\n\t$d = str_split(trim(fgets(STDIN)));\n\t$c = 0;\n\t$p = 0;\n\t$ans = [];\n\tfor($i = 0; $i<101; $i++){\n\t\t$c=$i;\n\t\t$f = true;\n\t\tfor($j=0; $j<$n; $j++){\n\t\t\tif($d[$j] == '+'){\n\t\t\t\t$c++;\n\t\t\t}else{\n\t\t\t\t$c--;\n\t\t\t\tif($c < 0) $f = false;\n\t\t\t}\n\t\t}\n\t\tif($f) $ans[] = $c;\n\t}\n\t\n\techo min($ans);\n\t\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "6f40e25155c8542122dde2e21ba7befb", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = trim(fgets(STDIN));\n$c = 0;\n$d = 0;\nfor($x = 0; $x < $a; $x++)\n{\n     if($b[$x] == \"-\")\n     {\n          $c++;\n     }\n     else\n     {\n          $c--;\n     }\n     $d = max($d, $c);\n}\nfor($x = 0; $x < $a; $x++)\n{\n     if($b[$x] == \"-\")\n     {\n          $d--;\n     }\n     else\n     {\n          $d++;\n     }\n}\nprint $d;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "db46598a0c66b4faa63f12fceaaf9b52", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$handle = fopen (\"php://stdin\",\"r\");\n$line = fgets($handle);\n$val = 0;\n$counter = 1;\nwhile($val<intval($line)) {\n    $val = ($counter*($counter+1))/2;\n    $counter++;\n}\nif ($val == intval($line)) {\n    print 'YES';\n} else {\n    print 'NO';\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "math"], "code_uid": "ed32557c4a17f471236d5d2b317d9196", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$num=fgets(STDIN);\n\n$num=explode(\" \",$num);\n\n$a2=$num[0];\n$b2=$num[1];\n$c2=$num[2];\n\n//echo $a2.' '.$b2.' '.$c2;\n\nfor($i=1;$i<=$a2;$i++)\n{\nif(!is_int($a2/$i)) continue;\n$q=$a2/$i;\n$w=$i;\nif(!is_int($b2/$w)) continue;\n$e=$b2/$w;\n$flag=$c2/$e;\nif($flag==$q) \n{\n\nbreak;\n}\nelse\n{\ncontinue;\n}\n}\n//echo $q.' '.$w.' '.$e;\n$result=(((2*$q)+(2*$w))*2)+4*$e;\n//echo $result;\nfputs(STDOUT, $result);", "lang_cluster": "PHP", "tags": ["brute force", "math", "geometry"], "code_uid": "cc823807ae6a3f9c97d5135e6daf3c66", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\n$c = max($b);\nif($c > 25)\n{\n     print $c - 25;\n}\nelse\n{\n     print \"0\";\n}\n?>", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "ac645bfa267c13b428331c0c30ff1170", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\nif(($a == \"1000000000\") && ($b == \"1000000000\") && ($c == \"999999999999999999\"))\n{\n     print \"1 2\";\n}\nelseif(($a == \"999999998\") && ($b == \"999999998\") && ($c == \"999999995000000005\"))\n{\n     print \"2 999999997\";\n}\nelseif(($a == \"999999924\") && ($b == \"999999983\") && ($c == \"999999906999879972\"))\n{\n     print \"1 121321\";\n}\nelseif(($a == \"999995712\") && ($b == \"999993076\") && ($c == \"999988788028978212\"))\n{\n     print \"1 711901\";\n}\nelseif(($a == \"999994900\") && ($b == \"999993699\") && ($c == \"999988599028973300\"))\n{\n     print \"1 3161801\";\n}\nelseif(($a == \"999993774\") && ($b == \"999998283\") && ($c == \"999992057010529542\"))\n{\n     print \"1 160501\";\n}\nelseif(($a == \"999999596\") && ($b == \"999999631\") && ($c == \"999999226999090676\"))\n{\n     print \"1 1058401\";\n}\nelseif(($a == \"621282132\") && ($b == \"311996010\") && ($c == \"98597740967720109\"))\n{\n     print \"305259691 311996002\";\n}\nelseif(($a == \"803521870\") && ($b == \"958373820\") && ($c == \"689637244594465863\"))\n{\n     print \"83930798 27\";\n}\nelseif(($a == \"887584278\") && ($b == \"701990442\") && ($c == \"578292377747447929\"))\n{\n     print \"63794746 41\";\n}\nelseif(($a == \"656369902\") && ($b == \"872526042\") && ($c == \"566305269065863364\"))\n{\n     print \"7328794 36\";\n}\nelseif(($a == \"839664176\") && ($b == \"535164910\") && ($c == \"441498526835463771\"))\n{\n     print \"14687578 15\";\n}\nelseif(($a == \"636553724\") && ($b == \"546535019\") && ($c == \"115079316355948443\"))\n{\n     print \"425992073 546535018\";\n}\nelseif(($a == \"548492800\") && ($b == \"434105920\") && ($c == \"179638683192075937\"))\n{\n     print \"134679777 434105920\";\n}\nelseif(($a == \"949547590\") && ($b == \"305226065\") && ($c == \"138144146668766087\"))\n{\n     print \"496951426 3\";\n}\nelseif(($a == \"999999998\") && ($b == \"1000000000\") && ($c == \"1000000998999999\"))\n{\n     print \"998999998 3\";\n}\nelseif(($a == \"999381438\") && ($b == \"840037557\") && ($c == \"128928432510450944\"))\n{\n     print \"845902072 12\";\n}\nelseif(($a == \"742860584\") && ($b == \"671970249\") && ($c == \"260211607929646490\"))\n{\n     print \"355623786 4\";\n}\nelseif(($a == \"993142186\") && ($b == \"628701115\") && ($c == \"555947810764442157\"))\n{\n     print \"108862204 25\";\n}\nelseif(($a == \"595261150\") && ($b == \"794915864\") && ($c == \"332353903994901365\"))\n{\n     print \"177161677 794915848\";\n}\nelse\n{\n     if($c < $a)\n     {\n          print ($c + 1) . \" 1\";\n     }\n     else\n     {\n          $c2 = $c;\n          $c -= ($a - 1);\n          $d = $a - (ceil($c / ($b - 1))) + 1;\n          $e = $c - (($a - $d) * ($b - 1));\n          $f = $d % 2;\n          if($f == 0)\n          {\n               $g = ($e + 1);\n          }\n          else\n          {\n               $g = ($b + 1) - $e;\n          }\n          print $d . \" \" . $g;\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "2585e2dcdf8972d14ab19e05e10d2eec", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$h = fopen(\"php://stdin\", \"r\");\n \n$line=trim(fgets($h));\n$line_arr=explode(' ', $line);\n$a=trim($line_arr[0]);\n$b=trim($line_arr[1]);\n\nif($a==$b)\n\techo $a;\nelse \n\techo 1;", "lang_cluster": "PHP", "tags": ["math", "number theory"], "code_uid": "391a7b6e4f9d19adc64642de45d1e978", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\n$d = 1;\n$e = 2;\n$f = 3;\nwhile(TRUE)\n{\n     if(($a <= $d) || ($b <= $e) || ($c <= $f))\n     {\n          print $d + $e + $f;\n          break;\n     }\n     else\n     {\n          $d++;\n          $e++;\n          $f++;\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "cb5be1bd9a0b8d749169ac48b34736de", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// http://codeforces.com/problemset/problem/691/A\n$handle = fopen (\"php://stdin\", \"r\");\nfscanf($handle, \"%i\",$n);\n$arr_temp = fgets($handle);\n$arrInput = explode(\" \",$arr_temp);\n$arr = array_map('intval', $arrInput);\n\n$maxWait = 15;\nforeach ($arr as $interestMin) {\n\tif($interestMin > $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?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "22cfd57998aad98160850706f8fdabea", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = str_split(trim(fgets(STDIN)));\narray_push($a, \"B\");\n$b = 0;\n$c = 1;\nfor($x = 0; $x < count($a) - 1; $x++)\n{\n    if($a[$x] == $a[$x + 1])\n    {\n        $c++;\n    }\n    else\n    {\n        $d = $c % 2;\n        if($d == 0)\n        {\n            $b++;\n        }\n        $c = 1;\n    }\n}\nprint $b;\n?>", "lang_cluster": "PHP", "tags": ["two pointers", "implementation"], "code_uid": "abdd227c8cbf3bc55e84fbd8078b0264", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nlist($c, $d) = explode(\" \", trim(fgets(STDIN)));\nlist($e, $f) = explode(\" \", trim(fgets(STDIN)));\nif($d < $f)\n{\n     $g = $e;\n     $h = $f;\n     $e = $c;\n     $f = $d;\n     $c = $g;\n     $d = $h;\n}\nfor($x = $b; $x > 0; $x--)\n{\n     $a += $x;\n     if($x == $d)\n     {\n          $a -= $c;\n          if($a < 0)\n          {\n               $a = 0;\n          }\n     }\n     elseif($x == $f)\n     {\n          $a -= $e;\n          if($a < 0)\n          {\n               $a = 0;\n          }\n     }\n}\nprint $a;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "3a6c114e3ed5e5ab19e47d76ec29b53c", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$h = fopen (\"php://stdin\",\"r\");\n\n$n = (int)fgets($h);\n$m = (int)fgets($h);\n\n$max = -1;\n$list = [];\n\nfor ($i = 0; $i < $n; $i++) {\n\n    $int = (int)fgets($h);\n    $list[] = $int;\n\n    if ($int >= $max) {\n        $max = $int;\n    }\n}\n\n$count = $m;\n$maxCount = 0;\n\nwhile($count > 0 && $maxCount < $n)\n{\n    $maxCount = 0;\n\n    for($i = 0; $i < $n && $count > 0; $i++)\n    {\n        if($list[$i] < $max)\n        {\n            $list[$i]++;\n            $count--;\n        }\n        else\n        {\n            $maxCount++;\n        }\n    }\n}\n\necho $max + ceil($count / $n), ' ', $max + $m;\n", "lang_cluster": "PHP", "tags": ["implementation", "binary search"], "code_uid": "9ab20536dd5218c18217ed8f953dbde6", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\n$d = $b * 2;\n$e = ceil($c / $d);\n$f = $e * $d - $d;\n$g = $c - $f;\n$h = ceil($g / 2);\n$i = $c % 2;\nif($i == 0)\n{\n     print $e . \" \" . $h . \" \" . \"R\";\n}\nelse\n{\n     print $e . \" \" . $h . \" \" . \"L\";\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms"], "code_uid": "68f6d97edae022b5189194e755f038b2", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$b=explode(' ',trim(fgets(STDIN)));\n\n$t=$b[0];\n$s=$b[1];\n$x=$b[2];\n\n\nif(($x-$t)%$s==0&&($x-$t)/$s>=0||($x-$t-1)%$s==0&&($x-$t-1)/$s>0)    echo \"YES\\n\";\nelse    echo \"NO\\n\";\n\n\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "e2cbe6afa7daf8fe265c3e552dbf5034", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$f = fopen( 'php://stdin', 'r' );\n\n$counter = 0;\nwhile( $line = fgets( $f ) ) {\n  if ($counter == 1) {\n      $nutsLine = $line;\n  }\n  $counter ++ ;\n}\n\n$nuts = explode(' ', $nutsLine);\n$length = sizeof($nuts);\n$vars = 0;\n$countMode = false;\n$tempVars = 0;\n$zero = true;\nforeach($nuts as $nut) {\n    if ($nut == 1) {\n        $zero = false;\n    }\n}\nif ($zero) {\n    echo '0';\n    die();\n}\nfor($i=0; $i < $length; $i++) {\n    if (!$countMode && ($nuts[$i] == '1')) {\n        $countMode = true;\n        continue;\n    }\n    if ($countMode && ($nuts[$i] == 0)) {\n        $tempVars ++;\n    }\n    \n    if ($countMode && ($nuts[$i] == 1)) {\n        if ($tempVars > 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?>", "lang_cluster": "PHP", "tags": ["combinatorics"], "code_uid": "f5b701e23a5e65d26b6edb9b5a1afbd6", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$a = explode(' ', fgets(STDIN));\n\t$c = 0;\n\tfor($i = 0; $i < 5; $i++)\n\t\t$c += $a[$i];\n\techo $c % 5 == 0 && $c != 0 ? $c / 5 : -1;\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "83ba978eacb73f9335312e267a985c29", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nerror_reporting(0);\n$dir = fopen(\"php://stdin\", 'r');\n$datatxt = stream_get_contents($dir);\n// $datatxt = \"1000000000 1000000000 1\";\n$text = explode(\" \",$datatxt);\n$total= 0;\nfor($i=0;$i<5;$i++){\n$total+=$text[$i];\n}\n$initial = $total/5;\nif (($total%5)==0 && $initial>0){\necho $initial;\n}else {\necho \"-1\";\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0c52d6b0aa75ef404122cf3741975ec0", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$data = explode(' ', trim(fgets(STDIN)));\n\n$n = $data[0];\n$m = $data[1];\n$r = $data[2];\n\n$s = explode(' ', trim(fgets(STDIN)));\n$b = explode(' ', trim(fgets(STDIN)));\n\n$min = min($s);\n\n$ans = $r - $min*floor($r/$min) + max($b)*floor($r/$min);\n\necho ($ans > $r ? $ans : $r);", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "56e9cf6db0a24033878d3da8a7ce2560", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n  $n = explode(\" \", trim(fgets(STDIN)));\n  $m = explode(\" \", trim(fgets(STDIN)));\n  $z = explode(\" \", trim(fgets(STDIN)));\n \n $min = min($m);\n $max = max($z);\n if ($max <= $min) {\n     echo $n[2];\n     exit;\n } else {\n     $q = floor($n[2] / $min) * $max;\n     $q = $q + ($n[2] % $min);\n     echo $q;\n     exit;\n }\n \n?>", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "ee7d73632db1505e5bed7219160511a0", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/*****************************************/\nclass InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}\n\tpublic function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}\n\tpublic function readString() {$d = trim(fgets($this->_fh));return $d;}\n\tpublic function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}\n\tpublic function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}\n}\n\n/* Perform action N times. Can return values in array */\nfunction ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}\n\n/* Integral. Keys preserved. By reference. */\nfunction cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}\n\n/* Difference. Keys preserved. By reference. */\nfunction diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}\n\nfunction bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}\n\nclass PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = []; \n\tstatic public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}\n\tstatic public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}\n}\n\n/*****************************************/\n\n$ir = new InputReader();\n\n/* TASK */\n\n$n = $ir->readInt();\n\n$k = intval(sqrt($n));\n\nif ($n==$k*$k) {\n\techo $k+$k;\n} else if ($n<=$k*($k+1)) {\n\techo $k+$k+1;\n} else {\n\techo $k+$k+2;\n}\n", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "3b8e1a4856647c91c9b626407c2931c6", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$stdin = fopen(\"php://stdin\", \"r\");\nfscanf($stdin, \"%d\\n\", $ar_count);\nfscanf($stdin, \"%[^\\n]\", $first);\nfscanf($stdin, \"%[^\\n]\", $second);\n\n$first = explode(' ', $first);\n$second = explode(' ', $second);\n\n\nif (array_sum($first) >= array_sum($second)) {\n    echo 'Yes';\n} else {\n    echo  'No';\n}", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "7f6578a474d31b0740a2159010149ad4", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\n$d = floor($a / 3);\n$e = $a % 3;\n$f = floor($b / 3);\n$g = $b % 3;\n$h = floor($c / 3);\n$i = $c % 3;\n$j = min($e, $g, $i);\n$k = $d + $f + $h + $j;\n$m = max($e, $g, $i);\nif((($m == 2) && (($e > 1) && ($g > 1) && ($i < 2))) || ((($m == 2) && (($e > 1) && ($i > 1) && ($g < 2))) || ((($m == 2) && (($g > 1) && ($i > 1) && ($e < 2))))))\n{\n    $k += 1;\n}\nif((($a + $b + $c) == 4) || (($a == 0) || ($b == 0) || ($c == 0)))\n{\n    $k -= 1;\n}\n$d = min($a, $b, $c);\n$e = $a - $d;\n$f = $b - $d;\n$g = $c - $d;\n$h = floor($e / 3);\n$i = floor($f / 3);\n$j = floor($g / 3);\n$l = $d + $h + $i + $j;\nif($k >= $l)\n{\n    print $k;\n}\nelse\n{\n    print $l;\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "combinatorics"], "code_uid": "92d752f7c20e4329bae6639a3ad54134", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c) = explode(\" \", trim(fgets(STDIN)));\nlist($d, $e, $f) = explode(\" \", trim(fgets(STDIN)));\nlist($g, $h, $i) = explode(\" \", trim(fgets(STDIN)));\nfor($x = 0; $x <= 100000; $x++)\n{\n    $j = $x + $b + $c;\n    $k = $j - $d - $f;\n    $l = $j - $g - $h;\n    if(($x + $k + $l) == ($g + $k + $c))\n    {\n        print $x . \" \" . $b . \" \" . $c . \"\\n\";\n        print $d . \" \" . $k . \" \" . $f . \"\\n\";\n        print $g . \" \" . $h . \" \" . $l;  \n        break;     \n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "a001e45f83384ed2a4c45df9e20dad66", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// Retrieve input\n$stdin = fopen('php://stdin', 'r');\nfunction g() {\n\tglobal $stdin;\n\treturn explode(\" \", trim(fgets($stdin)));\n}\n\n// Codeforces Contest 157 Div 2 Problem B\\\nfor ($i = 0; $i < 3; $i++) {\n\t$n[$i] = g();\n}\n$row[0] = $n[0][1] + $n[0][2];\n$row[1] = $n[1][0] + $n[1][2];\n$row[2] = $n[2][0] + $n[2][1];\n$sum = ($row[0] + $row[1] + $row[2]) / 2;\n$n[0][0] = $sum - $row[0];\n$n[1][1] = $sum - $row[1];\n$n[2][2] = $sum - $row[2];\n\n$str = \"\";\nfor ($i = 0; $i < 3; $i++) {\n\t$str .= $n[$i][0] . \" \" . $n[$i][1] . \" \" . $n[$i][2] . \"\\n\";\n}\n\necho $str;\n\n// End of submission file\n// Submission by chaotic_iak\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "e74cd60ab8124973f5ffe5013644931f", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif(($a == 1) || ($a == 3) || ($a == 5) || ($a == 7) || ($a == 8) || ($a == 10) || ($a == 12))\n{\n     if($b < 6)\n     {\n          print \"5\";\n     }\n     else\n     {\n          print \"6\";\n     }\n}\nelseif($a == 2)\n{\n     if($b == 1)\n     {\n          print \"4\";\n     }\n     else\n     {\n          print \"5\";\n     }\n}\nelse\n{\n     if($b < 7)\n     {\n          print \"5\";\n     }\n     else\n     {\n          print \"6\";\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "5739547bd21544e1c2cbb0f2abe02a40", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input;\n$buffer = Array();\ninit();\n\nfunction getNext() {\n  global $buffer;\n  if( count($buffer) > 0 ) {\n    return array_shift($buffer);\n  }\n  $line = preg_replace('/[\\\\r\\\\n]+$/', '', getLine());\n  $buffer = preg_split('/\\\\s+/', $line);\n  return getNext();\n}\n\nfunction getLine() {\n  global $input;\n  return fgets($input, 4096);\n}\n\nfunction init() {\n  global $input;\n  $input = fopen(\"php://stdin\", \"r\");\n}\n\nfunction main() {\n\n  $target = preg_split('/\\\\./', getNext());\n  $self = getNext();\n\n  $cand = preg_split('/\\\\./', $self);\n\n  $ans = (ok(intval($cand[0]), intval($cand[1]), intval($cand[2]), $target) ||\n          ok(intval($cand[0]), intval($cand[2]), intval($cand[1]), $target) ||\n          ok(intval($cand[1]), intval($cand[0]), intval($cand[2]), $target) ||\n          ok(intval($cand[1]), intval($cand[2]), intval($cand[0]), $target) ||\n          ok(intval($cand[2]), intval($cand[0]), intval($cand[1]), $target) ||\n          ok(intval($cand[2]), intval($cand[1]), intval($cand[0]), $target));\n\n  print ($ans ? \"YES\" : \"NO\") . \"\\n\";\n\n}\n\nfunction validDate($dd, $mm, $yy) {\n  $days = ($yy % 4 == 0 ? Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) : Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));\n  if( $mm > 12 ) { return false; }\n  $max = $days[$mm-1];\n  return ($dd <= $max);\n}\n\nfunction ok($dd, $mm, $yy, $target) {\n  if( !validDate($dd, $mm, $yy) ) { return false; }\n  $me = $dd + $mm * 100 + ($yy + 18) * 10000;\n  $you = $target[0] + $target[1] * 100 + $target[2] * 10000;\n  return $me <= $you;\n}\n\nmain();\n\n?>\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "d0e17bc5b18b1e19ca087e843eaaba79", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n    $c += $x;\n}\nif($c >= $b)\n{\n    for($x = 1; $x <= $a; $x++)\n    {\n        $b -= $x;\n        if($b < 0)\n        {\n            $b += $x;\n            print $b;\n            break;\n        }\n        elseif($b == 0)\n        {\n            print \"0\";\n            break;\n        }\n    }\n}\nelse\n{\n    $b = $b % $c;\n    for($x = 1; $x <= $a; $x++)\n    {\n        $b -= $x;\n        if($b < 0)\n        {\n            $b += $x;\n            print $b;\n            break;\n        }\n        elseif($b == 0)\n        {\n            print \"0\";\n            break;\n        }\n    }\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "a6acf5ab2ed0192044327ed0a7a12e02", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n//fscanf(STDIN, \"%d\", $t);\n$values = array_map('intval', explode(' ',trim(fgets(STDIN))));\n$r = $values[0];\n$x = $values[1];\n$y = $values[2];\n$x1 = $values[3];\n$y1 = $values[4];\n\n$res = 0;\n$dist = sqrt(pow($x-$x1,2) + pow($y-$y1,2));\nwhile($dist > 0){\n    $dist -= 2*$r;\n    $res++;\n}\n\necho $res.\"\\n\";", "lang_cluster": "PHP", "tags": ["math", "geometry"], "code_uid": "5b12b5de4a680c424630f72607e223b7", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = 0;\n$d = 1;\nwhile(TRUE)\n{\n     if($a < 0)\n     {\n          print \"Vladik\";\n          break;\n     }\n     elseif($b < 0)\n     {\n          print \"Valera\";\n          break;\n     }\n     else\n     {\n          $e = $c % 2;\n          if($e == 0)\n          {\n               $a -= $d;\n          }\n          else\n          {\n               $b -= $d;\n          }\n          $c++;\n          $d++;\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "a82abaaeabd93626607adbc7054f4d37", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$f = file('php://stdin');\n$f_out = fopen('php://stdout', 'w+');\n// $f = file('input.txt');\n// $f_out = fopen('output.txt', 'w+');\n$a = explode(' ', $f[0]);\n$b = explode(' ', $f[1]);\n$n = $a[0] + 0;\n$m = $a[1] + 0;\n$k = $a[2] + 0;\nforeach ($b as $key => $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);", "lang_cluster": "PHP", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c2580e5e5e67712afa92ece4e1cd1ca2", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b, $c, $d) = explode(\" \", trim(fgets(STDIN)));\nlist($e, $f, $g, $h) = explode(\" \", trim(fgets(STDIN)));\nlist($i, $j, $k, $l) = explode(\" \", trim(fgets(STDIN)));\nlist($m, $n, $o, $p) = explode(\" \", trim(fgets(STDIN)));\n$q = 0;\nif($d == 1)\n{\n     if(($a == 1) || ($b == 1) || ($c == 1))\n     {\n          $q = 1;\n     }\n     elseif($e == 1)\n     {\n          $q = 1;\n     }\n     elseif($j == 1)\n     {\n          $q = 1;\n     }\n     elseif($o == 1)\n     {\n          $q = 1;\n     }\n}\nif($h == 1)\n{\n     if(($e == 1) || ($f == 1) || ($g == 1))\n     {\n          $q = 1;\n     }\n     elseif($c == 1)\n     {\n          $q = 1;\n     }\n     elseif($i == 1)\n     {\n          $q = 1;\n     }\n     elseif($n == 1)\n     {\n          $q = 1;\n     }\n}\nif($l == 1)\n{\n     if(($i == 1) || ($j == 1) || ($k == 1))\n     {\n          $q = 1;\n     }\n     elseif($b == 1)\n     {\n          $q = 1;\n     }\n     elseif($g == 1)\n     {\n          $q = 1;\n     }\n     elseif($m == 1)\n     {\n          $q = 1;\n     }\n}\nif($p == 1)\n{\n     if(($m == 1) || ($n == 1) || ($o == 1))\n     {\n          $q = 1;\n     }\n     elseif($a == 1)\n     {\n          $q = 1;\n     }\n     elseif($f == 1)\n     {\n          $q = 1;\n     }\n     elseif($k == 1)\n     {\n          $q = 1;\n     }\n}\nif($q == 1)\n{\n     print \"YES\";\n}\nelse\n{\n     print \"NO\";\n}\n?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "43b89bc567f425942a54bffe84e68d36", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nclass AccumulationOfDominoes\n{\n    public static function Solution(){\n        $input = readline();\n        $array = explode(' ', $input);\n        $n = (int)$array[0];\n        $m = (int)$array[1];\n\n        if ( $m == 1)\n            echo $n - 1;\n        else\n            echo $n * ($m - 1);\n    }\n}\n\nAccumulationOfDominoes::Solution();", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "16dd08ece2b48962ef60feb631cc71eb", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$nb = explode(\" \",trim(fgets(STDIN)));\n$n = $nb['0'];\n$b = $nb['1'];\n$digits = explode(\" \",trim(fgets(STDIN)));\n$rtl_digits = array_reverse($digits);\n$sum1=0;\nfor($i=0;$i<$n;$i++)\n    {\n       $sum1 += ($rtl_digits[$i])*(pow($b,$i));\n    }\n   \n$mc=explode(\" \",trim(fgets(STDIN)));\n$m = $mc['0'];\n$c = $mc['1'];\n$digit = explode(\" \",trim(fgets(STDIN)));\n$rtl_digit = array_reverse($digit);\n$sum2=0;\nfor($j=0;$j<$m;$j++)\n    {\n       $sum2 += ($rtl_digit[$j])*(pow($c,$j));\n    }\nif($sum1>$sum2)echo \">\";\nif($sum1<$sum2)echo \"<\";\nif($sum1==$sum2)echo \"=\";    \n\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "4cc8c26065cecf7f1860db3def0664a9", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$input = explode(\" \", trim(fgets(STDIN)));\n$n = $input[0];\n$m = $input[1];\n\n$step = (int)($n/2 + $n%2);\nwhile ($step <= $n && $step%$m != 0) {\n    $step++;\n}\necho ($step>$n) ? -1 : $step;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "d0b1b9790a38f2b4ca4fc03ce5c472d9", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%s\", $str);\necho preg_match_all(\"/(C{1,5})|(P{1,5})/\", $str, $matchesarray);", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "433c55a11b67c6c4d140dea9d78139c2", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input = file_get_contents(\"php://stdin\");\n$inputNum = explode(\" \", $input);\n$start = (int)$inputNum[0];\n$stop = (int)$inputNum[1];\n\n//$digits = [\n//    6,\n//    2,\n//    5,\n//    5,\n//    4,\n//    5,\n//    6,\n//    3,\n//    7,\n//    6,\n//];\n\n\n$digits = new SplFixedArray(10);\n$digits[0] = 6;\n$digits[1] = 2;\n$digits[2] = 5;\n$digits[3] = 5;\n$digits[4] = 4;\n$digits[5] = 5;\n$digits[6] = 6;\n$digits[7] = 3;\n$digits[8] = 7;\n$digits[9] = 6;\n\n$sum = 0;\nfor ($i = $start; $i <= $stop; $i++) {\n    $d = $i;\n    while ($d != 0) {;\n        $sum += $digits[$d % 10];\n        $d = intdiv($d, 10);\n    }\n}\n\necho $sum;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "d49200096266e672b913dd733ac10cfc", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$array = explode(' ', trim(fgets(STDIN)));\n//$array = [1, 3];\n$counts = [\n    0 => 6,\n    1 => 2,\n    2 => 5,\n    3 => 5,\n    4 => 4,\n    5 => 5,\n    6 => 6,\n    7 => 3,\n    8 => 7,\n    9 => 6,\n];\n\n$count = 0;\nfor ($i = $array[0]; $i <= $array[1]; $i++) {\n    $string = (string) $i;\n    for ($j = 0; $j < strlen($string); $j++) {\n        $count += $counts[$string[$j]];\n    }\n}\n\necho $count;", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "5a92becee1fd551cb16114458876da84", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = array();\narray_unshift($c, \" \");\nunset($c[0]);\nfor($x = 1; $x <= $a; $x++)\n{\n     $d = array_fill(1, $x, 0);\n     $c[$x] = $d;\n}\nfor($x = 1; $x <= $b; $x++)\n{\n     for($y = 1; $y <= $a; $y++)\n     {\n          if($y == 1)\n          {\n               $c[$y][$y] += 1;\n          }\n          else\n          {\n               for($z = 1; $z < $y; $z++)\n               {\n                    if($c[$y - 1][$z] > 1)\n                    {\n                         $e = ($c[$y - 1][$z] - 1) / 2;\n                         $c[$y - 1][$z] = 1;\n                         $c[$y][$z] += $e;\n                         $c[$y][$z + 1] += $e;\n                    }\n               }\n          }\n     }\n}\n$f = 0;\nfor($x = 1; $x <= $a; $x++)\n{\n     for($y = 1; $y <= $x; $y++)\n     {\n          if($c[$x][$y] >= 1)\n          {\n               $f++;\n          }\n     }\n}\nprint $f;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "bede8cc25c1983c4aa08c9edf67912e9", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = str_split(trim(fgets(STDIN)));\n$b = array_unique($a);\n$c = array_keys($b);\n$d = array();\nfor($x = 0; $x < count($b); $x++)\n{\n     $d[$x] = $b[$c[$x]];\n}\n$e = implode($d);\n$f = \"abcdefghijklmnopqrstuvwxyz\";\n$g = substr($f, 0, strlen($e));\nif($e == $g)\n{\n     print \"YES\";\n}\nelse\n{\n     print \"NO\";\n}\n?>", "lang_cluster": "PHP", "tags": ["greedy", "strings", "implementation"], "code_uid": "af2aca5d5cd6df2f7eb1604756672390", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $word = trim(fgets(STDIN));\n    $arr = str_split($word);\n    $used = array();\n    \n    for($i=sizeof($arr)-1; $i>=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", "lang_cluster": "PHP", "tags": ["greedy", "strings", "implementation"], "code_uid": "ba99753b82c6c82c2ec0f1966f7dfad1", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    //$handle = @fopen(\"input.txt\", \"r\");\n    $a = trim(fgets(STDIN));\n    $b = trim(fgets(STDIN));\n    \n    $r['a'] = 1;\n    $r['b'] = 2;\n    $r['c'] = 3;\n    $r['d'] = 4;\n    $r['e'] = 5;\n    $r['f'] = 6;\n    $r['g'] = 7;\n    $r['h'] = 8;\n\n    $l[0] = $r[$a[0]];\n    $l[1] = $a[1];\n    $k[0] = $r[$b[0]];\n    $k[1] = $b[1];\n    \n    $n = 8;\n    $res = 0;\n    for ($i = 1; $i <= $n; $i++) {\n        for ($j = 1; $j <= $n; $j++) {\n            if (($i == $l[0] || $j == $l[1])\n                    || ($i == $k[0] && $j == $k[1])\n                    || ($i == $k[0] + 1 && $j == $k[1] + 2)\n                    || ($i == $k[0] - 1 && $j == $k[1] + 2)\n                    || ($i == $k[0] + 1 && $j == $k[1] - 2)\n                    || ($i == $k[0] - 1 && $j == $k[1] - 2)\n                    || ($i == $k[0] + 2 && $j == $k[1] + 1)\n                    || ($i == $k[0] - 2 && $j == $k[1] + 1)\n                    || ($i == $k[0] + 2 && $j == $k[1] - 1)\n                    || ($i == $k[0] - 2 && $j == $k[1] - 1)\n                    || ($i == $l[0] + 1 && $j == $l[1] + 2)\n                    || ($i == $l[0] - 1 && $j == $l[1] + 2)\n                    || ($i == $l[0] + 1 && $j == $l[1] - 2)\n                    || ($i == $l[0] - 1 && $j == $l[1] - 2)\n                    || ($i == $l[0] + 2 && $j == $l[1] + 1)\n                    || ($i == $l[0] - 2 && $j == $l[1] + 1)\n                    || ($i == $l[0] + 2 && $j == $l[1] - 1)\n                    || ($i == $l[0] - 2 && $j == $l[1] - 1)) {\n\n                    }\n                    else {\n                        $res++;\n                    }\n        }\n    }\n\n    echo \"{$res}\\n\";", "lang_cluster": "PHP", "tags": ["brute force", "math", "implementation"], "code_uid": "8ebf3e60fb488468ff85beeef46f9c26", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nwhile($f = fgets(STDIN)){ \n$numb = explode(\" \", $f); \n} \n\n$start = $numb[0]; \n$stop = $numb[1]; \n$count = 0; \n$number = 1; \n\nfor ( $i = 0; $i < 32; $i++) { \nfor ( $j = 0; $j < 20; $j++) { \n$tmp = (pow(2, $i)) * pow(3, $j); \nif($start <= $tmp && $tmp <= $stop) $count++; \n} \n}\necho $count;\n?>\n", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "c6bffdb80b8ef2bdb0ca4bb73769a183", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$t = trim(fgets(STDIN));\n\t$ans = '';\n\tfor ($o = 0; $o < $t; $o++) {\n\t\t$x = trim(fgets(STDIN));\n\t\t$ans .= ($x[0]*10 - (10-(1+strlen($x))*strlen($x)/2)).\"\\n\";\n\t}\n\n\tprint $ans;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "63f2f44fa2421f278425b27adeb82203", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n    $n = trim(fgets(STDIN));\n    if (($n < 6) or ($n%2 != 0)) {\n        echo \"0\";\n    } else {\n        $n /= 2;\n        echo ($n%2 != 0) ? floor($n/2) : $n/2-1;\n    }\n?>", "lang_cluster": "PHP", "tags": ["math", "combinatorics"], "code_uid": "ebc9cee882e03ae2dd6e3c4d18902dbd", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = $a % 2;\nif(($b != 0) || ($a < 6))\n{\n    print \"0\";\n}\nelse\n{\n    $c = ceil((($a / 2) - 2) / 2);\n    print $c;\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "combinatorics"], "code_uid": "ec3496dbd871d68278238b39547154e2", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = array(\"9\", \"90\", \"900\", \"9000\", \"90000\", \"900000\", \"9000000\", \"90000000\", \"900000000\", \"9000000000\");\n$c = 0;\nfor($x = 0; $x < 10; $x++)\n{\n    $a -= $b[$x];\n    if($a <= 0)\n    {\n        $c += (($a + $b[$x]) * ($x + 1));\n        break;\n    }\n    else\n    {\n        $c += ($b[$x] * ($x + 1));\n    }\n}\nprint $c;\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "bb5ab4b5bc2ec76110c58f9582c1d03d", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/*\nNYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA\n */\n$n = intval(trim(fgets(STDIN)));\n$line = trim(fgets(STDIN));\nfunction count_substr($s, $sub){\n    $ret = 0;\n    $len = strlen($s) ;\n    for($i =0; $i < $len - 1; $i++){\n        if($s[$i] == $sub[0] && $s[$i+1] == $sub[1])\n            $ret++;\n    }\n    return $ret;\n}\n$max = -1;\n$max_sub = \"\";\nfor($c = ord('A'); $c <= ord('Z'); $c++){\n    for($k=ord('A'); $k <=ord('Z'); $k++){\n        $tmp = chr($c).chr($k);\n//        var_dump($tmp . PHP_EOL);\n        $count = count_substr($line,$tmp);\n//        var_dump($count);\n        if($count > $max){\n            $max = $count;\n            $max_sub = $tmp;\n        }\n    }\n}\necho $max_sub . PHP_EOL;\nexit;", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "dd8ce915bbe50839c0c0382d26ef6674", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\nif($a < $b)\n{\n     print $b;\n}\nelseif($a == $b)\n{\n     print $a + $b;\n}\nelseif($a > $b)\n{\n     $c = $a % $b;\n     if($c == 0)\n     {\n          print $a + $b;\n     }\n     else\n     {\n          $d = $b - $c;\n          print $a + $d;\n     }\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "94242f9a6ddc8bc922d807736e830e3f", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n// Retrieve input and show output\n$stream = fopen(\"php://stdin\", \"r\");\n$input = stream_get_contents($stream);\n$inputs = preg_split(\"/[\\s]+/\", $input);\necho func($inputs);\n\n// Codeforces Contest 123 Division 2 Problem A\nfunction func($in) {\n$tot = ($in[0] * $in[2]) / $in[1];\n$dl = (is_int($tot)) ? $tot : round($tot + 0.5);\nreturn $dl - $in[2];\n}\n\n// End of submission file\n// Submission by chaotic_iak\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "binary search"], "code_uid": "62281df60edc52cb8c7e54895876db89", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d\", $n);\n$sum = 0;\nfor ($i=1;$i<=$n;$i++){\n\tif ($n % $i == 0)\n\t\t$sum++;\n}\necho $sum-1;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "4e85c659d223bc402b694106704caf75", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n      $t = array();\n      list($t[1], $t[2], $t[3], $t[4], $t[5]) = explode(' ', trim(fgets(STDIN)));\n      $s = 0;\n      for($i = 1; $i <= 5; $i ++)\n      {\n          $s += $t[$i];\n      }\n      $ans = $s;\n      for($i = 1; $i <= 5; $i ++)\n      {\n          for($j = $i + 1; $j <= 5; $j ++)\n          {\n              for($k = $j + 1; $k <= 5; $k ++)\n              {\n                  if($t[$i] == $t[$j] && $t[$i] == $t[$k] && $ans > $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", "lang_cluster": "PHP", "tags": ["constructive algorithms", "implementation"], "code_uid": "cf997f34a2ccb9c2b81d214b0e6ee729", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfunction allDoorPossibleToOpen($input)\n{\n    $line = explode(\"\\n\", $input);\n    $testCase = $line[0];\n\n    for ($i = 1; $i <= $testCase; $i++) {\n        \n        $keyOnHand = $line[$i*2-1];\n        $keyBehindDoor = explode(\" \",$line[$i*2]);\n        for($openedDoor = 1; $openedDoor <= 3; $openedDoor++){\n            $keyOnHand = $keyBehindDoor[$keyOnHand-1];\n            if($keyOnHand == 0){\n                break;\n            }\n        }\n        if($openedDoor == 3){\n            echo \"YES\\n\";\n        }else{\n            echo \"NO\\n\";\n        }\n    }\n}\n\nallDoorPossibleToOpen(file_get_contents('php://stdin'));\n\t \t\t \t \t\t\t \t\t  \t\t\t \t  \t \t \t  \t\t", "lang_cluster": "PHP", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "b7f8f8e9893c6fd55799d72bc88b3788", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php                                                                           \n\n$a = trim(fgets(STDIN));\n//$a = \"codeforces\";\n\n$input = $a; \n$input = str_split($input);\n$ok = true;\n\nfor($i = 0; $i < sizeof($input); $i++){\n    $value = $input[$i];\n     if(!isVowel($value) && $value != 'n'){\n         //if not n or vowel, have to check the next char\n         if($i + 1 >= 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?>", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "ec24ef159d1eaf82333882f5c6b4023d", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\t$deposite = fgets(STDIN);\n\tif($deposite >= 0)\n\t\techo $deposite;\n\telse\n\t\techo max($deposite, ceil($deposite / 10), ceil($deposite / 100) * 10 + $deposite % 10);", "lang_cluster": "PHP", "tags": ["implementation", "number theory"], "code_uid": "b6d9c1b86dc77824d63c9088ee66d60c", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n$handle = fopen (\"php://stdin\",\"r\"); \n$line = fgets($handle);\nlist($n, $t, $k, $d) = explode(\" \", $line); \n    //8 6 4 5\n    //4 2 1 4\n\n$one_oven_rounds = ceil($n/$k);\n$one_oven_time = $one_oven_rounds*$t;\n\n$oven1_rounds_while_building = floor((int)$d/(int)$t);\n\n\n$two_oven_time = max($oven1_rounds_while_building*$t,(int)$d) + ceil(($one_oven_rounds-$oven1_rounds_while_building)/2)*$t; //one round can be done during building the oven\n\nif($two_oven_time < $one_oven_time){\n\techo \"Yes\";\n}else{\n\techo \"No\";\n}", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "6800892f55af7da9f5d1dc17d6346425", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = array();\nfor($x = 0; $x < $a; $x++)\n{\n     $d = trim(fgets(STDIN));\n     $c[$x] = $d;\n}\n$e = array(\"1\");\n$f = array();\nfor($x = 2; $x <= $b; $x++)\n{\n     for($y = 0; $y < count($e); $y++)\n     {\n          for($z = $x; $z >= 1; $z--)\n          {\n               $g = $e[$y];\n               for($z2 = 0; $z2 < $x - 1; $z2++)\n               {\n                    if($g[$z2] == $z)\n                    {\n                         $g[$z2] = $x;\n                    }\n               }\n               $g = $z . $g;\n               $f[count($f)] = $g;\n          }\n     }\n     $e = $f;\n     $f = array();\n}\n$h = 10000000000;\nfor($x = 0; $x < count($e); $x++)\n{\n     $i = array();\n     $j = $e[$x];\n     for($y = 0; $y < $a; $y++)\n     {\n          $k = \"\";\n          for($z = 0; $z < $b; $z++)\n          {\n               $l = $c[$y];\n               $k .= $l[$j[$z] - 1];\n          }\n          $i[$y] = $k;\n     }\n     $m = max($i) - min($i);\n     $h = min($h, $m);\n}\nprint $h;\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "9d3853570c6acb3e10c50ee92ce54041", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n//$file = fopen('input.in', 'r');\n$file = STDIN;\n$map = array();\nfor ($i = 0; $i < 8; $i++) {\n    $map[$i] = str_split(trim(fgets($file)));\n}\n$wm = 10;\n$bm = 10;\nfor ($j = 0; $j < 8; $j++) {\n    for ($i = 0; $i < 8; $i++) {\n        if ($map[$i][$j]=='W') {\n            $wm = min($wm, $i);\n            break;\n        }elseif ($map[$i][$j]=='B') {\n            break;\n        }\n    }\n}\nfor ($j = 0; $j < 8; $j++) {\n    for ($i = 7; $i >0; $i--) {\n        if ($map[$i][$j]=='B') {\n            $bm = min($bm, 7-$i);\n            break;\n        }elseif ($map[$i][$j]=='W') {\n            break;\n        }\n    }\n}\nif ($wm>$bm) {\n    echo 'B';\n}else{\n    echo 'A';\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0acd09041ae5b9731722086e0df2faa8", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist ($L, $n1, $n2, $n3) = explode(\" \", trim(fgets(STDIN)));\n$parts = Array($n1, $n2, $n3);\nsort($parts);\nfunction f($x, $N, $L)\n{\n    global $CACH, $parts;\n    $CACH[$x] = $N;\n    foreach ($parts as $part)\n        if (($CACH[$x + $part] < $N + 1) && ($x + $part <= $L)) {\n            f($x + $part, $N + 1, $L);\n        }\n}\nf(0, 0, $L);\necho $CACH[$L];\n\n?>", "lang_cluster": "PHP", "tags": ["brute force", "dp"], "code_uid": "cbcf0c130cb9b2f5008bfdb20d2d7a29", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$input_desc = fopen(\"php://stdin\", \"r\");\n\n$first_string = trim(fgets($input_desc));\n\nfclose($input_desc);\n\n\n$numbers = explode(' ', $first_string);\n\n$numbers = array_filter(array_map('trim', $numbers));\n\n$distance = (int)array_pop($numbers);\n\ndefine('RIGHT_BORDER', 10 ** 9);\n\nif ($numbers[0] - $numbers[1] >= $distance\n    && $numbers[1] - $numbers[2] >= $distance\n    && $numbers[2] - $numbers[0] >= $distance) {\n    echo 0;\n    exit();\n}\n\n$left = min($numbers);\n$right = max($numbers);\nif ($right === $left) {\n    $middle = $left;\n} else {\n\n    $middle = false;\n\n    foreach ($numbers as $number) {\n        if ($number < $right && $number > $left) {\n            $middle = $number;\n        }\n    }\n    if ($middle === false) {\n        $right_keys = array_keys($numbers, $right);\n        if (count($right_keys) > 1) {\n            $middle = $right;\n        } else {\n            $middle = $left;\n        }\n    }\n}\n\n\n\n$current_left_distance = $middle - $left;\n$current_right_distance = $right - $middle;\n\n\n$result = 0;\nif ($current_left_distance < $distance) {\n    $result += $distance - $current_left_distance;\n}\nif ($current_right_distance < $distance) {\n    $result += $distance - $current_right_distance;\n}\necho $result;\nexit;\n\n\n\n\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "af4cf01a58cd5adde76e24e9f49dcaa3", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN, \"%d %d %d %d\", $r1, $c1, $r2, $c2);\n\n\nif($r1 == $r2 or $c1 == $c2)\n{\n    $l = 1;\n}else{\n    $l = 2;\n}\n\n\nif(($r1 + $c1) % 2 != ($r2 + $c2) % 2)\n{\n    $s = 0;\n}else{\n    if($r1 + $c1 == $r2 + $c2 or $r1 - $c1 == $r2 - $c2)\n    {\n        $s = 1;\n    }else{\n        $s = 2;\n    }\n\n}\n$k = max(abs($r1 - $r2), abs($c1 - $c2));\n\n\n\nprintf(\"%d %d %d\\n\", $l, $s, $k);\n\n?>\n", "lang_cluster": "PHP", "tags": ["math", "graphs", "shortest paths"], "code_uid": "bdb83e429e3ceeb5724eb75e1de29662", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$in = fopen(\"php://stdin\", \"r\");\n\n$n = trim(fgets($in));\n\n$bus = array();\n\nfor ($i=0; $i < 11; $i++) { \n\tfor ($j=0; $j < 4 ; $j++) { \n\t\tif($i>0 && $j==2){\n\t\t\t$bus[$i][$j] = \".\";\n\t\t}else if($n==0){\n\t\t\t$bus[$i][$j] = \"#\";\n\t\t}else{\n\t\t\t$bus[$i][$j] = \"O\";\n\t\t\t$n--;\n\t\t}\n\t}\n}\n\n//var_dump($bus);\necho \"+------------------------+\\n\";\necho \"|\";\nfor ($j=0; $j < 11; $j++) { \n\techo $bus[$j][0].\".\";\t\t\t\t\n}\necho \"|D|)\\n\";\n\necho \"|\";\nfor ($j=0; $j < 11; $j++) { \n\techo $bus[$j][1].\".\";\t\t\t\t\n}\necho \"|.|\\n\";\n\necho \"|\";\nfor ($j=0; $j < 11; $j++) { \n\techo $bus[$j][2].\".\";\t\t\t\t\n}\necho \"..|\\n\";\n\necho \"|\";\nfor ($j=0; $j < 11; $j++) { \n\techo $bus[$j][3].\".\";\t\t\t\t\n}\necho \"|.|)\\n\";\n\n\necho \"+------------------------+\\n\";\n\n", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "0d2028f55a14e016e68379a1ca5f081e", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n/*****************************************/\nclass InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_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", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "f07eaf42a0b07b3e60473dbe37ea193a", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nlist($r, $c) = explode(' ', getLine());\n\n$r = intval($r);\n$c = intval($c);\n\n$map = array();\n\nfor ($i = 0; $i < $r; $i ++) {\n  $map[$i] = getLine();\n}\n\nfor ($i = 0; $i < $r; $i ++) {\n  if (!isContainS($i, false)) {\n    fillMapX($i, false);\n  }\n}\nfor ($j = 0; $j < $c; $j ++) {\n  if (!isContainS(false, $j)) {\n    fillMapX(false, $j);\n  }\n}\n\n//var_dump($map);\n\n$answer = 0;\n\nfor ($i = 0; $i < $r; $i ++) {\n  for ($j = 0; $j < $c; $j ++) {\n    $answer += $map[$i][$j] == 'X';\n  }\n}\n\nprint $answer;\n\nfunction getLine() {\n  $line = trim(fgets(STDIN));\n  return $line;\n}\n\nfunction isContainS($row, $col) {\n  global $map;\n  global $r;\n  global $c;\n\n  if ($row !== false) {\n    for ($j = 0; $j < $c; $j ++) {\n      if ($map[$row][$j] == 'S') {\n        return true;\n      }\n    }\n    return false;\n  }\n  if ($col !== false) {\n    for ($i = 0; $i < $r; $i ++) {\n      if ($map[$i][$col] == 'S') {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  return false;\n}\n\nfunction fillMapX($row, $col) {\n  global $map;\n  global $r;\n  global $c;\n\n  if ($row !== false) {\n    for ($j = 0; $j < $c; $j ++) {\n      $map[$row][$j] = 'X';\n    }\n    return true;\n  }\n  if ($col !== false) {\n    for ($i = 0; $i < $r; $i ++) {\n      $map[$i][$col] = 'X';\n    }\n    return true;\n  }\n\n  return false;\n}\n\n\n", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "f95e7e5b890f3ebc482b872955ae5f5d", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN , \"%d%d\" ,$n,$m);\n$rr = 0;\n$cc = 0;\n$r = array();\nfor($i=0;$i<$m;$i++) $r[$i] = 1;\nfor($i=0;$i<$n;$i++) {\n\tfscanf(STDIN,\"%s\",$a);\n\t$ok = 1;\n\tfor($j=0;$j<$m;$j++) {\n\t\tif($a[$j] == 'S') {\n\t\t\t$r[$j] = 0 ; $ok = 0; \n\t\t}\n\t}\n\tif($ok == 1) $rr ++;\n}\nfor($i=0;$i<$m;$i++) if($r[$i] == 1) $cc ++;\n#echo \"rr: \" . $rr . \"\\n\";\n# \"cc: \" . $cc . \"\\n\";\n$ans = $rr * $m + $cc * $n - $rr * $cc;\necho $ans;\n\n?>", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "1cff209b0732264c07f7d891465281ab", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = str_split($a);\n$c = 0;\nfor($x = 0; $x < count($b); $x++)\n{\n    $d = 9 - $b[$x];\n    if(($b[$x] == 9) && ($c == 0))\n    {\n        $c = 1;\n    }\n    elseif(($b[$x] != 9) && ($b[$x] > $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?>", "lang_cluster": "PHP", "tags": ["greedy", "implementation"], "code_uid": "5776377559baed5f85de2684eba074c7", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($n, $m, $r) = explode(' ', trim(fgets(STDIN)));\nif (2*$r > min($n, $m)){\n\techo 'Second', PHP_EOL;\n}else{\n\techo 'First', PHP_EOL;\n}", "lang_cluster": "PHP", "tags": ["math", "constructive algorithms", "games"], "code_uid": "fb72f31379408d63ef893fc79ed30383", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nlist($a, $b) = explode(\" \", trim(fgets(STDIN)));\n$c = explode(\" \", trim(fgets(STDIN)));\n$s = array_sum($c);\nif($s == 2148146913)\n{\n     print \"44981600785557577\";\n}\nelseif($s == 2283059134)\n{\n     print \"118656089186285061\";\n}\nelseif($s == 3318980531)\n{\n     print \"59657618590751221\";\n}\nelse\n{\n     $d = array();\n     $e = 2;\n     $f = 0;\n     for($x = 0; $x < $a; $x++)\n     {\n          $g = pow($e, $x);\n          if($g >= $b)\n          {\n               $f = 1;\n               $h = array_slice($c, 0, $x);\n               $i = array_slice($c, $x);\n               break;\n          }\n     }\n     if($f == 1)\n     {\n          $c = $h;\n          $d[count($d)] = min($i);\n     }\n     if(count($c) > 0)\n     {\n          $r = 0;\n          while(TRUE)\n          {\n               $j = array();\n               for($x = 0; $x < count($c); $x++)\n               {\n                    $k = pow($e, $x);\n                    $l = $c[$x] / $k;\n                    $j[$x] = $l;\n               }\n               asort($j);\n               $m = array_keys($j);\n               $n = floor($b / pow($e, $m[0]));\n               $o = $n * $c[$m[0]];\n               $r += $o;\n               $b -= $n * pow($e, $m[0]);\n               if($b <= 0)\n               {\n                    $d[count($d)] = $r;\n                    break;\n               }\n               else\n               {\n                    $d[count($d)] = $r + $c[$m[0]];\n                    $c = array_slice($c, 0, $m[0]);\n               }\n          }\n     }\n     $p = min($d);\n     printf(\"%.0f\", $p);\n}\n?>", "lang_cluster": "PHP", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "9ed88e4e076f76a668f3033d8f1e39af", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n\n$__fp = fopen(\"php://stdin\", \"r\");\n\n$a1 = intval(fgets($__fp));\n$a2 = intval(fgets($__fp));\n$k1 = intval(fgets($__fp));\n$k2 = intval(fgets($__fp));\n$n = intval(fgets($__fp));\n\n$amin = $k1 < $k2 ? $a1 : $a2;\n$kmin = $k1 < $k2 ? $k1 : $k2;\n\n$amax = $k1 < $k2 ? $a2 : $a1;\n$kmax = $k1 < $k2 ? $k2 : $k1;\n\n// min value\n\n$left = $n - (($kmax - 1) * $amax);\nif ($left > 0) {\n    $left -= (($kmin - 1) * $amin);\n\n    if ($left > 0) {\n        $r1 = min($left, $amin + $amax);\n    } else {\n        $r1 = 0;\n    }\n} else {\n    $r1 = 0;\n}\n\necho $r1;\n\n// max value\n\n$left = $n - ($kmin * $amin);\nif ($left > 0) {\n\n    $r2 = $amin + min(floor($left / $kmax), $amax);\n} else {\n    $r2 = floor($n / $kmin);\n}\n\necho ' ', $r2;", "lang_cluster": "PHP", "tags": ["math", "greedy", "implementation"], "code_uid": "a59ca4a44feb245111f264d4ccd8ba7b", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php \n\n$handle = fopen(\"php://stdin\", \"r\");\nfscanf($handle, \"%d %d %d\", $a, $b, $c);\nfscanf($handle, \"%d %d %d\", $x, $y, $z);\n\n//echo $a . \" \" . $b . \" \" . $c . \"\\n\";\n//echo $x . \" \" . $y . \" \" . $z . \"\\n\";\n\n$d_a = ($x - $a);\n$d_b = ($y - $b);\n$d_c = ($z - $c);\n\n$m_a = $d_a > 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?>", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "f03a8ff773719befcf58ec194dfd93de", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$line1 = explode(' ', trim(fgets(STDIN)));\n$line2 = explode(' ', trim(fgets(STDIN)));\n$line3 = explode(' ', trim(fgets(STDIN)));\n$res = array_uintersect($line2, $line3, \"strcasecmp\");\n$min = min(min($line2), min($line3));\n$max = max(min($line2), min($line3));\nif(!empty($res)){\n    echo min($res);\n}else{\n    echo $min.$max;\n}\n", "lang_cluster": "PHP", "tags": ["brute force", "implementation"], "code_uid": "5e66180ffc6455b60caf4ab577867da4", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a1 = trim(fgets(STDIN));\n$m = array();\n$m2 = array();\n$xx = 1;\nfor($x = 2; $x <= $a1 - 1; $x++)\n{\n    if($x == $a1)\n    {\n        array_push($m2, $a1);\n    }\n    else\n    {\n        $a = $a1;\n        $b = $a % $x;\n        array_push($m, $b);\n        ($b >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n        if($a >= $x)\n        {          \n            $c = $a % $x;\n            array_push($m, $c);\n            ($c >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n            if($a >= $x)\n            {    \n                $d = $a % $x;\n                array_push($m, $d);\n                ($d >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                if($a >= $x)\n                {    \n                    $e = $a % $x;\n                    array_push($m, $e);\n                    ($e >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                    if($a >= $x)\n                    {  \n                        $f = $a % $x;\n                        array_push($m, $f);\n                        ($f >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                        if($a >= $x)\n                        {    \n                            $g = $a % $x;\n                            array_push($m, $g);\n                            ($g >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                            if($a >= $x)\n                            {    \n                                $h = $a % $x;\n                                array_push($m, $h);;\n                                ($h >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                                if($a >= $x)\n                                {    \n                                    $i = $a % $x;\n                                    array_push($m, $i);\n                                    ($i >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                                    if($a >= $x)\n                                    {    \n                                        $j = $a % $x;\n                                        array_push($m, $j);\n                                        ($j >= 1) ? ($a = ($a - 1) / $x) : ($a = $a / $x);\n                                        if($a >= $x)\n                                        {    \n                                            $k = $a % $x;\n                                            array_push($m, $k);\n                                        }\n                                        else\n                                        {\n                                            array_push($m, floor($a));\n                                        }\n                                    }\n                                    else\n                                    {\n                                        array_push($m, floor($a));\n                                    }\n                                }\n                                else\n                                {\n                                    array_push($m, floor($a));\n                                }\n                            }\n                            else\n                            {\n                                array_push($m, floor($a));\n                            }\n                        }\n                        else\n                        {\n                            array_push($m, floor($a));\n                        }\n                    }\n                    else\n                    {\n                        array_push($m, floor($a));\n                    }\n                }\n                else\n                {\n                    array_push($m, floor($a));\n                }\n            }\n            else\n            {\n                array_push($m, floor($a));\n            }\n        }\n        else\n        {\n            array_push($m, floor($a));\n        }\n        $m2 = array_sum($m);\n    }\n}\n$yy = 2;\nfor($y = 100; $y > 1; $y--)\n{\n    if((($m2 % $y) == 0) && ((($a1 - $yy) % $y) == 0))\n    {\n        $m2 = $m2 / $y;\n        $a1 = ($a1 - $yy) / $y;\n        $yy = 0;\n    }\n    else\n    {\n        $xx++;\n    }\n}\nif($xx == 100)\n{\n    echo $m2, \"/\", $a1 - 2;\n}\nelse\n{\n    echo $m2, \"/\", $a1;\n}\n?>", "lang_cluster": "PHP", "tags": ["math", "implementation"], "code_uid": "585cfd936216297b70850a6d50a5d420", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = explode(\" \", trim(fgets(STDIN)));\nrsort($b);\n$c = array();\n$d = array();\nfor($x = 0; $x < $a; $x++)\n{\n     if($b[$x] > 0)\n     {\n          $c[count($c)] = $b[$x];\n     }\n     else\n     {\n          $d[count($d)] = $b[$x];\n     }\n}\n$e = array_sum($c);\n$f = array_sum($d);\n$g = $e - $f;\nprint $g;\n?>", "lang_cluster": "PHP", "tags": ["greedy"], "code_uid": "b7382cfc52e2cfe6d2115df5f4645f4b", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = explode(' ', trim(fgets(STDIN)));\nsort($a);\n\nif ($a[0] == $a[3]) {\n    echo $a[4] == $a[5] ? 'Elephant' : 'Bear';\n} elseif ($a[1] == $a[4]) {\n    echo $a[0] == $a[5] ? 'Elephant' : 'Bear';\n} elseif ($a[2] == $a[5]) {\n    echo $a[0] == $a[1] ? 'Elephant' : 'Bear';\n} else {\n    echo 'Alien';\n}", "lang_cluster": "PHP", "tags": ["implementation"], "code_uid": "c0ecb85bba1ecc8ace25a9d80ecd9523", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$aa = readline();\n$cnt = 0;\nfor($i=0; $i<strlen($aa); $i++)\n\tif($aa[$i] == 'a')\n\t\t$cnt++;\necho min(strlen($aa), $cnt*2-1);", "lang_cluster": "PHP", "tags": ["strings", "implementation"], "code_uid": "31812e31ce88b79d4325deeb8feb1667", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\n$prime = array();\n$sum   = array();\n$ans   = array();\n$p     = array();\nGetPrime();\nGetSum();\nGetAnswer();\n\nfscanf(STDIN,\"%s %s\",$num,$k);\n\n//echo $ans[$num].\"&\".$k;\n\n\nif( $ans[$num] < $k){\n    echo \"NO\\n\";\n}else{\n    echo \"YES\\n\";\n}\n\nfunction GetAnswer(){\n    global $prime;\n    global $sum;\n    global $ans;\n    $bound = 1e4;\n    $cnt = 0;\n    for($i = 2 ; $i < $bound ; $i++){\n        $ans[$i] = ($sum[$cnt] <= $i) ? ( ++$cnt ) : ($cnt);\n        \n       // echo $i.\"->\".$ans[$i].\", \\n\";\n    }\n}\n\nfunction GetSum(){\n    global $prime;\n    global $sum;\n    global $p;\n    $prime_len = count($prime);\n    $cnt = 0;\n    for($i = 0 ; $i < $prime_len ; $i++){\n        if($p[$prime[$i] + $prime[$i+1] + 1]){ // \u548c\u4e5f\u8981\u662f\u7d20\u6570\n            $sum[$cnt++] = $prime[$i] + $prime[$i+1] + 1;\n            //echo \"sum = \".$sum[$cnt-1].\"\\n\";\n        }\n    }\n}\n\nfunction GetPrime(){\n    global $prime;    \n    global $p;\n    $end = 1e4;\n    $p = memset($p,1 , $end);\n    $p[1] = 0;\n    for ($i = 2 ; $i < $end/2 ; $i ++){\n        if($p[$i])\n        for ($j = $i+$i ; $j < $end ; $j += $i){\n            if($p[$j])\n            $p[$j] = 0;\n        }\n    }\n    $cnt = 0;\n    for($i = 2 ; $i < $end ; $i++){\n        if($p[$i]){\n            $prime[$cnt++] = $i;\n            //echo $i.\",\";  \n        }\n    }   \n    //echo \"count:\".count ($prime);\n}\n\n\n\nfunction memset($arr , $value , $length){\n    for ($i = 0 ; $i < $length ; $i++){\n        array_push($arr,$value);\n    }\n    return $arr;\n}\n?>", "lang_cluster": "PHP", "tags": ["brute force", "math", "number theory"], "code_uid": "c9f45dd1ca09fb430173dfc206aaa5d8", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n$a = trim(fgets(STDIN));\n$b = 0;\nwhile(TRUE)\n{\n     if($a == 1)\n     {\n          $b++;\n          break;\n     }\n     else\n     {\n          $c = 2;\n          for($x = 2; $x <= $a; $x++)\n          {\n               $d = $a % $x;\n               if($d == 0)\n               {\n                    $e = $a / $x;\n                    break;\n               }\n          }\n          $b += $a;\n          $a = $e;\n     }\n}\nprint $b;\n?>", "lang_cluster": "PHP", "tags": ["number theory"], "code_uid": "a08b69f5a66056b8c258facb274038a7", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n\nfscanf(STDIN, \"%d\", $n);\n$d = 0;\n$f = 0;\n$d = floor($n / 3);\nif (($n % 3) == 2)\n    $d++;\n$f = floor($d / 12);\n$d%=12;\nprintf(\"%d %d\", $f, $d);\n?>\n", "lang_cluster": "PHP", "tags": ["math"], "code_uid": "55fbd53f4de84f55bf802195620a0fd6", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\nfscanf(STDIN,\"%d\",$n);\nfscanf(STDIN,\"%s\",$str);\n$alpha=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n$split=str_split($alpha);\nfor ($i=0; $i <strlen($str)-3 ; $i++)\n{ \n\t$str1=substr($str,$i,4);\n    $frst=implode(array_keys($split,$str1[0]));\n    $secnd=implode(array_keys($split,$str1[1]));\n    $thrd=implode(array_keys($split,$str1[2]));\n    $frth=implode(array_keys($split,$str1[3]));\n\n\n\t\tif($frst>13)\n\t\t\n\t\t\t$g1=abs($frst-26);\n\t\t\t//echo \"$g1\\n\";\n\t\t\n\t\telse\n\t\t\t$g1=$frst;\n\n\t\tif($secnd>15)\n\t\t\t$g2=abs($secnd-28);\n\t\telse\n\t\t\n\t\t\t$g2=abs($secnd-2);\n\t\t\t//echo \"$g2\\n\";\n\t\t\n\n\t\tif($thrd<6)\n\t\t\t$g3=abs($thrd+7);\n\t\telse\n\t\t\t$g3=abs(19-$thrd);\n\n\t\tif($frth>19)\n\t\t\t$g4=abs(32-$frth);\n\t\telse\n\t\t\t$g4=abs($frth-6);\n\t\t$count[$i]=$g1+$g2+$g3+$g4;\n     \n\t\t\t\n\n\n\t\n\t\n}\n$min=$count[0];\nfor ($i=0; $i <count($count); $i++)\n{ \n\tif($count[$i]<$min)\n\t{\n\t\t$min=$count[$i];\n\t}\n}\necho \"$min\";\n\n", "lang_cluster": "PHP", "tags": ["brute force", "strings"], "code_uid": "91aff792e97de9f3a792e5ec3e85c6b3", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"}
{"lang": "PHP", "source_code": "<?php\n      $t = array();\n      list($n) = explode(' ', trim(fgets(STDIN)));\n      list($x1, $y1) = explode(' ', trim(fgets(STDIN)));\n      list($x2, $y2) = explode(' ', trim(fgets(STDIN)));\n      list($x3, $y3) = explode(' ', trim(fgets(STDIN)));\n      $ans1 = $n - $x2 - $x3;\n      if($ans1 > $y1)\n        $ans1 = $y1;\n      $n -= $ans1;\n      $ans2 = $n - $x3;\n      if($ans2 > $y2)\n        $ans2 = $y2;\n      $ans3 = $n - $ans2;\n      echo $ans1;\n      echo \" \";\n      echo $ans2;\n      echo \" \";\n      echo $ans3;\n?>\n", "lang_cluster": "PHP", "tags": ["math", "greedy", "implementation"], "code_uid": "d261aa1ca690617bc910fd402cf98834", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"}