p_id
stringlengths
6
6
language
stringclasses
10 values
status
stringclasses
2 values
code
stringlengths
1
563k
prompt
stringlengths
113
563k
answer
stringclasses
2 values
p03456
PHP
Accepted
<?php fscanf(STDIN, "%s %s", $a, $b); $all = sqrt($a.$b); $result = $all - floor($all); echo $result == 0 ? 'Yes' : 'No';
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%s %s", $a, $b); $all = sqrt($a.$b); $result = $all - floor($all); echo $result == 0 ? 'Yes' : 'No'; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02791
PHP
Accepted
<?php fscanf(STDIN, "%d", $a); $search = "%d"; for($i = 1; $i < $a; $i++) { $search .= " %d"; } $list = fscanf(STDIN, $search); $num = 1; $limit = 0; foreach($list as $key=>$val) { if($key == 0) { $limit = $val; continue; } if($limit > $val){ $num += 1; $limit = $val; } } echo $num;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $a); $search = "%d"; for($i = 1; $i < $a; $i++) { $search .= " %d"; } $list = fscanf(STDIN, $search); $num = 1; $limit = 0; foreach($list as $key=>$val) { if($key == 0) { $limit = $val; continue; } if($limit > $val){ $num += 1; $limit = $val; } } echo $num; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03149
PHP
Accepted
<?php fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $d); $nums = [$a, $b, $c, $d]; sort($nums); if ($nums[0] === 1 && $nums[1] === 4 && $nums[2] === 7 && $nums[3] === 9) { echo 'YES'; } else { echo 'NO'; } echo "\n";
Here is a piece of code written in PHP: <?php fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $d); $nums = [$a, $b, $c, $d]; sort($nums); if ($nums[0] === 1 && $nums[1] === 4 && $nums[2] === 7 && $nums[3] === 9) { echo 'YES'; } else { echo 'NO'; } echo "\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02817
PHP
Accepted
<?php fscanf(STDIN,"%s %s", $S, $T); echo $T.$S; ?>
Here is a piece of code written in PHP: <?php fscanf(STDIN,"%s %s", $S, $T); echo $T.$S; ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03264
PHP
Accepted
<?php fscanf(STDIN, "%d", $k); $h = floor($k / 2); echo $k % 2 ? $h * ($h + 1) : $h * $h;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $k); $h = floor($k / 2); echo $k % 2 ? $h * ($h + 1) : $h * $h; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03844
PHP
Accepted
<?php /* Problem URL : http://abc050.contest.atcoder.jp/tasks/abc050_a Score : Result : Time : ms Memory : KB */ fscanf(STDIN, "%d %s %d", $a, $op, $b); switch ($op) { case "+": echo $a + $b . PHP_EOL; break; case "-": echo $a - $b . PHP_EOL; break; }
Here is a piece of code written in PHP: <?php /* Problem URL : http://abc050.contest.atcoder.jp/tasks/abc050_a Score : Result : Time : ms Memory : KB */ fscanf(STDIN, "%d %s %d", $a, $op, $b); switch ($op) { case "+": echo $a + $b . PHP_EOL; break; case "-": echo $a - $b . PHP_EOL; break; } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02258
PHP
Accepted
<?php fscanf(STDIN, '%d', $n); $max = -INF; fscanf(STDIN, '%d', $min); for ($j = 1; $j < $n; $j++) { fscanf(STDIN, '%d', $R); $max = max($max, $R - $min); $min = min($min, $R); } echo $max, PHP_EOL;
Here is a piece of code written in PHP: <?php fscanf(STDIN, '%d', $n); $max = -INF; fscanf(STDIN, '%d', $min); for ($j = 1; $j < $n; $j++) { fscanf(STDIN, '%d', $R); $max = max($max, $R - $min); $min = min($min, $R); } echo $max, PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p00001
PHP
Accepted
<?php $arr = array(); for($i = 0; $i < 10; $i++){ fscanf(STDIN, "%d", $arr[$i]); } rsort($arr); $count = 0; foreach($arr as $row){ echo $row."\n"; $count++; if($count >= 3){ break; } }
Here is a piece of code written in PHP: <?php $arr = array(); for($i = 0; $i < 10; $i++){ fscanf(STDIN, "%d", $arr[$i]); } rsort($arr); $count = 0; foreach($arr as $row){ echo $row."\n"; $count++; if($count >= 3){ break; } } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02404
PHP
Accepted
<?php while(true){ list($height, $width) = explode(" ",trim(fgets(STDIN))); if($height == 0 && $width == 0) exit; $bar1 = str_repeat("#",$width)."\n"; $bar2 = "#".str_repeat(".",$width-2)."#\n"; print $bar1; for($j = 0; $j < $height - 2 ; $j++){ print $bar2; } print $bar1."\n"; }
Here is a piece of code written in PHP: <?php while(true){ list($height, $width) = explode(" ",trim(fgets(STDIN))); if($height == 0 && $width == 0) exit; $bar1 = str_repeat("#",$width)."\n"; $bar2 = "#".str_repeat(".",$width-2)."#\n"; print $bar1; for($j = 0; $j < $height - 2 ; $j++){ print $bar2; } print $bar1."\n"; } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03804
PHP
Accepted
<?php list($n, $m) = explode(" ", trim(fgets(STDIN))); $s = []; for ($i=0; $i<$n; $i++) { list($s[]) = explode(" ", trim(fgets(STDIN))); } $t = []; for ($i=0; $i<$m; $i++) { list($t[]) = explode(" ", trim(fgets(STDIN))); } $sa = $n-$m; for ($i=0; $i<=$sa; $i++) { for ($j=0; $j<=$sa; $j++) { $icchi = true; for ($k=0; $k<$m; $k++) { for ($l=0; $l<$m; $l++) { if($t[$k][$l] != $s[$k+$i][$l+$j]){ // echo $t[$k][$l]." ".$s[$k+$i][$l+$j]." ".$k." ".$l." ".$i." ".$j.PHP_EOL; $icchi = false; } } } if($icchi){ echo "Yes"; exit; } } } echo "No";
Here is a piece of code written in PHP: <?php list($n, $m) = explode(" ", trim(fgets(STDIN))); $s = []; for ($i=0; $i<$n; $i++) { list($s[]) = explode(" ", trim(fgets(STDIN))); } $t = []; for ($i=0; $i<$m; $i++) { list($t[]) = explode(" ", trim(fgets(STDIN))); } $sa = $n-$m; for ($i=0; $i<=$sa; $i++) { for ($j=0; $j<=$sa; $j++) { $icchi = true; for ($k=0; $k<$m; $k++) { for ($l=0; $l<$m; $l++) { if($t[$k][$l] != $s[$k+$i][$l+$j]){ // echo $t[$k][$l]." ".$s[$k+$i][$l+$j]." ".$k." ".$l." ".$i." ".$j.PHP_EOL; $icchi = false; } } } if($icchi){ echo "Yes"; exit; } } } echo "No"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03206
PHP
Accepted
<?php $day = trim(fgets(STDIN)); if($day == 22)echo "Christmas Eve Eve Eve"; if($day == 23)echo "Christmas Eve Eve"; if($day == 24)echo "Christmas Eve"; if($day == 25)echo "Christmas";
Here is a piece of code written in PHP: <?php $day = trim(fgets(STDIN)); if($day == 22)echo "Christmas Eve Eve Eve"; if($day == 23)echo "Christmas Eve Eve"; if($day == 24)echo "Christmas Eve"; if($day == 25)echo "Christmas"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02256
PHP
Accepted
<?php function gcb( $x, $y ) { while( 0 != $y ) { $t = $y; $y = $x%$y; $x = $t; } return $x; } $nums = explode( " ", trim( fgets( STDIN ) ) ); $x = max( $nums ); $y = min( $nums ); print gcb( $x, $y ); ?>
Here is a piece of code written in PHP: <?php function gcb( $x, $y ) { while( 0 != $y ) { $t = $y; $y = $x%$y; $x = $t; } return $x; } $nums = explode( " ", trim( fgets( STDIN ) ) ); $x = max( $nums ); $y = min( $nums ); print gcb( $x, $y ); ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03206
PHP
Accepted
<?php fscanf(STDIN, "%d", $D); $msg = array('Christmas'); for ($i = 25; $i > $D; $i--) { $msg[] = "Eve"; } echo implode(" ", $msg);
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $D); $msg = array('Christmas'); for ($i = 25; $i > $D; $i--) { $msg[] = "Eve"; } echo implode(" ", $msg); Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02731
PHP
Accepted
<?php $input = (float)file_get_contents('php://stdin'); $result = ($input/3)*($input/3)*($input/3); echo $result; ?>
Here is a piece of code written in PHP: <?php $input = (float)file_get_contents('php://stdin'); $result = ($input/3)*($input/3)*($input/3); echo $result; ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02407
PHP
Accepted
<?php $num = trim(fgets(STDIN)); $str = explode(" ", trim(fgets(STDIN))); for($i = 1; $i <= $num; $i++){ ($i == $num)?$format = "%s":$format = "%s "; printf("$format", $str[$num - $i]); } echo PHP_EOL;
Here is a piece of code written in PHP: <?php $num = trim(fgets(STDIN)); $str = explode(" ", trim(fgets(STDIN))); for($i = 1; $i <= $num; $i++){ ($i == $num)?$format = "%s":$format = "%s "; printf("$format", $str[$num - $i]); } echo PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03636
PHP
Accepted
<?php $s = trim(fgets(STDIN)); $start = substr($s, 0, 1); $last = substr($s, -1); $other = strlen($s) - 2; echo $start.$other.$last;
Here is a piece of code written in PHP: <?php $s = trim(fgets(STDIN)); $start = substr($s, 0, 1); $last = substr($s, -1); $other = strlen($s) - 2; echo $start.$other.$last; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02397
PHP
Accepted
<?php while (true) { fscanf(STDIN, "%d %d", $inputNumX, $inputNumY); if ($inputNumX === 0 && $inputNumY === 0) { break; } echo orderByAskForTwoNums($inputNumX, $inputNumY), PHP_EOL; } function orderByAskForTwoNums($inputNumX, $inputNumY) { return min($inputNumX, $inputNumY).' '.max($inputNumX, $inputNumY); }
Here is a piece of code written in PHP: <?php while (true) { fscanf(STDIN, "%d %d", $inputNumX, $inputNumY); if ($inputNumX === 0 && $inputNumY === 0) { break; } echo orderByAskForTwoNums($inputNumX, $inputNumY), PHP_EOL; } function orderByAskForTwoNums($inputNumX, $inputNumY) { return min($inputNumX, $inputNumY).' '.max($inputNumX, $inputNumY); } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03795
PHP
Accepted
<?php fscanf(STDIN, "%d", $n); $y = floor($n/15) * 200; $x = $n * 800; echo $x-$y;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $n); $y = floor($n/15) * 200; $x = $n * 800; echo $x-$y; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02886
PHP
Accepted
<?php $N = trim(fgets(STDIN)); $del = explode(" ", trim(fgets(STDIN))); $res = 0; for($i = 0; $i < $N; $i++ ) { for ($j = 0; $j < $N; $j++) { if ($i < $j) { $res += $del[$i] * $del[$j] ; } } } echo $res; ?>
Here is a piece of code written in PHP: <?php $N = trim(fgets(STDIN)); $del = explode(" ", trim(fgets(STDIN))); $res = 0; for($i = 0; $i < $N; $i++ ) { for ($j = 0; $j < $N; $j++) { if ($i < $j) { $res += $del[$i] * $del[$j] ; } } } echo $res; ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03852
PHP
Accepted
<?php fscanf(STDIN, "%s", $c); if($c == 'a' || $c == 'e' || $c == 'i' || $c == 'o' || $c == 'u') { echo "vowel\n"; } else { echo "consonant\n"; }
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%s", $c); if($c == 'a' || $c == 'e' || $c == 'i' || $c == 'o' || $c == 'u') { echo "vowel\n"; } else { echo "consonant\n"; } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03416
PHP
Accepted
<?php fscanf(STDIN, "%d %d", $a, $b); $c = 0; for($i = $a; $i <= $b; $i++) { if($i == strrev($i)) $c++; } echo $c."\n";
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d %d", $a, $b); $c = 0; for($i = $a; $i <= $b; $i++) { if($i == strrev($i)) $c++; } echo $c."\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03139
PHP
Accepted
<?php // Get N A B fscanf(STDIN, "%d %d %d", $N, $A, $B); $max_pos = min($A, $B); $min_pos = max(0, ($A + $B) - $N); echo $max_pos . " " . $min_pos;
Here is a piece of code written in PHP: <?php // Get N A B fscanf(STDIN, "%d %d %d", $N, $A, $B); $max_pos = min($A, $B); $min_pos = max(0, ($A + $B) - $N); echo $max_pos . " " . $min_pos; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02879
PHP
Accepted
<?php fscanf(STDIN, "%d %d", $a, $b); if($a > 9 || $b > 9) { echo -1; } else echo $a*$b;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d %d", $a, $b); if($a > 9 || $b > 9) { echo -1; } else echo $a*$b; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02711
PHP
Accepted
<?php // AtCoder Beginner Contest 162 // A - Lucky 7 $n = in(); $num = str_split($n); if (in_array('7', $num)) { yes(); } else { no(); } // ----------------------------------------------------- function in() { return trim(fgets(STDIN)); } function in_int() { return (int)in(); } function in_vals() { return explode(' ', in()); } function in_ints() { return array_map('intval', in_vals()); } function out($s) { echo $s . PHP_EOL; } function yes() { out('Yes'); } function no() { out('No'); }
Here is a piece of code written in PHP: <?php // AtCoder Beginner Contest 162 // A - Lucky 7 $n = in(); $num = str_split($n); if (in_array('7', $num)) { yes(); } else { no(); } // ----------------------------------------------------- function in() { return trim(fgets(STDIN)); } function in_int() { return (int)in(); } function in_vals() { return explode(' ', in()); } function in_ints() { return array_map('intval', in_vals()); } function out($s) { echo $s . PHP_EOL; } function yes() { out('Yes'); } function no() { out('No'); } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03415
PHP
Accepted
<?php fscanf(STDIN, '%s' ,$a); fscanf(STDIN, '%s' ,$b); fscanf(STDIN, '%s',$c); $as =str_split($a); $bs =str_split($b); $cs =str_split($c); echo $as[0].$bs[1].$cs[2];
Here is a piece of code written in PHP: <?php fscanf(STDIN, '%s' ,$a); fscanf(STDIN, '%s' ,$b); fscanf(STDIN, '%s',$c); $as =str_split($a); $bs =str_split($b); $cs =str_split($c); echo $as[0].$bs[1].$cs[2]; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02916
PHP
Accepted
<?php $n = fgets(STDIN); $a = explode(' ', fgets(STDIN)); $b = explode(' ', fgets(STDIN)); $c = explode(' ', fgets(STDIN)); $ans = $b[$a[0]-1]; for($i = 1; $i<$n+1; $i++){ $A = $a[$i]; $B = $b[$A-1]; $ans += $B; if($a[$i-1] + 1 == $A){ $ans += $c[$A-2]; } } echo $ans;
Here is a piece of code written in PHP: <?php $n = fgets(STDIN); $a = explode(' ', fgets(STDIN)); $b = explode(' ', fgets(STDIN)); $c = explode(' ', fgets(STDIN)); $ans = $b[$a[0]-1]; for($i = 1; $i<$n+1; $i++){ $A = $a[$i]; $B = $b[$A-1]; $ans += $B; if($a[$i-1] + 1 == $A){ $ans += $c[$A-2]; } } echo $ans; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02708
PHP
Accepted
<?php list($n, $k) = explode(" ", trim(fgets(STDIN))); $ans = 0; for($i=$k; $i<=$n+1; $i++){ $least = (1 + $i) * $i / 2; $most = (($n+1) + (($n+1)-$i+1)) * $i / 2; $ans = ($ans + ($most - $least + 1)) % 1000000007; } echo $ans;
Here is a piece of code written in PHP: <?php list($n, $k) = explode(" ", trim(fgets(STDIN))); $ans = 0; for($i=$k; $i<=$n+1; $i++){ $least = (1 + $i) * $i / 2; $most = (($n+1) + (($n+1)-$i+1)) * $i / 2; $ans = ($ans + ($most - $least + 1)) % 1000000007; } echo $ans; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02999
PHP
Accepted
<?php fscanf(STDIN, "%d%d", $x, $a); echo ($x < $a) ? 0 : 10; ?>
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d%d", $x, $a); echo ($x < $a) ? 0 : 10; ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03272
PHP
Accepted
<?php $a = explode(" ",fgets(STDIN)); echo $a[0] - $a[1] + 1;
Here is a piece of code written in PHP: <?php $a = explode(" ",fgets(STDIN)); echo $a[0] - $a[1] + 1; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02785
PHP
Accepted
<?php fscanf(STDIN, '%d %d', $N, $K); $H = array_map('intval', explode(' ', trim(fgets(STDIN)))); rsort($H); printf('%d', array_sum(array_slice($H, $K)));
Here is a piece of code written in PHP: <?php fscanf(STDIN, '%d %d', $N, $K); $H = array_map('intval', explode(' ', trim(fgets(STDIN)))); rsort($H); printf('%d', array_sum(array_slice($H, $K))); Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02397
PHP
Accepted
<?php $ary = array(); while (true) { $a_val = explode(" ", trim(fgets(STDIN))); if ($a_val[0] == "0" && $a_val[1] == "0") { break; } array_push($ary, $a_val); } $count = count($ary); foreach ($ary as $key => $val) { asort($val); print implode(" ", $val); if ($key+1 < $count) { print "\n"; } } ?>
Here is a piece of code written in PHP: <?php $ary = array(); while (true) { $a_val = explode(" ", trim(fgets(STDIN))); if ($a_val[0] == "0" && $a_val[1] == "0") { break; } array_push($ary, $a_val); } $count = count($ary); foreach ($ary as $key => $val) { asort($val); print implode(" ", $val); if ($key+1 < $count) { print "\n"; } } ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02261
PHP
Accepted
<?php fscanf(STDIN, '%d', $N); $line = trim(fgets(STDIN)); $arr = explode(' ', $line); $bubbleArr = BubbleSort($arr,$N); echo(implode(' ',$bubbleArr).PHP_EOL."Stable".PHP_EOL); $selectionArr = SelectionSort($arr,$N); echo implode(" ",$selectionArr) . PHP_EOL; isStable($bubbleArr, $selectionArr); function BubbleSort($arr,$N) { for ($i = 0; $i<$N; ++$i) { for ($j = $N-1; $j>$i; --$j) { if ($arr[$j][1] < $arr[$j-1][1]) { $tmp = $arr[$j]; $arr[$j] = $arr[$j - 1]; $arr[$j - 1] = $tmp; } } } return $arr; } function SelectionSort($arr, $N){ for ($i=0; $i<$N; ++$i){ $mini = $i; for ($j=$i; $j<$N; ++$j){ if ($arr[$j][1] < $arr[$mini][1]){ $mini = $j; } } if($mini!=$i){ $tmp = $arr[$i]; $arr[$i] = $arr[$mini]; $arr[$mini] = $tmp; } } return $arr; } function isStable($bubbleArr, $selectionArr){ $result = array_diff_assoc($bubbleArr, $selectionArr); if(count($result)==0){ echo("Stable".PHP_EOL); } else { echo("Not stable".PHP_EOL); } }
Here is a piece of code written in PHP: <?php fscanf(STDIN, '%d', $N); $line = trim(fgets(STDIN)); $arr = explode(' ', $line); $bubbleArr = BubbleSort($arr,$N); echo(implode(' ',$bubbleArr).PHP_EOL."Stable".PHP_EOL); $selectionArr = SelectionSort($arr,$N); echo implode(" ",$selectionArr) . PHP_EOL; isStable($bubbleArr, $selectionArr); function BubbleSort($arr,$N) { for ($i = 0; $i<$N; ++$i) { for ($j = $N-1; $j>$i; --$j) { if ($arr[$j][1] < $arr[$j-1][1]) { $tmp = $arr[$j]; $arr[$j] = $arr[$j - 1]; $arr[$j - 1] = $tmp; } } } return $arr; } function SelectionSort($arr, $N){ for ($i=0; $i<$N; ++$i){ $mini = $i; for ($j=$i; $j<$N; ++$j){ if ($arr[$j][1] < $arr[$mini][1]){ $mini = $j; } } if($mini!=$i){ $tmp = $arr[$i]; $arr[$i] = $arr[$mini]; $arr[$mini] = $tmp; } } return $arr; } function isStable($bubbleArr, $selectionArr){ $result = array_diff_assoc($bubbleArr, $selectionArr); if(count($result)==0){ echo("Stable".PHP_EOL); } else { echo("Not stable".PHP_EOL); } } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03779
PHP
Accepted
<?php fscanf(STDIN,"%d",$h); $i = 1; $X = 0; while($x < $h){ $x = $i + $x; $i++; } echo ($i-1) . PHP_EOL;
Here is a piece of code written in PHP: <?php fscanf(STDIN,"%d",$h); $i = 1; $X = 0; while($x < $h){ $x = $i + $x; $i++; } echo ($i-1) . PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02388
PHP
Accepted
<?php echo pow(trim(fgets(STDIN)), 3), PHP_EOL;
Here is a piece of code written in PHP: <?php echo pow(trim(fgets(STDIN)), 3), PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03046
PHP
Accepted
<?php list($m, $k) = explode(" ", trim(fgets(STDIN))); if($k == 0){ $limit = 2 ** $m; for($i = 0; $i < $limit; $i++){ $array[] = $i; $array[] = $i; } echo implode(" ", $array); }elseif($m == 1){ echo -1; }else{ if($k > 2 ** $m - 1){ echo -1; }else{ for($i = 0; $i < 2 ** $m; $i++){ if($i != $k)$array[] = $i; } $array[] = $k; for($i = 2 ** $m - 1; $i >= 0; $i--){ if($i != $k)$array[] = $i; } $array[] = $k; echo implode(" ", $array); } }
Here is a piece of code written in PHP: <?php list($m, $k) = explode(" ", trim(fgets(STDIN))); if($k == 0){ $limit = 2 ** $m; for($i = 0; $i < $limit; $i++){ $array[] = $i; $array[] = $i; } echo implode(" ", $array); }elseif($m == 1){ echo -1; }else{ if($k > 2 ** $m - 1){ echo -1; }else{ for($i = 0; $i < 2 ** $m; $i++){ if($i != $k)$array[] = $i; } $array[] = $k; for($i = 2 ** $m - 1; $i >= 0; $i--){ if($i != $k)$array[] = $i; } $array[] = $k; echo implode(" ", $array); } } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03325
PHP
Accepted
<?php //3ใ‚’ใ‹ใ‘ใŸใจใ“ใ‚ใง๏ผ’ใงๅ‰ฒใ‚Œใ‚‹ใƒใƒ†ใƒณใ‚ทใƒฃใƒซใฏใ‹ใ‚ใ‚‰ใชใ„ใ€‚ //ใชใ‚‰ใ€nใ“ใฎใใ‚Œใžใ‚Œใฎๆ•ฐๅ€คใŒ๏ผ’ใงไฝ•ๅ›žใ‚ใ‚Œใ‚‹ใ‹ใฟใฆใ€ //ใใ‚Œใ‚’่ถณใ—ๅˆใ‚ใ›ใŸๅ€คใŒๆ“ไฝœๆ•ฐใฎๆœ€ๅคงๅ€ค fscanf(STDIN,"%d",$n); $a_li=array(); $a_li=explode(" ",trim(fgets(STDIN))); $c=0; foreach($a_li as $a){ while($a%2==0){ $a /= 2; $c++; } } echo ($c)."\n";
Here is a piece of code written in PHP: <?php //3ใ‚’ใ‹ใ‘ใŸใจใ“ใ‚ใง๏ผ’ใงๅ‰ฒใ‚Œใ‚‹ใƒใƒ†ใƒณใ‚ทใƒฃใƒซใฏใ‹ใ‚ใ‚‰ใชใ„ใ€‚ //ใชใ‚‰ใ€nใ“ใฎใใ‚Œใžใ‚Œใฎๆ•ฐๅ€คใŒ๏ผ’ใงไฝ•ๅ›žใ‚ใ‚Œใ‚‹ใ‹ใฟใฆใ€ //ใใ‚Œใ‚’่ถณใ—ๅˆใ‚ใ›ใŸๅ€คใŒๆ“ไฝœๆ•ฐใฎๆœ€ๅคงๅ€ค fscanf(STDIN,"%d",$n); $a_li=array(); $a_li=explode(" ",trim(fgets(STDIN))); $c=0; foreach($a_li as $a){ while($a%2==0){ $a /= 2; $c++; } } echo ($c)."\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03326
PHP
Accepted
<?php fscanf(STDIN, "%d%d", $N, $M); $map = array_fill(1,$N,[]); for($i=1;$i<=$N;$i++){ list($map[$i][1], $map[$i][2], $map[$i][4]) = explode(" ", trim(fgets(STDIN))); } $ans = PHP_INT_MIN; for($k = 0;$k<8;$k++) { $list = []; $sum = 0; foreach($map as $row) { $tmp = 0; foreach ($row as $key => $value) { if (($key & $k) > 0) { $value *= -1; } $tmp += $value; } $list[] = $tmp; } rsort($list); $a_tmp = 0; for($i=0;$i<$M;$i++){ $a_tmp += $list[$i]; } $ans = max($ans, $a_tmp); } echo $ans;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d%d", $N, $M); $map = array_fill(1,$N,[]); for($i=1;$i<=$N;$i++){ list($map[$i][1], $map[$i][2], $map[$i][4]) = explode(" ", trim(fgets(STDIN))); } $ans = PHP_INT_MIN; for($k = 0;$k<8;$k++) { $list = []; $sum = 0; foreach($map as $row) { $tmp = 0; foreach ($row as $key => $value) { if (($key & $k) > 0) { $value *= -1; } $tmp += $value; } $list[] = $tmp; } rsort($list); $a_tmp = 0; for($i=0;$i<$M;$i++){ $a_tmp += $list[$i]; } $ans = max($ans, $a_tmp); } echo $ans; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02898
PHP
Accepted
<?php fscanf(STDIN, "%d %d", $b, $c); $datas = explode(' ',trim(fgets(STDIN))); $count = 0; foreach ($datas as $data) { if ($data >= $c) { $count++; } } echo $count;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d %d", $b, $c); $datas = explode(' ',trim(fgets(STDIN))); $count = 0; foreach ($datas as $data) { if ($data >= $c) { $count++; } } echo $count; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03415
PHP
Accepted
<?php //Request Question function getq($get_word=null){ if($get_word===null){ return str_replace("\n","",fgets(STDIN)); }else if($get_word===1){ return explode(" ",str_replace("\n","",fgets(STDIN))); } } /* START */ $a=getq(); echo $a[0]; $a=getq(); echo $a[1]; $a=getq(); echo $a[2]; echo "\n"; ?>
Here is a piece of code written in PHP: <?php //Request Question function getq($get_word=null){ if($get_word===null){ return str_replace("\n","",fgets(STDIN)); }else if($get_word===1){ return explode(" ",str_replace("\n","",fgets(STDIN))); } } /* START */ $a=getq(); echo $a[0]; $a=getq(); echo $a[1]; $a=getq(); echo $a[2]; echo "\n"; ?> Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02917
PHP
Accepted
<?php fscanf(STDIN, "%d", $n); $B = array_map('intval', explode(' ', trim(fgets(STDIN)))); $A = []; $A[0] = $B[0]; for ($i = 1; $i < $n - 1; $i++) { $A[$i] = min($B[$i - 1], $B[$i]); } $A[$n - 1] = $B[$n - 2]; echo array_sum($A);
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $n); $B = array_map('intval', explode(' ', trim(fgets(STDIN)))); $A = []; $A[0] = $B[0]; for ($i = 1; $i < $n - 1; $i++) { $A[$i] = min($B[$i - 1], $B[$i]); } $A[$n - 1] = $B[$n - 2]; echo array_sum($A); Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03308
PHP
Accepted
<?php fscanf(STDIN, "%d", $N); $A = explode(" ", trim(fgets(STDIN))); echo max($A) - min($A) , "\n";
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d", $N); $A = explode(" ", trim(fgets(STDIN))); echo max($A) - min($A) , "\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03018
PHP
Accepted
<?php [$S] = fscanf(STDIN, "%s"); $list = str_split($S); $now = 0; $mode = 0; $ans = 0; for($i=0;$i<count($list);$i++){ if($mode === 0){ if($list[$i] === "A"){ $now++; }elseif($list[$i] === "B"){ if($now > 0){ $mode = 1; } }else{ $now = 0; } }elseif($mode === 1){ if($list[$i]==="C"){ $ans += $now; // $now = $ans; $mode = 0; }else{ $mode = 0; $now = 0; if($list[$i] === "A"){ $now++; } } } } echo $ans;
Here is a piece of code written in PHP: <?php [$S] = fscanf(STDIN, "%s"); $list = str_split($S); $now = 0; $mode = 0; $ans = 0; for($i=0;$i<count($list);$i++){ if($mode === 0){ if($list[$i] === "A"){ $now++; }elseif($list[$i] === "B"){ if($now > 0){ $mode = 1; } }else{ $now = 0; } }elseif($mode === 1){ if($list[$i]==="C"){ $ans += $now; // $now = $ans; $mode = 0; }else{ $mode = 0; $now = 0; if($list[$i] === "A"){ $now++; } } } } echo $ans; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02388
PHP
Accepted
<?php $x = trim(fgets(STDIN)); echo pow($x,3),PHP_EOL;
Here is a piece of code written in PHP: <?php $x = trim(fgets(STDIN)); echo pow($x,3),PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p04044
PHP
Accepted
<?php $args = []; $input = explode(' ', trim(fgets(STDIN))); $count = $input[0]; $length = $input[1]; while(true){ $input = explode(' ', trim(fgets(STDIN))); foreach ($input as $value) { if (!empty($value)) { $args[] = $value; } if (count($args) >= $count) { break; } } if (count($args) >= $count) { break; } } usort($args, function($a, $b) use($length){ for ($i=0; $i < $length; $i++) { if ($a[$i] < $b[$i]) { return -1; }elseif ($a[$i] > $b[$i]) { return 1; } } return 0; }); echo implode('', $args);
Here is a piece of code written in PHP: <?php $args = []; $input = explode(' ', trim(fgets(STDIN))); $count = $input[0]; $length = $input[1]; while(true){ $input = explode(' ', trim(fgets(STDIN))); foreach ($input as $value) { if (!empty($value)) { $args[] = $value; } if (count($args) >= $count) { break; } } if (count($args) >= $count) { break; } } usort($args, function($a, $b) use($length){ for ($i=0; $i < $length; $i++) { if ($a[$i] < $b[$i]) { return -1; }elseif ($a[$i] > $b[$i]) { return 1; } } return 0; }); echo implode('', $args); Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02959
PHP
Accepted
<?php $n = intval(fgets(STDIN)); $arrayA = explode(" ", trim(fgets(STDIN))); $arrayB = explode(" ", trim(fgets(STDIN))); $total = 0; for($i=0; $i<$n; $i++){ if($arrayA[$i]>=$arrayB[$i]){ $total += $arrayB[$i]; }else{ $total += $arrayA[$i]; $arrayB[$i] -= $arrayA[$i]; if($arrayB[$i]>0){ if($arrayA[$i+1]>=$arrayB[$i]){ $total += $arrayB[$i]; $arrayA[$i+1] -= $arrayB[$i]; }else{ $total += $arrayA[$i+1]; $arrayA[$i+1] = 0; } } } } echo $total."\n";
Here is a piece of code written in PHP: <?php $n = intval(fgets(STDIN)); $arrayA = explode(" ", trim(fgets(STDIN))); $arrayB = explode(" ", trim(fgets(STDIN))); $total = 0; for($i=0; $i<$n; $i++){ if($arrayA[$i]>=$arrayB[$i]){ $total += $arrayB[$i]; }else{ $total += $arrayA[$i]; $arrayB[$i] -= $arrayA[$i]; if($arrayB[$i]>0){ if($arrayA[$i+1]>=$arrayB[$i]){ $total += $arrayB[$i]; $arrayA[$i+1] -= $arrayB[$i]; }else{ $total += $arrayA[$i+1]; $arrayA[$i+1] = 0; } } } } echo $total."\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02780
PHP
Accepted
<?php list($n,$k)=explode(" ",trim(fgets(STDIN))); $a=explode(" ",trim(fgets(STDIN))); $ans=0; $i=0; while($i<$k){ $e=($a[$i]+1)/2; $ans+=$e; $a[$i]=$e; ++$i; } $sum=$ans; $j=0; while($i<$n){ $e=($a[$i]+1)/2; $sum+=$e-$a[$j]; if($ans<$sum){ $ans=$sum; } $a[$i]=$e; ++$i; ++$j; } echo $ans;
Here is a piece of code written in PHP: <?php list($n,$k)=explode(" ",trim(fgets(STDIN))); $a=explode(" ",trim(fgets(STDIN))); $ans=0; $i=0; while($i<$k){ $e=($a[$i]+1)/2; $ans+=$e; $a[$i]=$e; ++$i; } $sum=$ans; $j=0; while($i<$n){ $e=($a[$i]+1)/2; $sum+=$e-$a[$j]; if($ans<$sum){ $ans=$sum; } $a[$i]=$e; ++$i; ++$j; } echo $ans; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03378
PHP
Accepted
<?php fscanf(STDIN,"%d %d %d",$n,$m,$x); $a_li = explode(" ",trim(fgets(STDIN))); $cost_up=0; $cost_d=0; $j=$x; for($i=$x;$i<=$n;$i++){ if(in_array($i,$a_li)){ $cost_up++; } } for($j=$x;$j>0;$j--){ if(in_array($j,$a_li)){ $cost_d++; } } echo min($cost_up,$cost_d)."\n";
Here is a piece of code written in PHP: <?php fscanf(STDIN,"%d %d %d",$n,$m,$x); $a_li = explode(" ",trim(fgets(STDIN))); $cost_up=0; $cost_d=0; $j=$x; for($i=$x;$i<=$n;$i++){ if(in_array($i,$a_li)){ $cost_up++; } } for($j=$x;$j>0;$j--){ if(in_array($j,$a_li)){ $cost_d++; } } echo min($cost_up,$cost_d)."\n"; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03001
PHP
Accepted
<?php fscanf(STDIN, "%d %d %d %d", $w, $h, $x, $y); echo $w * $h / 2; echo " "; echo ($w === 2 * $x) && ($h === 2 * $y) ? 1 : 0;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%d %d %d %d", $w, $h, $x, $y); echo $w * $h / 2; echo " "; echo ($w === 2 * $x) && ($h === 2 * $y) ? 1 : 0; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02692
PHP
Accepted
<?php [$N, $A, $B, $C] = array_map('intval',explode(' ',trim(fgets(STDIN))));; for($i = 0; $i < $N; $i++){ $S[] = trim(fgets(STDIN)); } $path = []; dfs(0, $path, $A, $B, $C); echo "No\n"; function dfs($d, &$path, $A, $B, $C){ global $S, $N; if($d == $N){ echo "Yes\n"; echo implode("\n", $path); exit; } $s = $S[$d]; for($i = 0; $i < 2; $i++){ if(${$s[$i]}>0){ $path[] = $s[1-$i]; ${$s[$i]}--; ${$s[1-$i]}++; dfs($d+1, $path, $A, $B, $C); ${$s[$i]}++; ${$s[1-$i]}--; array_pop($path); } } }
Here is a piece of code written in PHP: <?php [$N, $A, $B, $C] = array_map('intval',explode(' ',trim(fgets(STDIN))));; for($i = 0; $i < $N; $i++){ $S[] = trim(fgets(STDIN)); } $path = []; dfs(0, $path, $A, $B, $C); echo "No\n"; function dfs($d, &$path, $A, $B, $C){ global $S, $N; if($d == $N){ echo "Yes\n"; echo implode("\n", $path); exit; } $s = $S[$d]; for($i = 0; $i < 2; $i++){ if(${$s[$i]}>0){ $path[] = $s[1-$i]; ${$s[$i]}--; ${$s[1-$i]}++; dfs($d+1, $path, $A, $B, $C); ${$s[$i]}++; ${$s[1-$i]}--; array_pop($path); } } } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p03493
PHP
Accepted
<?php fscanf(STDIN, "%s", $input); $cnt = 0; for ($i = 0; $i < 3; $i++) { $cnt += $input[$i]; } echo $cnt . PHP_EOL;
Here is a piece of code written in PHP: <?php fscanf(STDIN, "%s", $input); $cnt = 0; for ($i = 0; $i < 3; $i++) { $cnt += $input[$i]; } echo $cnt . PHP_EOL; Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02910
PHP
Accepted
<?php $a = trim(fgets(STDIN)); $a = str_split($a); $count = 0; for($i=0;$i<count($a);$i++){ if($i%2 ==0){ if($a[$i] == 'L'){ $count++; } }else{ if($a[$i] == 'R'){ $count++; } } } if($count == 0){ echo('Yes'); }else{ echo('No'); }
Here is a piece of code written in PHP: <?php $a = trim(fgets(STDIN)); $a = str_split($a); $count = 0; for($i=0;$i<count($a);$i++){ if($i%2 ==0){ if($a[$i] == 'L'){ $count++; } }else{ if($a[$i] == 'R'){ $count++; } } } if($count == 0){ echo('Yes'); }else{ echo('No'); } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes
p02675
PHP
Accepted
<?php fscanf(STDIN,"%d",$n); $x=$n%100%10; switch ($x) { case 2; case 4; case 5; case 7; case 9; echo "hon"; break; case 0; case 1; case 6; case 8; echo "pon"; break; case 3; echo "bon"; }
Here is a piece of code written in PHP: <?php fscanf(STDIN,"%d",$n); $x=$n%100%10; switch ($x) { case 2; case 4; case 5; case 7; case 9; echo "hon"; break; case 0; case 1; case 6; case 8; echo "pon"; break; case 3; echo "bon"; } Do you think this code will compile successfully? Answer 'Yes' or 'No'.
Yes