{"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\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=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\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 = 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$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$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$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, \"%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\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// 450A     Jzzhu и дети \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\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\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\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$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\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\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\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\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    $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$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\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($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\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\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$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\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\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\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\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    $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$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    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\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/*****************************************/\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$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"}
